54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
#include <Arduino.h>
|
|
#include <LiquidCrystal_I2C.h>
|
|
|
|
enum LCDScreenState {
|
|
DISPLAY_DEFAULT_MESSAGE,
|
|
DISPLAY_TEMPERATURE,
|
|
DISPLAY_PARKING_SPOTS
|
|
};
|
|
|
|
class LCDScreen {
|
|
|
|
private:
|
|
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27,20,4);
|
|
LCDScreenState state;
|
|
String default_message = "Bem vindo!";
|
|
|
|
public:
|
|
LCDScreen(String default_message = ""){
|
|
if (default_message != ""){
|
|
this->default_message = default_message;
|
|
}
|
|
}
|
|
|
|
void init(){
|
|
lcd.init();
|
|
lcd.backlight();
|
|
this->display_default_message();
|
|
}
|
|
|
|
void clear(){
|
|
lcd.clear();
|
|
}
|
|
|
|
void display_temperature(float temp){
|
|
if (this->state != DISPLAY_TEMPERATURE){
|
|
this->clear();
|
|
this->state = DISPLAY_TEMPERATURE;
|
|
}
|
|
lcd.setCursor(0, 0);
|
|
lcd.print("Temp: ");
|
|
lcd.print(temp,1);
|
|
lcd.print(" C ");
|
|
}
|
|
|
|
void display_default_message(){
|
|
if (this->state != DISPLAY_DEFAULT_MESSAGE){
|
|
this->clear();
|
|
this->state = DISPLAY_DEFAULT_MESSAGE;
|
|
}
|
|
lcd.setCursor(0, 0);
|
|
lcd.print(this->default_message);
|
|
}
|
|
|
|
}; |