#include #include 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); } void display_parking_spots(int total_spots, int occupied_spots){ if (this->state != DISPLAY_PARKING_SPOTS){ this->clear(); this->state = DISPLAY_PARKING_SPOTS; } int free_spots = total_spots - occupied_spots; lcd.setCursor(0, 0); lcd.print("Occupied: "); lcd.print(occupied_spots); lcd.print(" / "); lcd.print(total_spots); lcd.setCursor(0, 1); lcd.print("Free: "); lcd.print(free_spots); } };