Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: TextLCD mbed MaxSonar RTC-DS1307
Fork of TextLCD_HelloWorld by
main.cpp@4:c669026b6f6e, 2017-05-24 (annotated)
- Committer:
- aueangpanit
- Date:
- Wed May 24 12:02:38 2017 +0000
- Revision:
- 4:c669026b6f6e
- Parent:
- 3:5e0ba6e35849
- Child:
- 5:2f13ec8efe0b
Multiple screen display
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| simon | 1:7418a52375a0 | 1 | // Hello World! for the TextLCD |
| simon | 1:7418a52375a0 | 2 | |
| simon | 0:334327d1a416 | 3 | #include "mbed.h" |
| aueangpanit | 4:c669026b6f6e | 4 | #include <string> |
| simon | 0:334327d1a416 | 5 | #include "TextLCD.h" |
| simon | 0:334327d1a416 | 6 | |
| aueangpanit | 3:5e0ba6e35849 | 7 | TextLCD lcd(PTE30, PTE29, PTE23, PTE22, PTE21, PTE20); // rs, e, d4-d7 |
| aueangpanit | 3:5e0ba6e35849 | 8 | |
| aueangpanit | 4:c669026b6f6e | 9 | DigitalOut screen1(PTE5); |
| aueangpanit | 4:c669026b6f6e | 10 | DigitalOut screen2(PTE4); |
| aueangpanit | 4:c669026b6f6e | 11 | |
| aueangpanit | 4:c669026b6f6e | 12 | void UpdateScreen(DigitalOut screen, string text); |
| aueangpanit | 4:c669026b6f6e | 13 | |
| aueangpanit | 3:5e0ba6e35849 | 14 | int i = 0; |
| simon | 0:334327d1a416 | 15 | |
| simon | 0:334327d1a416 | 16 | int main() { |
| aueangpanit | 4:c669026b6f6e | 17 | screen1 = 1; |
| aueangpanit | 4:c669026b6f6e | 18 | screen2 = 1; |
| aueangpanit | 4:c669026b6f6e | 19 | wait(1); |
| aueangpanit | 4:c669026b6f6e | 20 | |
| aueangpanit | 4:c669026b6f6e | 21 | UpdateScreen(screen2, "Screen2"); |
| aueangpanit | 4:c669026b6f6e | 22 | |
| aueangpanit | 4:c669026b6f6e | 23 | UpdateScreen(screen1, "Screen1"); |
| aueangpanit | 4:c669026b6f6e | 24 | |
| aueangpanit | 4:c669026b6f6e | 25 | } |
| aueangpanit | 4:c669026b6f6e | 26 | |
| aueangpanit | 4:c669026b6f6e | 27 | void UpdateScreen(DigitalOut screen, string text) |
| aueangpanit | 4:c669026b6f6e | 28 | { |
| aueangpanit | 4:c669026b6f6e | 29 | //disable all E pin for all screens |
| aueangpanit | 4:c669026b6f6e | 30 | screen1 = 0; |
| aueangpanit | 4:c669026b6f6e | 31 | screen2 = 0; |
| aueangpanit | 4:c669026b6f6e | 32 | |
| aueangpanit | 4:c669026b6f6e | 33 | //enable E pin for the scrren that we want to update |
| aueangpanit | 4:c669026b6f6e | 34 | screen = 1; |
| aueangpanit | 4:c669026b6f6e | 35 | |
| aueangpanit | 4:c669026b6f6e | 36 | //some weird behaviour after disabling the E pin once means that we need to update the screen several times for it to display properly |
| aueangpanit | 4:c669026b6f6e | 37 | for(i = 0; i < 10; i++) |
| aueangpanit | 4:c669026b6f6e | 38 | { |
| aueangpanit | 3:5e0ba6e35849 | 39 | lcd.cls(); |
| aueangpanit | 4:c669026b6f6e | 40 | char text_char_array[1024]; |
| aueangpanit | 4:c669026b6f6e | 41 | strcpy(text_char_array, text.c_str()); |
| aueangpanit | 4:c669026b6f6e | 42 | lcd.printf(text_char_array); |
| aueangpanit | 3:5e0ba6e35849 | 43 | } |
| aueangpanit | 4:c669026b6f6e | 44 | |
| aueangpanit | 4:c669026b6f6e | 45 | |
| simon | 0:334327d1a416 | 46 | } |
