Skip to content

Commit 0e67abb

Browse files
committed
Continue remove old TFT code, add status bar
1 parent 9ca0164 commit 0e67abb

File tree

7 files changed

+621
-738
lines changed

7 files changed

+621
-738
lines changed

src/components/display/assets/splash.h

Lines changed: 602 additions & 601 deletions
Large diffs are not rendered by default.

src/components/display/controller.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ bool DisplayController::Handle_Display_AddOrReplace(
6969
return false;
7070
}
7171

72-
//WS.feedWDT();
73-
//display->showSplash();
72+
WS.feedWDT();
73+
display->showSplash();
7474
WS.feedWDT();
7575
display->drawStatusBar(WS._config.aio_user);
7676
WS.feedWDT();

src/components/display/drivers/dispDrvSt7789.h

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ class dispDrvSt7789 : public dispDrvBase {
5252
delete _display;
5353
_display = nullptr;
5454
}
55-
//digitalWrite(TFT_BACKLIGHT, LOW);
55+
#if defined(ARDUINO_FUNHOUSE_ESP32S2)
56+
digitalWrite(TFT_BACKLIGHT, LOW);
57+
#endif
5658
}
5759

5860
/*!
@@ -68,13 +70,14 @@ class dispDrvSt7789 : public dispDrvBase {
6870
_display->init(_width, _height);
6971
_display->setRotation(_rotation);
7072
setTextSize(ST7789_TEXT_SZ_DEFAULT);
71-
_display->fillScreen(ST77XX_WHITE);
73+
_display->fillScreen(ST77XX_BLACK);
7274
_display->setTextColor(ST77XX_WHITE);
7375

74-
/* #ifdef TFT_BACKLIGHT
76+
#if defined(ARDUINO_FUNHOUSE_ESP32S2)
77+
// Turn backlight on
7578
pinMode(TFT_BACKLIGHT, OUTPUT);
76-
digitalWrite(TFT_BACKLIGHT, HIGH); // Backlight on
77-
#endif */
79+
digitalWrite(TFT_BACKLIGHT, HIGH);
80+
#endif
7881

7982
return true;
8083
}
@@ -102,15 +105,15 @@ class dispDrvSt7789 : public dispDrvBase {
102105

103106
// Display the appropriate splash screen based on resolution
104107
if (_width == 240 && _height == 240) {
105-
_display->drawBitmap(0, 0, tft_bmp_logo_240240, 240, 240, ST77XX_BLACK);
108+
_display->drawBitmap(0, 0, tft_bmp_logo_240240, 240, 240, ST77XX_WHITE);
106109
} else if (_width == 240 && _height == 135) {
107110
_display->drawBitmap(0, 0, tft_bmp_logo_240135, 240, 135, EPD_BLACK);
108111
} else {
109112
// Unsupported resolution
110113
return;
111114
}
112115

113-
delay(1500); // Pause for 1.5 seconds
116+
delay(1000);
114117
}
115118

116119
/*!
@@ -141,10 +144,8 @@ class dispDrvSt7789 : public dispDrvBase {
141144
_display->fillScreen(ST77XX_BLACK);
142145

143146
// Draw status bar
144-
// TODO: We are not drawing a border here because it isnt
145-
// required on a color display, I think.
146147
_display->fillRect(0, 0, _display->width(), _status_bar_height,
147-
ST77XX_BLACK);
148+
ST77XX_WHITE);
148149

149150
// Draw username on left side of the status bar
150151
_display->setTextSize(1);
@@ -202,8 +203,11 @@ class dispDrvSt7789 : public dispDrvBase {
202203
if (_display == nullptr)
203204
return;
204205

205-
// Start with a fresh display buffer
206-
_display->fillScreen(ST77XX_BLACK);
206+
_display->setTextColor(ST77XX_WHITE);
207+
208+
// Clear only the area below the status bar
209+
_display->fillRect(0, _status_bar_height, _width,
210+
_height - _status_bar_height, ST77XX_BLACK);
207211
int16_t y_idx = _status_bar_height;
208212
_display->setCursor(0, y_idx);
209213

src/provisioning/ConfigJson.cpp

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -47,40 +47,4 @@ void convertFromJson(JsonVariantConst src, secretsConfig &dst) {
4747
dst.status_pixel_brightness = src["status_pixel_brightness"] | 0.2;
4848
// Parse MQTT port from secrets, if exists
4949
dst.io_port = src["io_port"] | 8883;
50-
}
51-
52-
// Converts a displayConfigSPI structure to a JSON variant
53-
void convertToJson(const displayConfigSPI &src, JsonVariant dst) {
54-
dst["pin_cs"] = src.pinCs;
55-
dst["pin_dc"] = src.pinDc;
56-
dst["pin_mosi"] = src.pinMosi;
57-
dst["pin_sck"] = src.pinSck;
58-
dst["pin_rst"] = src.pinRst;
59-
}
60-
61-
// Extracts a displayConfigSPI structure from a JSON variant
62-
void convertFromJson(JsonVariantConst src, displayConfigSPI &dst) {
63-
dst.pinCs = src["pin_cs"] | 40;
64-
dst.pinDc = src["pin_dc"] | 39;
65-
dst.pinMosi = src["pin_mosi"] | 0;
66-
dst.pinSck = src["pin_sck"] | 0;
67-
dst.pinRst = src["pin_rst"] | 41;
68-
}
69-
70-
// Converts a displayConfig structure to a JSON variant
71-
void convertToJson(const displayConfig &src, JsonVariant dst) {
72-
dst["driver"] = src.driver;
73-
dst["width"] = src.width;
74-
dst["height"] = src.height;
75-
dst["rotation"] = src.rotation;
76-
dst["spi_config"] = src.spiConfig;
77-
}
78-
79-
// Extracts a displayConfig structure from a JSON variant
80-
void convertFromJson(JsonVariantConst src, displayConfig &dst) {
81-
strlcpy(dst.driver, src["driver"] | "ST7789", sizeof(dst.driver));
82-
dst.width = src["width"] | 128;
83-
dst.height = src["height"] | 64;
84-
dst.rotation = src["rotation"] | 0;
85-
dst.spiConfig = src["spi_config"];
86-
}
50+
}

src/provisioning/ConfigJson.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,4 @@ void convertFromJson(JsonVariantConst src, networkConfig &dst);
2525
// Converters for secrets configuration
2626
void convertToJson(const secretsConfig &src, JsonVariant dst);
2727
void convertFromJson(JsonVariantConst src, secretsConfig &dst);
28-
// Converters for display configuration
29-
void convertToJson(const displayConfig &src, JsonVariant dst);
30-
void convertFromJson(JsonVariantConst src, displayConfig &dst);
3128
#endif // CONFIGJSON_H

src/provisioning/tinyusb/Wippersnapper_FS.cpp

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -496,83 +496,6 @@ void Wippersnapper_FS::fsHalt(String msg) {
496496
}
497497
}
498498

499-
#ifdef ARDUINO_FUNHOUSE_ESP32S2
500-
void Wippersnapper_FS::createDisplayConfig() {
501-
// Open file for writing
502-
File32 displayFile = wipperFatFs.open("/display_config.json", FILE_WRITE);
503-
504-
// Create a default displayConfig structure
505-
displayConfig displayConfig;
506-
strcpy(displayConfig.driver, "ST7789");
507-
displayConfig.width = 240;
508-
displayConfig.height = 240;
509-
displayConfig.rotation = 0;
510-
displayConfig.spiConfig.pinCs = 40;
511-
displayConfig.spiConfig.pinDc = 39;
512-
displayConfig.spiConfig.pinMosi = 0;
513-
displayConfig.spiConfig.pinSck = 0;
514-
displayConfig.spiConfig.pinRst = 41;
515-
516-
// Create and fill JSON document from displayConfig
517-
JsonDocument doc;
518-
if (!doc.set(displayConfig)) {
519-
fsHalt("ERROR: Unable to set displayConfig, no space in arduinoJSON "
520-
"document!");
521-
}
522-
// Write the file out to the filesystem
523-
serializeJsonPretty(doc, displayFile);
524-
displayFile.flush();
525-
displayFile.close();
526-
delay(2500); // give FS some time to write the file
527-
}
528-
529-
bool Wippersnapper_FS::parseDisplayConfig(displayConfig &dispCfg, bool force_recreate) {
530-
if (force_recreate) {
531-
if (wipperFatFs.exists("/display_config.json")) {
532-
wipperFatFs.remove("/display_config.json");
533-
}
534-
#ifdef ARDUINO_FUNHOUSE_ESP32S2
535-
createDisplayConfig();
536-
#endif
537-
}
538-
539-
// Check if display_config.json file exists, if not, generate it
540-
if (!wipperFatFs.exists("/display_config.json")) {
541-
WS_DEBUG_PRINTLN("Could not find display_config.json, generating...");
542-
#ifdef ARDUINO_FUNHOUSE_ESP32S2
543-
createDisplayConfig(); // generate a default display_config.json for
544-
// FunHouse
545-
#endif
546-
}
547-
548-
// Attempt to open file for JSON parsing
549-
File32 file = wipperFatFs.open("/display_config.json", FILE_READ);
550-
if (!file) {
551-
if (!force_recreate) {
552-
return false;
553-
}
554-
fsHalt("FATAL ERROR: Unable to open display_config.json for parsing");
555-
}
556-
557-
// Attempt to deserialize the file's json document
558-
JsonDocument doc;
559-
DeserializationError error = deserializeJson(doc, file);
560-
if (error) {
561-
if (!force_recreate) {
562-
return false;
563-
}
564-
fsHalt(String("FATAL ERROR: Unable to parse display_config.json - "
565-
"deserializeJson() failed with code") +
566-
error.c_str());
567-
}
568-
// Close the file, we're done with it
569-
file.close();
570-
// Extract a displayConfig struct from the JSON document
571-
dispCfg = doc.as<displayConfig>();
572-
return true;
573-
}
574-
#endif // ARDUINO_FUNHOUSE_ESP32S2
575-
576499
/**************************************************************************/
577500
/*!
578501
@brief Callback invoked when received READ10 command. Copies disk's

src/provisioning/tinyusb/Wippersnapper_FS.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
// forward decl.
2828
class Wippersnapper;
29-
struct displayConfig;
3029

3130
// global TinyUSB callbacks
3231
int32_t qspi_msc_write_cb(uint32_t lba, uint8_t *buffer, uint32_t bufsize);
@@ -57,11 +56,6 @@ class Wippersnapper_FS {
5756
void fsHalt(String msg);
5857

5958
void parseSecrets();
60-
61-
#ifdef ARDUINO_FUNHOUSE_ESP32S2
62-
bool parseDisplayConfig(displayConfig &displayFile, bool force_recreate = false);
63-
void createDisplayConfig();
64-
#endif
6559
private:
6660
bool _freshFS = false; /*!< True if filesystem was initialized by
6761
WipperSnapper, False otherwise. */

0 commit comments

Comments
 (0)