Use long-hand write on Digital I/O

Dependencies:   mbed SLCD

Fork of blink_kl46z by Stanley Cohen

Files at this revision

API Documentation at this revision

Comitter:
scohennm
Date:
Sat Jan 17 23:41:30 2015 +0000
Parent:
2:24090ed5f981
Commit message:
Update revision to include LCD

Changed in this revision

SLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SLCD.lib	Sat Jan 17 23:41:30 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/SLCD/#ef2b3b7f1b01
--- a/main.cpp	Wed Sep 03 15:03:30 2014 +0000
+++ b/main.cpp	Sat Jan 17 23:41:30 2015 +0000
@@ -1,22 +1,41 @@
 #include "mbed.h"
+#include "SLCD.h"
+ 
 #define LEDON false
 #define LEDOFF true
-#define PWMDWELL 50// milliseconds
-#define DFDELTA 0.01
-
+#define LCDCHARLEN 10
+#define NUMMESS 2
+#define ONEL "   .1"
+#define TWOL "2."
+ 
 // slightly more interesting blinky 140814 sc
-// Change to use PWM
-
-float dutyFactor = 0.0;
-PwmOut greenColor(LED_GREEN);
-PwmOut redColor(LED_RED);
-
+SLCD slcd; //define LCD display
+ 
+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();
+        slcd.clear();
+        slcd.printf(lMess);
+}
+//--------------------------------
 int main() {
+    char rMess[NUMMESS][LCDCHARLEN]={ONEL, TWOL};
+ 
+    
     while(true) {
-        redColor.write(dutyFactor);
-        greenColor.write(1.0 - dutyFactor);
-        dutyFactor += DFDELTA; 
-        if(dutyFactor >= 1.0) dutyFactor = 0.0;  
-        wait_ms(PWMDWELL);
+        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]);
+        wait(blinks[ledState]);
     }
-}
\ No newline at end of file
+}