CircleOS  1
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
dma2d_graphic.h File Reference

Types definitions and declarations for the STM32F42x DMA2D controller. More...

Go to the source code of this file.

Data Structures

struct  sdbmp
 
struct  sDMA2D_Object
 
struct  tDMA2D_Screen
 
struct  tTrans
 

Macros

#define MAX_DMA2D_SCREEN   2
 Number of screens stored in SDRAM. More...
 
#define MAX_DMA2D_OBJECT   256
 Number of object managed per screen. More...
 
#define TEST_BEFORE_TRANSFER   0
 Optimisation that is not fully tested, and probably not so useful. More...
 
#define TEST_AFTER_TRANSFER   (!TEST_BEFORE_TRANSFER)
 
#define OBJECT_SINGLE_MEMORY_POOL_SIZE   (1024*512)
 512 KB used for objects on OP4 More...
 

Typedefs

typedef u32 color32_t
 Pixel color type: ARGB where A is the alpha constant. More...
 
typedef u8 tpixel24 [3]
 Pixel color type sent to the OP4 LCD controller. More...
 
typedef struct sdbmp tBmpDescriptor
 Descriptor for the legacy bitmap files (Windows .BMP) More...
 
typedef struct sDMA2D_Object tDMA2D_Object
 Descriptor for an object. More...
 
typedef tDMA2D_ObjecttDMA2D_pObject
 Pointer to an object. More...
 
typedef tDMA2D_ScreentDMA2D_pScreen
 Pointer to a screen. More...
 
typedef int(* tFctXY )(int x, int y)
 
typedef int(* tFctObjXY )(tDMA2D_pObject obj, int x, int y)
 

Enumerations

enum  SELECT_MODE {
  SELNONE = 0, SELADDR = 1, SELDISP = 2, SELFULL = 3,
  SELNONE = 0, SELADDR = 1, SELDISP = 2, SELFULL = 3
}
 
enum  CD_DMA2D_FCT {
  CD_SCREENINIT = 0, CD_UPDATE = 1, CD_UNUSED_2 = 2, CD_SCREENCLEAR = 3,
  CD_SCREENSELECT = 4, CD_SCREENSETDIRTY = 5, CD_SCREENREDRAW = 6, CD_SCREENCOPY = 7,
  CD_SCREENUNUSED = 8, CD_OBJECTCREATE = 9, CD_OBJECTDELETE = 10, CD_OBJECTSETTOSCREEN = 11,
  CD_OBJECTASSIGNBITMAP = 12, CD_OBJECTSETPARTIAL = 13, CD_OBJECTMOVE = 14, CD_OBJECTSETVISIBLE = 15,
  CD_OBJECTSELECT = 16, CD_OBJECTSETTRANSPARENCY = 17, CD_OBJECTGETPIXEL = 18, CD_OBJECTGETINTERSECTION = 19,
  CD_OBJECTGETPOS = 20, CD_OBJECTGETSIZE = 21, CD_OBJECTFIND = 22, CD_OBJECTGETIMAGE = 23,
  CD_OBJECTSETOFFSET = 24, CD_OBJECTPOPZ = 25, CD_OBJECTPUSHZ = 26, CD_OBJECTSETFOREGROUND = 27,
  CD_OBJECTSETBACKGROUND = 28, CD_SETTRANSFORM = 29, CD_OBJECTTRANSFORM = 30, CD_OBJECTTRANSFORMREVERSE = 31,
  CD_SDRAMBANKSWITCH = 32
}
 

Functions

void DMA2D_ScreenInit (void)
 
void DMA2D_Update (void)
 
void DMA2D_SetDrawingMode (int mode, void *obj)
 
void DMA2D_ScreenClear (unsigned int screen, int del)
 
void DMA2D_ScreenSelect (unsigned int screen, enum SELECT_MODE mode)
 
void DMA2D_ScreenSetDirty (unsigned int screen)
 
void DMA2D_ScreenRedraw (unsigned int screen)
 
void DMA2D_ScreenCopy (unsigned int dest, unsigned int src)
 
void DMA2D_Rotate (Rotate_H12_V_Match_TypeDef old_orientation, Rotate_H12_V_Match_TypeDef new_orientation)
 
tDMA2D_pObject DMA2D_ObjectCreate (int width, int height, int rdonly)
 
void DMA2D_ObjectDelete (tDMA2D_pObject obj)
 
int DMA2D_ObjectSetToScreen (tDMA2D_pObject obj, unsigned int screen)
 
int DMA2D_ObjectAssignBitmap (tDMA2D_pObject obj, void *pbitmap, int format)
 
int DMA2D_ObjectSetPartial (tDMA2D_pObject obj, int width, int height)
 
int DMA2D_ObjectSetOffset (tDMA2D_pObject obj, int offsx, int offsy)
 
int DMA2D_ObjectMove (tDMA2D_pObject obj, int x, int y)
 
void DMA2D_ObjectSetVisible (tDMA2D_pObject obj, int mode)
 
int DMA2D_ObjectSelect (tDMA2D_pObject obj)
 
void DMA2D_ObjectSetTransparency (tDMA2D_pObject obj, int transparency)
 
color32_t DMA2D_ObjectGetPixel (tDMA2D_pObject obj, int x, int y)
 
u32 DMA2D_ObjectGetIntersection (unsigned int screen, tDMA2D_pObject obj1, tDMA2D_pObject obj2)
 
tDMA2D_pObject DMA2D_ObjectFind (unsigned int screen, int x, int y)
 
int DMA2D_ObjectGetPos (tDMA2D_pObject obj, unsigned int screen)
 
u32 DMA2D_ObjectGetImage (tDMA2D_pObject obj)
 
int DMA2D_ObjectPushZ (tDMA2D_pObject obj, unsigned int screen)
 
int DMA2D_ObjectPopZ (tDMA2D_pObject obj, unsigned int screen)
 
int DMA2D_ObjectSetForeground (tDMA2D_pObject obj, unsigned int screen)
 
int DMA2D_ObjectSetBackground (tDMA2D_pObject obj, unsigned int screen)
 
void DMA2D_SetTransform (tFctXY fct_X, tFctXY fct_Y)
 
u32 DMA2D_ObjectTransform (tDMA2D_pObject obj_dest, tDMA2D_pObject obj_src, tTrans *trsf)
 
u32 DMA2D_ObjectTransformReverse (tDMA2D_pObject obj_dest, tDMA2D_pObject obj_src, tFctObjXY fct)
 
void DMA2D_SDRAM_SwitchToBank (int bank)
 

Variables

tDMA2D_Screen LCD_ScreenImage [MAX_DMA2D_SCREEN]
 The screen table. More...
 
int DisplayedScreen
 This is the reference of the screen we see on the LCD. More...
 
int AddressedScreen
 This is the reference of the screen we are writing on. More...
 
tDMA2D_pObject SelectedObject
 Pointer to the selected object if any. More...
 
coord_t Xmin
 
coord_t Xmax
 
coord_t Ymin
 
coord_t Ymax
 
enum tModeLCDAccess DMALCD_ModeLCDAccess
 
int LCD_ScreenDirty
 General flag that indicates that the screen needs to be redrawn. More...
 
u16 DMALCD_Register_Table []
 

Detailed Description

Author
FL
Date
07/2013
Note
Platform = Open4 STM3242x Daughter Board

Definition in file dma2d_graphic.h.

Macro Definition Documentation

#define MAX_DMA2D_OBJECT   256

Definition at line 19 of file dma2d_graphic.h.

#define MAX_DMA2D_SCREEN   2

Definition at line 18 of file dma2d_graphic.h.

#define OBJECT_SINGLE_MEMORY_POOL_SIZE   (1024*512)

Definition at line 24 of file dma2d_graphic.h.

#define TEST_AFTER_TRANSFER   (!TEST_BEFORE_TRANSFER)

Definition at line 22 of file dma2d_graphic.h.

#define TEST_BEFORE_TRANSFER   0

Definition at line 21 of file dma2d_graphic.h.

Typedef Documentation

typedef u32 color32_t

Definition at line 27 of file dma2d_graphic.h.

typedef struct sdbmp tBmpDescriptor
typedef struct sDMA2D_Object tDMA2D_Object

Definition at line 94 of file dma2d_graphic.h.

Definition at line 115 of file dma2d_graphic.h.

typedef int( * tFctObjXY)(tDMA2D_pObject obj, int x, int y)

Definition at line 131 of file dma2d_graphic.h.

typedef int( * tFctXY)(int x, int y)

Definition at line 130 of file dma2d_graphic.h.

typedef u8 tpixel24[3]

Definition at line 28 of file dma2d_graphic.h.

Enumeration Type Documentation

Enumerator
CD_SCREENINIT 
CD_UPDATE 
CD_UNUSED_2 
CD_SCREENCLEAR 
CD_SCREENSELECT 
CD_SCREENSETDIRTY 
CD_SCREENREDRAW 
CD_SCREENCOPY 
CD_SCREENUNUSED 
CD_OBJECTCREATE 
CD_OBJECTDELETE 
CD_OBJECTSETTOSCREEN 
CD_OBJECTASSIGNBITMAP 
CD_OBJECTSETPARTIAL 
CD_OBJECTMOVE 
CD_OBJECTSETVISIBLE 
CD_OBJECTSELECT 
CD_OBJECTSETTRANSPARENCY 
CD_OBJECTGETPIXEL 
CD_OBJECTGETINTERSECTION 
CD_OBJECTGETPOS 
CD_OBJECTGETSIZE 
CD_OBJECTFIND 
CD_OBJECTGETIMAGE 
CD_OBJECTSETOFFSET 
CD_OBJECTPOPZ 
CD_OBJECTPUSHZ 
CD_OBJECTSETFOREGROUND 
CD_OBJECTSETBACKGROUND 
CD_SETTRANSFORM 
CD_OBJECTTRANSFORM 
CD_OBJECTTRANSFORMREVERSE 
CD_SDRAMBANKSWITCH 

Definition at line 192 of file dma2d_graphic.h.

Enumerator
SELNONE 
SELADDR 
SELDISP 
SELFULL 
SELNONE 
SELADDR 

If selected, the object (or screen) will handle all the "DRAW_xxx" commands.

SELDISP 

If selected, the screen will be displayed.

SELFULL 

If selected, both of the previous selections are performed.

Definition at line 117 of file dma2d_graphic.h.

Function Documentation

int DMA2D_ObjectAssignBitmap ( tDMA2D_pObject  obj,
void *  pbitmap,
int  fbitmap0constant1 
)

For a "rd only" object, assign the image bitmap.

Parameters
[in]obj,:object to be added on the screen
[in]pbitmap,:pointer to the bitmap or to a 32bit ARGB value for a colored rectangle
[in]fbitmap0constant1,:0 for a bitmap, and 1 for a constant (colored rectangle).

Definition at line 1137 of file dma2d_graphic.c.

tDMA2D_pObject DMA2D_ObjectCreate ( int  max_width,
int  max_height,
int  rdonly 
)

Allocate memory for the object (and the graphic area when rdonly=0) Reset memory and position. The return value should be tested (ok is non-zero).

Parameters
[in]max_width,:width of the overall bitmap
[in]max_height,:height of the overall bitmap
[in]rdonly,:1 if FLASH (read only) or 0 if RAM (rw)
Returns
: a pointer to the created object. 0 if there is not enough memory.

Definition at line 1011 of file dma2d_graphic.c.

void DMA2D_ObjectDelete ( tDMA2D_pObject  obj)

Remove the object from all screens and mark as dirty these screens. Free the memory of the object.

Parameters
[in]obj,:object to delete

Definition at line 1084 of file dma2d_graphic.c.

tDMA2D_pObject DMA2D_ObjectFind ( unsigned int  screen,
int  x,
int  y 
)

Search for an object (upper Z-order) that has a visible pixel on the point specified by the coordinates (x,y).

Parameters
[in]screen,:Id of the screen to be scanned
[in]x,:Absolute X position on the screen
[in]y,:Absolute Y position on the screen

Definition at line 1412 of file dma2d_graphic.c.

u32 DMA2D_ObjectGetImage ( tDMA2D_pObject  obj)

Return a pointer to the image

Parameters
[in]obj,:Pointer to the object

Definition at line 1448 of file dma2d_graphic.c.

u32 DMA2D_ObjectGetIntersection ( unsigned int  scrn,
tDMA2D_pObject  obj1,
tDMA2D_pObject  obj2 
)

Find the intersection between two objects. Ignore the pixel when one is fully transparent. The return value quantifies the intensity of the intersection on a 32 bit number. Note that this function is quite long (in execution time) because it could make many calls to DMA2D_ObjectGetPixel

Parameters
[in]scrnScreen that contains the object
[in]obj1Pointer to the first object
[in]obj2Pointer to the first object
Returns
the sum of the MIN_alpha values of all the pixels that belong to both objects. MIN_alpha is the smaller alpha value of the pixels of each objects.

Definition at line 865 of file dma2d_graphic.c.

color32_t DMA2D_ObjectGetPixel ( tDMA2D_pObject  obj,
int  x,
int  y 
)

Get a pixel within an object

Parameters
[in]objThe reference of the object to read.
[in]xX coordinates inside the object
[in]yY coordinates inside the object

Definition at line 791 of file dma2d_graphic.c.

int DMA2D_ObjectGetPos ( tDMA2D_pObject  obj,
unsigned int  screen 
)

Return the current position of an object.

Parameters
[in]obj,:Pointer to the object to draw.
[in]screen,:id of the screen.
Returns
: a 32 bit value. The upper 16 bit half-word contains Y, and the lower 16-bit contains X.

Definition at line 1475 of file dma2d_graphic.c.

int DMA2D_ObjectMove ( tDMA2D_pObject  obj,
int  x,
int  y 
)

Move an object for the selected screen.

Parameters
[in]obj,:Pointer to the object
[in]x,:New column for the left corners
[in]y,:New row for the lower corners.

Definition at line 1313 of file dma2d_graphic.c.

int DMA2D_ObjectPopZ ( tDMA2D_pObject  obj,
unsigned int  scr 
)

Pop the object to one layer upper (heading to the foreground)

Parameters
[in]obj,:Pointer to the object to draw.
[in]scr,:Index of the screen.
Returns
: current Z order after the operation. -1 if the object is not assigned to the screen.

Definition at line 1514 of file dma2d_graphic.c.

int DMA2D_ObjectPushZ ( tDMA2D_pObject  obj,
unsigned int  scr 
)

Push the object to one layer deeper (heading to the background)

Parameters
[in]obj,:Pointer to the object to draw.
[in]scr,:Index of the screen.
Returns
: current Z order after the operation. -1 if the object is not assigned to the screen.

Definition at line 1552 of file dma2d_graphic.c.

int DMA2D_ObjectSelect ( tDMA2D_pObject  obj)

Select the current object. The DRAW_xx functions can be applied either to a screen or to a simple object. DMA2D_ObjectSelect select an object, and DMA2D_ScreenSelect will unselect it. It could be also unselected by selecting another object...

Parameters
[in]obj,:The reference of the object to draw.

Definition at line 1360 of file dma2d_graphic.c.

int DMA2D_ObjectSetBackground ( tDMA2D_pObject  obj,
unsigned int  scr 
)

Push the object to layer 0 (the background)

Parameters
[in]obj,:Pointer to the object to draw.
[in]scr,:Index of the screen.
Returns
: current Z order after the operation. -1 if the object is not assigned to the screen.

Definition at line 1626 of file dma2d_graphic.c.

int DMA2D_ObjectSetForeground ( tDMA2D_pObject  obj,
unsigned int  scr 
)

Pop the object to the top layer (the foreground)

Parameters
[in]obj,:Pointer to the object to draw.
[in]scr,:Index of the screen.
Returns
: current Z order after the operation. -1 if the object is not assigned to the screen.

Definition at line 1590 of file dma2d_graphic.c.

int DMA2D_ObjectSetOffset ( tDMA2D_pObject  obj,
int  offsX,
int  offsY 
)

Specify an offset (from the low left corner) for the display of an object. This function is used to reduce the part of the image that will be displayed. It has to be combined with a call to DMA2D_ObjectSetPartial.

Parameters
[in]obj,:A pointer to the object to be modified.
[in]offsX,:The new offset on the X axis.
[in]offsY,:The new offset on the Y axis.

Definition at line 1275 of file dma2d_graphic.c.

int DMA2D_ObjectSetPartial ( tDMA2D_pObject  obj,
int  width,
int  height 
)

Resize an object. This function is used with DMA2D_ObjectSetOffset to display just a part of an object.

Parameters
[in]objPointer to the object to be modified.
[in]widthPartial width to be displayed (from the offset)
[in]heightPartial height to be displayed (from the offset)

Definition at line 1236 of file dma2d_graphic.c.

int DMA2D_ObjectSetToScreen ( tDMA2D_pObject  obj,
unsigned int  screen 
)

Attach an object to a screen.

Parameters
[in]screen,:reference of the screen.
[in]obj,:object to be added on the screen

Definition at line 1103 of file dma2d_graphic.c.

void DMA2D_ObjectSetTransparency ( tDMA2D_pObject  obj,
int  transparency 
)

Modify the transparency for the current object. The DRAW_ functions will agglomerate this transparency information to build the 32-bit pixel.

Parameters
[in]obj,:Pointer to the object to draw.
[in]transparency,:New global alpha constant for the object. Must be in the range [0,255].

Definition at line 1387 of file dma2d_graphic.c.

void DMA2D_ObjectSetVisible ( tDMA2D_pObject  obj,
int  mode 
)

Make an object visible/not visible

Parameters
[in]obj,:Pointer to the object
[in]mode,:1 to see the object, 0 to hide it.

Definition at line 1339 of file dma2d_graphic.c.

u32 DMA2D_ObjectTransform ( tDMA2D_pObject  obj_dest,
tDMA2D_pObject  obj_src,
tTrans trsf 
)

Generic transform function use to copy, rotate, resize an object. The destination and the source objects could be the same. This function takes every pixel of the SOURCE, and calculate its destination. Note that when an offset or/and a partial size is specified, they will be used. This function is a bit complex (comparing with ObjectTransformReverse) because it properly manages the case of identical SOURCE/DESTINATION.

Parameters
[in]obj_dest,:Destination object.
[in]obj_src,:Source object
[in]trsf,:Definition of the transform functions
Returns
: 0 is ok, error code

Definition at line 1725 of file dma2d_graphic.c.

u32 DMA2D_ObjectTransformReverse ( tDMA2D_pObject  obj_dest,
tDMA2D_pObject  obj_src,
tFctObjXY  fct 
)

Generic transform function use to copy, rotate, resize, modify the color of an object.... This function takes every pixel of the DESTINATION, and calculate its new value. If the destination and the source are the same, some issues could happen depending on how the object is read (order). For example, it cannot be used to rotate an image on itself (the direct DMA2D_ObjectTransform must be used).

Parameters
[in]obj_dest,:Destination object
[in]obj_src,:Source object
[in]fct,:Definition of the transform function (return the pixel new contents for (x,y)
Returns
: 0 is ok, error code

Definition at line 1885 of file dma2d_graphic.c.

void DMA2D_Rotate ( Rotate_H12_V_Match_TypeDef  old_orientation,
Rotate_H12_V_Match_TypeDef  new_orientation 
)
void DMA2D_ScreenClear ( unsigned int  screen,
int  del 
)
Parameters
[in]screenThe reference of the new screen to delete.
[in]delwhen 1, the referenced objects will be deleted as well

Definition at line 674 of file dma2d_graphic.c.

void DMA2D_ScreenCopy ( unsigned int  dest,
unsigned int  src 
)

Copy a screen into another.

Parameters
[in]destThe reference of the destination screen.
[in]srcThe reference of the source screen.

Definition at line 963 of file dma2d_graphic.c.

void DMA2D_ScreenInit ( void  )

Enable DMA/DMA2D mode Clear all screens, select screen0, Create generic home page for the application on screen0 Update screen0

< Enable DMA, DMA2D and SDRAM

Definition at line 586 of file dma2d_graphic.c.

void DMA2D_ScreenRedraw ( unsigned int  screen)

Rebuild the screen.

Parameters
[in]screenThe reference of the new screen to activate.

Definition at line 710 of file dma2d_graphic.c.

void DMA2D_ScreenSelect ( unsigned int  screen,
enum SELECT_MODE  mode 
)

Select the current screen.

Parameters
[in]screenThe reference of the new screen to activate.
[in]modeSpecifies if the selection is for the display or the addressing (or both)

Definition at line 643 of file dma2d_graphic.c.

void DMA2D_ScreenSetDirty ( unsigned int  screen)
inline

Set the dirty flag to trigger an update.

Parameters
[in]screenThe reference of the new screen to declare dirty.

Definition at line 624 of file dma2d_graphic.c.

void DMA2D_SDRAM_SwitchToBank ( int  bank)

The following codes are used by the DMA2D_Dispatch function to redirect to the right action. (because the general jump table is almost full an indirection has been used for DMA2D functions).

void DMA2D_SetDrawingMode ( int  mode,
void *  obj 
)
void DMA2D_SetTransform ( tFctXY  fct_X,
tFctXY  fct_Y 
)

Define the transform function before calling DMA2D_ObjectTransform

Parameters
[in]fct_X,:Transform function for X
[in]fct_Y,:Transform function for Y
Returns
: none

Definition at line 1861 of file dma2d_graphic.c.

void DMA2D_Update ( void  )

Variable Documentation

int AddressedScreen
int DisplayedScreen
enum tModeLCDAccess DMALCD_ModeLCDAccess
u16 DMALCD_Register_Table[]
int LCD_ScreenDirty
tDMA2D_Screen LCD_ScreenImage[MAX_DMA2D_SCREEN]
tDMA2D_pObject SelectedObject
coord_t Xmax
coord_t Xmin
coord_t Ymax
coord_t Ymin