Allows for a 90 frame animated gauge to be display on the uLCD
Diff: uLCD_gauges.cpp
- Revision:
- 0:9101c0ce36a1
- Child:
- 1:5666427710f2
diff -r 000000000000 -r 9101c0ce36a1 uLCD_gauges.cpp --- /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