Struggling to call functions from ui_events.c

What do you want to achieve?

I want to avoid a “undeclared (first use in this function)” error, and keep my events in the ui_events.c file if possible.

What have you tried so far?

I have an event that successfully calls a function, and it’s perfectly placed in ui_events.c. However, when I try and put something in that function (such as a Serial.Println(“test”);), I get an “undeclared” warning. If I remove the function from ui_evcents.c and put it in my main .ino file, all is groovy. I know I must be missing something simple in how C does this (my background is C++, so I know I’m missing something here).

Screenshot or video

/Users/mark/Documents/lvgl_testing/SmartVac/ui_events.c: In function 'splashMuppet':
ui_events.c:10:3: error: 'Serial' undeclared (first use in this function)
   Serial.println("t");
   ^~~~~~
/Users/mark/Documents/lvgl_testing/SmartVac/ui_events.c:10:3: note: each undeclared identifier is reported only once for each function it appears in
exit status 1
'Serial' undeclared (first use in this function)

Others

  • SquareLine Studio version: — 1.1.0
  • Operating system: — MacOs, Arduino editor 1.8.19
  • Target hardware: — Arduino nano RP2040 Connect

It can be related to Arduino. Not that it’s ui_events.c and not ui_events.cpp so Serial.Println(“test”) won’t work as it’s Cpp syntax.

I know that unfortunately creating a multi-file Arduino project is not that trivial. Just as a quick test: does it make any difference if you rename ui_events.c to ui_events.cpp?

This is what I do (renaming to .cpp). That workaround works for me.

I had the same error thrown. However, it’s a trivial thing really - I’m happy just lumping the function into the main .ino file. Once my interface settles down, this is hardly going to be a problem compared to all the other porting I’ve got to do … and get it working with a rotary encoder :slight_smile:

If ui_event.cpp solves the issues we can add an option to make it configurable.