Listing 51 continued LCD C

*******************************************************

* DEFINE CHARACTER

* Description : This function defines the dot pattern for a character.

* Arguments : 'id' is the identifier for the desired dot pattern.

* 'pat' is a pointer to an 8 BYTE array containing the dot pattern.

*********************************************************************************************************

void DispDefChar (INT8U id, INT8U »pat) {

INT8U err; XNT8U i;

OSSemPend(DispSem, 0, Serr) ; DispSel (DISP_SEL_CMD_KEG) ; DispDataWr(0x40 + (id « 3)); DispSel (DISPJ3EL_DATA_REG) ; for (i = 0; i < 8; i++) { DispDataWr ( *pat++) ;

OSSemPost (DispSan) ;

/* Obtain exclusive access to the display /* Select command register /* Set address of CG RAM /* Select the data register

/* Write pattern into CG RAM

/* Release access to display

************************************************************************** * DUMMY FUNCTION

* Description : This function doesn't do anything. It is used to act like a NOP (i.e. No Operation) to

* waste a few CPU cycles and thus, act as a short delay.

* Arguments : none

*********************************************************************************************************

void DispDunrny (void) {

*********************************************************************************************************

* DISPLAY A HORIZONTAL BAR

* Description : This function allows you to display horizontal bars (bar graphs) on the LCD module.

* Arguments : 'row' is the row position of the cursor in the LCD Display

* 'val' is the value of the horizontal bar. This value cannot exceed:

* DispMaxCols * 5

* Notes : To use this function, you must first call DispHorBarlnitO *********************************************************************************************************

void DispHorBar CENT8U row, INT8U col, INT8U val) {

INT8U i; INT8U full; ZNT8U fract; INr8U err;

if (row < DisfMaxRows && (col + full OSSemPend (DispSem, 0, &err) ; i = 0;

DispCursorSet ( row, col ) ; DispSel (DISPJ3EL_DATA_REG) ; while (full > 0) { DispDataVfr(5) ; i++; full—;

lïispEataVJr(fract) ;

OSSenPost (DispSem) ;

/* Compute portion of block */

1) < DisfMaxCols) { /* Obtain exclusive access to the display */

/* Set counter to limit column to maximum allowable column */ /* Position cursor at beginning of the bar graph */

/* Send custom character #5 which is full block /* Increment limit counter

/* Send custom character ft 'fract' (i.e. portion of block) */ /* Release access to display */

Was this article helpful?

0 0

Post a comment