Example of using a GDM2004D LCD with Elmicro\'s TestBed for mbed carrier board. Uses an altered version of the TextLCD-library.
main.cpp@0:7c694e032688, 2011-10-11 (annotated)
- Committer:
- elmicro
- Date:
- Tue Oct 11 08:13:19 2011 +0000
- Revision:
- 0:7c694e032688
Initial Revision
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elmicro | 0:7c694e032688 | 1 | #include "mbed.h" |
elmicro | 0:7c694e032688 | 2 | //the library "TextLCD.h" was slightly altered to work with the GDM2004D LCD |
elmicro | 0:7c694e032688 | 3 | #include "TextLCD.h" |
elmicro | 0:7c694e032688 | 4 | |
elmicro | 0:7c694e032688 | 5 | //the object "lcd" is initialized to act as a TextLCD with 20x4 characters |
elmicro | 0:7c694e032688 | 6 | TextLCD lcd(p26, p25, p24, p23, p22, p20, p19, TextLCD::LCD20x4); |
elmicro | 0:7c694e032688 | 7 | |
elmicro | 0:7c694e032688 | 8 | int main() { |
elmicro | 0:7c694e032688 | 9 | //each line of the LCD can be accessed directly using the .locate(column, line) function |
elmicro | 0:7c694e032688 | 10 | lcd.locate(0,0); |
elmicro | 0:7c694e032688 | 11 | lcd.printf("12345678901234567890"); |
elmicro | 0:7c694e032688 | 12 | lcd.locate(0,1); |
elmicro | 0:7c694e032688 | 13 | lcd.printf("UVWXYZabcdefghijklmn"); |
elmicro | 0:7c694e032688 | 14 | lcd.locate(0,2); |
elmicro | 0:7c694e032688 | 15 | lcd.printf("ABCDEFGHIJKLMNOPQRST"); |
elmicro | 0:7c694e032688 | 16 | lcd.locate(0,3); |
elmicro | 0:7c694e032688 | 17 | lcd.printf("12345678901234567890"); |
elmicro | 0:7c694e032688 | 18 | wait(2); |
elmicro | 0:7c694e032688 | 19 | |
elmicro | 0:7c694e032688 | 20 | //the LCD is cleared using function .cls() |
elmicro | 0:7c694e032688 | 21 | lcd.cls(); |
elmicro | 0:7c694e032688 | 22 | //a "\n" in a text string causes a line feed |
elmicro | 0:7c694e032688 | 23 | lcd.printf("HELLO WORLD\n"); |
elmicro | 0:7c694e032688 | 24 | //if the end of a line is reached, the text is written to the next line automatically |
elmicro | 0:7c694e032688 | 25 | lcd.printf("Testbed for mbed\nLCD example softwarewith altered library"); |
elmicro | 0:7c694e032688 | 26 | |
elmicro | 0:7c694e032688 | 27 | //the endless loop keeps mbed in low power mode |
elmicro | 0:7c694e032688 | 28 | while(1) |
elmicro | 0:7c694e032688 | 29 | { |
elmicro | 0:7c694e032688 | 30 | __WFI(); |
elmicro | 0:7c694e032688 | 31 | } |
elmicro | 0:7c694e032688 | 32 | } |