Restructure
[liquid-crystal-terminal.git] / terminal / lcd.h
1 #ifndef _H_LCD
2 #define _H_LCD
3
4 // LCD pins
5 #define LCD_REGSEL 3 // Register select
6 #define LCD_ENABLE 4 // Chip enable
7 #define LCD_D4 5 // Data line
8 #define LCD_D5 6 // Data line
9 #define LCD_D6 7 // Data line
10 #define LCD_D7 8 // Data line
11 #define LCD_BL 2 // Backlight
12
13 LiquidCrystal lcd(LCD_REGSEL, LCD_ENABLE, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
14
15 enum backlight_state {
16 BL_OFF,
17 BL_ON,
18 BL_FLASH
19 };
20
21 struct backlight {
22 enum backlight_state state;
23 unsigned int timer;
24 };
25
26 #define COLS 40
27 #define ROWS 2
28
29 /**
30 * Special characters.
31 * See https://www.quinapalus.com/hd44780udg.html to make more.
32 * Define which ones are used (max. 8) in setup().
33 * When they need to be changed at runtime, make sure the cursor is disabled
34 * and call setCursor afterwards.
35 */
36 unsigned char char_music[8] = {0x02,0x03,0x02,0x0e,0x1e,0x0c,0x00};
37 unsigned char char_smile[8] = {0x00,0x00,0x0a,0x00,0x11,0x0e,0x00};
38 unsigned char char_bar_1[8] = {0x00,0x00,0x00,0x00,0x00,0x00,0x1f};
39 unsigned char char_bar_2[8] = {0x00,0x00,0x00,0x00,0x00,0x1f,0x1f};
40 unsigned char char_bar_3[8] = {0x00,0x00,0x00,0x00,0x1f,0x1f,0x1f};
41 unsigned char char_bar_4[8] = {0x00,0x00,0x00,0x1f,0x1f,0x1f,0x1f};
42 unsigned char char_bar_5[8] = {0x00,0x00,0x1f,0x1f,0x1f,0x1f,0x1f};
43 unsigned char char_bar_6[8] = {0x00,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f};
44 unsigned char char_bar_7[8] = {0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f};
45 unsigned char char_hbar_start_empty[8] = {0x1f,0x10,0x10,0x10,0x10,0x10,0x1f};
46 unsigned char char_hbar_start_full[8] = {0x1f,0x10,0x17,0x17,0x17,0x10,0x1f};
47 unsigned char char_hbar_inner_empty[8] = {0x1f,0x00,0x00,0x00,0x00,0x00,0x1f};
48 unsigned char char_hbar_inner_half[8] = {0x1f,0x00,0x1c,0x1c,0x1c,0x00,0x1f};
49 unsigned char char_hbar_inner_full[8] = {0x1f,0x00,0x1f,0x1f,0x1f,0x00,0x1f};
50 unsigned char char_hbar_end_empty[8] = {0x1f,0x01,0x01,0x01,0x01,0x01,0x1f};
51 unsigned char char_hbar_end_full[8] = {0x1f,0x01,0x1d,0x1d,0x1d,0x01,0x1f};
52
53 void lcd_setup(void);
54 void bl_tasks(void);
55 void bl_set(enum backlight_state);
56
57 #endif