martedì 11 maggio 2010

LCD 20x4 and graphical characters

clipped from www.sparkfun.com
I had to reboot (power cycle) the LCD display after every command changing the LCD setup (0x7c-0x03 to 0x7c-0x06); anyway, these are stored in the backpack EEPROM as well, thus once set I don't need to use them anymore.
I was also able to define graphical characters sending the command 0xfe-0x40 and then from 1 to 8 sequences of 8 bytes containing the bitmaps (for example 0x15-0x0a-0x15-0x0a-0x15-0x0a-0x15-0x0a will define a 5x8 checkered pattern) and finally a 0xfe-0x01 (clear screen ending bitmap definition mode). The defined characters are 0x00 up to 0x07. Characters are stored in CG-RAM of the display; this means that they will have to be redefined on every reboot.
Questo LCD backpack costa un pozzo di soldi ($16.95, more than a 20x4 LCD itself! ma si trova anche altrove, non necessariamente da Sparfkun) ma mi ha risparmiato un cumulo di rogne, perché anziché aver a che fare con RS/RW/E/DB4-DB7, si ha a che fare con una seriale a 9600 (dunque ottimo per la Arduino e per qualsiasi altro aggeggio a cui avanza una seriale TTL 5V, anzi, basta solo il pin TX), ed anziché dover sbariare con alimentazione 5V-4.2V-vdd-vss-etc, basta dargli i canonici 5V.

Definizione di caratteri grafici sugli HD44780-compatible:
- command 0xfe-0x40
(0x40 = character address in CG-RAM; 0x40: first char, 0x48: second char, etc; up to 8 characters)
- then 8 bytes for every character (containing a 5x8 bitmap; note that the 3 most significant bits are ignored)
- finally, send a command 0xfe-0x01 (exit CG-RAM mode and clear the screen)
- then, to print those characters: just send 0x00 to 0x07.

(perbacco, mi tocca scriverlo in inglese perché ci cliccano da tutte le parti).

Nota: lavora a 4 bit (DB4-DB7), per cui lo spazio dei DB0-DB3 è... senza pin!

Nessun commento:

Posta un commento