Example program that exercises most of the capabilities of the mbed application shield (via arduino headers) with ST Nucleo board

Dependencies:   C12832 LM75B MMA7660 mbed

Files at this revision

API Documentation at this revision

Comitter:
CBMalloch
Date:
Mon Mar 30 12:28:02 2015 +0000
Parent:
1:189f0ee0223e
Commit message:
Exercises most capabilities of the application shield

Changed in this revision

C12832.lib Show annotated file Show diff for this revision Revisions of this file
LM75B.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
diff -r 189f0ee0223e -r a9c2014f9bd5 C12832.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C12832.lib	Mon Mar 30 12:28:02 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/askksa12543/code/C12832/#990d5eec2ef6
diff -r 189f0ee0223e -r a9c2014f9bd5 LM75B.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LM75B.lib	Mon Mar 30 12:28:02 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/chris/code/LM75B/#6a70c9303bbe
diff -r 189f0ee0223e -r a9c2014f9bd5 MMA7660.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA7660.lib	Mon Mar 30 12:28:02 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/Sissors/code/MMA7660/#36a163511e34
diff -r 189f0ee0223e -r a9c2014f9bd5 main.cpp
--- a/main.cpp	Mon Feb 17 22:12:58 2014 +0000
+++ b/main.cpp	Mon Mar 30 12:28:02 2015 +0000
@@ -1,17 +1,56 @@
 #include "mbed.h"
+#include "C12832.h"
+#include "MMA7660.h"
+#include "LM75B.h"
+
+PwmOut red(D5);
+PwmOut blue(D8);
+PwmOut green(D9);
 
-DigitalOut red(D5);
-DigitalOut blue(D8);
-DigitalOut green(D9);
 int i;
 
+C12832 lcd ( D11, D13, D12, D7, D10 );
+// testing using PB9 instead of D14: yields "undefined identifier"
+MMA7660 MMA ( D14, D15 );  // SDA, SCL (defs stolen from temp sensor demo)
+LM75B thermometer ( D14, D15 );
+
+AnalogIn pot1 (A0);
+AnalogIn pot2 (A1);
+
+PwmOut spkr(D6);
+
 int main() {
-    while(1) {
-        for (i=1; i<7; i++) {
-            red = i & 1;
-            blue = i & 2;
-            green = i & 4;
-            wait(0.2);
-        }
+    float temperature;
+    float frequency;
+    float lnSemitone = log ( 2.0 ) / 12.0f;
+
+    while ( 1 ) {
+        // for (i=0; i<8; i++) {
+            // red = 1.0 - double ( pot1 );
+            // blue = i & 2;
+            // green = i & 4;
+        // }
+
+        red = MMA.x() * 0.5f + 0.5f;
+        green = MMA.y() * 0.5f + 0.5f;
+        blue = float ( pot1 );
+
+        lcd.cls();
+        lcd.locate ( 1, 1 );
+        lcd.printf ( "%5.3f %5.3f %5.3f", MMA.x(), MMA.y(), MMA.z() );
+            
+        lcd.locate ( 1, 10 );
+        temperature = thermometer.read();
+        lcd.printf ( "%6.4f degC", temperature );
+        
+        int pitch = ( ( ( temperature - 21.5f ) * 8.0f ) );
+        frequency = exp ( lnSemitone * pitch ) * 440.0f;
+        lcd.locate ( 1, 20 );
+        lcd.printf ( "p: %3d; f: %6.2f", pitch, frequency );
+        spkr.period ( 1.0f / frequency );
+        spkr = pot2;  // volume, presumably
+ 
+        wait ( 0.1 );
+        
     }
 }
diff -r 189f0ee0223e -r a9c2014f9bd5 mbed.bld
--- a/mbed.bld	Mon Feb 17 22:12:58 2014 +0000
+++ b/mbed.bld	Mon Mar 30 12:28:02 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0
\ No newline at end of file