Variation. Temperature reading moves across x-axis with time, it is positioned in y-axis proportional to temperature as read.

Dependencies:   C12832_lcd LM75B mbed

Fork of app-board-LM75B by Chris Styles

Files at this revision

API Documentation at this revision

Comitter:
chapfohn
Date:
Wed Oct 23 04:16:10 2013 +0000
Parent:
4:e7ecb33e5806
Commit message:
Variation on parent program.; Temperature reading moves across x-axis of screen with time, its position in y-axis is proportional to the temperature as read.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r e7ecb33e5806 -r b7c60e64fbf0 main.cpp
--- a/main.cpp	Wed Oct 23 04:06:27 2013 +0000
+++ b/main.cpp	Wed Oct 23 04:16:10 2013 +0000
@@ -6,24 +6,24 @@
 C12832_LCD lcd;
 LM75B tmp(p28,p27);
 
-float   temp=0;
-int     i = 0;
-int     n = 129;
+float   temp=0;                             //Initialise temperature
+int     i = 0;                              //Initialise counter
+int     n = 129;                            //Set LCD screen width
 
 int main ()
 {
-    lcd.cls();
-    for (i = 0; i < n; i = i + 1) {
-        temp = floor(tmp.read());
-        lcd.locate(i,(32-(temp)));
-        lcd.printf("%.0f\n",temp);
-        wait(.1);
-        if (i == (n-10)){
-        i = 0;
-        lcd.cls();
+    lcd.cls();                              //Clear screen
+    for (i = 0; i < n; i = i + 1) {         //Move temperature reading across x-axis of the LCD screen
+        temp = floor(tmp.read());           //Round down temperature reading
+        lcd.locate(i,(32-(temp)));          //Locate reading on LCD screen, 32- inverts position in y-axis
+        lcd.printf("%.0f\n",temp);          //Print the value
+        wait(.1);                           //Pause
+        if (i == (n-10)){                   //Whether the x-axis position on LCD screen reached the maximum value
+        i = 0;                              //If so reset x-axis position to 0
+        lcd.cls();                          //Clear screen
         }
         else
-            ;
+            ;                               //Otherwise continue the loop
     }
 }