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
Diff: ThermalDisplayer.cpp
- Revision:
- 6:6c61186c8739
- Parent:
- 4:5bf99eb2d740
--- a/ThermalDisplayer.cpp Fri Feb 12 09:45:41 2016 +0000 +++ b/ThermalDisplayer.cpp Mon Feb 22 19:09:17 2016 +0000 @@ -1,9 +1,11 @@ #include "ThermalDisplayer.h" -/* +/** * Constructor, initialize Potentiometer, LCD and variables */ -ThermalDisplayer::ThermalDisplayer(): pot(A1), accel(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1) +ThermalDisplayer::ThermalDisplayer() + : pot(A1), + accel(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1) { this->lcd = new C12832(D11, D13, D12, D7, D10); this->lcd->set_auto_up(0); @@ -14,8 +16,9 @@ this->accel.enable(); } -/* +/** * Add record to temperature historic + * @param const float &temp, the record to add. */ void ThermalDisplayer::addTemp(const float &temp) { @@ -23,22 +26,20 @@ this->temperatures.push_back(temp); } -/* +/** * Display informations to the LCD screen * Screen isn't even flusing ! + * For each temperature record, it draw a white rectangle to erase previous data + * then draw on top of it the new data. */ void ThermalDisplayer::display() { - list<float>::const_iterator it; + std::list<float>::const_iterator it; int pos = 0; for (it = this->temperatures.begin(); it != this->temperatures.end(); it++, pos++) { int height = (int) (32 * ((*it) - this->minScale) / (this->maxScale - this->minScale)); height = height > DISPLAY_Y ? DISPLAY_Y : (height < 0 ? 0 : height); - /* - * Draw a white rectangle to erase previous data. - * Then, draw on top of it the new data. - */ if (this->screenOrientation) { this->lcd->rect(pos * 2, 0, pos * 2 + 1, DISPLAY_Y, 0); this->lcd->rect(pos * 2, DISPLAY_Y - height, pos * 2 + 1, DISPLAY_Y, 1); @@ -50,11 +51,11 @@ this->lcd->copy_to_lcd(); } -/* +/** * Adjust scale of the display according to POT2 * Also adjust the screen orientation accodring to FXOS8700CQ accelerometer */ -void ThermalDisplayer::adjustScale(Serial &host) +void ThermalDisplayer::adjustScale() { float potValue = this->pot;