![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
LCD Example program with attached library
Fork of blink_kl46z_LCD by
Revision 4:fe9652973a7f, committed 2015-09-10
- Comitter:
- scohennm
- Date:
- Thu Sep 10 00:05:30 2015 +0000
- Parent:
- 3:f445e67012ee
- Commit message:
- LCD Example program with attached library
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f445e67012ee -r fe9652973a7f main.cpp --- a/main.cpp Sat Jan 17 23:41:30 2015 +0000 +++ b/main.cpp Thu Sep 10 00:05:30 2015 +0000 @@ -1,21 +1,21 @@ #include "mbed.h" #include "SLCD.h" +#define PROGNAME "kl46z_LCD v1\n\r" #define LEDON false #define LEDOFF true #define LCDCHARLEN 10 -#define NUMMESS 2 -#define ONEL " .1" -#define TWOL "2." +#define HELLO_LCD "HLLO" // slightly more interesting blinky 140814 sc SLCD slcd; //define LCD display - +Serial pc(USBTX, USBRX); + float blinks[]={0.400, 0.700}; int ledState = LEDON; DigitalOut greenColor(LED_GREEN); DigitalOut redColor(LED_RED); -int lcdCounter = 1; + void LCDMess(char *lMess){ slcd.Home(); @@ -24,18 +24,19 @@ } //-------------------------------- int main() { - char rMess[NUMMESS][LCDCHARLEN]={ONEL, TWOL}; - + pc.printf(PROGNAME); while(true) { - lcdCounter++; - lcdCounter = lcdCounter % NUMMESS; ledState = !ledState; // Flip the general state redColor = ledState; greenColor = !ledState;// flip state but don't store it. redColor.write(ledState); greenColor.write(!ledState);// flip state but don't store it. - LCDMess(rMess[lcdCounter]); + if(ledState){ + LCDMess(HELLO_LCD); + } else { + slcd.clear(); + } wait(blinks[ledState]); } }