Basically it works, but I have a little complex issues.
I want to call the TFT display instance(normally it was made before setup, as global instance) from timer interrupt.
But I have to prepare two variation of pin map for LCD. Because I have made two different revision of hardware, and I want to make a compatible firmware on both of them.
I want to set "if branch" which reads the hardware revision, before making a global instance which sets the pin map.
But it seems that I cannot write any digital read or "if branch" before Arduino's setup(). And interrupt function cannot access to the private instance.
Would anyone tell me how to resolve this issue? Please.
casper2020:
I want to change the #define pinmap values based on the judgement pin(it is set L/H on each different revision board). But it looks difficult...
It sounds impossible to me.
The #defines are set at compile time but the pins cannot be checked until run time for the fairly obvious reason that the program is not on the Arduino at compile time.
Perhaps it would be possible to create an interface for both modules at compile time and in setup() choose which one to use.
I want to set "if branch" which reads the hardware revision, before making a global instance which sets the pin map.
is the "hardware revision" in a #define ? You could use conditional compilation to generate code for the right hardware but still keep everything in one source code
Yes, so I tried to declare the instance in the setup(), but then interrupts cannot call the LCD functions.
I'm not sure I buy that... if the instance is a global variable, it will be known everywhere. Also I'm Not sure it's a good idea to talk to the TFT in an interrupt in the first place. that's probably slow.
J-M-L:
is the "hardware revision" in a #define ? You could use conditional compilation to generate code for the right hardware but still keep everything in one source code
I'm not sure I buy that... if the instance is a global variable, it will be known everywhere. Also I'm Not sure it's a good idea to talk to the TFT in an interrupt in the first place. that's probably slow.
I'd like to automatically follow the hardware, old or new. I use a blank pin to manage the revision, so if I just digitalread, I can find it's old or new.
And actually the interrupts is for the sensor capture. And if the interrupt function find the signal(it's rare), it calls the display instance. So it's not slow for me.
Thank you!! Probably I understand your idea, I just keep the address of instance in the global area, and after that I call constructor in the setup. I'll do it right now.