30 #define DELAY_PULSE_NS 1000 // 1us
31 #define DELAY_SETTLE_NS 40000 // 40us
32 #define DELAY_SETUP_0_NS 15000000L // 15ms
33 #define DELAY_SETUP_1_NS 5000000L // 5ms
34 #define DELAY_SETUP_2_NS 1000000L // 1ms
44 #define PIN_BACKLIGHT 7
47 #define LCD_CLEARDISPLAY 0x01
48 #define LCD_RETURNHOME 0x02
49 #define LCD_ENTRYMODESET 0x04
50 #define LCD_DISPLAYCONTROL 0x08
51 #define LCD_CURSORSHIFT 0x10
52 #define LCD_FUNCTIONSET 0x20
53 #define LCD_SETCGRAMADDR 0x40
54 #define LCD_SETDDRAMADDR 0x80
55 #define LCD_NEWLINE 0xC0
58 #define LCD_ENTRYRIGHT 0x00
59 #define LCD_ENTRYLEFT 0x02
60 #define LCD_ENTRYSHIFTINCREMENT 0x01
61 #define LCD_ENTRYSHIFTDECREMENT 0x00
64 #define LCD_DISPLAYON 0x04
65 #define LCD_DISPLAYOFF 0x00
66 #define LCD_CURSORON 0x02
67 #define LCD_CURSOROFF 0x00
68 #define LCD_BLINKON 0x01
69 #define LCD_BLINKOFF 0x00
72 #define LCD_DISPLAYMOVE 0x08
73 #define LCD_CURSORMOVE 0x00
74 #define LCD_MOVERIGHT 0x04
75 #define LCD_MOVELEFT 0x00
78 #define LCD_8BITMODE 0x10
79 #define LCD_4BITMODE 0x00
80 #define LCD_2LINE 0x08
81 #define LCD_1LINE 0x00
82 #define LCD_5X10DOTS 0x04
83 #define LCD_5X8DOTS 0x00
85 #define LCD_MAX_LINES 2
87 #define LCD_RAM_WIDTH 80 // RAM is 80 wide, split over two lines
89 static const uint8_t ROW_OFFSETS[] = {0, 0x40};
102 int pifacecad_open(
void);
115 int pifacecad_open_noinit(
void);
126 void pifacecad_close(
void);
137 void pifacecad_lcd_init(
void);
147 uint8_t pifacecad_read_switches(
void);
157 uint8_t pifacecad_read_switch(uint8_t switch_num);
170 uint8_t pifacecad_lcd_write(
const char * message);
180 uint8_t pifacecad_lcd_set_cursor(uint8_t col, uint8_t row);
190 void pifacecad_lcd_set_cursor_address(uint8_t address);
200 uint8_t pifacecad_lcd_get_cursor_address(
void);
210 void pifacecad_lcd_clear(
void);
220 void pifacecad_lcd_home(
void);
230 void pifacecad_lcd_display_on(
void);
240 void pifacecad_lcd_display_off(
void);
250 void pifacecad_lcd_blink_on(
void);
260 void pifacecad_lcd_blink_off(
void);
270 void pifacecad_lcd_cursor_on(
void);
280 void pifacecad_lcd_cursor_off(
void);
290 void pifacecad_lcd_backlight_on(
void);
300 void pifacecad_lcd_backlight_off(
void);
310 void pifacecad_lcd_move_left(
void);
320 void pifacecad_lcd_move_right(
void);
331 void pifacecad_lcd_left_to_right(
void);
342 void pifacecad_lcd_right_to_left(
void);
352 void pifacecad_lcd_autoscroll_on(
void);
362 void pifacecad_lcd_autoscroll_off(
void);
373 void pifacecad_lcd_write_custom_bitmap(uint8_t location);
385 void pifacecad_lcd_store_custom_bitmap(uint8_t location, uint8_t bitmap[]);
395 void pifacecad_lcd_send_command(uint8_t command);
405 void pifacecad_lcd_send_data(uint8_t data);
415 void pifacecad_lcd_send_byte(uint8_t byte);
425 void pifacecad_lcd_set_rs(uint8_t state);
435 void pifacecad_lcd_set_rw(uint8_t state);
445 void pifacecad_lcd_set_enable(uint8_t state);
455 void pifacecad_lcd_set_backlight(uint8_t state);
465 void pifacecad_lcd_pulse_enable(
void);
475 uint8_t colrow2address(uint8_t col, uint8_t row);
485 uint8_t address2col(uint8_t address);
495 uint8_t address2row(uint8_t address);