Skip to content

Commit 900718e

Browse files
authored
fix: resolve all build and lint errors on main refactoring (#22)
1 parent 8f11fb0 commit 900718e

7 files changed

Lines changed: 113 additions & 85 deletions

File tree

platformio.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ lib_deps =
3434
build_flags =
3535
${env.build_flags}
3636
; FW_VERSION is auto-maintained by release-please — do not edit manually
37-
'-D FW_VERSION="0.1.0"' # x-release-please-version
38-
'-D GITHUB_REPO="smart-swimmingpool/monitor"'
37+
'-DFW_VERSION="0.1.0"'
38+
'-DGITHUB_REPO="smart-swimmingpool/monitor"'
3939
-D SERIAL_SPEED=${common.serial_speed}
4040
-D LILYGO_T5_V231
41-
-std=c++17
41+
-std=gnu++11
4242
-Wno-deprecated-declarations
4343
upload_speed = ${common.serial_speed}
4444
monitor_speed = ${common.serial_speed}

src/PoolMonitor/Config.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ constexpr std::uint8_t PIN_ELINK_SS{5};
6060
/** @brief SPI MOSI pin for display. */
6161
constexpr std::uint8_t PIN_SPI_MOSI{23};
6262
/** @brief SPI MISO pin for display (not used). */
63-
constexpr std::uint8_t PIN_SPI_MISO{-1};
63+
constexpr std::int8_t PIN_SPI_MISO{-1};
6464
/** @brief SPI CLK pin for display. */
6565
constexpr std::uint8_t PIN_SPI_CLK{18};
6666

@@ -73,8 +73,10 @@ constexpr std::uint8_t PIN_LED_BUILTIN{2};
7373
/** @brief Device name for mDNS and MQTT client ID. */
7474
constexpr const char* DEVICE_NAME{"pool-monitor"};
7575

76-
/** @brief GitHub repository for OTA updates. */
76+
/** @brief GitHub repository for OTA updates (provided via -D build flag). */
77+
#ifndef GITHUB_REPO
7778
constexpr const char* GITHUB_REPO{"smart-swimmingpool/monitor"};
79+
#endif
7880

7981
// Serial speed - provided as build flag from platformio.ini
8082
#ifndef SERIAL_SPEED

src/PoolMonitor/DisplayManager.cpp

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,20 @@
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-
1912
namespace 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

2920
bool DisplayManager::begin() {
3021
Serial.println("🖥️\tInitializing 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("🖥️\tUpdating 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

src/PoolMonitor/DisplayManager.hpp

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,40 @@
1111
#pragma once
1212

1313
#include <Arduino.h>
14+
#include <GxIO/GxIO_SPI/GxIO_SPI.h>
1415
#include <GxEPD.h>
16+
#include <SPI.h>
1517
#include <U8g2_for_Adafruit_GFX.h>
1618
#include "Config.hpp"
1719

20+
// Include the appropriate display driver based on board definition
21+
#if defined(LILYGO_T5_V231)
22+
#include <GxDEPG0213BN/GxDEPG0213BN.h>
23+
#else
24+
#include <GxGDE0213B1/GxGDE0213B1.h>
25+
#endif
26+
27+
// FreeFonts from Adafruit_GFX
28+
#include <Fonts/FreeMono9pt7b.h>
29+
#include <Fonts/FreeMonoBold9pt7b.h>
30+
#include <Fonts/FreeSans9pt7b.h>
31+
#include <Fonts/FreeSansBold9pt7b.h>
32+
#include <Fonts/FreeSans12pt7b.h>
33+
#include <Fonts/FreeSansBold12pt7b.h>
34+
#include <Fonts/FreeSans24pt7b.h>
35+
#include <Fonts/FreeSansBold24pt7b.h>
36+
37+
// U8g2 font declarations for icons
38+
extern const uint8_t u8g2_font_streamline_all_t[] U8G2_FONT_SECTION("u8g2_font_streamline_all_t");
39+
extern const uint8_t u8g2_font_streamline_ecology_t[] U8G2_FONT_SECTION("u8g2_font_streamline_ecology_t");
40+
41+
// Text alignment constants (replaces the anonymous enum from u8g2_display.h)
42+
enum {
43+
GxEPD_ALIGN_RIGHT,
44+
GxEPD_ALIGN_LEFT,
45+
GxEPD_ALIGN_CENTER,
46+
};
47+
1848
namespace PoolMonitor {
1949

2050
/**
@@ -24,7 +54,7 @@ namespace PoolMonitor {
2454
* and dynamic content updates (temperatures, pump status, etc.).
2555
*/
2656
class DisplayManager {
27-
public:
57+
public:
2858
DisplayManager() = default;
2959

3060
/**
@@ -47,7 +77,7 @@ class DisplayManager {
4777
* @param mode Operation mode string.
4878
* @param lastUpdate Time string for last update.
4979
*/
50-
static void updateDisplay(float poolTemp, float solarTemp, bool poolPumpOn,
80+
static void updateDisplay(float poolTemp, float solarTemp, bool poolPumpOn,
5181
bool solarPumpOn, const char* mode, const char* lastUpdate);
5282

5383
/** @brief Power down the display. */
@@ -63,30 +93,25 @@ class DisplayManager {
6393
static uint16_t getHeight();
6494

6595
/** @brief Get reference to the display instance. */
66-
static auto getDisplay() -> GxEPD::GxEPD_Class&;
96+
static auto getDisplay() -> GxEPD_Class&;
6797

6898
/** @brief Get reference to the u8g2 instance. */
6999
static auto getU8g2() -> U8G2_FOR_ADAFRUIT_GFX&;
70100

71-
private:
72-
// Display type selection based on board definition
73-
#if defined(LILYGO_T5_V231)
74-
static GxDEPG0213BN display_;
75-
#else
76-
static GxGDE0213B1 display_;
77-
#endif
78-
79-
static U8G2_FOR_ADAFRUIT_GFX u8g2_for_adafruit_gfx_;
80-
81101
/**
82102
* @brief Draw text on display with alignment.
83103
* @param text Text to draw.
84104
* @param y Y position (baseline).
85105
* @param align Alignment (GxEPD_ALIGN_LEFT, RIGHT, CENTER).
86106
* @param xOffset X offset from alignment position.
87107
*/
88-
static void displayText(const char* text, int16_t y, uint8_t align = GxEPD_ALIGN_LEFT,
108+
static void displayText(const char* text, int16_t y, uint8_t align = GxEPD_ALIGN_LEFT,
89109
int16_t xOffset = 0);
110+
111+
private:
112+
static GxIO_Class io_;
113+
static GxEPD_Class display_;
114+
static U8G2_FOR_ADAFRUIT_GFX u8g2_for_adafruit_gfx_;
90115
};
91116

92117
} // namespace PoolMonitor

0 commit comments

Comments
 (0)