This program is an advanced "IoT" thermometer using LM75B component library. It displays the current value to the Serial host in Celcius or Fahrenheit (possible to change using a switch). It also stores an historic and displays it to the user using the LCD screen. Moreover, you can change the orientation of the screen by turning the device, just like a smartphone.

Dependencies:   C12832 FXOS8700CQ LM75B mbed

ThermalDisplayer.cpp

Committer:
co838_gtvl2
Date:
2016-02-09
Revision:
1:06713d1b69cf
Child:
2:5d0c209e5c61

File content as of revision 1:06713d1b69cf:

#include "ThermalDisplayer.h"

ThermalDisplayer::ThermalDisplayer() { 
     this->lcd = new C12832(D11, D13, D12, D7, D10);
     this->pot = new AnalogIn(A1);
     this->temperatures = std::list<float>(MAX_SIZE);
}

void    ThermalDisplayer::addTemp(const float &temp) {
    this->temperatures.pop_front();
    this->temperatures.push_back(temp);
}

void    ThermalDisplayer::display() {
    list<float>::const_iterator it;
    
    this->lcd->cls();
    int pos = 0;
    for (it = this->temperatures.begin(); it != this->temperatures.end(); it++, pos++) {
        float tmp = *it;
        
        this->lcd->rect(pos * 2, 32, pos * 2 + 1, 32 - (int) (tmp * 32.0 / 50.0), 1);
    }
}