Allows for a 90 frame animated gauge to be display on the uLCD

Dependents:   uLCDgaugeTest

Files at this revision

API Documentation at this revision

Comitter:
Striker121
Date:
Thu Mar 12 18:19:26 2015 +0000
Child:
1:5666427710f2
Commit message:
First maybe functioning revision;

Changed in this revision

uLCD_gauges.cpp Show annotated file Show diff for this revision Revisions of this file
uLCD_gauges.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uLCD_gauges.cpp	Thu Mar 12 18:19:26 2015 +0000
@@ -0,0 +1,22 @@
+#include "uLCD_gauges.h"
+#include "mbed.h"
+ 
+uLCD_gauges::uLCD_gauges(uLCD_4DGL& screen, float min, float max){
+    uLCD = &screen;
+    minVal = min;
+    maxVal = max;
+    mapOffset = 1;
+    mapSlope = (90 - 1) / (maxVal - minVal);
+}
+ 
+void uLCD_gauges::start() {
+    uLCD->cls();
+    uLCD->media_init();
+    uLCD->set_sector_address(0,0);
+}
+
+void uLCD_gauges::update(float value){
+    //Map value in range minVal to maxVal onto 1 to 99
+    int mappedValue = int(mapOffset + mapSlope*(value - minVal));
+    uLCD->display_frame(0,0, mappedValue);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uLCD_gauges.h	Thu Mar 12 18:19:26 2015 +0000
@@ -0,0 +1,21 @@
+#ifndef ULCD_GAUGES_H
+#define ULCD_GAUGES_H
+ 
+#include "uLCD_4DGL.h"
+#include "mbed.h"
+ 
+class uLCD_gauges {
+public:
+    uLCD_gauges(uLCD_4DGL& screen, float min, float max);
+    void start();
+    void update(float value);
+  
+private:  
+    uLCD_4DGL *uLCD;
+    float minVal;
+    float maxVal;
+    float mapOffset;
+    float mapSlope;
+};
+ 
+#endif