Micrium

µC/GUI Memory Devices

Simulation

Font Comverter

Bitmap Converter

Licensing

Pricing Information

Font Support

Windows Manager

Widgets

Antialiasing

Dialogs

Multiple Layers/Displays

Touch Screen Support

Virtual Screen Support

VNC Support

Overview

Benefits

Drivers

PC Windows Evaluation

PC Windows Samples

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.

  • 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 (using GUI_MEMDEV_Delete()).

Memory device API

The table below lists the available functions of the µC/GUI memory device API. All functions are listed in alphabetical order within their respective categories.

Function Description
Basic functions
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_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_MEMEDV_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.
Banding memory device
GUI_MEMDEV_Draw Use a memory device for drawing.
Auto device object functions
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.
Measurement device object functions
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

A memory device is first filled by executing the specified drawing functions. After filling the device, the contents are drawn to the LCD. There may not be enough memory available to store the complete output area at once, depending on your configuration. A banding memory device divides the drawing area into bands, in which each band covers as many lines as possible with the currently available memory.

Auto device object

Memory devices are useful when the display must be updated to reflect the movement or changing of items, since it is important in such applications to prevent the LCD from flickering. An auto device object is based on the banding memory device, and may be more efficient for applications such as moving indicators, in which only a small part of the display is updated at a time.

The device automatically distinguishes which areas of the display consist of fixed objects and which areas consist of moving or changing objects that must be updated. When the drawing function is called for the first time, all items are drawn. 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 space. The main advantage of using an auto device object (versus direct usage of a banding memory device) is that it saves computation time, since it does not keep updating the entire display.

Measurement device object

Measurement devices are useful when you need to know the area used to draw something. Creating and selecting a measurement device as target for drawing operations makes it possible to retrieve the rectangle used for drawing operations.