I'm trying to code a sketch to write data to four LCD screen using LiquidCrystal I2C. I want to have only one fucntion for the four LCD, so I need to find a way to pass lcd1.xxxx(xx,xx), lcd2.xxxx(xx.xx), etc. as arguments so data are printed to the selected screen.
That way I can switch easily data to be print from one LCD to another. I could write a function for each LCD, but I'm trying to simplify the process...
I'm not yet really familiar with pointers, I don't know if it would be the way to do it or somthing else. Is it possible to define a char pointer to define the LCD object name and using it in my function to complete the function call ? I mean its only in "lcdx.print()" or "lcdx.SetCursor(xx,xx)", its only the "lcdx" that need to be corrected in my function...
Also in the simulator you will a few different versions of doing the same basic thing. You can make an array of LCDs which might work better, and eliminate the need for explicit use of pointers, as now each LCD would be reached by index from 0 to N - 1 rather than your idea of cobbling together the name. Which is harder to do in C/C++ than it would be worth in this case probably.
Exactly what I was looking for ! Still learning every day! The array version is so simple. I think i've just unlock a lot of dead ends in my previous projects with that.