Refactor Sensors to remove publish responsibility and instead return values. Add Screen class to output to OLED screen.

This commit is contained in:
Robert Marshall 2019-03-03 21:37:31 +00:00
parent 12e756fef1
commit d51b140050
5 changed files with 81 additions and 27 deletions

29
Screen.cpp Normal file
View file

@ -0,0 +1,29 @@
#include "Screen.h"
Screen::Screen(Sensors *sensors, int sdaPin, int sclPin){
_sensors = sensors;
_sdaPin = sdaPin;
_sclPin = sclPin;
}
void Screen::setup() {
Wire.begin(_sdaPin, _sclPin);
_screen.begin(SSD1306_SWITCHCAPVCC, 0x3C);
_screen.clearDisplay();
_screen.setTextWrap(false);
_screen.setTextColor(WHITE);
}
void Screen::writeTemperature(){
_screen.setTextSize(1);
_screen.setCursor(0, 0);
_screen.println("Temperature:");
_screen.setTextSize(2);
_screen.setCursor(0, 10);
_screen.println(_sensors->getTemperature());
}
void Screen::update(){
writeTemperature();
_screen.display();
}