Simple Hello World! for the TextLCD library
Dependencies: TextLCD mbed-rtos mbed
Fork of TextLCD_HelloWorld by
main.cpp@3:39825a5cf7cf, 2015-01-22 (annotated)
- Committer:
- myren
- Date:
- Thu Jan 22 15:47:19 2015 +0000
- Revision:
- 3:39825a5cf7cf
- Parent:
- 2:ad0b044d0a10
SuperTues test program
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" |
myren | 3:39825a5cf7cf | 4 | #include "TextLCD.h"//LCD bibliotek |
myren | 3:39825a5cf7cf | 5 | #include "rtos.h"//threading bibliotek |
simon | 0:334327d1a416 | 6 | |
myren | 3:39825a5cf7cf | 7 | TextLCD lcd_txt(p26, p25, p24, p23, p22, p21,TextLCD::LCD20x4); // rs, e, d4-d7 |
myren | 3:39825a5cf7cf | 8 | DigitalOut Led1 (LED1); |
myren | 3:39825a5cf7cf | 9 | DigitalOut Led2 (LED2); |
myren | 3:39825a5cf7cf | 10 | DigitalOut MyLed (p28); |
myren | 3:39825a5cf7cf | 11 | |
myren | 3:39825a5cf7cf | 12 | DigitalIn Btn1 (p27); |
myren | 3:39825a5cf7cf | 13 | |
myren | 3:39825a5cf7cf | 14 | |
myren | 3:39825a5cf7cf | 15 | |
simon | 0:334327d1a416 | 16 | |
myren | 3:39825a5cf7cf | 17 | void CheckBtn_thread(void const *args) |
myren | 3:39825a5cf7cf | 18 | { |
myren | 3:39825a5cf7cf | 19 | while (true) //tråd der scanner knapper |
myren | 3:39825a5cf7cf | 20 | { |
myren | 3:39825a5cf7cf | 21 | Led2 = !Led2; |
myren | 3:39825a5cf7cf | 22 | if (MyLed == true) |
myren | 3:39825a5cf7cf | 23 | { |
myren | 3:39825a5cf7cf | 24 | lcd_txt.locate(0,2); |
myren | 3:39825a5cf7cf | 25 | lcd_txt.printf("LED aktiveret! "); |
myren | 3:39825a5cf7cf | 26 | } |
myren | 3:39825a5cf7cf | 27 | else |
myren | 3:39825a5cf7cf | 28 | { |
myren | 3:39825a5cf7cf | 29 | lcd_txt.locate(0,2); |
myren | 3:39825a5cf7cf | 30 | lcd_txt.printf("LED deaktiveret!"); |
myren | 3:39825a5cf7cf | 31 | } |
myren | 3:39825a5cf7cf | 32 | |
myren | 3:39825a5cf7cf | 33 | |
myren | 3:39825a5cf7cf | 34 | lcd_txt.locate(0,0); |
myren | 3:39825a5cf7cf | 35 | lcd_txt.printf("***** SuperTue *****"); |
myren | 3:39825a5cf7cf | 36 | |
myren | 3:39825a5cf7cf | 37 | if (Btn1 == true)//scanner knap |
myren | 3:39825a5cf7cf | 38 | { |
myren | 3:39825a5cf7cf | 39 | lcd_txt.locate(0,3); |
myren | 3:39825a5cf7cf | 40 | lcd_txt.printf("Switch aktiv!"); |
myren | 3:39825a5cf7cf | 41 | MyLed = !MyLed; //tænder og slukker for diode |
myren | 3:39825a5cf7cf | 42 | Thread::wait(500); |
myren | 3:39825a5cf7cf | 43 | } |
myren | 3:39825a5cf7cf | 44 | else |
myren | 3:39825a5cf7cf | 45 | { |
myren | 3:39825a5cf7cf | 46 | lcd_txt.locate(0,3); |
myren | 3:39825a5cf7cf | 47 | lcd_txt.printf(" "); |
myren | 3:39825a5cf7cf | 48 | } |
myren | 3:39825a5cf7cf | 49 | |
myren | 3:39825a5cf7cf | 50 | |
myren | 3:39825a5cf7cf | 51 | } |
myren | 3:39825a5cf7cf | 52 | |
myren | 3:39825a5cf7cf | 53 | } |
myren | 3:39825a5cf7cf | 54 | |
myren | 3:39825a5cf7cf | 55 | int main() |
myren | 3:39825a5cf7cf | 56 | { |
myren | 3:39825a5cf7cf | 57 | Thread thread(CheckBtn_thread); |
myren | 3:39825a5cf7cf | 58 | lcd_txt.cls(); |
myren | 3:39825a5cf7cf | 59 | |
myren | 3:39825a5cf7cf | 60 | while (true) |
myren | 3:39825a5cf7cf | 61 | { |
myren | 3:39825a5cf7cf | 62 | Led1 = !Led1; //starter "tråd" i hovedprogram |
myren | 3:39825a5cf7cf | 63 | Thread::wait(500); |
myren | 3:39825a5cf7cf | 64 | } |
myren | 3:39825a5cf7cf | 65 | |
simon | 0:334327d1a416 | 66 | } |
myren | 3:39825a5cf7cf | 67 |