I've always had this question in my mind. When sending out data to be displayed on an LCD display (or in my case an OLED display) I have always wondered if there is anything wrong with hammering the registers repeatedly with the same data over and over again. Example:
I hate that I am sending the same thing to the display over and over again when really I just need to send it once when the button is pressed and once when the button is released. Because of this I end up doing something that feels convoluted like:
Now given my propensity to always find the absolute worst way to do something programmatically, I can only assume that this is possibly the worst way to do this. What do you guys do to avoid constantly sending the same data to be displayed over and over again?
I have always wondered if there is anything wrong with hammering the registers repeatedly with the same data over and over again.
They don't know. They don't care.
The problem comes when the clearing and redisplay of data takes a while. If that time doesn't matter (the display doesn't flicker; the code doesn't block), then it doesn't matter. If it does, then clearing the screen and re-displaying the data only when there is a change can improve the performance of the overall program.
Changing only those parts of the display that have actually changed, rather than clearing the whole display can make a difference too. The code would be neater and be easier to maintain if the routine to display data were made into a function with the parameters being the data to display and the coordinates where it should be displayed.
So basically it doesn't matter unless I need my program to run faster. It does get a bit behind when reading serial information coming in so I guess I will put the test in there to see if I need to update the display or not.
That's basically what my second code example above does. I ended up just making a boolean that keeps track of which of two states the system can be in. If the state is 0 and the boolean shows that we are displaying state as 1 then we update the display and vice versa. Seems to work fine for me.
But now my display has quite a flicker to it, which is
a) Distracting
b) I wonder about the effect on the display?
I attach an image as it wouldn't paste where I wanted it to.
Basically the display is:
Tue 1 Nov 2016
08:49:48 AM GMT
(GMT is Greenwich Mean Time - a hark back to the UK's Imperial Days!)
What would be nice would be if only the changes get output
that is easy with the first line as it only changes once a day
but rather more complex with the second line, where it would be good to only output the one or two (or more) digits which change
Maybe this is only an intellectual exercise but it has certainly got my brain ticking, and I wondered if anyone had sorted it (or similar)? - I have Googled the Forum and the web
But now my display has quite a flicker to it, which is
a) Distracting
b) I wonder about the effect on the display?
We cannot locate the problem unless you post your code. And it will save us time if you begin by posting the entire sketch, not just the part you think is the problem.