Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1920 | - | 1 | /***************************************************************************** |
2 | * Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
||
3 | * - original LCD control by Thomas "thkais" Kaiser * |
||
4 | * - special number formating routines taken from C-OSD * |
||
5 | * from Claas Anders "CaScAdE" Rathje * |
||
6 | * - some extension, ellipse and circ_line by Peter "woggle" Mack * |
||
7 | * Thanks to Oliver Schwaneberg for adding several functions to this library!* |
||
8 | * * |
||
9 | * Author: Jan Michel (jan at mueschelsoft dot de) * |
||
10 | * License: GNU General Public License, version 3 * |
||
11 | * Version: v0.93 September 2010 * |
||
12 | * * |
||
13 | * This program is free software; you can redistribute it and/or modify * |
||
14 | * it under the terms of the GNU General Public License as published by * |
||
15 | * the Free Software Foundation; either version 2 of the License. * |
||
16 | * * |
||
17 | * This program is distributed in the hope that it will be useful, * |
||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
20 | * GNU General Public License for more details. * |
||
21 | * * |
||
22 | * You should have received a copy of the GNU General Public License * |
||
23 | * along with this program; if not, write to the * |
||
24 | * Free Software Foundation, Inc., * |
||
25 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
26 | * * |
||
27 | *****************************************************************************/ |
||
28 | |||
29 | #ifndef _LCD_H |
||
30 | #define _LCD_H |
||
31 | |||
32 | /* |
||
33 | |||
34 | //----------------------------------------------------------------------------- |
||
35 | // Command Codes |
||
36 | //----------------------------------------------------------------------------- |
||
37 | //1: Display on/off |
||
38 | #define LCD_DISPLAY_ON 0xAF //switch display on |
||
39 | #define LCD_DISPLAY_OFF 0xAE //switch display off |
||
40 | |||
41 | //2: display start line set (lower 6 bits select first line on lcd from 64 lines in memory) |
||
42 | #define LCD_START_LINE 0x40 |
||
43 | |||
44 | //3: Page address set (lower 4 bits select one of 8 pages) |
||
45 | #define LCD_PAGE_ADDRESS 0xB0 |
||
46 | |||
47 | //4: column address (lower 4 bits are upper / lower nibble of column address) |
||
48 | #define LCD_COL_ADDRESS_MSB 0x10 |
||
49 | #define LCD_COL_ADDRESS_LSB 0x00 //second part of column address |
||
50 | |||
51 | //8: select orientation (black side of the display should be further away from viewer) |
||
52 | #define LCD_BOTTOMVIEW 0xA1 //6 o'clock view |
||
53 | #define LCD_TOPVIEW 0xA0 //12 o'clock view |
||
54 | |||
55 | //9: select normal (white background, black pixels) or reverse (black background, white pixels) mode |
||
56 | #define LCD_DISPLAY_POSITIVE 0xA6 //not inverted mode |
||
57 | #define LCD_DISPLAY_INVERTED 0xA7 //inverted display |
||
58 | |||
59 | //10: show memory content or switch all pixels on |
||
60 | #define LCD_SHOW_NORMAL 0xA4 //show dram content |
||
61 | #define LCD_SHOW_ALL_POINTS 0xA5 //show all points |
||
62 | |||
63 | //11: lcd bias set |
||
64 | #define LCD_BIAS_1_9 0xA2 |
||
65 | #define LCD_BIAS_1_7 0xA3 |
||
66 | |||
67 | //14: Reset Controller |
||
68 | #define LCD_RESET_CMD 0xE2 |
||
69 | |||
70 | //15: output mode select (turns display upside-down) |
||
71 | #define LCD_SCAN_DIR_NORMAL 0xC0 //normal scan direction |
||
72 | #define LCD_SCAN_DIR_REVERSE 0xC8 //reversed scan direction |
||
73 | |||
74 | //16: power control set (lower 3 bits select operating mode) |
||
75 | //Bit 0: Voltage follower on/off - Bit 1: Voltage regulator on/off - Bit 2: Booster circuit on/off |
||
76 | #define LCD_POWER_CONTROL 0x28 //base command |
||
77 | #define LCD_POWER_LOW_POWER 0x2F |
||
78 | #define LCD_POWER_WIDE_RANGE 0x2F |
||
79 | #define LCD_POWER_LOW_VOLTAGE 0x2B |
||
80 | |||
81 | //17: voltage regulator resistor ratio set (lower 3 bits select ratio) |
||
82 | //selects lcd voltage - 000 is low (~ -2V), 111 is high (~ - 10V), also depending on volume mode. Datasheet suggests 011 |
||
83 | #define LCD_VOLTAGE 0x20 |
||
84 | |||
85 | //18: Volume mode set (2-byte command, lower 6 bits in second word select value, datasheet suggests 0x1F) |
||
86 | #define LCD_VOLUME_MODE_1 0x81 |
||
87 | #define LCD_VOLUME_MODE_2 0x00 |
||
88 | |||
89 | //#if DISPLAY_TYPE == 128 || DISPLAY_TYPE == 132 |
||
90 | //19: static indicator (2-byte command), first on/off, then blinking mode |
||
91 | #define LCD_INDICATOR_ON 0xAD //static indicator on |
||
92 | #define LCD_INDICATOR_OFF 0xAC //static indicator off |
||
93 | #define LCD_INDICATOR_MODE_OFF 0x00 |
||
94 | #define LCD_INDICATOR_MODE_1HZ 0x01 |
||
95 | #define LCD_INDICATOR_MODE_2HZ 0x10 |
||
96 | #define LCD_INDICATOR_MODE_ON 0x11 |
||
97 | |||
98 | //20: booster ratio set (2-byte command) |
||
99 | #define LCD_BOOSTER_SET 0xF8 //set booster ratio |
||
100 | #define LCD_BOOSTER_234 0x00 //2x-4x |
||
101 | #define LCD_BOOSTER_5 0x01 //5x |
||
102 | #define LCD_BOOSTER_6 0x03 //6x |
||
103 | //#endif |
||
104 | |||
105 | //22: NOP command |
||
106 | #define LCD_NOP 0xE3 |
||
107 | |||
108 | //#if DISPLAY_TYPE == 102 |
||
109 | ////25: advanced program control |
||
110 | //#define LCD_ADV_PROG_CTRL 0xFA |
||
111 | //#define LCD_ADV_PROG_CTRL2 0x10 |
||
112 | //#endif |
||
113 | |||
114 | //----------------------------------------------------------------------------- |
||
115 | // Makros to execute commands |
||
116 | //----------------------------------------------------------------------------- |
||
117 | |||
118 | #define LCD_SWITCH_ON() lcd_command(LCD_DISPLAY_ON) |
||
119 | #define LCD_SWITCH_OFF() lcd_command(LCD_DISPLAY_OFF) |
||
120 | #define LCD_SET_FIRST_LINE(i) lcd_command(LCD_START_LINE | ((i) & 0x3F)) |
||
121 | #define LCD_SET_PAGE_ADDR(i) lcd_command(LCD_PAGE_ADDRESS | ((i) & 0x0F)) |
||
122 | #define LCD_SET_COLUMN_ADDR(i) lcd_command(LCD_COL_ADDRESS_MSB | ((i>>4) & 0x0F)); \ |
||
123 | lcd_command(LCD_COL_ADDRESS_LSB | ((i) & 0x0F)) |
||
124 | #define LCD_GOTO_ADDRESS(page,col); lcd_command(LCD_PAGE_ADDRESS | ((page) & 0x0F)); \ |
||
125 | lcd_command(LCD_COL_ADDRESS_MSB | ((col>>4) & 0x0F)); \ |
||
126 | lcd_command(LCD_COL_ADDRESS_LSB | ((col) & 0x0F)); |
||
127 | |||
128 | #define LCD_SET_BOTTOM_VIEW() lcd_command(LCD_BOTTOMVIEW) |
||
129 | #define LCD_SET_TOP_VIEW() lcd_command(LCD_TOPVIEW) |
||
130 | #define LCD_SET_MODE_POSITIVE() lcd_command(LCD_DISPLAY_POSITIVE) |
||
131 | #define LCD_SET_MODE_INVERTED() lcd_command(LCD_DISPLAY_INVERTED) |
||
132 | #define LCD_SHOW_ALL_PIXELS_ON() lcd_command(LCD_SHOW_ALL_POINTS) |
||
133 | #define LCD_SHOW_ALL_PIXELS_OFF() lcd_command(LCD_SHOW_NORMAL) |
||
134 | #define LCD_SET_BIAS_RATIO_1_7() lcd_command(LCD_BIAS_1_7) |
||
135 | #define LCD_SET_BIAS_RATIO_1_9() lcd_command(LCD_BIAS_1_9) |
||
136 | #define LCD_SEND_RESET() lcd_command(LCD_RESET_CMD) |
||
137 | #define LCD_ORIENTATION_NORMAL() lcd_command(LCD_SCAN_DIR_NORMAL) |
||
138 | #define LCD_ORIENTATION_UPSIDEDOWN() lcd_command(LCD_SCAN_DIR_REVERSE) |
||
139 | #define LCD_SET_POWER_CONTROL(i) lcd_command(LCD_POWER_CONTROL | ((i) & 0x07)) |
||
140 | #define LCD_SET_LOW_POWER() lcd_command(LCD_POWER_LOW_POWER) |
||
141 | #define LCD_SET_WIDE_RANGE() lcd_command(LCD_POWER_WIDE_RANGE) |
||
142 | #define LCD_SET_LOW_VOLTAGE() lcd_command(LCD_POWER_LOW_VOLTAGE) |
||
143 | #define LCD_SET_BIAS_VOLTAGE(i) lcd_command(LCD_VOLTAGE | ((i) & 0x07)) |
||
144 | #define LCD_SET_VOLUME_MODE(i) lcd_command(LCD_VOLUME_MODE_1); \ |
||
145 | lcd_command(LCD_VOLUME_MODE_2 | ((i) & 0x3F)) |
||
146 | |||
147 | //#if DISPLAY_TYPE == 128 || DISPLAY_TYPE == 132 |
||
148 | #define LCD_SET_INDICATOR_OFF() lcd_command(LCD_INDICATOR_OFF); \ |
||
149 | lcd_command(LCD_INDICATOR_MODE_OFF) |
||
150 | #define LCD_SET_INDICATOR_STATIC() lcd_command(LCD_INDICATOR_ON); \ |
||
151 | lcd_command(LCD_INDICATOR_MODE_ON) |
||
152 | #define LCD_SET_INDICATOR_1HZ() lcd_command(LCD_INDICATOR_ON); \ |
||
153 | lcd_command(LCD_INDICATOR_MODE_1HZ) |
||
154 | #define LCD_SET_INDICATOR_2HZ() lcd_command(LCD_INDICATOR_ON); \ |
||
155 | lcd_command(LCD_INDICATOR_MODE_2HZ) |
||
156 | #define LCD_SET_INDICATOR(i,j) lcd_command(LCD_INDICATOR_OFF | ((i) & 1)); \ |
||
157 | lcd_command(((j) & 2)) |
||
158 | #define LCD_SLEEP_MODE lcd_command(LCD_INDICATOR_OFF); \ |
||
159 | lcd_command(LCD_DISPLAY_OFF); \ |
||
160 | lcd_command(LCD_SHOW_ALL_POINTS) |
||
161 | //#endif |
||
162 | |||
163 | //#if DISPLAY_TYPE == 102 |
||
164 | //#define LCD_TEMPCOMP_HIGH 0x80 |
||
165 | //#define LCD_COLWRAP 0x02 |
||
166 | //#define LCD_PAGEWRAP 0x01 |
||
167 | //#define LCD_SET_ADV_PROG_CTRL(i) lcd_command(LCD_ADV_PROG_CTRL); |
||
168 | // lcd_command(LCD_ADV_PROG_CTRL2 & i) |
||
169 | //#endif |
||
170 | |||
171 | */ |
||
172 | |||
173 | |||
174 | |||
175 | extern volatile uint8_t LCD_ORIENTATION; |
||
176 | |||
177 | //#define LCD_LINES 8 |
||
178 | //#define LCD_COLS 21 |
||
179 | |||
180 | extern uint8_t lcd_xpos; |
||
181 | extern uint8_t lcd_ypos; |
||
182 | |||
183 | void lcd_command(uint8_t cmd); |
||
184 | void send_byte (uint8_t data); |
||
185 | void LCD_Init (uint8_t LCD_Mode); |
||
186 | void new_line (void); |
||
187 | void lcd_puts_at(uint8_t x, uint8_t y,const char *s, uint8_t mode ); |
||
188 | void lcd_putc (uint8_t x, uint8_t y, uint8_t c, uint8_t mode); |
||
189 | void send_byte (uint8_t data); |
||
190 | void lcd_print (uint8_t *text, uint8_t mode); |
||
191 | void lcd_print_at (uint8_t x, uint8_t y, uint8_t *text, uint8_t mode); |
||
192 | void lcd_printp (const char *text, uint8_t mode); |
||
193 | void lcd_printp_at (uint8_t x, uint8_t y, const char *text, uint8_t mode); |
||
194 | void lcd_printpns (const char *text, uint8_t mode); |
||
195 | void lcd_printpns_at (uint8_t x, uint8_t y, const char *text, uint8_t mode); |
||
196 | void lcd_cls (void); |
||
197 | void lcd_cls_line (uint8_t x, uint8_t y, uint8_t w); |
||
198 | |||
199 | void print_display (uint8_t *text); |
||
200 | void print_display_at (uint8_t x, uint8_t y, uint8_t *text); |
||
201 | void copy_line (uint8_t y); |
||
202 | void paste_line (uint8_t y); |
||
203 | |||
204 | // Jeti |
||
205 | void lcd_putc_jeti (uint8_t x, uint8_t y, uint8_t c, uint8_t mode); |
||
206 | void lcd_printpj (const char *text, uint8_t mode); |
||
207 | void lcd_printpj_at (uint8_t x, uint8_t y, const char *text, uint8_t mode); |
||
208 | |||
209 | void lcd_plot (uint8_t x, uint8_t y, uint8_t mode); |
||
210 | void lcd_line (unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, uint8_t mode); |
||
211 | void lcd_rect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode); |
||
212 | void lcd_frect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode); |
||
213 | void lcd_circle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode); |
||
214 | void lcd_fcircle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode); |
||
215 | void lcd_circ_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode); |
||
216 | |||
217 | void lcd_ellipse (int16_t x0, int16_t y0, int16_t rx, int16_t ry, uint8_t mode); |
||
218 | void lcd_ellipse_line (uint8_t x, uint8_t y, uint8_t rx, uint8_t ry, uint16_t deg, uint8_t mode); |
||
219 | |||
220 | void lcd_ecircle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode); |
||
221 | void lcd_ecirc_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode); |
||
222 | |||
223 | void lcd_view_font (uint8_t page); |
||
224 | void lcd_print_hex_at (uint8_t x, uint8_t y, uint8_t h, uint8_t mode); |
||
225 | |||
226 | void lcd_write_number_u (uint8_t number); |
||
227 | void lcd_write_number_u_at (uint8_t x, uint8_t y, uint8_t number); |
||
228 | void lcd_print_hex (uint8_t h, uint8_t mode); |
||
229 | /** |
||
230 | * Write only some digits of a unsigned <number> at <x>/<y> |
||
231 | * <length> represents the length to rightbound the number |
||
232 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
||
233 | */ |
||
234 | void write_ndigit_number_u (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad,uint8_t mode); |
||
235 | |||
236 | /** |
||
237 | * Write only some digits of a signed <number> at <x>/<y> |
||
238 | * <length> represents the length to rightbound the number |
||
239 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
||
240 | */ |
||
241 | |||
242 | void write_ndigit_number_s (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode); |
||
243 | |||
244 | /** |
||
245 | * Write only some digits of a unsigned <number> at <x>/<y> as /10th of the value |
||
246 | * <length> represents the length to rightbound the number |
||
247 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
||
248 | */ |
||
249 | void write_ndigit_number_u_10th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad, uint8_t mode); |
||
250 | |||
251 | /** |
||
252 | * Write only some digits of a unsigned <number> at <x>/<y> as /100th of the value |
||
253 | * <length> represents the length to rightbound the number |
||
254 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
||
255 | */ |
||
256 | void write_ndigit_number_u_100th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad); |
||
257 | |||
258 | /** |
||
259 | * Write only some digits of a signed <number> at <x>/<y> as /10th of the value |
||
260 | * <length> represents the length to rightbound the number |
||
261 | * <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
||
262 | */ |
||
263 | void write_ndigit_number_s_10th (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad, uint8_t mode); |
||
264 | |||
265 | /** |
||
266 | * write <seconds> as human readable time at <x>/<y> |
||
267 | */ |
||
268 | void write_time (uint8_t x, uint8_t y, uint16_t seconds); |
||
269 | |||
270 | /** |
||
271 | * wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude |
||
272 | */ |
||
273 | void write_gps_pos (uint8_t x, uint8_t y, int32_t position); |
||
274 | |||
275 | //------------------------------------------------------------------------------------ |
||
276 | // Show PKT Baudrate at given position |
||
277 | // |
||
278 | |||
279 | void show_baudrate (uint8_t x, uint8_t y, uint8_t Baudrate, uint8_t mode); |
||
280 | |||
281 | |||
282 | #endif |