I am collecting output commands for a couple of 74HC595 output shift registers in form of integers corresponding with a bit in a 16 bit binary, add them up and send them as output command to the shift registers. I am using the same output command to display the pin states of the shift registers on a LCD display which works pretty fine. The only problem I have is that the display refreshes it self with every pass of the main program loop which results in kind of a blinking display output. Is there a way to refresh the display only if the output command has changed and if not just keep on using the old output state without refreshing the whole display in every program loop?
The LCD is controlled through a 74HC595 shift register and the shiftLCD library which I downloaded from herehttp://www.miselph.co.uk/arduino/ShiftLCD.zip
#include <ShiftLCD.h>
ShiftLCD lcd(9, 11, 10); //initializing the LCD adapter pins
unsigned int lightOutput[17] = {1, 0, 0, 8, 0, 0, 64,0, 254, 512, 0, 2048,0, 0, 0, 0, 0, 0}; //for testing
unsigned int outputL = 0;
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
}
void loop() {
// put your main code here, to run repeatedly:
for(int i=0; i<17; i++) { //loop through the light output array
outputL += lightOutput[i]; //adding up the numbers
}
lcd.setCursor(0,0);
printBinary16(outputL); //sending the result to dislplay
}
//function to keep a 16 digit display
void printBinary16(unsigned int iIn) {
// 0b1234567812345678
for (unsigned int mask = 0b1000000000000000; mask; mask >>= 1) {
if (mask & iIn) {
lcd.print('1');
}
else {
lcd.print('0');
}
}
}
I have tried already with adding a outputOld variable and display the outputOld var which only got updated when outputL changed. with the same result, a kind of blinking display.
Thanks for any ideas to get a steady display which updates only if the value changes.