Memory devices can be used in a variety of situations, mainly to prevent the display from flickering when using drawing operations for overlapping items. Without the use of a memory device, drawing operations write directly to the display. The screen is updated as drawing operations are executed, which gives it a flickering appearance as the various updates are made. For example, if you want to draw a bitmap in the background and some transparent text in the foreground, you would first have to draw the bitmap and then the text. The effect would be a flickering of the text. If a memory device is used for such a procedure, however, all drawing operations are executed in memory. The final result is displayed on the screen only when all operations have been carried out, with the advantage of no flickering. This difference can be seen in the example in the following section, which illustrates a sequence of drawing operations both with and without the use of a memory device.
The distinction may be summarized as follows: If no memory device is used, the effects of drawing operations can be seen step by step, with the disadvantage of a flickering display. With a memory device, the effects of all routines are made visible as a single operation. No intermediate steps can actually be seen. The advantage, as explained above, is that display flickering is completely eliminated, and this is often desirable. Memory devices are an additional (optional) software item and are not shipped with the µC/GUI basic package.
Using memory devices
The following table shows screen shots of the same operations handled with and without a memory device. The objective in both cases is identical: a work piece is to be rotated and labeled with the respective angle of rotation (here, 10 degrees). In the first case (without a memory device) the screen must be cleared, then the polygon is redrawn in the new position and a string with the new label is written. In the second case (with a memory device) the same operations are performed in memory, but the screen is not updated during this time. The only update occurs when the routine GUI_MEMDEV_CopyToLCD() is called, and this update reflects all the operations at once. Note that the initial states and final outputs of both procedures are identical
API function Without memory device With memory device
Step 0: Initial state
Step 1: GUI_Clear
Step 2: GUI_DrawPolygon
Step 3: GUI_DispString
Step 4: GUI_MEMDEV_CopyToLCD
(only when using memory device)
Using memory devices
Memory devices are available in 3 different color depth: 1bpp, 8 bpp and 16 bpp.
Creating memory devices "compatible" to the display
There are two ways to create memory devices. If they are use to avoid flickering, a memory device compatible to the display is created. This "compatible" memory device needs to have the same or a higher color depth as the display. µC/GUI automatically selects the "right" type of memory device for the display if the functions GUI_MEMDEV_Create(), GUI_MEMDEV_CreateEx() are used. The Window manager, which also has the ability to use memory devices for some or all windows in the system, also uses these functions. This way, the memory device with the lowest color depth (using the least memory) is automatically used.
Memory requirements
If creating a memory device the required number of bytes depends on the color depth of the memory device and whether transparency support is needed or not.
Memory usage without transparency support
The following table shows the memory requirement in dependence of the system color depth for memory devices without transparency support.
Color depth of memory device System color depth
(LCD_BITSPERPIXEL) Memory usage
1 bpp 1 bpp 1 byte / 8 pixels:
(XSIZE + 7) / 8 * YSIZE
8 bpp 2, 4 and 8 bpp XSIZE * YSIZE
16 bpp 12 and 16 bpp 2 bytes / pixel:
XSIZE * YSIZE * 2
Example:
A memory device of 111 pixels in X and 33 pixels in Y should be created. It should be compatible to a display with a color depth of 12 bpp and should support transparency. The required number of bytes can be calculated as follows:
Number of required bytes = (111 * 2 + (111 + 7) / 8) * 33 = 7788 bytes
Memory usage with transparency support
If a memory device should support transparency it needs one additional byte / 8 pixels for internal management.
Color depth of memory device System color depth
(LCD_BITSPERPIXEL) Memory usage
1 bpp 1 bpp 1 byte / pixel + 1 byte / 8 pixels:
(XSIZE + (XSIZE + 7) / 8) * YSIZE
8 bpp 2, 4 and 8 bpp 2 bytes / pixel + 1 byte / 8 pixels:
(XSIZE * 2 + (XSIZE + 7) / 8) * YSIZE
16 bpp 12 and 16 bpp 2 bytes / pixel + 1 byte / 8 pixels:
(XSIZE * 2 + (XSIZE + 7) / 8) * YSIZE
Example:
A memory device of 200 pixels in X and 50 pixels in Y should be created. It should be compatible to a display with a color depth of 4bpp and should support transparency. The required number of bytes can be calculated as follows:
Number of required bytes = (200 + (200 + 7) / 8) * 50 = 11250 bytes.
Performance
Using memory devices typically does no significantly affect performance. When memory devices are used, the work of the driver is easier: It simply transfers bitmaps to the display controller. On systems with slow drivers (for example displays connected via serial interface), the performance is better if memory devices are used; on systems with a fast driver (such as memory mapped display memory, LCDLin driver and others) the use of memory devices costs some performance. If 'banding' is needed, the used time to draw a window increases with the number of bands. The more memory available for memory devices, the better the performance.
Basic functions
The following functions are those that are normally called when using memory devices.
More informations: