ST7920 Testes

Dependencies:   mbed

Committer:
Marcelocostanzo
Date:
Tue Dec 15 12:27:29 2020 +0000
Revision:
2:5bcfb7105fa2
Parent:
1:08481151e25e
Versao funcionando com linhas horizontais e verticais e strings

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Marcelocostanzo 1:08481151e25e 1 #include "ST7920.h"
Marcelocostanzo 1:08481151e25e 2
Marcelocostanzo 1:08481151e25e 3 BusOut DB(D5, D6, D7, D8, D9, D10, D11, D12); // DB0 - DB7 RESPECTIVAMENTE
Marcelocostanzo 1:08481151e25e 4 //BusOut DB(D12, D11, D10, D9, D8, D7, D6, D5); // DB7 - DB0 RESPECTIVAMENTE
Marcelocostanzo 1:08481151e25e 5
Marcelocostanzo 1:08481151e25e 6 DigitalOut RS(D2);
Marcelocostanzo 1:08481151e25e 7 DigitalOut RW(D3);
Marcelocostanzo 1:08481151e25e 8 DigitalOut EN(D4);
Marcelocostanzo 1:08481151e25e 9
Marcelocostanzo 1:08481151e25e 10
Marcelocostanzo 1:08481151e25e 11 void ST7920_Init()
Marcelocostanzo 1:08481151e25e 12 {
Marcelocostanzo 2:5bcfb7105fa2 13 //function set 8-bit mode
Marcelocostanzo 2:5bcfb7105fa2 14 wait_ms(100);
Marcelocostanzo 2:5bcfb7105fa2 15 RS = 0;
Marcelocostanzo 2:5bcfb7105fa2 16 RW = 0;
Marcelocostanzo 2:5bcfb7105fa2 17 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 18 EN = 1;
Marcelocostanzo 2:5bcfb7105fa2 19 DB = FUNCTION_SET | DATA_LENGTH_DL;
Marcelocostanzo 2:5bcfb7105fa2 20 wait_us(100);
Marcelocostanzo 1:08481151e25e 21 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 22
Marcelocostanzo 2:5bcfb7105fa2 23 //function set 8-bit mode again
Marcelocostanzo 2:5bcfb7105fa2 24 wait_us(1000);
Marcelocostanzo 1:08481151e25e 25 RS = 0;
Marcelocostanzo 1:08481151e25e 26 RW = 0;
Marcelocostanzo 1:08481151e25e 27 wait_us(100);
Marcelocostanzo 1:08481151e25e 28 EN = 1;
Marcelocostanzo 1:08481151e25e 29 DB = FUNCTION_SET | DATA_LENGTH_DL;
Marcelocostanzo 2:5bcfb7105fa2 30 wait_us(100);
Marcelocostanzo 1:08481151e25e 31 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 32
Marcelocostanzo 2:5bcfb7105fa2 33 // display on
Marcelocostanzo 2:5bcfb7105fa2 34 wait_us(1000);
Marcelocostanzo 1:08481151e25e 35 RS = 0;
Marcelocostanzo 1:08481151e25e 36 RW = 0;
Marcelocostanzo 1:08481151e25e 37 wait_us(100);
Marcelocostanzo 1:08481151e25e 38 EN = 1;
Marcelocostanzo 1:08481151e25e 39 DB = DISPLAY_CONTROL | DISPLAY_ON_D;
Marcelocostanzo 2:5bcfb7105fa2 40 wait_us(100);
Marcelocostanzo 1:08481151e25e 41 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 42
Marcelocostanzo 2:5bcfb7105fa2 43 // cursor - Display shift right by 1, cursor also follows to shift.
Marcelocostanzo 2:5bcfb7105fa2 44 wait_us(1000);
Marcelocostanzo 2:5bcfb7105fa2 45 RS = 0;
Marcelocostanzo 2:5bcfb7105fa2 46 RW = 0;
Marcelocostanzo 2:5bcfb7105fa2 47 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 48 EN = 1;
Marcelocostanzo 2:5bcfb7105fa2 49 DB = 0x1C;
Marcelocostanzo 2:5bcfb7105fa2 50 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 51 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 52
Marcelocostanzo 2:5bcfb7105fa2 53 // clear screen
Marcelocostanzo 2:5bcfb7105fa2 54 wait_us(1000);
Marcelocostanzo 1:08481151e25e 55 RS = 0;
Marcelocostanzo 1:08481151e25e 56 RW = 0;
Marcelocostanzo 1:08481151e25e 57 wait_us(100);
Marcelocostanzo 1:08481151e25e 58 EN = 1;
Marcelocostanzo 1:08481151e25e 59 DB = DISPLAY_CLEAR;
Marcelocostanzo 2:5bcfb7105fa2 60 wait_us(100);
Marcelocostanzo 1:08481151e25e 61 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 62
Marcelocostanzo 2:5bcfb7105fa2 63 // Returns to home. Cursor moves to starting point
Marcelocostanzo 2:5bcfb7105fa2 64 wait_ms(1);
Marcelocostanzo 1:08481151e25e 65 RS = 0;
Marcelocostanzo 1:08481151e25e 66 RW = 0;
Marcelocostanzo 1:08481151e25e 67 wait_us(100);
Marcelocostanzo 1:08481151e25e 68 EN = 1;
Marcelocostanzo 1:08481151e25e 69 DB = RETURN_HOME;
Marcelocostanzo 2:5bcfb7105fa2 70 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 71 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 72
Marcelocostanzo 2:5bcfb7105fa2 73 // Setting location to write characters. In this case 0,0 - Top Left Corner
Marcelocostanzo 2:5bcfb7105fa2 74 wait_ms(1);
Marcelocostanzo 2:5bcfb7105fa2 75 RS = 0;
Marcelocostanzo 2:5bcfb7105fa2 76 RW = 0;
Marcelocostanzo 2:5bcfb7105fa2 77 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 78 EN = 1;
Marcelocostanzo 2:5bcfb7105fa2 79 DB = 0x80;
Marcelocostanzo 2:5bcfb7105fa2 80 wait_us(100);
Marcelocostanzo 1:08481151e25e 81 EN = 0;
Marcelocostanzo 1:08481151e25e 82 }
Marcelocostanzo 1:08481151e25e 83
Marcelocostanzo 1:08481151e25e 84 void ST7920_Clear()
Marcelocostanzo 1:08481151e25e 85 {
Marcelocostanzo 2:5bcfb7105fa2 86 //=========== This function set all the pixels to off in the graphic controller =================
Marcelocostanzo 2:5bcfb7105fa2 87 for(int y = 0; y < 64; y++)
Marcelocostanzo 2:5bcfb7105fa2 88 {
Marcelocostanzo 2:5bcfb7105fa2 89 if(y < 32)
Marcelocostanzo 2:5bcfb7105fa2 90 {
Marcelocostanzo 2:5bcfb7105fa2 91 wait_us(100);//wait_us(1000);
Marcelocostanzo 2:5bcfb7105fa2 92 RS = 0;
Marcelocostanzo 2:5bcfb7105fa2 93 RW = 0;
Marcelocostanzo 2:5bcfb7105fa2 94 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 95 EN = 1;
Marcelocostanzo 2:5bcfb7105fa2 96 DB = 0x80 | y;
Marcelocostanzo 2:5bcfb7105fa2 97 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 98 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 99 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 100
Marcelocostanzo 2:5bcfb7105fa2 101 wait_us(100);//wait_us(1000);
Marcelocostanzo 2:5bcfb7105fa2 102 RS = 0;
Marcelocostanzo 2:5bcfb7105fa2 103 RW = 0;
Marcelocostanzo 2:5bcfb7105fa2 104 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 105 EN = 1;
Marcelocostanzo 2:5bcfb7105fa2 106 DB = 0x80;
Marcelocostanzo 2:5bcfb7105fa2 107 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 108 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 109 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 110 }
Marcelocostanzo 2:5bcfb7105fa2 111
Marcelocostanzo 2:5bcfb7105fa2 112 else
Marcelocostanzo 2:5bcfb7105fa2 113 {
Marcelocostanzo 2:5bcfb7105fa2 114 wait_us(100);//wait_us(1000);
Marcelocostanzo 2:5bcfb7105fa2 115 RS = 0;
Marcelocostanzo 2:5bcfb7105fa2 116 RW = 0;
Marcelocostanzo 2:5bcfb7105fa2 117 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 118 EN = 1;
Marcelocostanzo 2:5bcfb7105fa2 119 DB = 0x80 | (y - 32);
Marcelocostanzo 2:5bcfb7105fa2 120 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 121 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 122 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 123
Marcelocostanzo 2:5bcfb7105fa2 124 wait_us(100);//wait_us(1000);
Marcelocostanzo 2:5bcfb7105fa2 125 RS = 0;
Marcelocostanzo 2:5bcfb7105fa2 126 RW = 0;
Marcelocostanzo 2:5bcfb7105fa2 127 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 128 EN = 1;
Marcelocostanzo 2:5bcfb7105fa2 129 DB = 0x88;
Marcelocostanzo 2:5bcfb7105fa2 130 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 131 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 132 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 133 }
Marcelocostanzo 2:5bcfb7105fa2 134
Marcelocostanzo 2:5bcfb7105fa2 135 for(int x = 0; x < 16; x++)
Marcelocostanzo 2:5bcfb7105fa2 136 {
Marcelocostanzo 2:5bcfb7105fa2 137 wait_us(100);//wait_us(1000);
Marcelocostanzo 2:5bcfb7105fa2 138 RS = 1;
Marcelocostanzo 2:5bcfb7105fa2 139 RW = 0;
Marcelocostanzo 2:5bcfb7105fa2 140 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 141 EN = 1;
Marcelocostanzo 2:5bcfb7105fa2 142 DB = 0x00;
Marcelocostanzo 2:5bcfb7105fa2 143 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 144 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 145 wait_us(20);
Marcelocostanzo 2:5bcfb7105fa2 146 }
Marcelocostanzo 2:5bcfb7105fa2 147 }
Marcelocostanzo 1:08481151e25e 148 }
Marcelocostanzo 1:08481151e25e 149
Marcelocostanzo 1:08481151e25e 150 void ST7920_SetGraphicsMode()
Marcelocostanzo 2:5bcfb7105fa2 151 {
Marcelocostanzo 1:08481151e25e 152 wait_us(1000);
Marcelocostanzo 1:08481151e25e 153 RS = 0;
Marcelocostanzo 1:08481151e25e 154 RW = 0;
Marcelocostanzo 1:08481151e25e 155 EN = 1;
Marcelocostanzo 1:08481151e25e 156 wait_us(100);
Marcelocostanzo 1:08481151e25e 157 DB = EXTENDED_FUNCTION_SET | DATA_LENGTH_DL;
Marcelocostanzo 1:08481151e25e 158 wait_us(100);
Marcelocostanzo 1:08481151e25e 159 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 160
Marcelocostanzo 1:08481151e25e 161 wait_us(1000);
Marcelocostanzo 1:08481151e25e 162 RS = 0;
Marcelocostanzo 1:08481151e25e 163 RW = 0;
Marcelocostanzo 1:08481151e25e 164 EN = 1;
Marcelocostanzo 1:08481151e25e 165 wait_us(100);
Marcelocostanzo 1:08481151e25e 166 DB = EXTENDED_FUNCTION_SET | DATA_LENGTH_DL | EXTENDED_INSTRUCTION_RE;
Marcelocostanzo 1:08481151e25e 167 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 168
Marcelocostanzo 2:5bcfb7105fa2 169 wait_us(100);
Marcelocostanzo 1:08481151e25e 170 RS = 0;
Marcelocostanzo 1:08481151e25e 171 RW = 0;
Marcelocostanzo 1:08481151e25e 172 EN = 1;
Marcelocostanzo 1:08481151e25e 173 wait_us(100);
Marcelocostanzo 1:08481151e25e 174 DB = EXTENDED_FUNCTION_SET | DATA_LENGTH_DL | EXTENDED_INSTRUCTION_RE | GRAPHIC_ON_G;
Marcelocostanzo 1:08481151e25e 175 EN = 0;
Marcelocostanzo 1:08481151e25e 176 }
Marcelocostanzo 1:08481151e25e 177
Marcelocostanzo 2:5bcfb7105fa2 178 void ST7920_SetTextMode()
Marcelocostanzo 1:08481151e25e 179 {
Marcelocostanzo 1:08481151e25e 180 wait_us(100);
Marcelocostanzo 1:08481151e25e 181 RS = 0;
Marcelocostanzo 1:08481151e25e 182 RW = 0;
Marcelocostanzo 1:08481151e25e 183 EN = 1;
Marcelocostanzo 1:08481151e25e 184 DB = FUNCTION_SET | DATA_LENGTH_DL;
Marcelocostanzo 1:08481151e25e 185 EN = 0;
Marcelocostanzo 1:08481151e25e 186 }
Marcelocostanzo 1:08481151e25e 187
Marcelocostanzo 1:08481151e25e 188 void ST7920_DrawHorizontalLine(uint8_t X, uint8_t Y, uint8_t LEN)
Marcelocostanzo 1:08481151e25e 189 {
Marcelocostanzo 1:08481151e25e 190 //desenhando uma linha de tamanho T em Y, com X offset
Marcelocostanzo 1:08481151e25e 191
Marcelocostanzo 1:08481151e25e 192 wait_us(1000);
Marcelocostanzo 1:08481151e25e 193 RS = 0;
Marcelocostanzo 1:08481151e25e 194 RW = 0;
Marcelocostanzo 1:08481151e25e 195 wait_us(100);
Marcelocostanzo 1:08481151e25e 196 EN = 1;
Marcelocostanzo 1:08481151e25e 197 DB = 0x80 | Y;
Marcelocostanzo 1:08481151e25e 198 wait_us(100);
Marcelocostanzo 1:08481151e25e 199 EN = 0;
Marcelocostanzo 1:08481151e25e 200 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 201
Marcelocostanzo 1:08481151e25e 202 wait_us(1000);
Marcelocostanzo 1:08481151e25e 203 RS = 0;
Marcelocostanzo 1:08481151e25e 204 RW = 0;
Marcelocostanzo 1:08481151e25e 205 wait_us(100);
Marcelocostanzo 1:08481151e25e 206 EN = 1;
Marcelocostanzo 1:08481151e25e 207 DB = 0x80 | X;
Marcelocostanzo 1:08481151e25e 208 wait_us(100);
Marcelocostanzo 1:08481151e25e 209 EN = 0;
Marcelocostanzo 1:08481151e25e 210 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 211
Marcelocostanzo 2:5bcfb7105fa2 212 for(int i = 0; i < (LEN / 8); i++)
Marcelocostanzo 2:5bcfb7105fa2 213 {
Marcelocostanzo 2:5bcfb7105fa2 214 wait_us(1000);
Marcelocostanzo 2:5bcfb7105fa2 215 RS = 1;
Marcelocostanzo 2:5bcfb7105fa2 216 RW = 0;
Marcelocostanzo 2:5bcfb7105fa2 217 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 218 EN = 1;
Marcelocostanzo 2:5bcfb7105fa2 219 DB = 255;
Marcelocostanzo 2:5bcfb7105fa2 220 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 221 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 222 wait_us(20);
Marcelocostanzo 2:5bcfb7105fa2 223 }
Marcelocostanzo 2:5bcfb7105fa2 224
Marcelocostanzo 2:5bcfb7105fa2 225 if(LEN%8 != 0)
Marcelocostanzo 2:5bcfb7105fa2 226 {
Marcelocostanzo 2:5bcfb7105fa2 227 int LEN_rest = LEN - ((LEN / 8) * 8);
Marcelocostanzo 2:5bcfb7105fa2 228 int bus_rest;
Marcelocostanzo 2:5bcfb7105fa2 229
Marcelocostanzo 2:5bcfb7105fa2 230 switch (LEN_rest)
Marcelocostanzo 2:5bcfb7105fa2 231 {
Marcelocostanzo 2:5bcfb7105fa2 232 case 1:
Marcelocostanzo 2:5bcfb7105fa2 233 bus_rest = 0x80;
Marcelocostanzo 2:5bcfb7105fa2 234 break;
Marcelocostanzo 2:5bcfb7105fa2 235 case 2:
Marcelocostanzo 2:5bcfb7105fa2 236 bus_rest = 0xC0;
Marcelocostanzo 2:5bcfb7105fa2 237 break;
Marcelocostanzo 2:5bcfb7105fa2 238 case 3:
Marcelocostanzo 2:5bcfb7105fa2 239 bus_rest = 0xE0;
Marcelocostanzo 2:5bcfb7105fa2 240 break;
Marcelocostanzo 2:5bcfb7105fa2 241 case 4:
Marcelocostanzo 2:5bcfb7105fa2 242 bus_rest = 0xF0;
Marcelocostanzo 2:5bcfb7105fa2 243 break;
Marcelocostanzo 2:5bcfb7105fa2 244 case 5:
Marcelocostanzo 2:5bcfb7105fa2 245 bus_rest = 0xF8;
Marcelocostanzo 2:5bcfb7105fa2 246 break;
Marcelocostanzo 2:5bcfb7105fa2 247 case 6:
Marcelocostanzo 2:5bcfb7105fa2 248 bus_rest = 0xFC;
Marcelocostanzo 2:5bcfb7105fa2 249 break;
Marcelocostanzo 2:5bcfb7105fa2 250 case 7:
Marcelocostanzo 2:5bcfb7105fa2 251 bus_rest = 0xFE;
Marcelocostanzo 2:5bcfb7105fa2 252 break;
Marcelocostanzo 2:5bcfb7105fa2 253 }
Marcelocostanzo 2:5bcfb7105fa2 254 //pc.printf("%x\n\r",bus_rest);
Marcelocostanzo 2:5bcfb7105fa2 255 wait_us(1000);
Marcelocostanzo 2:5bcfb7105fa2 256 RS = 1;
Marcelocostanzo 2:5bcfb7105fa2 257 RW = 0;
Marcelocostanzo 2:5bcfb7105fa2 258 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 259 EN = 1;
Marcelocostanzo 2:5bcfb7105fa2 260 DB = bus_rest; // tem que ser 254 no exemplo de T 255
Marcelocostanzo 2:5bcfb7105fa2 261 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 262 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 263 wait_us(20);
Marcelocostanzo 2:5bcfb7105fa2 264 }
Marcelocostanzo 2:5bcfb7105fa2 265 }
Marcelocostanzo 2:5bcfb7105fa2 266
Marcelocostanzo 2:5bcfb7105fa2 267 void ST7920_DrawVerticalLine(uint8_t X, uint8_t Y, uint8_t LEN)
Marcelocostanzo 2:5bcfb7105fa2 268 {
Marcelocostanzo 2:5bcfb7105fa2 269 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 270 RS = 0;
Marcelocostanzo 2:5bcfb7105fa2 271 RW = 0;
Marcelocostanzo 2:5bcfb7105fa2 272 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 273 EN = 1;
Marcelocostanzo 2:5bcfb7105fa2 274 DB = 0x80 | Y;
Marcelocostanzo 2:5bcfb7105fa2 275 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 276 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 277 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 278
Marcelocostanzo 2:5bcfb7105fa2 279 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 280 RS = 0;
Marcelocostanzo 2:5bcfb7105fa2 281 RW = 0;
Marcelocostanzo 2:5bcfb7105fa2 282 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 283 EN = 1;
Marcelocostanzo 2:5bcfb7105fa2 284 DB = 0x80 | X;
Marcelocostanzo 2:5bcfb7105fa2 285 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 286 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 287 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 288
Marcelocostanzo 2:5bcfb7105fa2 289 for(int y = 0; y < LEN; y++)
Marcelocostanzo 2:5bcfb7105fa2 290 {
Marcelocostanzo 2:5bcfb7105fa2 291 if(y < 32) {
Marcelocostanzo 2:5bcfb7105fa2 292 wait_us(100);
Marcelocostanzo 1:08481151e25e 293 RS = 0;
Marcelocostanzo 1:08481151e25e 294 RW = 0;
Marcelocostanzo 1:08481151e25e 295 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 296 EN = 1;
Marcelocostanzo 2:5bcfb7105fa2 297 DB = 0x80 | y;
Marcelocostanzo 1:08481151e25e 298 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 299 EN = 0;
Marcelocostanzo 1:08481151e25e 300 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 301
Marcelocostanzo 1:08481151e25e 302 wait_us(1000);
Marcelocostanzo 1:08481151e25e 303 RS = 0;
Marcelocostanzo 1:08481151e25e 304 RW = 0;
Marcelocostanzo 1:08481151e25e 305 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 306 EN = 1;
Marcelocostanzo 1:08481151e25e 307 DB = 0x80;
Marcelocostanzo 1:08481151e25e 308 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 309 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 310 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 311 }
Marcelocostanzo 2:5bcfb7105fa2 312
Marcelocostanzo 2:5bcfb7105fa2 313 else
Marcelocostanzo 2:5bcfb7105fa2 314 {
Marcelocostanzo 1:08481151e25e 315 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 316 RS = 0;
Marcelocostanzo 2:5bcfb7105fa2 317 RW = 0;
Marcelocostanzo 2:5bcfb7105fa2 318 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 319 EN = 1;
Marcelocostanzo 2:5bcfb7105fa2 320 DB = 0x80 | (y - 32);
Marcelocostanzo 2:5bcfb7105fa2 321 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 322 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 323 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 324
Marcelocostanzo 1:08481151e25e 325 wait_us(1000);
Marcelocostanzo 1:08481151e25e 326 RS = 0;
Marcelocostanzo 1:08481151e25e 327 RW = 0;
Marcelocostanzo 1:08481151e25e 328 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 329 EN = 1;
Marcelocostanzo 1:08481151e25e 330 DB = 0x88;
Marcelocostanzo 1:08481151e25e 331 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 332 EN = 0;
Marcelocostanzo 1:08481151e25e 333 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 334 }
Marcelocostanzo 2:5bcfb7105fa2 335
Marcelocostanzo 2:5bcfb7105fa2 336 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 337 RS = 1;
Marcelocostanzo 2:5bcfb7105fa2 338 RW = 0;
Marcelocostanzo 2:5bcfb7105fa2 339 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 340 EN = 1;
Marcelocostanzo 2:5bcfb7105fa2 341 DB = 0x80;
Marcelocostanzo 2:5bcfb7105fa2 342 wait_us(100);
Marcelocostanzo 2:5bcfb7105fa2 343 EN = 0;
Marcelocostanzo 2:5bcfb7105fa2 344 wait_us(20);
Marcelocostanzo 2:5bcfb7105fa2 345 }
Marcelocostanzo 2:5bcfb7105fa2 346 }
Marcelocostanzo 1:08481151e25e 347
Marcelocostanzo 1:08481151e25e 348 void ST7920_DisplayString(int Row,int Column,unsigned char *ptr,int length)
Marcelocostanzo 1:08481151e25e 349 {
Marcelocostanzo 1:08481151e25e 350 int i=0;
Marcelocostanzo 1:08481151e25e 351
Marcelocostanzo 1:08481151e25e 352 switch (Row)
Marcelocostanzo 1:08481151e25e 353 {
Marcelocostanzo 1:08481151e25e 354 case 0:
Marcelocostanzo 1:08481151e25e 355 Column|=0x80;
Marcelocostanzo 1:08481151e25e 356 break;
Marcelocostanzo 1:08481151e25e 357 case 1:
Marcelocostanzo 1:08481151e25e 358 Column|=0x90;
Marcelocostanzo 1:08481151e25e 359 break;
Marcelocostanzo 1:08481151e25e 360 case 2:
Marcelocostanzo 1:08481151e25e 361 Column|=0x88;
Marcelocostanzo 1:08481151e25e 362 break;
Marcelocostanzo 1:08481151e25e 363 case 3:
Marcelocostanzo 1:08481151e25e 364 Column|=0x98;
Marcelocostanzo 1:08481151e25e 365 break;
Marcelocostanzo 1:08481151e25e 366 default:
Marcelocostanzo 1:08481151e25e 367 Column=0x80;
Marcelocostanzo 1:08481151e25e 368 break;
Marcelocostanzo 1:08481151e25e 369 }
Marcelocostanzo 1:08481151e25e 370
Marcelocostanzo 2:5bcfb7105fa2 371 if (Column%2!=0)
Marcelocostanzo 2:5bcfb7105fa2 372 {
Marcelocostanzo 1:08481151e25e 373 Column-=1;
Marcelocostanzo 1:08481151e25e 374 i=1;
Marcelocostanzo 1:08481151e25e 375 }
Marcelocostanzo 2:5bcfb7105fa2 376
Marcelocostanzo 1:08481151e25e 377 wait_us(100);
Marcelocostanzo 1:08481151e25e 378 RS = 0;
Marcelocostanzo 1:08481151e25e 379 RW = 0;
Marcelocostanzo 1:08481151e25e 380 EN = 1;
Marcelocostanzo 1:08481151e25e 381 wait_us(100);
Marcelocostanzo 1:08481151e25e 382 DB = Column;
Marcelocostanzo 1:08481151e25e 383 EN = 0;
Marcelocostanzo 1:08481151e25e 384
Marcelocostanzo 1:08481151e25e 385 if (i==1)
Marcelocostanzo 1:08481151e25e 386 {
Marcelocostanzo 1:08481151e25e 387 wait_us(100);
Marcelocostanzo 1:08481151e25e 388 RS = 1;
Marcelocostanzo 1:08481151e25e 389 RW = 0;
Marcelocostanzo 1:08481151e25e 390 EN = 1;
Marcelocostanzo 1:08481151e25e 391 DB = ' ';
Marcelocostanzo 1:08481151e25e 392 EN = 0;
Marcelocostanzo 1:08481151e25e 393 }
Marcelocostanzo 1:08481151e25e 394 for (i=0; i<length; i++)
Marcelocostanzo 1:08481151e25e 395 {
Marcelocostanzo 1:08481151e25e 396 wait_us(100);
Marcelocostanzo 1:08481151e25e 397 RS = 1;
Marcelocostanzo 1:08481151e25e 398 RW = 0;
Marcelocostanzo 1:08481151e25e 399 EN = 1;
Marcelocostanzo 1:08481151e25e 400 DB = ((unsigned int)ptr[i]);
Marcelocostanzo 1:08481151e25e 401 EN = 0;
Marcelocostanzo 1:08481151e25e 402 }
Marcelocostanzo 2:5bcfb7105fa2 403 }