#include <inttypes.h>
#include <stdio.h>
#include <avr/pgmspace.h>
Functions | |
void | lcd_init (void) |
void | lcd_set_custom_char (uint8_t chnum, uint8_t *data) |
void | lcd_write_data (uint8_t data) |
void | lcd_print (const char *string) |
int | lcd_vprintf (const char *fmt, va_list ap) |
int | lcd_printf (const char *fmt,...) |
int | lcd_print_char (char ch, FILE *f) |
void | lcd_clear (void) |
uint8_t | lcd_get_pos (void) |
void | lcd_set_pos (uint8_t p) |
+----------------+ line 1: |0123456789012345| line 2: |6789 | +----------------+
For general LCD printing, printf() is suggested. printf() is a wrapper around the functions documented below. As such these functions should only be used when printf() is insufficient.
Printing a newline character ("\n" in C) to the display clears it. Thus, printf("hello world\n"), will not display anything (the display is cleared after the text is displayed). Instead, you should use printf("\nhello world")
The OS will occasionally use the bottom right character of the display for warning/information icons, which may obscure user printouts (if they use the full 32 characters of the display).
The LCD supports 8 user-defined characters. On startup these characters are set to a system defaults as follows:
0: unsused 1: smiley face 2: alternate smiley face 3: frowny face 4: low battery indicator 5: loading indicator 6: bootloader indicator 7: unused
These special characters can be reconfigured by the user with the lcd_set_custom_char() function, as long as you remember this will change the OS warning indicator icons.
void lcd_clear | ( | void | ) |
Clear the LCD Screen.
uint8_t lcd_get_pos | ( | void | ) |
Return the current cursor position.
void lcd_init | ( | void | ) |
Initialise the LCD driver
void lcd_print | ( | const char * | string | ) |
Display a string to the LCD.
string | string to display |
int lcd_print_char | ( | char | ch, | |
FILE * | f | |||
) |
Print a single character to the LCD.
ch | character to display | |
f | ignored |
int lcd_printf | ( | const char * | fmt, | |
... | ||||
) |
Display a formated string to the LCD.
fmt | format to display |
void lcd_set_custom_char | ( | uint8_t | chnum, | |
uint8_t * | data | |||
) |
Sets a custom LCD character. The LCD has space for 8 custom characters (characters 0-7.) Note that the OS uses some of these charaters for the status indicator. The data is read from program (flash) memory and therefore should be defined as PROGMEM, eg:
uint8_t my_custom_char[] PROGMEM = { 12, 23, 34, 45, 56, 67, 78, 89 };
chnum | character to set | |
data | 8 byte array of pixel data |
void lcd_set_pos | ( | uint8_t | p | ) |
Set the current cursor position.
p | position to move to [0..31] |
int lcd_vprintf | ( | const char * | fmt, | |
va_list | ap | |||
) |
Display a formated string to the LCD.
fmt | format to display | |
ap | virtual argument list |
void lcd_write_data | ( | uint8_t | data | ) |
Write a data byte to the LCD. Should not normally be needed by user code.
data | byte to write. |