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

Dependents:   uLCDgaugeTest

Committer:
Striker121
Date:
Fri Mar 13 15:47:13 2015 +0000
Revision:
8:4a69fe1bc451
Parent:
4:069b01d563a3
final dox update

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Striker121 0:9101c0ce36a1 1 #include "uLCD_gauges.h"
Striker121 0:9101c0ce36a1 2 #include "mbed.h"
Striker121 2:38006c26dda5 3
Striker121 2:38006c26dda5 4 /**
Striker121 3:eee40e4de1c4 5 * @file uLCD_gauges.cpp
Striker121 3:eee40e4de1c4 6 * @brief This cpp file defines all the functions for uLCD_gauges.h
Striker121 3:eee40e4de1c4 7 * @author Matthew Arceri and Harsha Nori
Striker121 3:eee40e4de1c4 8 * @date 3/13/2015
Striker121 3:eee40e4de1c4 9 */
Striker121 3:eee40e4de1c4 10
Striker121 0:9101c0ce36a1 11 uLCD_gauges::uLCD_gauges(uLCD_4DGL& screen, float min, float max){
Striker121 0:9101c0ce36a1 12 uLCD = &screen;
Striker121 0:9101c0ce36a1 13 minVal = min;
Striker121 0:9101c0ce36a1 14 maxVal = max;
Striker121 0:9101c0ce36a1 15 mapOffset = 1;
Striker121 2:38006c26dda5 16 highFrame = 90;
Striker121 2:38006c26dda5 17 mapSlope = (highFrame - mapOffset) / (maxVal - minVal);
Striker121 1:5666427710f2 18 memHigh = 0;
Striker121 1:5666427710f2 19 memLow = 0;
Striker121 0:9101c0ce36a1 20 }
Striker121 4:069b01d563a3 21
Striker121 2:38006c26dda5 22 uLCD_gauges::uLCD_gauges(uLCD_4DGL& screen, float min, float max, int lowF, int highF, long memoryAddressHigh, long memoryAddressLow){
Striker121 1:5666427710f2 23 uLCD = &screen;
Striker121 1:5666427710f2 24 minVal = min;
Striker121 1:5666427710f2 25 maxVal = max;
Striker121 2:38006c26dda5 26 highFrame = highF;
Striker121 2:38006c26dda5 27 mapOffset = lowF;
Striker121 2:38006c26dda5 28 mapSlope = (highFrame - mapOffset) / (maxVal - minVal);
Striker121 1:5666427710f2 29 memHigh = memoryAddressHigh;
Striker121 1:5666427710f2 30 memLow = memoryAddressLow;
Striker121 1:5666427710f2 31 }
Striker121 2:38006c26dda5 32
Striker121 0:9101c0ce36a1 33 void uLCD_gauges::start() {
Striker121 1:5666427710f2 34 uLCD->baudrate(3000000);
Striker121 0:9101c0ce36a1 35 uLCD->cls();
Striker121 0:9101c0ce36a1 36 uLCD->media_init();
Striker121 0:9101c0ce36a1 37 uLCD->set_sector_address(0,0);
Striker121 0:9101c0ce36a1 38 }
Striker121 0:9101c0ce36a1 39
Striker121 0:9101c0ce36a1 40 void uLCD_gauges::update(float value){
Striker121 0:9101c0ce36a1 41 //Map value in range minVal to maxVal onto 1 to 99
Striker121 0:9101c0ce36a1 42 int mappedValue = int(mapOffset + mapSlope*(value - minVal));
Striker121 0:9101c0ce36a1 43 uLCD->display_frame(0,0, mappedValue);
Striker121 0:9101c0ce36a1 44 }