Description
After months of procrastinating, I have finally started to connect my LVGL app to live data.
My .ino file includes the LVGL touch and display driver as well as my CAN driver and application that fetches the data.
My LVGL app is built in .c file and is included in the main .ino file.
In the main .ino file (lets just call it main.ino), I have a float declared and initialised.
I want the lvgl .c file (lets call it app.c) to read that float and pass it to a widget.
For this I have created a header file called global_vars.h and I have declared it in there, but for some reason the compiler shouts that its either declared twice or it does not contain a name type (depending on where I include the header file or it I declare extern etc)
Hoping someone can help as I am getting more and more confused the more I Google this topic
What LVGL version are you using?
7.10
Arduino IDE 1.83 (Teensyduino 1.53)
Teensy 4.1
What do you want to achieve?
Set a variable value in a main .ino file and have LVGL read it in a separate app .c file
What have you tried so far?
Code to reproduce
main.ino
#include "global_vars.h"
#include "app.c"
void setup() {
globalVar = 1.1;
}
void loop() {
// put your main code here, to run repeatedly:
}
global_vars.h
#ifndef GLOBAL_VARS_H
#define GLOBAL_VARS_H
extern float globalVar;
#endif
app.c
#include "global_vars.h"
float abc = globalVar;