I'm using the 4-bit LCD library that comes with version 0018. I can get the LCD working fine. But every once in a while it gets a glitch and the display becomes scrambled. So I want to regenerate LCD module after it suffers this event. A power cycle on the LCD alone doesn't help, because the LCD boots up in 8bit mode again. It needs the magic 4-bit initialization sent to it that the LCD library does.
The goal is to keep the Arduino running. The program has a lot of state and context that is way more important than the display.. I need to keep it running and it continues to function fine as the LCD does its burp. So no, I don't want to power cycle the whole Arduino to "solve" this problem.
It's easy to control power to the LCD using an I/O pin. It draws so little, setting the pin HIGH is enough to power its Vcc. I tried that, works fine. Or alternatively, I could use a LOW to ground its GND pin. But the way things sit now, the LCD module is being powered by the 5volt and GND lines on the Arduino board.
I had to give it constant power because I learned the instance creation of an LCD variable done by this line of code, I guess...
LiquidCrystal(rs, enable, d4, d5, d6, d7);
is actually executed in Arduinoland before any setup() code runs, so it happens sooner than I can turn on an I/O pin to control power to the LCD module !? Lovely. The only "solution" is powering up the LCD with the Arduino (at the same time), or well before the Arduino. And it's impossible to cycle power on just the LCD module anytime after the starts up.
I want the ability to re-boot the LCD module, with bringing down the ATmega chip. So a button, when pressed, reboots the LCD by cycling its power, pausing, then re-sending the LCD library initialization code to it again. I might just regenerate the LCD every minute or so just as preventative maintenance and save the user from pressing a button labeled "if screen is garbled press this button".
Question: Can I just put the line of code
LiquidCrystal(rs, enable, d4, d5, d6, d7);
inline anywhere in setup() or loop() (again) and will it generate code that compiles and runs in that spot to re-initialize the LCD again, after taking a power cycle?
Or how else can I get the initialization string out to the LCD whenever I want?
thanks!