Platform-specific layer provides a consistent API to upper layers of the driver.
Character LCD Overview
This API contains the functions to configure and control a character LCD based on the HD44780, KS0066U or equivalent display controller, with a programmable XBee device.
Character LCD Macros
The character LCD API needs to have defined the XBee pins that compose the data port and which XBee pins are used to control the LCD. For that purpose you have to define some macros before initialize the character LCD.
- Macros to configure the data port of the character LCD:
- \b CHAR_LCD_DATA_XPINS : Indicates which XBee pins are used for
the data port of the LCD.
- Macros to configure the control lines of the character LCD:
- \b CHAR_LCD_RS_XPIN : Indicates which XBee pin will be
configured for the RS line.
- \b CHAR_LCD_RW_XPIN : Indicates which XBee pin will be
configured for the RW line.
- \b CHAR_LCD_EN_XPIN : Indicates which XBee pin will be
configured for the EN line.
Usage example:
#define CHAR_LCD_DATA_XPINS {XPIN_4, XPIN_7, XPIN_11, XPIN_12}
#define CHAR_LCD_RS_XPIN XPIN_16
#define CHAR_LCD_RW_XPIN XPIN_17
#define CHAR_LCD_EN_XPIN XPIN_18
- Warning
- It is recommended not to use these macros, they are used by the XBee Project Smart Editor of the XBee extensions.
There are other macros that configures the number of lines and columns (characters) of the display. This configuration macro must be also defined before initializing the LCD.
- Macros to configure the number of lines and columns:
- CHAR_LCD_CFG_2x16 : Indicates that the LCD has 2 lines and 16 characters.
- CHAR_LCD_CFG_4x20 : Indicates that the LCD has 4 lines and 20 characters.
Usage example:
#define CHAR_LCD_CFG_2x16
- Warning
- It is recommended not to use these macros, they are used by the XBee Project Smart Editor of the XBee extensions.
Appart from the previous macros, the char_lcd_init() method of the character LCD API needs as argument a byte containing the initial configuration masks for the display. These masks are defined with macros and they are the following:
- Macros to configure the \b LCD display:
- \b CHAR_LCD_DISP_ON : The LCD display is ON.
- \b CHAR_LCD_DISP_OFF : The LCD display is OFF.
- Macros to configure (show/hide) the LCD cursor:
- \b CHAR_LCD_CURSOR_ON : The LCD cursor is displayed.
- \b CHAR_LCD_CURSOR_OFF : The LCD cursor is hidden.
- Macros to enable or disable the the LCD cursor blinking:
- \b CHAR_LCD_CUR_BLINK_ON : The LCD cursor blinking is enabled.
- \b CHAR_LCD_CUR_BLINK_OFF : The LCD cursor blinking is disabled.
Usage example:
char_lcd_init(CHAR_LCD_DISP_ON | CHAR_LCD_CURSOR_ON | CHAR_LCD_CUR_BLINK_OFF);
- Warning
- It is recommended not to use these macros, they are used by the XBee Project Smart Editor of the XBee extensions.
void char_lcd_clear |
( |
void |
| ) |
|
Clears the LCD display screen and sets the cursor position to 0,0.
- Parameters
-
- Return values
-
void char_lcd_cmd_write |
( |
uint8_t |
cmd | ) |
|
Writes a command in the display instruction register.
- Parameters
-
[in] | cmd | the value (command) to write. |
- Return values
-
void char_lcd_cursor_blink_on_off |
( |
bool_t |
on | ) |
|
Enables the cursor blink.
- Parameters
-
[in] | on | if equal to 1, enables the cursor blink |
- Return values
-
void char_lcd_cursor_on_off |
( |
bool_t |
on | ) |
|
Turns ON/OFF the display cursor.
- Parameters
-
[in] | on | if equal to 1, turns on the display cursor. |
- Return values
-
Sets the cursor position to the specified coordinates.
- Parameters
-
[in] | x | set the cursor to column x |
[in] | y | set the cursor to row y |
- Return values
-
int | 0 on success |
-EINVAL | on error (invalid coordinates) |
int char_lcd_init |
( |
uint8_t |
config | ) |
|
Initialices the LCD display.
- Parameters
-
[in] | config | a byte containing the Initial configuration for display on/off, cursor on/off and blink on/off. See Character LCD Macros for more information. |
- Return values
-
int | 0 on success |
int | error code on error |
Turns ON/OFF the entire display. When turned off, the data remains in the display DDRAM.
- Parameters
-
[in] | on | if equal to 1, turns on the display. |
- Return values
-
void char_lcd_putchar |
( |
uint8_t |
data | ) |
|
Writes data byte in the LCD display.
- Parameters
-
[in] | data | byte that will be written |
- Return values
-
Reads a byte from the display memory, at the specified coordinates.
- Parameters
-
[in] | x | column from where will be read the display character |
[in] | y | row from where will be read teh display character |
- Return values
-
int | the value read from teh display DDRAM |
int | error code on error |
Writes in the display len bytes from data buffer.
- Parameters
-
[in] | data | buffer that will be written in the display |
[in] | len | number of bytes that will be written |
- Return values
-
ssize_t | number of bytes written on success |
error | code on error |