Commit [5a5a59] Maximize Restore History

drivers/display: Implement virtual screens

This patch introduces a very cool feature. Basically it introduces
virtual screens. What is a virtual screen?

A virtual screen is a pointer to a memory region created by
lcd_screen_create(). You can pass that pointer to all of the
display functions:


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()
functions respectively.

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.

Angelo Arrifano Angelo Arrifano 2012-05-13

changed drivers
changed drivers/display.c
changed drivers/display.h
changed ezchronos.c
changed modules
changed modules/alarm.c
changed modules/clock.c
changed modules/rfbsl.c
drivers/display.c Diff Switch to side-by-side view
drivers/display.h Diff Switch to side-by-side view
ezchronos.c Diff Switch to side-by-side view
modules/alarm.c Diff Switch to side-by-side view
modules/clock.c Diff Switch to side-by-side view
modules/rfbsl.c Diff Switch to side-by-side view