Hello,
Im have not worked with C alot before, i only have some experience in java.
Now i have bumped into something i do not understand.
While working on a project i was trying to clean my code a bit (make it a bit more modular).
The arduino im currently working on has multiple TFT screens attached to it.
I would like to start all the screens at the start of my program without having to initialize all of them seperatly. ( This makes it easier to attach more or less screens to it in the future).
The code below does not seem to work, but i dont know why.
TFT screens[3] = {screen1, screen2, screen3};
int screensSize = 3;
void setup() {
for (int i = 0; i < screensSize - 1; i++) {
screens[i].begin();
screenSetup(screens[i]);
}
}
This on the other hand does work.
TFT screens[3] = {screen1, screen2, screen3};
int screensSize = 3;
void setup() {
screen1.begin();
screen2.begin();
screen3.begin();
for (int i = 0; i < screensSize - 1; i++) {
screenSetup(screens[i]);
}
}