Introduction
Memory devices can be used in a variety of situations,
mainly to prevent the display from flickering when using drawing operations
for overlapping items. The basic idea is quite simple. 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 wanted 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
emWin basic package. The software for memory devices is located in the
subdirectory Memdev of the GUI directory.
Using memory devices: an illustration
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 is first 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.
| 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) |
 |
Basic functions
The following routines are those that are typically
used with memory devices. Basic usage is rather simple:
- Create the memory device (using GUI_MEMDEV_Create).
- Activate it (using GUI_MEMDEV_Select).
- Execute drawing operations.
- Copy the result into the display (using GUI_MEMDEV_CopyToLCD).
- Delete the memory device (if you no longer need it).
In order to be able to use memory devices
Memory devices are enabled by default. In order to optimize
performance of the software, support for memory devices can be switched
off in the configuration file GUIConf.h with the following line:
#define GUI_SUPPORT_MEMDEV 0
If this line is in the configuration file and you want
to use memory devices, either delete the line or change the define to
1.
API reference: memory devices
The table below lists the available routines of the
emWin memory device API.
All functions are listed in alphabetical order within their respective
categories. Detailed descriptions of the routines can be found in the
sections that follow.
| GUI_MEMDEV_Clear | Marks the memory device contents as unchanged |
| GUI_MEMDEV_CopyFromLCD | Copies contents of LCD to memory device |
| GUI_MEMDEV_CopyToLCD | Copies contents of memory device to LCD |
| GUI_MEMDEV_CopyToLCDAA | Copies the contents of memory device antialiased |
| GUI_MEMDEV_CopyToLCDAt | Copies contents of memory device to LCD at the given position |
| GUI_MEMDEV_Create | Creates the memory device (first step) |
| GUI_MEMDEV_CreateEx | Creates the memory device with additional creation flags |
| GUI_MEMDEV_CreateFixed | Creates a memory device with a given color depth |
| GUI_MEMDEV_Delete | Frees the memory used by the memory device |
| GUI_MEMDEV_GetDataPtr | Returns a pointer to the data area for direct manipulation |
| GUI_MEMDEV_GetXSize | Returns the X-size (width) of memory device |
| GUI_MEMDEV_GetYSize | Returns the Y-size (height) of memory device |
| GUI_MEMDEV_MarkDirty | Marks the given area as containing pixels to be drawn |
| GUI_MEMDEV_ReduceYSize | Reduces Y-size of memory device |
| GUI_MEMDEV_Select | Selects a memory device as target for drawing operations |
| GUI_MEMDEV_SetOrg | Changes the origin of the memory device on the LCD |
| GUI_MEMDEV_Write | Writes the contents of a memory device into a memory device |
| GUI_MEMDEV_WriteAlpha | Writes the contents of a memory device into a memory device using alpha blending |
| GUI_MEMDEV_WriteAlphaAt | Writes the contents of a memory device into a memory device using the given position and alpha blending |
| GUI_MEMDEV_WriteAt | Writes the contents of a memory device into a memory device to the given position |
| GUI_MEMDEV_WriteEx | Writes the contents of a memory device into a memory device using alpha blending and scaling |
| GUI_MEMDEV_WriteExAt | Writes the contents of a memory device into a memory device to the given position using alpha blending and scaling |
| GUI_SelectLCD | Selects the LCD as target for drawing operations |
| GUI_MEMDEV_Draw | Use a memory device for drawing |
| GUI_MEMDEV_CreateAuto | Creates an auto device object |
| GUI_MEMDEV_DeleteAuto | Deletes an auto device object |
| GUI_MEMDEV_DrawAuto | Uses a GUI_AUTODEV object for drawing |
| GUI_MEASDEV_ClearRect | Clears the measurement rectangle |
| GUI_MEASDEV_Create | Creates a measurement device |
| GUI_MEASDEV_Delete | Deletes a measurement device |
| GUI_MEASDEV_GetRect | Retrieves the measurement result |
| GUI_MEASDEV_Select | Selects a measurement device as target for drawing operations |
Banding memory device
The size of available memory is normally not enough
to cover the whole drawing area. A banding memory device divides the drawing
area into bands. One band covers as many lines as possible with the currently
available memory.
Take a look at the c-code and download the demo
file here:
Auto device object
An auto device object is often preferred for applications
such as moving pointers, in which only a small part of the display is
updated at a time. The device automatically distinguishes which parts
of the display consist of fixed items and which parts consist of moving
or changing items. When the drawing function for the auto device object
is called for the first time, it draws all items. Each further call updates
only the space used by the moving or changing objects. The actual drawing
operation uses the banding memory device, but only within the necessary
area. The main advantage of using an auto device object is that it saves
computation time, since it does not keep updating the entire display.
Take a look at the c-code and download the
demo file here

Copyright SEGGER Microcontroller GmbH & Co.KG.
All rights reserved.
For more information, please visit our web site
www.segger.com or contact us at info@segger.com
Last update:
December 7, 2007
|