/*
Reference to a LCD object
2024-09-30 by noiasca
https://forum.arduino.cc/t/own-library-problem/1306536/3
code in thread
*/
#include <LiquidCrystal_I2C.h> // if you don´t have I2C version of the display, use LiquidCrystal.h library instead
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
template <class T>
class Helper {
T &local; // you could call it lcd also
public:
Helper (T &local) : local(local) {}
void foo(char value) {
local.print(value);
}
};
Helper<LiquidCrystal_I2C> helper(lcd);
void setup() {
lcd.init(); // initialize the 16x2 lcd module
lcd.backlight(); // enable backlight for the LCD module
lcd.print(F("direct "));
helper.foo('a');
helper.foo('b');
}
void loop() {
}