BRT Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Author Topic: How to create a new Host Platform (e.g. Arduino) for EVE Screen Designer  (Read 1320 times)

karst.drenth

  • Newbie
  • *
  • Posts: 17
    • View Profile

Hi All,

I am busy designing a custom board, Arduino MKRzero compatible, which hosts a BT815 to connect to a 480x480 display.

As I am very impressed and pleased with Screen Designer, I'd like to use it for my project.
But... it (of course) cannot generate code for an Arduino platform.

I already managed to define my display and a new "Host Platform"... logically SD will crash when I press the "generate & upload" button.

( see Attachments )

Is there more Info around how to do this ?

As for now my only feasible option looks like choosing RP2040 and manually editing the generated HAL files in my project directory


Greets,
Karst
Logged

pauljiao

  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: How to create a new Host Platform (e.g. Arduino) for EVE Screen Designer
« Reply #1 on: November 24, 2021, 06:54:09 AM »

ESD will generate the ANSI C code for the selected platform. Arduino is using its own C++ variety language to program.  However, I think it is possible to build C for MCU on the Arduino board.  You may need to modify the code in the HAL of the ESD-generated application. You may refer to this porting guide:

https://brtchip.com/wp-content/uploads/2021/06/ESD-4.10-Exported-Project-Porting-Guide-for-STM32L4-Discovery-Board-and-FreeRTOS.pdf
Logged

karst.drenth

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: How to create a new Host Platform (e.g. Arduino) for EVE Screen Designer
« Reply #2 on: November 24, 2021, 12:24:57 PM »

Hi Paul,

Thanks for the link, I will study it and see what's in there for me :)

At first glance, it looks like exactly what I need !  8)

Greets,
Karst
Logged

karst.drenth

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: How to create a new Host Platform (e.g. Arduino) for EVE Screen Designer
« Reply #3 on: November 25, 2021, 11:12:37 PM »

Hi,

A little progress-report :)

Quote from: pauljiao
ESD will generate the ANSI C code for the selected platform.
Arduino is using its own C++ variety language to program. 
However, I think it is possible to build C for MCU on the Arduino board. 

Yes it is. But it can either have all it's code together with it's INO file or in the libraries folder each library in it's own directory.

So the trick I used is using "Junction-Links" to an MSVC exported version's generated libraries ( see attachment 1 ), then just listing the "main" header files of the ESD generated code in the INO ( see attachment 2 ) .

This will automagically pull-in all the ESD generated code  8) ;D

But... since ESD relies heavily on compile-time defines, the last thing is to take these defines from the MSVC project file and enter them in the Arduino boards.txt definition file as "extra_flags"

Then when it all compiles error free, it will generate a bunch of "undefined references" during link-time. ( only when also "App.h" is also present in the INO )

So...

Quote from: pauljiao
You may need to modify the code in the HAL of the ESD-generated application. You may refer to this porting guide:

Yep, better not modify, but write your own HAL_Impl. Which is my next challenge ;)

All the new platform definition stuff is done by editing EVE_Config.h, EVE_util.h, EVE_util.c and EVE_Platform.h ( if anybody is interested, tell me, I'll upload them here ;) )

Greets,
Karst
Logged

karst.drenth

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: How to create a new Host Platform (e.g. Arduino) for EVE Screen Designer
« Reply #4 on: November 26, 2021, 10:21:49 PM »

Hi All,

One day further down the road, but for sure really on top of the hill  ;D

It's done and it works  8)

https://youtu.be/kIJu7Trx1sk

In the video you can see first the EVE Screen Designer 4.14.0 in which I designed my Application, then the camera panned to my module.
The first screen is the one from yesterday, coded with Rudolph's library. I still haver a bit of trouble with the touchscreen. Sometimes does not react at all, sometimes it generates "ghost" taps :(
Then after about 5 seconds the generated EVE App takes over.

I built the HAL based upon Rudolph's library routines. Which was pretty straight forward  8)

The first attachment shows the parts which I included in the Arduino sketch's setup() and loop().
The second attachment shows the only mods ( the comments ;) ) to be done in the generated code... not too bad is it ?

Attachment 3 contains the HAL I crafted :P

Greets,
Karst
Logged

karst.drenth

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: How to create a new Host Platform (e.g. Arduino) for EVE Screen Designer
« Reply #5 on: November 26, 2021, 10:22:30 PM »

Attachment 2
Logged

karst.drenth

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: How to create a new Host Platform (e.g. Arduino) for EVE Screen Designer
« Reply #6 on: November 26, 2021, 10:23:18 PM »

Attachment 3
Logged

fr3ud

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: How to create a new Host Platform (e.g. Arduino) for EVE Screen Designer
« Reply #7 on: December 29, 2021, 10:38:16 PM »

Hi,

A little progress-report :)

Quote from: pauljiao
ESD will generate the ANSI C code for the selected platform.
Arduino is using its own C++ variety language to program. 
However, I think it is possible to build C for MCU on the Arduino board. 

Yes it is. But it can either have all it's code together with it's INO file or in the libraries folder each library in it's own directory.

So the trick I used is using "Junction-Links" to an MSVC exported version's generated libraries ( see attachment 1 ), then just listing the "main" header files of the ESD generated code in the INO ( see attachment 2 ) .

This will automagically pull-in all the ESD generated code  8) ;D

But... since ESD relies heavily on compile-time defines, the last thing is to take these defines from the MSVC project file and enter them in the Arduino boards.txt definition file as "extra_flags"

Then when it all compiles error free, it will generate a bunch of "undefined references" during link-time. ( only when also "App.h" is also present in the INO )

So...

Quote from: pauljiao
You may need to modify the code in the HAL of the ESD-generated application. You may refer to this porting guide:

Yep, better not modify, but write your own HAL_Impl. Which is my next challenge ;)

All the new platform definition stuff is done by editing EVE_Config.h, EVE_util.h, EVE_util.c and EVE_Platform.h ( if anybody is interested, tell me, I'll upload them here ;) )

Greets,
Karst

Nice work ! Would you mind sharing how you added a new platform for noobs like me?
Thanks!
Logged

fr3ud

  • Newbie
  • *
  • Posts: 7
    • View Profile

Any update?  :)
Logged

karst.drenth

  • Newbie
  • *
  • Posts: 17
    • View Profile

Hi,

Sorry, have been offline quite a long time due to Covid 19 infection  :(

But you can look at the attached files and look for the string YD7201 in the files.

In the next post I will post also the new HALImpl ;)

Greets,
Karst
Logged

karst.drenth

  • Newbie
  • *
  • Posts: 17
    • View Profile

Here comes the HALimpl :)

It is based upon Rudolph's Arduino Library as an API to the Arduino.

The App_Generated.c file is output from ESD. It just needs commenting out the "main()" function and the Application definition.

like this:

Code: [Select]
//static App application;
//static Esd_Context s_Esd;

void App__Start(App *context)
{
App__Initializer(context);
App_Start(context);
}

//int main(int argc, char *argv[])
//{
// Esd_Initialize();
//
// {
// Esd_Parameters ep;
// Esd_Defaults(&ep);
// ep.UserContext = &application;
// ep.Start = (Esd_Callback)App__Start;
// ep.Update = (Esd_Callback)App_Update;
// ep.Render = (Esd_Callback)App_Render;
// ep.Idle = (Esd_Callback)App_Idle;
// ep.End = (Esd_Callback)App_End;
// if (!Esd_Open(&s_Esd, &ep))
// return EXIT_FAILURE;
// }
// Esd_Loop(&s_Esd);
// Esd_Close(&s_Esd);
//
// Esd_Release();
// return EXIT_SUCCESS;
//}

which is then replaced in the .ino by:

Code: [Select]
void setup()
{
pinMode     (SWITCH,  INPUT);

pinMode (EVE_PDN, OUTPUT); // keep EVE in Reset (PD ==> PowerDown)
digitalWrite(EVE_PDN, LOW);

pinMode (PIN_SPI_SS, OUTPUT);
digitalWrite(PIN_SPI_SS, HIGH); // deselect EVE

pinMode (PIN_SPI1_SS, OUTPUT);
digitalWrite(PIN_SPI1_SS, HIGH); // deselect Flash

pinMode (PIN_SPI2_SS, OUTPUT);
digitalWrite(PIN_SPI2_SS, HIGH); // deselect FPC

pinMode     (LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);

SerialUSB.begin(115200); // USB
Serial1 .begin(  9600); // ES_Link
Serial2  .begin( 16667); // LocoNet

Flash.begin(SPI1, PIN_SPI1_SS); // SerialFlash does the SPI startup by itself

SPI2.begin(); // start the display SPI
init_ST7701_Display(); // configure and start the display

SPI.begin(); // startup EVE's SPI
SPI.beginTransaction(EVE_SPI_SETTINGS);

TFT_init(); // Make EVE start working
TFT_display();

  delay(500);
arduino_printf("hello, Display is up :)");

int times = 180;
while (times--) {
  delay(26);
  TFT_display();
rotate += 2;
}

if (digitalRead(SWITCH) == 0) {
TFT_calibrate();
while (digitalRead(SWITCH) != 0);
while (digitalRead(SWITCH) == 0);
}

arduino_printf("hello, EVE is up :)");

Esd_Initialize();

Esd_Parameters ep;
Esd_Defaults(&ep);

ep.UserContext = &application;
ep.Start = (Esd_Callback)App__Start;
ep.Update = (Esd_Callback)App_Update;
ep.Render = (Esd_Callback)App_Render;
ep.Idle = (Esd_Callback)App_Idle;
ep.End = (Esd_Callback)App_End;

if (Esd_Open(&s_Esd, &ep)) {
EVE_HalContext* phost = &s_Esd.HalContext;
Esd_SetCurrent(&s_Esd);
Esd_Start(&s_Esd);

Esd_Started = true;

application.App_Screen.Main_Page.DDC_Logo_Input    = DDC_Logo_Input;
application.App_Screen.Main_Page.DCC_Logo_Rotation = DDC_Logo_Rotation;
}
else {
TFT_display();
}

SerialUSB.println("setup() done");
}


that's "setup()"

and in "loop()"

Code: [Select]
display_delay++;

// refresh the display every 20ms or 5 ms when ESD is running
if (display_delay > 4) {
display_delay = 0;

micros_start = micros();

if (Esd_Started) {
if (toggle_state != 0)
if (++rotate == 360)
rotate = 0;

Esd_Update (&s_Esd);
Esd_Render (&s_Esd);
Esd_WaitSwap(&s_Esd);
}
else
TFT_display();

micros_end = micros();

num_profile_a = (micros_end - micros_start); // calculate the micro-seconds passed during the call to TFT_display
}

Grettz,
Karst
Logged

fr3ud

  • Newbie
  • *
  • Posts: 7
    • View Profile

Many thanks Karst.drenth ! Can't wait to test it ! Hopefully this weekend  ;D
Logged

Kaetemi

  • Newbie
  • *
  • Posts: 21
    • View Profile

You can add an additional platform implementation to the HAL library that ESD uses directly, add the appropriate presets to EVE_Config.h, and then modify Toolchain.config to specify the build commands, and Programmer.config to specify a programmer.

For ESD emulation, an ESD_SIMULATION compile flag is always set, which overrides whatever platform flags are set to use the desktop target for the emulator instead. You can also use this flag to hide any C coded hardware behaviour from ESD.
Logged

fr3ud

  • Newbie
  • *
  • Posts: 7
    • View Profile

I tried poking around but being a beginner I haven't be able to make it work.
ESD side seems good, it's on the arduino side with the
Code: [Select]
ep.UserContext = &application;and all the Callback not being defined
I see them in the App_Generated.c and I inluded App.h in the beginning of my arduino program. But no chance

I'm using RudolphRiedel PlatformIO example, I added as libraries :
  • Esd_Core
  • Esd_WebStyle_Widgets
  • FT_Esd_Framework
  • FT_Esd_Widgets
  • FT_Eve_Hal
  • And all the ESD project specific generated files (App ,AppScreen,...)
Logged