Fred Barnes / Mbed 2 deprecated co657_driving_test_2

Dependencies:   C12832 LM75B mbed

Fork of co657_driving_test_1 by Fred Barnes

Revision:
2:2b973afc0924
Parent:
1:a6827c4eef14
Child:
3:729390b9d794
--- a/dtest2.cpp	Mon Sep 28 15:34:29 2015 +0000
+++ b/dtest2.cpp	Mon Sep 28 15:42:57 2015 +0000
@@ -6,6 +6,7 @@
 
 #include "mbed.h"                       /* stock MBED API */
 #include "C12832.h"                     /* for the LCD */
+#include "LM75B.h"                      /* for the temperature sensor */
 
 /* assorted globals */
 
@@ -26,6 +27,8 @@
 
 C12832 shld_lcd (D11, D13, D12, D7, D10);   /* LCD on the shield (128x32) */
 
+LM75B lm_temp (D14, D15);               /* temperature sensor */
+
 static volatile uint16_t counters[3];   /* red, green, blue */
 static volatile uint8_t bright[3];
 
@@ -118,7 +121,7 @@
     
     shld_lcd.cls ();
     shld_lcd.locate (1, 1);
-    shld_lcd.printf ("Hello, LCD!");
+    shld_lcd.printf ("Hello, CO657!");
     
     rgb_tick.attach (&rgb_tick_interrupt, 0.001);
     ctr = 0;
@@ -135,6 +138,14 @@
     for (;;) {
         wait (0.02);                            /* approx 50 cycles/sec */
         
+        if ((ctr & 0x1f) == 0) {
+            /* every 32 cycles, or thereabouts (will be truncated) */
+            float t = lm_temp.read ();
+            
+            shld_lcd.locate (1, 10);
+            shld_lcd.printf ("Temp: %.2f", t);
+        }
+        
         if (sw2_trig) {
             ctr += 104;
             sw2_trig = 0;