00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef __LCD_H__
00042 #define __LCD_H__
00043
00044 #include <avr/io.h>
00045 #include <avr/interrupt.h>
00046 #include <avr/pgmspace.h>
00047
00048 #include <stdint.h>
00049 #include <stdbool.h>
00050 #include <stdlib.h>
00051 #include <stdio.h>
00052 #include <string.h>
00053
00054
00055 #define LCD_SYMBOL_FISRT 0
00056 #define LCD_SYMBOL_COUNT 34
00057
00058
00059 #define LCD_SYMBOL_ARR_UP LCD_SYMBOL_ENV_OP
00060 #define LCD_SYMBOL_ARR_DN LCD_SYMBOL_ENV_CL
00061
00062 #define LCD_CLCK_FRQ 32768
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 #define NUM_LCD_SYMBOL_A 0x01
00074 #define NUM_LCD_SYMBOL_B 0x02
00075 #define NUM_LCD_SYMBOL_C 0x04
00076 #define NUM_LCD_SYMBOL_D 0x08
00077 #define NUM_LCD_SYMBOL_E 0x10
00078 #define NUM_LCD_SYMBOL_F 0x20
00079 #define NUM_LCD_SYMBOL_G 0x40
00080
00081
00082
00083
00084 #define LCD_SEV_SEG_INDEX_0 (0)
00085 #define LCD_SEV_SEG_INDEX_1 (1)
00086 #define LCD_SEV_SEG_INDEX_2 (2)
00087 #define LCD_SEV_SEG_INDEX_3 (3)
00088 #define LCD_SEV_SEG_INDEX_4 (4)
00089 #define LCD_SEV_SEG_INDEX_5 (5)
00090 #define LCD_SEV_SEG_INDEX_6 (6)
00091 #define LCD_SEV_SEG_INDEX_7 (7)
00092 #define LCD_SEV_SEG_INDEX_8 (8)
00093 #define LCD_SEV_SEG_INDEX_9 (9)
00094 #define LCD_SEV_SEG_INDEX_A (10)
00095 #define LCD_SEV_SEG_INDEX_B (11)
00096 #define LCD_SEV_SEG_INDEX_C (12)
00097 #define LCD_SEV_SEG_INDEX_D (13)
00098 #define LCD_SEV_SEG_INDEX_E (14)
00099 #define LCD_SEV_SEG_INDEX_F (15)
00100 #define LCD_SEV_SEG_INDEX_SPACE (16)
00101 #define LCD_SEV_SEG_INDEX_MINUS (17)
00102
00103
00104 #define lcd_symbol_set_all() lcd_symbol_set_group(0, sizeof(lcd_symbol_chart))
00105 #define lcd_symbol_clr_all() lcd_symbol_clr_group(0, sizeof(lcd_symbol_chart))
00106
00107 typedef enum {
00108 LCD_NUM_PADDING_ZERO,
00109 LCD_NUM_PADDING_SPACE
00110 } lcd_padding_t;
00111
00112 typedef enum {
00113
00114
00115 LCD_SYMBOL_RAVEN = (7<<5) | 3,
00116
00117
00118 LCD_SYMBOL_BELL = (2<<5) | 17,
00119 LCD_SYMBOL_TONE = (6<<5) | 17,
00120 LCD_SYMBOL_MIC = (3<<5) | 3,
00121 LCD_SYMBOL_SPEAKER = (2<<5) | 18,
00122
00123
00124 LCD_SYMBOL_KEY = (3<<5) | 2,
00125 LCD_SYMBOL_ATT = (7<<5) | 2,
00126
00127
00128 LCD_SYMBOL_SUN = (6<<5) | 13,
00129 LCD_SYMBOL_MOON = (6<<5) | 3,
00130 LCD_SYMBOL_AM = (2<<5) | 15,
00131 LCD_SYMBOL_PM = (6<<5) | 15,
00132
00133
00134 LCD_SYMBOL_RX = (6<<5) | 18,
00135 LCD_SYMBOL_TX = (5<<5) | 13,
00136 LCD_SYMBOL_IP = (7<<5) | 13,
00137 LCD_SYMBOL_PAN = (7<<5) | 18,
00138 LCD_SYMBOL_ZLINK = (5<<5) | 8,
00139 LCD_SYMBOL_ZIGBEE = (5<<5) | 3,
00140
00141
00142 LCD_SYMBOL_ANT_FOOT= (5<<5) | 18,
00143 LCD_SYMBOL_ANT_SIG1= (3<<5) | 0,
00144 LCD_SYMBOL_ANT_SIG2= (7<<5) | 0,
00145 LCD_SYMBOL_ANT_SIG3= (3<<5) | 1,
00146 LCD_SYMBOL_ANT_DIS = (7<<5) | 1,
00147
00148
00149 LCD_SYMBOL_BAT_CONT= (4<<5) | 18,
00150 LCD_SYMBOL_BAT_CAP1= (4<<5) | 3,
00151 LCD_SYMBOL_BAT_CAP2= (4<<5) | 8,
00152 LCD_SYMBOL_BAT_CAP3= (4<<5) | 13,
00153
00154
00155 LCD_SYMBOL_ENV_OP = (6<<5) | 8,
00156 LCD_SYMBOL_ENV_CL = (0<<5) | 4,
00157 LCD_SYMBOL_ENV_MAIN= (2<<5) | 4,
00158
00159
00160 LCD_SYMBOL_C = (6<<5) | 16,
00161 LCD_SYMBOL_F = (2<<5) | 16,
00162
00163
00164 LCD_SYMBOL_MINUS = (7<<5) | 8,
00165 LCD_SYMBOL_DOT = (4<<5) | 4,
00166 LCD_SYMBOL_COL = (6<<5) | 4,
00167 } lcd_symbol_t;
00168
00169 typedef enum {
00170 LCD_WAVE_DEFAULT = 0,
00171 LCD_WAVE_LOW_POWER = 1
00172 } lcd_wave_t;
00173
00174 typedef enum {
00175 LCD_BUFFER_ON = 0,
00176 LCD_BUFFER_OFF = 1
00177 } lcd_buffer_t;
00178
00179 typedef enum {
00180 LCD_BLANKING_OFF = 0,
00181 LCD_BLANKING_ON = 1
00182 } lcd_blanking_t;
00183
00184 typedef enum {
00185 LCD_CLOCK_SYSTEM = 0,
00186 LCD_CLOCK_EXTERN = 1
00187 } lcd_clock_t;
00188
00189 typedef enum {
00190 LCD_BIAS_THIRD = 0,
00191 LCD_BIAS_HALF = 1
00192 } lcd_bias_t;
00193
00194 typedef enum {
00195 LCD_PRESCL_16 = 0x0,
00196 LCD_PRESCL_64 = 0x1,
00197 LCD_PRESCL_128 = 0x2,
00198 LCD_PRESCL_256 = 0x3,
00199 LCD_PRESCL_512 = 0x4,
00200 LCD_PRESCL_1024 = 0x5,
00201 LCD_PRESCL_2048 = 0x6,
00202 LCD_PRESCL_4096 = 0x7,
00203 } lcd_prescl_t;
00204
00205 typedef enum {
00206 LCD_DIV_1 = 0,
00207 LCD_DIV_2 = 1,
00208 LCD_DIV_3 = 2,
00209 LCD_DIV_4 = 3,
00210 LCD_DIV_5 = 4,
00211 LCD_DIV_6 = 5,
00212 LCD_DIV_7 = 6,
00213 LCD_DIV_8 = 7
00214 } lcd_div_t;
00215
00216
00217 typedef enum {
00218 LCD_DRIVE_300 = 0x0,
00219 LCD_DRIVE_70 = 0x2,
00220 LCD_DRIVE_150 = 0x4,
00221 LCD_DRIVE_450 = 0x6,
00222 LCD_DRIVE_575 = 0x8,
00223 LCD_DRIVE_850 = 0xA,
00224 LCD_DRIVE_1150 = 0xC,
00225 LCD_DRIVE_HALF = 0xE,
00226 LCD_DRIVE_FULL = 0xF
00227 } lcd_drive_t;
00228
00229 typedef enum {
00230 LCD_CONTRAST_2_60 = 0x0,
00231 LCD_CONTRAST_2_65 = 0x1,
00232 LCD_CONTRAST_2_70 = 0x2,
00233 LCD_CONTRAST_2_75 = 0x3,
00234 LCD_CONTRAST_2_80 = 0x4,
00235 LCD_CONTRAST_2_85 = 0x5,
00236 LCD_CONTRAST_2_90 = 0x6,
00237 LCD_CONTRAST_2_95 = 0x7,
00238 LCD_CONTRAST_3_00 = 0x8,
00239 LCD_CONTRAST_3_05 = 0x9,
00240 LCD_CONTRAST_3_10 = 0xA,
00241 LCD_CONTRAST_3_15 = 0xB,
00242 LCD_CONTRAST_3_20 = 0xC,
00243 LCD_CONTRAST_3_25 = 0xD,
00244 LCD_CONTRAST_3_30 = 0xE,
00245 LCD_CONTRAST_3_35 = 0xF
00246 } lcd_contrast_t;
00247
00248 typedef struct {
00249 union {
00250 struct {
00251 unsigned int blanking: 1;
00252 unsigned int : 1;
00253 unsigned int buffer : 1;
00254 unsigned int : 3;
00255 unsigned int wave : 1;
00256 unsigned int : 1;
00257 };
00258 uint8_t lcdcra;
00259 };
00260 union {
00261 struct {
00262 unsigned int : 6;
00263 unsigned int bias : 1;
00264 unsigned int clock : 1;
00265 };
00266 uint8_t lcdcrb;
00267 };
00268 union {
00269 struct {
00270 unsigned int div : 3;
00271 unsigned int : 1;
00272 unsigned int prescl : 3;
00273 unsigned int : 1;
00274 };
00275 uint8_t lcdfrr;
00276 };
00277 union {
00278 struct {
00279 unsigned int contrast: 4;
00280 unsigned int drive : 4;
00281 };
00282 uint8_t lcdccr;
00283 };
00284 } lcd_config_t;
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316 int lcd_init(void);
00317 void lcd_deinit(void);
00318 uint8_t itobcd(uint8_t inNumber);
00319
00320
00321
00322 int lcd_num_puthex(uint16_t numb, lcd_padding_t padding);
00323 int lcd_num_putdec(int numb, lcd_padding_t padding);
00324 int lcd_num_clr(void);
00325 void lcd_single_print_dig(uint8_t numb, uint8_t pos);
00326
00327
00328
00329
00330 int lcd_puts(const char* s);
00331 int lcd_puts_P(const char *s);
00332 int lcd_puta(size_t length, const uint8_t *s);
00333 int lcd_putchar(unsigned char c);
00334
00335
00336
00337
00338 void lcd_symbol_set(lcd_symbol_t symbol);
00339 void lcd_symbol_set_group(int start, int count);
00340 void lcd_symbol_clr(lcd_symbol_t symbol);
00341 void lcd_symbol_clr_group(int start, int count);
00342
00343
00344
00345
00346 void led_on(void);
00347 void led_off(void);
00348
00349
00350 #endif
00351