-
Notifications
You must be signed in to change notification settings - Fork 75
/
lcd.h
184 lines (143 loc) · 4.7 KB
/
lcd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*
lcd - include file
Copyright (C) 2011 Pavel Semerad
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _LCD_INCLUDED
#define _LCD_INCLUDED
#include "gt3b.h"
// manipulating individual segments, pos is one of 128 segments
// as special value (see below)
#define LS_OFF 0
#define LS_ON 1
extern void lcd_segment(u8 pos, u8 on_off);
#define LB_OFF 0
#define LB_SPC 1
#define LB_INV 2
extern void lcd_segment_blink(u8 pos, u8 on_off);
// arrays of segment positions for lcd_segment()
// for chars and 7seg is order from top left to down, then next column
// for menu is order from top left to right, then next line
#define LCD_CHAR_COLS 5
#define LCD_CHAR_ROWS 7
#define LCD_CHAR_BYTES (LCD_CHAR_COLS * LCD_CHAR_ROWS)
extern const u8 lcd_seg_char1[];
extern const u8 lcd_seg_char2[];
extern const u8 lcd_seg_char3[];
extern const u8 lcd_seg_7seg[];
extern const u8 lcd_seg_menu[];
// lcd segments addresses for symbols
#define LS_SYM_LOWPWR 0xdf
#define LS_SYM_CHANNEL 0xde
#define LS_SYM_MODELNO 0xdd
#define LS_SYM_PERCENT 0xc7
#define LS_SYM_LEFT 0xcf
#define LS_SYM_RIGHT 0xc8
#define LS_SYM_DOT 0xdc
#define LS_SYM_VOLTS 0xc6
// lcd segment addresses for menu
#define LS_MENU_MODEL 0xd0
#define LS_MENU_NAME 0xcd
#define LS_MENU_REV 0xcb
#define LS_MENU_EPO 0xca
#define LS_MENU_TRIM 0xd1
#define LS_MENU_DR 0xce
#define LS_MENU_EXP 0xcc
#define LS_MENU_ABS 0xc9
// manipulating group of segment together by applying bitmaps
extern void lcd_set(u8 id, u8 *bitmap);
extern void lcd_set_blink(u8 id, u8 on_off);
// IDs for lcd_set(), lcd_set_blink()
#define LCHR1 0
#define LCHR2 1
#define LCHR3 2
#define L7SEG 3
#define LMENU 4
// special (fake) bitmaps for lcd_set()
#define LB_EMPTY (u8 *)0xff00
#define LB_FULL (u8 *)0xffff
// high level functions to write chracters and numbers
#define LCHAR_MINUS_ONE ('Z' + 1)
#define LCHAR_ONE_ZERO ('Z' + 2)
#define LCHAR_MIN ' '
#define LCHAR_MAX LCHAR_ONE_ZERO
#define L7SEG_MAX 15
extern void lcd_char(u8 id, u8 c); // id the same as in lcd_set()
extern void lcd_chars(u8 *chars); // 3 chars
extern void lcd_chars2(u8 *chars); // 2 chars to chars 2+3
extern void lcd_char_num3(s16 num); // num -199...1099 to 3 chars
extern void lcd_char_num2_lbl(s8 num, u8 *labels); // num -99..99 with labels for <0, =0, >0
extern void lcd_7seg(u8 number); // num 0-15 (>=10 as hexa numbers)
extern void lcd_menu(u8 menus); // OR-ed selected menus
extern void lcd_chars_blink(u8 on_off); // lcd_set_blink() for 3 chars
extern void lcd_chars_blink_mask(u8 on_off, u8 mask); // lcd_set_blink() for 3 chars masked by bits
#define LB_CHR1 0b00000001
#define LB_CHR2 0b00000010
#define LB_CHR3 0b00000100
// values for lcd_menu()
#define LM_MODEL 0x80
#define LM_NAME 0x40
#define LM_REV 0x20
#define LM_EPO 0x10
#define LM_TRIM 0x08
#define LM_DR 0x04
#define LM_EXP 0x02
#define LM_ABS 0x01
// values for lcd_7seg() - IDs of 7seg letters
#define L7_A 10
#define L7_B 11
#define L7_C 12
#define L7_D 13
#define L7_E 14
#define L7_F 15
#define L7_G 16
#define L7_H 17
#define L7_I 18
#define L7_J 19
#define L7_K 20
#define L7_L 21
#define L7_M 22
#define L7_N 23
#define L7_O 24
#define L7_P 25
#define L7_R 26
#define L7_T 27
#define L7_U 28
#define L7_V 29
#define L7_Y 30
#define L7_MINUS 31
// update/clear/set
extern void lcd_update(void); // this one actually write to display
#define lcd_update_pause() lcd_update(); pause()
#define lcd_update_stop() lcd_update(); stop()
extern void lcd_clear(void);
extern void lcd_set_full_on(void);
// for lcd_blink_cnt, maximal value and value when changing to space
// in 5ms steps
#define LCD_BLNK_CNT_MAX 160
#define LCD_BLNK_CNT_BLANK 100
extern volatile _Bool lcd_blink_flag;
extern volatile u8 lcd_blink_cnt;
extern volatile _Bool lcd_blink_something;
// for backlight
#define LCD_BCK0 BRES(PD_ODR, 2)
#define LCD_BCK1 BSET(PD_ODR, 2)
extern _Bool lcd_bck_on;
extern u16 lcd_bck_count;
#define BACKLIGHT_MAX (u16)(0xffff)
extern void backlight_set_default(u16 seconds);
extern void backlight_on_sec(u16 seconds);
extern void backlight_on(void);
extern void backlight_off(void);
// LCD task
E_TASK(LCD);
#endif