when you do that, the data is not actually written to the real LCD
memory but to a dynamic memory region. If you want to directly
write to the real screen, just set the screen parameter of any
of the above functions to NULL.
You can also copy, at any time, the contents of a virtual screen
into the real screen and vice-versa, using the
lcd_screen_virtual_to_real() and lcd_screen_real_to_virtual()
You may now ask, alright but why do we need this?
Suppose you are developing a module which uses the num button to
switch between several "screens". An actual example is the clock
module, where in the first screen it shows the time, day and month
and in the second screen it shows the year. As I was implementing
that functionality, I realized the code was getting too complex.
I started wondering if there was a more efficient way of doing it
and here we are!
If you look to the clock module, where I'm already using this
functionality, you can see that two virtual screens are created.
Each virtual screen saves both segment and blinking information.
So I actually display stuff in the two virtual screens
(time, day and month in screen0 and year in screen1) without worrying
which screen is actually being shown. At each point where the
real screen actually needs to be refreshed, I just copy the contents
of the "active" virtual screen into the real screen using
Now some technical notes:
Each virtual screen actually takes 24bytes of memory. It might seem
a lot but if you consider the size of the code that you would
actually need to write to handle the cases where these functions
are meant to be used, I'm pretty sure the size of the code you
would need to write would be way bigger. Hence we are saving flash
by using a little more RAM.