Skip to content

Commit 7073839

Browse files
committed
Fix: Text resize on Tft, Bug: Text resize improperly due to no deinit
1 parent 9fd844e commit 7073839

File tree

4 files changed

+42
-34
lines changed

4 files changed

+42
-34
lines changed

src/Wippersnapper_demo.ino.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# 1 "/var/folders/ff/dmzflvf52tq9kzvt6g8jglxw0000gn/T/tmp4dvs_pq5"
2+
#include <Arduino.h>
3+
# 1 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo.ino"
4+
# 16 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo.ino"
5+
#include "Wippersnapper_Networking.h"
6+
Wippersnapper_WiFi wipper;
7+
8+
9+
#define WS_DEBUG
10+
void setup();
11+
void loop();
12+
#line 22 "/Users/brentrubell/Documents/Arduino/libraries/Adafruit_Wippersnapper_Arduino/src/Wippersnapper_demo.ino"
13+
void setup() {
14+
15+
wipper.provision();
16+
17+
Serial.begin(115200);
18+
19+
20+
wipper.connect();
21+
22+
}
23+
24+
void loop() {
25+
wipper.run();
26+
}

src/components/display/controller.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ bool DisplayController::Handle_Display_AddOrReplace(
4545
WS_DEBUG_PRINT("[display] Adding or replacing display: ");
4646
WS_DEBUG_PRINTLN(msgAdd->name);
4747

48+
// Does this display hw instance already exist?
49+
for (auto it = _hw_instances.begin(); it != _hw_instances.end(); ++it) {
50+
if (strcmp((*it)->getName(), msgAdd->name) == 0) {
51+
WS_DEBUG_PRINTLN("[display] Display instance already exists, removing...");
52+
delete *it;
53+
_hw_instances.erase(it);
54+
break;
55+
}
56+
}
57+
4858
// Configure display type
4959
display->setType(msgAdd->type);
5060

src/components/display/drivers/dispDrvSt7789.h

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "dispDrvBase.h"
1919
#include <Adafruit_ST7789.h>
2020

21-
#define ST7789_TEXT_SZ_DEFAULT 2 ///< Default text size for ST7789 displays
2221
#define ST7789_STATUSBAR_HEIGHT 20 ///< Default status bar height
2322
#define ST7789_STATUSBAR_ICON_SZ 16 ///< Default status bar icon size
2423
#define ST7789_STATUSBAR_ICON_SPACING \
@@ -81,7 +80,6 @@ class dispDrvSt7789 : public dispDrvBase {
8180

8281
_display->init(_width, _height);
8382
_display->setRotation(_rotation);
84-
setTextSize(ST7789_TEXT_SZ_DEFAULT);
8583
_display->fillScreen(ST77XX_BLACK);
8684
_display->setTextColor(ST77XX_WHITE);
8785

@@ -100,20 +98,6 @@ class dispDrvSt7789 : public dispDrvBase {
10098
return true;
10199
}
102100

103-
/*!
104-
@brief Sets the text size for the display.
105-
@param s
106-
The text size to set.
107-
@note This method overrides the base class method to provide specific
108-
functionality for the ST7789 driver.
109-
*/
110-
void setTextSize(uint8_t s) override {
111-
if (!_display)
112-
return;
113-
_text_sz = s;
114-
_display->setTextSize(s);
115-
}
116-
117101
/*!
118102
@brief Displays the splash screen on the display.
119103
*/
@@ -176,6 +160,12 @@ class dispDrvSt7789 : public dispDrvBase {
176160
_display->drawBitmap(_statusbar_icon_battery_x, _statusbar_icons_y,
177161
epd_bmp_bat_full, ST7789_STATUSBAR_ICON_SZ,
178162
ST7789_STATUSBAR_ICON_SZ, ST77XX_BLACK);
163+
164+
// Reset text color and size for main text area
165+
_display->setTextColor(ST77XX_WHITE);
166+
WS_DEBUG_PRINTLN("SB Text Size:");
167+
WS_DEBUG_PRINTLN(_text_sz);
168+
_display->setTextSize(_text_sz);
179169
}
180170

181171
/*!
@@ -254,8 +244,6 @@ class dispDrvSt7789 : public dispDrvBase {
254244
if (_display == nullptr)
255245
return;
256246

257-
_display->setTextColor(ST77XX_WHITE);
258-
259247
// Clear only the area below the status bar
260248
_display->fillRect(0, ST7789_STATUSBAR_HEIGHT, _width,
261249
_height - ST7789_STATUSBAR_HEIGHT, ST77XX_BLACK);

src/components/display/hardware.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -216,19 +216,6 @@ bool DisplayHardware::beginEPD(
216216
return false;
217217
}
218218

219-
/* // For "magtag" component name, attempt to autodetect the driver type
220-
if (strncmp(_name, "eink-29-grayscale-ssd1680", 6) == 0) {
221-
if (detect_ssd1680(cs, dc, rst)) {
222-
// Detected SSD1680, use EAAMFGN driver
223-
strncpy(_name, "thinkink-gs4-eaamfgn", sizeof(_name) - 1);
224-
_name[sizeof(_name) - 1] = '\0';
225-
} else {
226-
// Did not detect SSD1680, use IL0373 driver
227-
strncpy(_name, "thinkink-gs4-t5", sizeof(_name) - 1);
228-
_name[sizeof(_name) - 1] = '\0';
229-
}
230-
} */
231-
232219
// Create display driver object using the factory function
233220
_drvDisp = CreateDrvDispEpd(_name, dc, rst, cs, srcs, busy);
234221
if (!_drvDisp) {
@@ -332,9 +319,6 @@ bool DisplayHardware::beginTft(
332319
miso = parsePin(spi_config->pin_miso);
333320
}
334321

335-
// TODO: Implement Text_size based on future Protobuf that includes it
336-
uint8_t text_sz; // Default text size
337-
338322
// Create display driver object using the factory function
339323
_drvDisp = CreateDrvDispTft(_name, cs, dc, mosi, sck, rst, miso);
340324
if (!_drvDisp) {

0 commit comments

Comments
 (0)