Segger Logo Embedded Software Solutions
Software productsHardware productsDownloadsPricesCustomersOur PartnersSitemapForumAbout us
emWin: Memory devices
| Samples | Simulation | Font Converter | Bitmap Converter | Memory devices | Window Manager | Widgets | Dialogs | Multiple Layer/Displays | VNC Support | Touch Screen | Antialiasing | Drivers | Starter Boards | Virtual Screen Support | emWin Applications | PC Evaluation Versions |

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.

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)

Basic functions

The following routines are those that are typically used with memory devices. Basic usage is rather simple:

  1. Create the memory device (using GUI_MEMDEV_Create).
  2. Activate it (using GUI_MEMDEV_Select).
  3. Execute drawing operations.
  4. Copy the result into the display (using GUI_MEMDEV_CopyToLCD).
  5. 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.

RoutineExplanation
Basic functions
GUI_MEMDEV_ClearMarks the memory device contents as unchanged
GUI_MEMDEV_CopyFromLCDCopies contents of LCD to memory device
GUI_MEMDEV_CopyToLCDCopies contents of memory device to LCD
GUI_MEMDEV_CopyToLCDAACopies the contents of memory device antialiased
GUI_MEMDEV_CopyToLCDAtCopies contents of memory device to LCD at the given position
GUI_MEMDEV_CreateCreates the memory device (first step)
GUI_MEMDEV_CreateExCreates the memory device with additional creation flags
GUI_MEMDEV_CreateFixedCreates a memory device with a given color depth
GUI_MEMDEV_DeleteFrees the memory used by the memory device
GUI_MEMDEV_GetDataPtrReturns a pointer to the data area for direct manipulation
GUI_MEMDEV_GetXSizeReturns the X-size (width) of memory device
GUI_MEMDEV_GetYSizeReturns the Y-size (height) of memory device
GUI_MEMDEV_MarkDirtyMarks the given area as containing pixels to be drawn
GUI_MEMDEV_ReduceYSizeReduces Y-size of memory device
GUI_MEMDEV_SelectSelects a memory device as target for drawing operations
GUI_MEMDEV_SetOrgChanges the origin of the memory device on the LCD
GUI_MEMDEV_WriteWrites the contents of a memory device into a memory device
GUI_MEMDEV_WriteAlphaWrites the contents of a memory device into a memory device using alpha blending
GUI_MEMDEV_WriteAlphaAtWrites the contents of a memory device into a memory device using the given position and alpha blending
GUI_MEMDEV_WriteAtWrites the contents of a memory device into a memory device to the given position
GUI_MEMDEV_WriteExWrites the contents of a memory device into a memory device using alpha blending and scaling
GUI_MEMDEV_WriteExAtWrites the contents of a memory device into a memory device to the given position using alpha blending and scaling
GUI_SelectLCDSelects the LCD as target for drawing operations
Banding memory device
GUI_MEMDEV_DrawUse a memory device for drawing
Auto device object functions
GUI_MEMDEV_CreateAutoCreates an auto device object
GUI_MEMDEV_DeleteAutoDeletes an auto device object
GUI_MEMDEV_DrawAutoUses a GUI_AUTODEV object for drawing
Measurement device object functions
GUI_MEASDEV_ClearRectClears the measurement rectangle
GUI_MEASDEV_CreateCreates a measurement device
GUI_MEASDEV_DeleteDeletes a measurement device
GUI_MEASDEV_GetRectRetrieves the measurement result
GUI_MEASDEV_SelectSelects 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