Closed hape65 closed 4 months ago
Judging by the serial output, we can conclude that a crash occurred when calling ui_init()
. Now it is necessary to find out exactly where in ui_init
the crash occurred. So may I recommended that you insert print to serial output inside the ui_init
function and deeper until you reach the line in EEZ Studio generated code that causes the crash.
if i add lines like this in ui.h Serial.println("before screens.h"); i get C:\Users\hape\Documents\Arduino\PDQgraphicstest2_short\ui.h:14:7: error: expected '=', ',', ';', 'asm' or 'attribute' before '.' token Serial.println("before screens.h"); So it seems this is not possible - what can i do to get .ino sketch with EEZ Studio to run?
I don't understand, where did you add Serial.println("before screens.h");
in ui.h
?
i want to know where the program breaks down - so my idea was to make a serial.println before and after each command. So i type in the line between each command this serial.println
#ifndef EEZ_LVGL_UI_GUI_H
#define EEZ_LVGL_UI_GUI_H
#include <lvgl.h>
------> here Serial.println("before screens.h");
#include "screens.h"
#ifdef __cplusplus
extern "C" {
#endif
void ui_init();
void ui_tick();
void loadScreen(enum ScreensEnum screenId);
#ifdef __cplusplus
}
#endif
#endif // EEZ_LVGL_UI_GUI_H
thats my ui.h
or how can i check the break down which command make this happen?
I can see that you are beginner in C programming. You can't add Serial.print
line anywhere, it must be inside function body. So, try to add it inside some function in ui.c
, for example start with ui_init
. And, later you can try in create_screen
functions located in screens.c
.
ok this
void ui_init() {
Serial.println("before create_screens");
create_screens();
Serial.println("before loadScreen");
loadScreen(SCREEN_ID_MAIN);
Serial.println("after loadScreen");
}
gives this:
C:\Users\hape\Documents\Arduino\PDQgraphicstest2_short\ui.c: In function 'ui_init':
C:\Users\hape\Documents\Arduino\PDQgraphicstest2_short\ui.c:29:5: error: 'Serial' undeclared (first use in this function)
Serial.println("before create_screens");
^~
Add #include <Arduino.h>
at the top.
no that also doesn't work it should be something like this (but for now that also doesn't work https://stackoverflow.com/questions/66632376/how-to-call-serial-print-from-c-file-in-arduino-ide
Stackoverflow answer is correct.
In ui.c
, add line void my_log(const char *msg);
after includes and replace Serial.println
with my_log
, like this:
#include ...
// ...
void my_log(const char *msg); // new!
// ...
void ui_init() {
my_log("before create_screens"); // use my_log instead of Serial.println
create_screens();
my_log("before loadScreen"); // same here
loadScreen(SCREEN_ID_MAIN);
my_log("after loadScreen"); // same here
}
In your .ino
file add at the end:
extern "C" void my_log(const char *msg) {
Serial.println(msg);
}
I hope I didn't make some syntax error while writing this without trying. If you still have an error please post here output of the build.
Let me explain. Of course Serial.println
didn't work in ui.c
file because ui.c
is writen in C and Serial
is C++ object with the println
method/function. Also, extern "C"
is required because of C++ name mangling.
And by the way, .ino
file is actually .cpp
file (C++ source file) but, I think, Arduino decided to invent a new extension so when you double click .ino
file OS will open Arduino IDE.
hi i compile this Source with LVLG 8.x.x
this is what i see in the Serial Monitor:
On the scree the GFX flashes red-green-blue-black
The ui is only one screen no actions with a field and a keyboard toched to a textarea
What is wrong that there is such an error and no GUI?
hape