KAIQUE DOGNANI
/
LCD_JOYSTICK
Utilizando a Nucleo F103RB com um módulo LCD e um Joystick para interface
LCD_ka.cpp@0:bf743d54917c, 2020-06-09 (annotated)
- Committer:
- kaiquedog
- Date:
- Tue Jun 09 00:35:52 2020 +0000
- Revision:
- 0:bf743d54917c
- Child:
- 1:ac6e904944c3
Comentar
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kaiquedog | 0:bf743d54917c | 1 | #include "LCD_ka.h" |
kaiquedog | 0:bf743d54917c | 2 | /* |
kaiquedog | 0:bf743d54917c | 3 | *********************** |
kaiquedog | 0:bf743d54917c | 4 | **** INICIALIZAÇÃO **** |
kaiquedog | 0:bf743d54917c | 5 | *********************** |
kaiquedog | 0:bf743d54917c | 6 | */ |
kaiquedog | 0:bf743d54917c | 7 | LCD::LCD(PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7) : RS(rs), E(e), dados(d4,d5,d6,d7){ |
kaiquedog | 0:bf743d54917c | 8 | Inicia_LCD(); |
kaiquedog | 0:bf743d54917c | 9 | setup_chars(); |
kaiquedog | 0:bf743d54917c | 10 | this ->_coluna = 1; |
kaiquedog | 0:bf743d54917c | 11 | this ->_linha = 1; |
kaiquedog | 0:bf743d54917c | 12 | } |
kaiquedog | 0:bf743d54917c | 13 | |
kaiquedog | 0:bf743d54917c | 14 | |
kaiquedog | 0:bf743d54917c | 15 | /* |
kaiquedog | 0:bf743d54917c | 16 | ******************** |
kaiquedog | 0:bf743d54917c | 17 | **** INICIA_LCD **** |
kaiquedog | 0:bf743d54917c | 18 | ******************** |
kaiquedog | 0:bf743d54917c | 19 | */ |
kaiquedog | 0:bf743d54917c | 20 | void LCD::Inicia_LCD(void){ |
kaiquedog | 0:bf743d54917c | 21 | RS = 0; |
kaiquedog | 0:bf743d54917c | 22 | E = 0; |
kaiquedog | 0:bf743d54917c | 23 | dados = 0x0; |
kaiquedog | 0:bf743d54917c | 24 | wait(0.05); |
kaiquedog | 0:bf743d54917c | 25 | for (int i=0; i<3; i++){ |
kaiquedog | 0:bf743d54917c | 26 | CMD(0x20); // Define como 4 bits |
kaiquedog | 0:bf743d54917c | 27 | |
kaiquedog | 0:bf743d54917c | 28 | CMD(0x28); // Define 0 0 1 DL - N F _ _ |
kaiquedog | 0:bf743d54917c | 29 | //(DL = Data Lengh: 0 --> 4 Bits |
kaiquedog | 0:bf743d54917c | 30 | // 1 --> 8 Bits) |
kaiquedog | 0:bf743d54917c | 31 | //(N = n° de linhas:0 --> 1 linha |
kaiquedog | 0:bf743d54917c | 32 | // 1 --> 2 linhas) |
kaiquedog | 0:bf743d54917c | 33 | //(F = n° de pontos:0 --> 5 x 8 pontos |
kaiquedog | 0:bf743d54917c | 34 | // 1 --> 5 x 10 pontos) |
kaiquedog | 0:bf743d54917c | 35 | |
kaiquedog | 0:bf743d54917c | 36 | |
kaiquedog | 0:bf743d54917c | 37 | CMD(0x0E); // Define 0 0 0 0 - 1 D C B |
kaiquedog | 0:bf743d54917c | 38 | //(D = Display on/off: 0 --> off |
kaiquedog | 0:bf743d54917c | 39 | // 1 --> on) |
kaiquedog | 0:bf743d54917c | 40 | //(C = Cursor on/off : 0 --> off |
kaiquedog | 0:bf743d54917c | 41 | // 1 --> on) |
kaiquedog | 0:bf743d54917c | 42 | //(B = Blink on/off : 0 --> off |
kaiquedog | 0:bf743d54917c | 43 | // 1 --> on) |
kaiquedog | 0:bf743d54917c | 44 | |
kaiquedog | 0:bf743d54917c | 45 | |
kaiquedog | 0:bf743d54917c | 46 | CMD(0x06); // Define 0 0 0 0 - 0 1 I/D S |
kaiquedog | 0:bf743d54917c | 47 | //(I/D = Direção de escrita: 0 --> Direita |
kaiquedog | 0:bf743d54917c | 48 | // 1 --> Esquerda) |
kaiquedog | 0:bf743d54917c | 49 | //(S = Display shift : 0 --> Não |
kaiquedog | 0:bf743d54917c | 50 | // 1 --> Sim) |
kaiquedog | 0:bf743d54917c | 51 | } |
kaiquedog | 0:bf743d54917c | 52 | clc(); // Limpa o diplay |
kaiquedog | 0:bf743d54917c | 53 | } |
kaiquedog | 0:bf743d54917c | 54 | |
kaiquedog | 0:bf743d54917c | 55 | /* |
kaiquedog | 0:bf743d54917c | 56 | ********************** |
kaiquedog | 0:bf743d54917c | 57 | **** FIM DE CURSO **** |
kaiquedog | 0:bf743d54917c | 58 | ********************** |
kaiquedog | 0:bf743d54917c | 59 | */ |
kaiquedog | 0:bf743d54917c | 60 | void LCD::fim_de_curso (void){ |
kaiquedog | 0:bf743d54917c | 61 | switch (_coluna){ |
kaiquedog | 0:bf743d54917c | 62 | case 17 : // Se a coluna for igual a 17 |
kaiquedog | 0:bf743d54917c | 63 | switch (_linha){ // o cursor vai para: |
kaiquedog | 0:bf743d54917c | 64 | case 1 : pos(2,1); break; // Linha debaixo |
kaiquedog | 0:bf743d54917c | 65 | case 2 : home(); break; // Posição (1,1) |
kaiquedog | 0:bf743d54917c | 66 | } |
kaiquedog | 0:bf743d54917c | 67 | break; |
kaiquedog | 0:bf743d54917c | 68 | |
kaiquedog | 0:bf743d54917c | 69 | case 0 : // Se a coluna for igual a 0 |
kaiquedog | 0:bf743d54917c | 70 | switch (_linha){ // o cursor vai para: |
kaiquedog | 0:bf743d54917c | 71 | case 1 : pos(2,16); break; // Linha debaixo |
kaiquedog | 0:bf743d54917c | 72 | case 2 : pos(1,16); break; // Linha de cima |
kaiquedog | 0:bf743d54917c | 73 | } |
kaiquedog | 0:bf743d54917c | 74 | break; |
kaiquedog | 0:bf743d54917c | 75 | } |
kaiquedog | 0:bf743d54917c | 76 | } |
kaiquedog | 0:bf743d54917c | 77 | |
kaiquedog | 0:bf743d54917c | 78 | /* |
kaiquedog | 0:bf743d54917c | 79 | ********************* |
kaiquedog | 0:bf743d54917c | 80 | **** BATE ENABLE **** |
kaiquedog | 0:bf743d54917c | 81 | ********************* |
kaiquedog | 0:bf743d54917c | 82 | */ |
kaiquedog | 0:bf743d54917c | 83 | void LCD::bate_enable(void){ |
kaiquedog | 0:bf743d54917c | 84 | E = 1; |
kaiquedog | 0:bf743d54917c | 85 | wait(0.000040f); |
kaiquedog | 0:bf743d54917c | 86 | E=0; |
kaiquedog | 0:bf743d54917c | 87 | wait(0.000040f); |
kaiquedog | 0:bf743d54917c | 88 | } |
kaiquedog | 0:bf743d54917c | 89 | |
kaiquedog | 0:bf743d54917c | 90 | /* |
kaiquedog | 0:bf743d54917c | 91 | ************* |
kaiquedog | 0:bf743d54917c | 92 | **** WRI **** |
kaiquedog | 0:bf743d54917c | 93 | ************* |
kaiquedog | 0:bf743d54917c | 94 | */ |
kaiquedog | 0:bf743d54917c | 95 | void LCD::WRI(int value){ |
kaiquedog | 0:bf743d54917c | 96 | RS = 1; |
kaiquedog | 0:bf743d54917c | 97 | dados = value>>4; |
kaiquedog | 0:bf743d54917c | 98 | bate_enable(); |
kaiquedog | 0:bf743d54917c | 99 | dados = value; |
kaiquedog | 0:bf743d54917c | 100 | bate_enable(); |
kaiquedog | 0:bf743d54917c | 101 | } |
kaiquedog | 0:bf743d54917c | 102 | |
kaiquedog | 0:bf743d54917c | 103 | /* |
kaiquedog | 0:bf743d54917c | 104 | ************* |
kaiquedog | 0:bf743d54917c | 105 | **** CMD **** |
kaiquedog | 0:bf743d54917c | 106 | ************* |
kaiquedog | 0:bf743d54917c | 107 | */ |
kaiquedog | 0:bf743d54917c | 108 | void LCD::CMD(int value){ |
kaiquedog | 0:bf743d54917c | 109 | RS = 0; |
kaiquedog | 0:bf743d54917c | 110 | dados = value>>4; |
kaiquedog | 0:bf743d54917c | 111 | bate_enable(); |
kaiquedog | 0:bf743d54917c | 112 | dados = value; |
kaiquedog | 0:bf743d54917c | 113 | bate_enable(); |
kaiquedog | 0:bf743d54917c | 114 | } |
kaiquedog | 0:bf743d54917c | 115 | |
kaiquedog | 0:bf743d54917c | 116 | /* |
kaiquedog | 0:bf743d54917c | 117 | ********************* |
kaiquedog | 0:bf743d54917c | 118 | **** SETUP_CHARS **** |
kaiquedog | 0:bf743d54917c | 119 | ********************* |
kaiquedog | 0:bf743d54917c | 120 | */ |
kaiquedog | 0:bf743d54917c | 121 | void LCD::setup_chars(){ |
kaiquedog | 0:bf743d54917c | 122 | int new_chars[] = {0x00, 0x01, 0x03, 0x16, 0x1c, 0x08, 0x00, 0x00, // Correto |
kaiquedog | 0:bf743d54917c | 123 | 0x00, 0x0A, 0x0A, 0x0A, 0x00, 0x11, 0x0E, 0x00, // Sorriso |
kaiquedog | 0:bf743d54917c | 124 | 0x0e, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x0e, 0x00, // Relógio |
kaiquedog | 0:bf743d54917c | 125 | 0x00, 0x04, 0x0E, 0x15, 0x04, 0x04, 0x00, 0x00, // Seta para cima |
kaiquedog | 0:bf743d54917c | 126 | 0x00, 0x00, 0x04, 0x04, 0x15, 0x0E, 0x04, 0x00, // Seta para baixo |
kaiquedog | 0:bf743d54917c | 127 | 0x0e, 0x11, 0x05, 0x09, 0x1e, 0x08, 0x04, 0x00, // Seta Horário |
kaiquedog | 0:bf743d54917c | 128 | 0x0e, 0x11, 0x14, 0x12, 0x0f, 0x02, 0x04, 0x00 // Seta Anti_horário |
kaiquedog | 0:bf743d54917c | 129 | }; |
kaiquedog | 0:bf743d54917c | 130 | |
kaiquedog | 0:bf743d54917c | 131 | CMD(0x40); |
kaiquedog | 0:bf743d54917c | 132 | for (int i = 0; i < 7*8; i++){ |
kaiquedog | 0:bf743d54917c | 133 | WRI(new_chars[i]); |
kaiquedog | 0:bf743d54917c | 134 | } |
kaiquedog | 0:bf743d54917c | 135 | CMD(0x80); |
kaiquedog | 0:bf743d54917c | 136 | |
kaiquedog | 0:bf743d54917c | 137 | } |
kaiquedog | 0:bf743d54917c | 138 | |
kaiquedog | 0:bf743d54917c | 139 | |
kaiquedog | 0:bf743d54917c | 140 | |
kaiquedog | 0:bf743d54917c | 141 | |
kaiquedog | 0:bf743d54917c | 142 | /* |
kaiquedog | 0:bf743d54917c | 143 | ********************** |
kaiquedog | 0:bf743d54917c | 144 | ***** FUNÇÃO CLC ***** |
kaiquedog | 0:bf743d54917c | 145 | ********************** |
kaiquedog | 0:bf743d54917c | 146 | */ |
kaiquedog | 0:bf743d54917c | 147 | |
kaiquedog | 0:bf743d54917c | 148 | void LCD::clc(void){ |
kaiquedog | 0:bf743d54917c | 149 | CMD(0x01); |
kaiquedog | 0:bf743d54917c | 150 | wait(0.002); |
kaiquedog | 0:bf743d54917c | 151 | _coluna = 1; |
kaiquedog | 0:bf743d54917c | 152 | _linha = 1; |
kaiquedog | 0:bf743d54917c | 153 | } |
kaiquedog | 0:bf743d54917c | 154 | |
kaiquedog | 0:bf743d54917c | 155 | |
kaiquedog | 0:bf743d54917c | 156 | /* |
kaiquedog | 0:bf743d54917c | 157 | *********************** |
kaiquedog | 0:bf743d54917c | 158 | ***** FUNÇÃO HOME ***** |
kaiquedog | 0:bf743d54917c | 159 | *********************** |
kaiquedog | 0:bf743d54917c | 160 | */ |
kaiquedog | 0:bf743d54917c | 161 | void LCD::home(void){ |
kaiquedog | 0:bf743d54917c | 162 | wait(0.002); |
kaiquedog | 0:bf743d54917c | 163 | |
kaiquedog | 0:bf743d54917c | 164 | dados = 0x0; |
kaiquedog | 0:bf743d54917c | 165 | bate_enable(); |
kaiquedog | 0:bf743d54917c | 166 | dados = 0x2; |
kaiquedog | 0:bf743d54917c | 167 | bate_enable(); |
kaiquedog | 0:bf743d54917c | 168 | |
kaiquedog | 0:bf743d54917c | 169 | wait(0.002); |
kaiquedog | 0:bf743d54917c | 170 | |
kaiquedog | 0:bf743d54917c | 171 | _coluna = 1; |
kaiquedog | 0:bf743d54917c | 172 | _linha = 1; |
kaiquedog | 0:bf743d54917c | 173 | } |
kaiquedog | 0:bf743d54917c | 174 | |
kaiquedog | 0:bf743d54917c | 175 | |
kaiquedog | 0:bf743d54917c | 176 | /* |
kaiquedog | 0:bf743d54917c | 177 | ************************** |
kaiquedog | 0:bf743d54917c | 178 | ***** FUNÇÃO DIREITA ***** |
kaiquedog | 0:bf743d54917c | 179 | ************************** |
kaiquedog | 0:bf743d54917c | 180 | */ |
kaiquedog | 0:bf743d54917c | 181 | |
kaiquedog | 0:bf743d54917c | 182 | void LCD::direita(void){ |
kaiquedog | 0:bf743d54917c | 183 | wait(0.0002); |
kaiquedog | 0:bf743d54917c | 184 | |
kaiquedog | 0:bf743d54917c | 185 | dados = 0x1; |
kaiquedog | 0:bf743d54917c | 186 | bate_enable(); |
kaiquedog | 0:bf743d54917c | 187 | dados = 0x4; |
kaiquedog | 0:bf743d54917c | 188 | bate_enable(); |
kaiquedog | 0:bf743d54917c | 189 | |
kaiquedog | 0:bf743d54917c | 190 | wait(0.0002); |
kaiquedog | 0:bf743d54917c | 191 | |
kaiquedog | 0:bf743d54917c | 192 | _coluna = _coluna+1; |
kaiquedog | 0:bf743d54917c | 193 | |
kaiquedog | 0:bf743d54917c | 194 | fim_de_curso(); |
kaiquedog | 0:bf743d54917c | 195 | } |
kaiquedog | 0:bf743d54917c | 196 | |
kaiquedog | 0:bf743d54917c | 197 | |
kaiquedog | 0:bf743d54917c | 198 | /* |
kaiquedog | 0:bf743d54917c | 199 | *************************** |
kaiquedog | 0:bf743d54917c | 200 | ***** FUNÇÃO ESQUERDA ***** |
kaiquedog | 0:bf743d54917c | 201 | *************************** |
kaiquedog | 0:bf743d54917c | 202 | */ |
kaiquedog | 0:bf743d54917c | 203 | |
kaiquedog | 0:bf743d54917c | 204 | void LCD::esquerda(void){ |
kaiquedog | 0:bf743d54917c | 205 | wait(0.0002); |
kaiquedog | 0:bf743d54917c | 206 | |
kaiquedog | 0:bf743d54917c | 207 | dados = 0x1; |
kaiquedog | 0:bf743d54917c | 208 | bate_enable(); |
kaiquedog | 0:bf743d54917c | 209 | dados = 0x0; |
kaiquedog | 0:bf743d54917c | 210 | bate_enable(); |
kaiquedog | 0:bf743d54917c | 211 | |
kaiquedog | 0:bf743d54917c | 212 | wait(0.0002); |
kaiquedog | 0:bf743d54917c | 213 | |
kaiquedog | 0:bf743d54917c | 214 | _coluna = _coluna - 1; |
kaiquedog | 0:bf743d54917c | 215 | |
kaiquedog | 0:bf743d54917c | 216 | fim_de_curso(); |
kaiquedog | 0:bf743d54917c | 217 | } |
kaiquedog | 0:bf743d54917c | 218 | |
kaiquedog | 0:bf743d54917c | 219 | |
kaiquedog | 0:bf743d54917c | 220 | /* |
kaiquedog | 0:bf743d54917c | 221 | ************************ |
kaiquedog | 0:bf743d54917c | 222 | ***** FUNÇÃO APAGA ***** |
kaiquedog | 0:bf743d54917c | 223 | ************************ |
kaiquedog | 0:bf743d54917c | 224 | */ |
kaiquedog | 0:bf743d54917c | 225 | |
kaiquedog | 0:bf743d54917c | 226 | void LCD::apaga(void){ |
kaiquedog | 0:bf743d54917c | 227 | RS = 1; |
kaiquedog | 0:bf743d54917c | 228 | |
kaiquedog | 0:bf743d54917c | 229 | wait(0.002); |
kaiquedog | 0:bf743d54917c | 230 | |
kaiquedog | 0:bf743d54917c | 231 | dados = 0x2; |
kaiquedog | 0:bf743d54917c | 232 | bate_enable(); |
kaiquedog | 0:bf743d54917c | 233 | dados = 0x0; |
kaiquedog | 0:bf743d54917c | 234 | bate_enable(); |
kaiquedog | 0:bf743d54917c | 235 | |
kaiquedog | 0:bf743d54917c | 236 | RS = 0; |
kaiquedog | 0:bf743d54917c | 237 | |
kaiquedog | 0:bf743d54917c | 238 | pos(_linha,_coluna); |
kaiquedog | 0:bf743d54917c | 239 | } |
kaiquedog | 0:bf743d54917c | 240 | |
kaiquedog | 0:bf743d54917c | 241 | |
kaiquedog | 0:bf743d54917c | 242 | /* |
kaiquedog | 0:bf743d54917c | 243 | *********************** |
kaiquedog | 0:bf743d54917c | 244 | ***** FUNÇÃO CMIA ***** |
kaiquedog | 0:bf743d54917c | 245 | *********************** |
kaiquedog | 0:bf743d54917c | 246 | */ |
kaiquedog | 0:bf743d54917c | 247 | |
kaiquedog | 0:bf743d54917c | 248 | void LCD::cima(void){ |
kaiquedog | 0:bf743d54917c | 249 | pos(1,_coluna); |
kaiquedog | 0:bf743d54917c | 250 | |
kaiquedog | 0:bf743d54917c | 251 | _linha = 1; |
kaiquedog | 0:bf743d54917c | 252 | } |
kaiquedog | 0:bf743d54917c | 253 | |
kaiquedog | 0:bf743d54917c | 254 | |
kaiquedog | 0:bf743d54917c | 255 | /* |
kaiquedog | 0:bf743d54917c | 256 | ************************ |
kaiquedog | 0:bf743d54917c | 257 | ***** FUNÇÃO BAIXO ***** |
kaiquedog | 0:bf743d54917c | 258 | ************************ |
kaiquedog | 0:bf743d54917c | 259 | */ |
kaiquedog | 0:bf743d54917c | 260 | |
kaiquedog | 0:bf743d54917c | 261 | void LCD::baixo(void){ |
kaiquedog | 0:bf743d54917c | 262 | pos(2,_coluna); |
kaiquedog | 0:bf743d54917c | 263 | |
kaiquedog | 0:bf743d54917c | 264 | _linha = 2; |
kaiquedog | 0:bf743d54917c | 265 | } |
kaiquedog | 0:bf743d54917c | 266 | |
kaiquedog | 0:bf743d54917c | 267 | |
kaiquedog | 0:bf743d54917c | 268 | // |
kaiquedog | 0:bf743d54917c | 269 | |
kaiquedog | 0:bf743d54917c | 270 | /* |
kaiquedog | 0:bf743d54917c | 271 | ********************** |
kaiquedog | 0:bf743d54917c | 272 | ***** FUNÇÃO POS ***** |
kaiquedog | 0:bf743d54917c | 273 | ********************** |
kaiquedog | 0:bf743d54917c | 274 | */ |
kaiquedog | 0:bf743d54917c | 275 | void LCD::pos(int li, int co){ |
kaiquedog | 0:bf743d54917c | 276 | int POSI = 0x80 + ((li-1) * 0x40) + (co-1); |
kaiquedog | 0:bf743d54917c | 277 | |
kaiquedog | 0:bf743d54917c | 278 | CMD(POSI); |
kaiquedog | 0:bf743d54917c | 279 | |
kaiquedog | 0:bf743d54917c | 280 | _coluna = co; |
kaiquedog | 0:bf743d54917c | 281 | _linha = li; |
kaiquedog | 0:bf743d54917c | 282 | } |
kaiquedog | 0:bf743d54917c | 283 | |
kaiquedog | 0:bf743d54917c | 284 | |
kaiquedog | 0:bf743d54917c | 285 | |
kaiquedog | 0:bf743d54917c | 286 | |
kaiquedog | 0:bf743d54917c | 287 | /* |
kaiquedog | 0:bf743d54917c | 288 | *********************** |
kaiquedog | 0:bf743d54917c | 289 | ***** FUNÇÃO PUTC ***** |
kaiquedog | 0:bf743d54917c | 290 | *********************** |
kaiquedog | 0:bf743d54917c | 291 | */ |
kaiquedog | 0:bf743d54917c | 292 | |
kaiquedog | 0:bf743d54917c | 293 | |
kaiquedog | 0:bf743d54917c | 294 | |
kaiquedog | 0:bf743d54917c | 295 | int LCD::_putc(int value) { |
kaiquedog | 0:bf743d54917c | 296 | if (value == '\n') { |
kaiquedog | 0:bf743d54917c | 297 | baixo(); |
kaiquedog | 0:bf743d54917c | 298 | } |
kaiquedog | 0:bf743d54917c | 299 | if(value == '~'){ |
kaiquedog | 0:bf743d54917c | 300 | WRI(0x00); |
kaiquedog | 0:bf743d54917c | 301 | WRI(0x01); |
kaiquedog | 0:bf743d54917c | 302 | WRI(0x02); |
kaiquedog | 0:bf743d54917c | 303 | WRI(0x03); |
kaiquedog | 0:bf743d54917c | 304 | WRI(0x04); |
kaiquedog | 0:bf743d54917c | 305 | } |
kaiquedog | 0:bf743d54917c | 306 | else{ |
kaiquedog | 0:bf743d54917c | 307 | RS = 1; |
kaiquedog | 0:bf743d54917c | 308 | dados = value>>4; |
kaiquedog | 0:bf743d54917c | 309 | bate_enable(); |
kaiquedog | 0:bf743d54917c | 310 | dados = value; |
kaiquedog | 0:bf743d54917c | 311 | bate_enable(); |
kaiquedog | 0:bf743d54917c | 312 | RS = 0; |
kaiquedog | 0:bf743d54917c | 313 | } |
kaiquedog | 0:bf743d54917c | 314 | _chars[_linha-1][_coluna-1] = value; |
kaiquedog | 0:bf743d54917c | 315 | _coluna++; |
kaiquedog | 0:bf743d54917c | 316 | fim_de_curso(); |
kaiquedog | 0:bf743d54917c | 317 | |
kaiquedog | 0:bf743d54917c | 318 | return value; |
kaiquedog | 0:bf743d54917c | 319 | } |
kaiquedog | 0:bf743d54917c | 320 | |
kaiquedog | 0:bf743d54917c | 321 | int LCD::_getc() { |
kaiquedog | 0:bf743d54917c | 322 | return -1; |
kaiquedog | 0:bf743d54917c | 323 | } |
kaiquedog | 0:bf743d54917c | 324 | |
kaiquedog | 0:bf743d54917c | 325 | |
kaiquedog | 0:bf743d54917c | 326 | void LCD::putc(int value){ |
kaiquedog | 0:bf743d54917c | 327 | RS = 1; |
kaiquedog | 0:bf743d54917c | 328 | dados = value>>4; |
kaiquedog | 0:bf743d54917c | 329 | bate_enable(); |
kaiquedog | 0:bf743d54917c | 330 | dados = value; |
kaiquedog | 0:bf743d54917c | 331 | bate_enable(); |
kaiquedog | 0:bf743d54917c | 332 | _coluna++; |
kaiquedog | 0:bf743d54917c | 333 | fim_de_curso(); |
kaiquedog | 0:bf743d54917c | 334 | } |
kaiquedog | 0:bf743d54917c | 335 | |
kaiquedog | 0:bf743d54917c | 336 | |
kaiquedog | 0:bf743d54917c | 337 | |
kaiquedog | 0:bf743d54917c | 338 | void LCD::Clock(int li, int co){ |
kaiquedog | 0:bf743d54917c | 339 | int relogio[8][8] = {0x00,0x0e,0x15,0x17,0x11,0x0e,0x00,0x00, |
kaiquedog | 0:bf743d54917c | 340 | 0x00,0x0e,0x15,0x15,0x13,0x0e,0x00,0x00, |
kaiquedog | 0:bf743d54917c | 341 | 0x00,0x0e,0x15,0x15,0x15,0x0e,0x00,0x00, |
kaiquedog | 0:bf743d54917c | 342 | 0x00,0x0e,0x15,0x15,0x19,0x0e,0x00,0x00, |
kaiquedog | 0:bf743d54917c | 343 | 0x00,0x0e,0x15,0x1d,0x11,0x0e,0x00,0x00, |
kaiquedog | 0:bf743d54917c | 344 | 0x00,0x0e,0x1d,0x15,0x11,0x0e,0x00,0x00, |
kaiquedog | 0:bf743d54917c | 345 | 0x00,0x0e,0x15,0x15,0x11,0x0e,0x00,0x00, |
kaiquedog | 0:bf743d54917c | 346 | 0x00,0x0e,0x17,0x15,0x11,0x0e,0x00,0x00 |
kaiquedog | 0:bf743d54917c | 347 | }; |
kaiquedog | 0:bf743d54917c | 348 | |
kaiquedog | 0:bf743d54917c | 349 | for (int i = 0; i < 8; i++){ |
kaiquedog | 0:bf743d54917c | 350 | CMD(0x40); |
kaiquedog | 0:bf743d54917c | 351 | for (int j = 0; j < 8; j++){ |
kaiquedog | 0:bf743d54917c | 352 | WRI(relogio[i][j]); |
kaiquedog | 0:bf743d54917c | 353 | } |
kaiquedog | 0:bf743d54917c | 354 | pos(li,co); |
kaiquedog | 0:bf743d54917c | 355 | wait(1); |
kaiquedog | 0:bf743d54917c | 356 | WRI(0x00); |
kaiquedog | 0:bf743d54917c | 357 | |
kaiquedog | 0:bf743d54917c | 358 | } |
kaiquedog | 0:bf743d54917c | 359 | |
kaiquedog | 0:bf743d54917c | 360 | |
kaiquedog | 0:bf743d54917c | 361 | } |
kaiquedog | 0:bf743d54917c | 362 | |
kaiquedog | 0:bf743d54917c | 363 | |
kaiquedog | 0:bf743d54917c | 364 | /* |
kaiquedog | 0:bf743d54917c | 365 | ************************ |
kaiquedog | 0:bf743d54917c | 366 | ***** FUNÇÃO LEPOS ***** |
kaiquedog | 0:bf743d54917c | 367 | ************************ |
kaiquedog | 0:bf743d54917c | 368 | */ |
kaiquedog | 0:bf743d54917c | 369 | |
kaiquedog | 0:bf743d54917c | 370 | |
kaiquedog | 0:bf743d54917c | 371 | string LCD::Lepos(void){ |
kaiquedog | 0:bf743d54917c | 372 | string buffer; |
kaiquedog | 0:bf743d54917c | 373 | char li[6]; |
kaiquedog | 0:bf743d54917c | 374 | sprintf(li,"(%d,%d)", _linha, _coluna); |
kaiquedog | 0:bf743d54917c | 375 | buffer.append(li); |
kaiquedog | 0:bf743d54917c | 376 | return buffer; |
kaiquedog | 0:bf743d54917c | 377 | |
kaiquedog | 0:bf743d54917c | 378 | } |
kaiquedog | 0:bf743d54917c | 379 | |
kaiquedog | 0:bf743d54917c | 380 |