Getting Events and Buttons to Work in Platform IO - SC01 Plus Display

I have been using the following template from github GitHub - fritsjan/WT32-SC01-PLUS-PLATFORMIO to create a Temperature Controller. I followed the example in the Squareline Tutorial to get me going. I created a ui folder in my lib platformio folder. All the ui files are exported to this folder from Squareline Studio.

I have a button event in ui_events.c This event is generated when the “button” is released.

void advanceButtonPressed(lv_event_t * e)
{
handleAdvancedButtonPressed();
}

It calls handleAdvanceButtonPressed in main.c

To compile correctly, I added the following line to ui_events.h

extern void handleAdvancedButtonPressed();

When I tap the “button”, the handleAdvancedButtonPressed() function sends out an mqtt message.

I had some stumbles getting to this point, but pass it on as I see others have been having a similar issue. It saves copy and pasting code around. I have not tried it in the Arduino IDE as I now prefer platformio.

Regards,

David

Beware, the extern entry in ui_events.h will be overwritten when you export the ui…

So remember to make a note and enter it again. The option not to export ui_events seems to only apply to ui_event.c, it will still export ui_events.h.

C basics
If you create func in c file declare it in h file. In other c files include h file.
main.c i use master.h and place here void handleAdvancedButtonPressed();
In uievent.c then include master.h

Yes, that is what I would expect. I have a definitions.h file that includes the functions declared in main.c. However, it did work when I put the definition in that and included it in ui_events.c. It could of been a paths thing in platform io as I have the ui in a seperate folder. Or something to do with platformio build system.

Why you place ui into lib/ui, normal is place export into src folder ahead main
Technicaly lib is folder for .a files

True, they are not really a library. It was just a convenient place to put them as I didn’t want them mixed with the files in the source folder. I could create a ui folder in src and may do that in the future. For now it is working fine for me.

Where you place definitions.h ? Right place is include folder
And read README file in lib folder maybe explain you why ui.a cant build…

definitions.h is in the include folder and it all builds fine for me. I don’t have any problems building now and I don’t have to do any moving files between folders.