App shield board demo

Dependencies:   C12832_lcd LM75B MMA7660 mbed

Fork of app-board-demo by kinlok chan

Files at this revision

API Documentation at this revision

Comitter:
MACRUM
Date:
Thu Jun 05 04:54:36 2014 +0000
Parent:
4:dac7e60ec354
Child:
6:df13ae9c5847
Commit message:
Initial release

Changed in this revision

C12832_lcd.lib Show annotated file Show diff for this revision Revisions of this file
MMA7660.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/C12832_lcd.lib	Tue Jul 30 02:47:21 2013 +0000
+++ b/C12832_lcd.lib	Thu Jun 05 04:54:36 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/dreschpe/code/C12832_lcd/#468cdccff7af
+http://mbed.org/users/dreschpe/code/C12832_lcd/#55d53324e7fa
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA7660.lib	Thu Jun 05 04:54:36 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/MMA7660/#a8e20db7901e
--- a/main.cpp	Tue Jul 30 02:47:21 2013 +0000
+++ b/main.cpp	Thu Jun 05 04:54:36 2014 +0000
@@ -1,80 +1,59 @@
 #include "mbed.h"
-#include "LM75B.h"
 #include "C12832_lcd.h"
-
-PwmOut r (p23);
-PwmOut g (p24);
-PwmOut b (p25);
+#include "LM75B.h"
+#include "MMA7660.h"
 
-C12832_LCD lcd;
-LM75B tmp(p28,p27);
+DigitalOut led1(D8);
+DigitalOut led2(D9);
+PwmOut     r(LED_RED);
+PwmOut     g(LED_GREEN);
+PwmOut     b(LED_BLUE);
+AnalogIn   pot1(A0);
+AnalogIn   pot2(A1);
+LM75B      sensor(SDA, SCL);
+InterruptIn button(D4);
+MMA7660    axis(SDA, SCL);
 
-BusIn joy(p12,p13,p15,p16);
-DigitalIn fire(p14);
+C12832 lcd(D11, D13, D12, D7, D10);
+
+Ticker flipper;
 
-BusOut leds(LED1,LED2,LED3,LED4);
-AnalogIn p(p19);
-AnalogIn p2(p20);
-PwmOut spkr(p26);
+void flip()
+{
+    led2 = !led2;
+}
 
-int main ()
-
+int main()
 {
-
-    while (1) {
-    int a=p*80;
+    int cnt = 0;
     
+    button.fall(&flip);
+    flipper.attach(&flip, 1.23);
+        
     lcd.cls();
+    lcd.locate(0, 0);
+    lcd.printf("LPC1549 + mbed app shield!");
+    led1 = 0;
 
-    lcd.locate(0,3);//location of Temp. information sentence
+    while(true) {
+        lcd.locate(0,15);
+        lcd.printf("Counting: %d", cnt);
+        
+        lcd.locate(70,15);
+        lcd.printf("p1=%f", pot1.read());
+                
+        lcd.locate(70,15+8);
+        lcd.printf("p2=%f", pot2.read());
 
-    lcd.printf("Room Temp. :%.2foC",tmp.read()); //Temp. information
-    
-    lcd.locate(a,15); //location of LEDs state sentence
-    
-    if (fire){//LEDs state
-    
-    lcd.printf("ALL LED ON");
+        lcd.locate(20,15+8);
+        lcd.printf("%f", sensor.read());
+
+        r = axis.x();
+        g = axis.y();
+        b = axis.x();
+        
+        led1 = !led1;
+        cnt++;
+        wait(0.5);
     }
-    else if(leds == 0x1) { 
-    lcd.printf("LED1 ON");
-    }
-    else if(leds == 0x2) { 
-    lcd.printf("LED2 ON");
-    }
-    else if(leds == 0x4) { 
-    lcd.printf("LED3 ON");
-    }
-    else if(leds == 0x8) { 
-    lcd.printf("LED4 ON");
-    }
-        wait(0.1);
-        if (fire) {
-         leds=0xf;
-           for (float i=2000.0; i<10000.0; i+=100) {//speaker enable if all LEDs on
-            spkr.period(1.0/i);
-            spkr=p2;
-            wait(0.1);
-        }                    
-            
-        } else {
-            leds=joy;
-            spkr = 0;
-        }
-       
-        wait(0.1);
-   
-       
-        for(float i = 0.0; i < 1.0 ; i += 0.01) {
-            float p = (((tmp.read()/100)-0.298)*60);//rgb LED colour calculation
-            b = 1.0 - ((p < 1.0) ? 1.0 - p : (p > 2.0) ? p - 2.0 : 0.0);
-            g = 1.0 - ((p < 1.0) ? p : (p > 2.0) ? 0.0 : 2.0 - p);
-            r = 1.0 - ((p < 1.0) ? 0.0 : (p > 2.0) ? 3.0 - p : p - 1.0);  ; 
-            wait (0.01);
-
-        }
-    
-    }
-
-
 }
--- a/mbed.bld	Tue Jul 30 02:47:21 2013 +0000
+++ b/mbed.bld	Thu Jun 05 04:54:36 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0
+http://mbed.org/users/mbed_official/code/mbed/builds/7d30d6019079
\ No newline at end of file