99#include " Config.hpp"
1010#include " ../Version.h"
1111
12- // Include the appropriate display driver based on board definition
13- #if defined(LILYGO_T5_V231)
14- #include < GxDEPG0213BN.h>
15- #else
16- #include < GxGDE0213B1.h>
17- #endif
18-
1912namespace PoolMonitor {
2013
2114// Initialize static members
22- #if defined(LILYGO_T5_V231)
23- GxDEPG0213BN DisplayManager::display_ (GxEPD::GxEPD_Class::GxEPD_213_BN);
24- #else
25- GxGDE0213B1 DisplayManager::display_ (GxEPD::GxEPD_Class::GxEPD_213_B1);
26- #endif
27- U8G2_FOR_ADAFRUIT_GFX DisplayManager::u8g2_for_adafruit_gfx_ (DisplayManager::display_);
15+ GxIO_Class DisplayManager::io_ (SPI , PIN_ELINK_SS , PIN_ELINK_DC , PIN_SPI_CLK );
16+ GxEPD_Class DisplayManager::display_ (DisplayManager::io_, PIN_ELINK_RESET ,
17+ PIN_ELINK_BUSY );
18+ U8G2_FOR_ADAFRUIT_GFX DisplayManager::u8g2_for_adafruit_gfx_;
2819
2920bool DisplayManager::begin () {
3021 Serial.println (" 🖥️\t Initializing display..." );
31-
22+
3223 display_.init ();
3324 u8g2_for_adafruit_gfx_.begin (display_);
34-
25+
3526 return true ;
3627}
3728
@@ -48,12 +39,12 @@ void DisplayManager::displayText(const char* text, int16_t y, uint8_t align, int
4839 x = display_.width () / 2 + xOffset;
4940 break ;
5041 }
51-
52- int16_t textWidth = 0 ;
53- int16_t textHeight = 0 ;
54- display_.getTextBounds (text, 0 , 0 , &x , &y , &textWidth, &textHeight);
55-
56- int16_t cursorY = y - textHeight / 2 ;
42+
43+ int16_t x1 = 0 , y1 = 0 ;
44+ uint16_t textWidth = 0 , textHeight = 0 ;
45+ display_.getTextBounds (text, 0 , 0 , &x1 , &y1 , &textWidth, &textHeight);
46+
47+ int16_t cursorY = y - static_cast < int16_t >( textHeight) / 2 ;
5748 display_.setCursor (x, cursorY);
5849 display_.print (text);
5950}
@@ -73,21 +64,21 @@ void DisplayManager::initDisplay() {
7364 // Draw pool icon
7465 u8g2_for_adafruit_gfx_.setFont (u8g2_font_streamline_all_t );
7566 u8g2_for_adafruit_gfx_.drawGlyph (4 , 50 , 0x02a6 ); /* hex pool */
76-
67+
7768 display_.setFont (&FreeSans12pt7b);
7869 displayText (" Pool:" , 50 , GxEPD_ALIGN_LEFT);
7970
8071 // Draw solar icon
8172 u8g2_for_adafruit_gfx_.setFont (u8g2_font_streamline_ecology_t );
8273 u8g2_for_adafruit_gfx_.drawGlyph (4 , 94 , 0x003E ); /* hex 3E solar panel */
83-
74+
8475 display_.setFont (&FreeSans12pt7b);
8576 displayText (" Solar:" , 94 , GxEPD_ALIGN_LEFT);
8677
8778 // Draw separator lines
8879 display_.drawLine (0 , 102 , display_.width (), 102 , GxEPD_BLACK);
8980 display_.drawLine (0 , 103 , display_.width (), 103 , GxEPD_BLACK);
90-
81+
9182 display_.setFont (&FreeSans9pt7b);
9283 displayText (" www.smart-swimmingpool.com" , 117 , GxEPD_ALIGN_LEFT);
9384
@@ -100,7 +91,7 @@ void DisplayManager::initDisplay() {
10091 fullUpdate ();
10192}
10293
103- void DisplayManager::updateDisplay (float poolTemp, float solarTemp, bool poolPumpOn,
94+ void DisplayManager::updateDisplay (float poolTemp, float solarTemp, bool poolPumpOn,
10495 bool solarPumpOn, const char * mode, const char * lastUpdate) {
10596 Serial.println (" 🖥️\t Updating display" );
10697
@@ -123,7 +114,7 @@ void DisplayManager::updateDisplay(float poolTemp, float solarTemp, bool poolPum
123114
124115 display_.setTextColor (GxEPD_BLACK);
125116 display_.setFont (&FreeSansBold24pt7b);
126-
117+
127118 // Pool temperature
128119 snprintf (buffer, sizeof (buffer), " %2.1f C" , poolTemp);
129120 displayText (buffer, 50 , GxEPD_ALIGN_RIGHT);
@@ -176,7 +167,7 @@ uint16_t DisplayManager::getHeight() {
176167 return display_.height ();
177168}
178169
179- auto DisplayManager::getDisplay () -> GxEPD:: GxEPD_Class& {
170+ auto DisplayManager::getDisplay () -> GxEPD_Class& {
180171 return display_;
181172}
182173
0 commit comments