Allows for a 90 frame animated gauge to be display on the uLCD
Embed:
(wiki syntax)
Show/hide line numbers
uLCD_gauges.cpp
Go to the documentation of this file.
00001 #include "uLCD_gauges.h" 00002 #include "mbed.h" 00003 00004 /** 00005 * @file uLCD_gauges.cpp 00006 * @brief This cpp file defines all the functions for uLCD_gauges.h 00007 * @author Matthew Arceri and Harsha Nori 00008 * @date 3/13/2015 00009 */ 00010 00011 uLCD_gauges::uLCD_gauges(uLCD_4DGL& screen, float min, float max){ 00012 uLCD = &screen; 00013 minVal = min; 00014 maxVal = max; 00015 mapOffset = 1; 00016 highFrame = 90; 00017 mapSlope = (highFrame - mapOffset) / (maxVal - minVal); 00018 memHigh = 0; 00019 memLow = 0; 00020 } 00021 00022 uLCD_gauges::uLCD_gauges(uLCD_4DGL& screen, float min, float max, int lowF, int highF, long memoryAddressHigh, long memoryAddressLow){ 00023 uLCD = &screen; 00024 minVal = min; 00025 maxVal = max; 00026 highFrame = highF; 00027 mapOffset = lowF; 00028 mapSlope = (highFrame - mapOffset) / (maxVal - minVal); 00029 memHigh = memoryAddressHigh; 00030 memLow = memoryAddressLow; 00031 } 00032 00033 void uLCD_gauges::start() { 00034 uLCD->baudrate(3000000); 00035 uLCD->cls(); 00036 uLCD->media_init(); 00037 uLCD->set_sector_address(0,0); 00038 } 00039 00040 void uLCD_gauges::update(float value){ 00041 //Map value in range minVal to maxVal onto 1 to 99 00042 int mappedValue = int(mapOffset + mapSlope*(value - minVal)); 00043 uLCD->display_frame(0,0, mappedValue); 00044 }
Generated on Wed Jul 13 2022 04:53:17 by 1.7.2