Simon Ford
/
TextLCDTest
main.cpp@0:b77078f30b97, 2009-11-17 (annotated)
- Committer:
- simon
- Date:
- Tue Nov 17 10:16:30 2009 +0000
- Revision:
- 0:b77078f30b97
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 0:b77078f30b97 | 1 | // Write to all HD44780 TextLCD RAM locations, sford |
simon | 0:b77078f30b97 | 2 | // |
simon | 0:b77078f30b97 | 3 | // A quick hack to write to all the display RAM locations |
simon | 0:b77078f30b97 | 4 | // in an HD44780 display, to identify which location maps |
simon | 0:b77078f30b97 | 5 | // to which character. |
simon | 0:b77078f30b97 | 6 | // |
simon | 0:b77078f30b97 | 7 | // Instructions: |
simon | 0:b77078f30b97 | 8 | // - Change TextLCD pinout as appropriate so it works |
simon | 0:b77078f30b97 | 9 | // - Run, and it should fill the screen with characters |
simon | 0:b77078f30b97 | 10 | // - Identify what characters are at the start of each row |
simon | 0:b77078f30b97 | 11 | // |
simon | 0:b77078f30b97 | 12 | // To determine what address each line starts at, you subtract the |
simon | 0:b77078f30b97 | 13 | // ascii code for '0'(48) from the character at the start of each line |
simon | 0:b77078f30b97 | 14 | // - see http://www.asciitable.com/ |
simon | 0:b77078f30b97 | 15 | // |
simon | 0:b77078f30b97 | 16 | // e.g. |
simon | 0:b77078f30b97 | 17 | // +----------------+ |
simon | 0:b77078f30b97 | 18 | // |0123456789:;<=>?| first char = '0' (48) |
simon | 0:b77078f30b97 | 19 | // |XYZ.... | first char = 'X' (88) |
simon | 0:b77078f30b97 | 20 | // +----------------+ |
simon | 0:b77078f30b97 | 21 | // |
simon | 0:b77078f30b97 | 22 | // So in this case, the RAM offsets are 0 and 40 |
simon | 0:b77078f30b97 | 23 | |
simon | 0:b77078f30b97 | 24 | #include "mbed.h" |
simon | 0:b77078f30b97 | 25 | #include "TextLCD.h" |
simon | 0:b77078f30b97 | 26 | |
simon | 0:b77078f30b97 | 27 | TextLCD lcd(p10, p11, p12, p15, p16, p29, p30); |
simon | 0:b77078f30b97 | 28 | DigitalOut led(LED1); |
simon | 0:b77078f30b97 | 29 | |
simon | 0:b77078f30b97 | 30 | int main() { |
simon | 0:b77078f30b97 | 31 | lcd.locate(0,0); |
simon | 0:b77078f30b97 | 32 | for(int i=0; i<80; i++) { |
simon | 0:b77078f30b97 | 33 | lcd._rs = 1; |
simon | 0:b77078f30b97 | 34 | lcd.writeByte('0' + i); |
simon | 0:b77078f30b97 | 35 | } |
simon | 0:b77078f30b97 | 36 | } |
simon | 0:b77078f30b97 | 37 |