Skip to content

Commit 8ba32f8

Browse files
committed
Working on MagTag, remove ProtoMq harness code
1 parent bab1f2b commit 8ba32f8

File tree

26 files changed

+250
-141
lines changed

26 files changed

+250
-141
lines changed

src/Wippersnapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2826,7 +2826,7 @@ void Wippersnapper::connect() {
28262826
WS._analogIO = new Wippersnapper_AnalogIO(5, 3.3);
28272827

28282828
// Configure hardware
2829-
WS.pinCfgCompleted = true;
2829+
// WS.pinCfgCompleted = true;
28302830
while (!WS.pinCfgCompleted) {
28312831
WS_DEBUG_PRINTLN(
28322832
"Polling for message containing hardware configuration...");

src/components/display/assets/splash.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <Arduino.h>
44

55
// 'adafruit_wippersnapper_logo', 240x135px
6-
static const unsigned char tft_bitmap_ws_logo_240135[] = {
6+
static const unsigned char tft_bmp_logo_240135[] = {
77
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
88
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
99
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@@ -344,7 +344,7 @@ static const unsigned char tft_bitmap_ws_logo_240135[] = {
344344
0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
345345

346346
// 'adafruit_wippersnapper_logo', 240x240px
347-
static const unsigned char tft_bitmap_ws_logo_240240[] = {
347+
static const unsigned char tft_bmp_logo_240240[] = {
348348
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
349349
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
350350
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,

src/components/display/drivers/dispDrvSt7789.h

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,104 @@ class dispDrvSt7789 : public dispDrvBase {
9898
_display->setTextSize(s);
9999
}
100100

101+
/*!
102+
@brief Displays the splash screen on the display.
103+
*/
104+
void showSplash() override {
105+
if (!_display)
106+
return;
107+
108+
// Display the appropriate splash screen based on resolution
109+
if (_width == 240 && _height == 240) {
110+
_display->drawBitmap(0, 0, tft_bmp_logo_240240, 240, 240, ST77XX_BLACK);
111+
} else if (_width == 240 && _height == 135) {
112+
_display->drawBitmap(0, 0, tft_bmp_logo_240135, 240, 135, EPD_BLACK);
113+
} else {
114+
// Unsupported resolution
115+
return;
116+
}
117+
118+
delay(1000);
119+
}
120+
121+
/*!
122+
@brief Draws a status bar at the top of the display.
123+
*/
124+
virtual void drawStatusBar(const char *io_username) override {
125+
if (!_display)
126+
return;
127+
128+
// Configure status bar parameters based on resolution
129+
if (_width == 240 && _height == 240) {
130+
_status_bar_height = 20;
131+
_status_bar_icon_sz = 16;
132+
_status_bar_icon_spacing = 4;
133+
_status_bar_icon_margin = 5;
134+
} else if (_width == 240 && _height == 135) {
135+
// TODO: The required icons are not added/implemented for 12px icons
136+
_status_bar_height = 16;
137+
_status_bar_icon_sz = 12;
138+
_status_bar_icon_spacing = 3;
139+
_status_bar_icon_margin = 4;
140+
} else {
141+
// Unsupported resolution
142+
return;
143+
}
144+
145+
// Clear the entire display buffer to remove splash screen
146+
_display->fillScreen(ST77XX_BLACK);
147+
148+
// Draw status bar
149+
// TODO: We are not drawing a border here because it isnt
150+
// required on a color display, I think.
151+
_display->fillRect(0, 0, _display->width(), _status_bar_height,
152+
ST77XX_BLACK);
153+
154+
// Draw username on left side of the status bar
155+
_display->setTextSize(1);
156+
_display->setTextColor(EPD_BLACK);
157+
_display->setCursor(5, 6);
158+
_display->print(io_username);
159+
160+
// Calculate icon positions and center vertically
161+
int iconY = (_status_bar_height - _status_bar_icon_sz) / 2;
162+
int batteryX =
163+
_display->width() - _status_bar_icon_sz - _status_bar_icon_margin;
164+
int wifiX = batteryX - _status_bar_icon_sz - _status_bar_icon_spacing;
165+
int cloudX = wifiX - _status_bar_icon_sz - _status_bar_icon_spacing;
166+
if (_height == 240) {
167+
// Draw 16px icons on right side of the status bar
168+
_display->drawBitmap(cloudX, iconY, epd_bmp_cloud_online,
169+
_status_bar_icon_sz, _status_bar_icon_sz, EPD_BLACK);
170+
_display->drawBitmap(wifiX, iconY, epd_bmp_wifi_full, _status_bar_icon_sz,
171+
_status_bar_icon_sz, EPD_BLACK);
172+
_display->drawBitmap(batteryX, iconY, epd_bmp_bat_full,
173+
_status_bar_icon_sz, _status_bar_icon_sz, EPD_BLACK);
174+
} else if (_height == 135) {
175+
// TODO: Draw 12px icons on right side of the status bar
176+
} else {
177+
// Unsupported resolution
178+
return;
179+
}
180+
}
181+
182+
/*!
183+
@brief Updates the status bar with current information (battery level,
184+
connectivity status, etc).
185+
@param rssi
186+
The current WiFi RSSI (signal strength) in dB.
187+
@param bat
188+
The current battery level as a percentage (0-100).
189+
@param mqtt_status
190+
The current MQTT connection status.
191+
*/
192+
void updateStatusBar(int8_t rssi, uint8_t bat, bool mqtt_status) override {
193+
if (!_display)
194+
return;
195+
196+
// TODO - needs to be implemented!
197+
}
198+
101199
/*!
102200
@brief Writes a message to the display.
103201
@param message
@@ -111,7 +209,7 @@ class dispDrvSt7789 : public dispDrvBase {
111209

112210
// Start with a fresh display buffer
113211
_display->fillScreen(ST77XX_BLACK);
114-
int16_t y_idx = 0;
212+
int16_t y_idx = _status_bar_height;
115213
_display->setCursor(0, y_idx);
116214

117215
// Calculate the line height based on the text size (NOTE: base height is
@@ -152,6 +250,12 @@ class dispDrvSt7789 : public dispDrvBase {
152250

153251
private:
154252
Adafruit_ST7789 *_display;
253+
uint8_t _status_bar_height; ///< Height of the status bar, in pixels
254+
uint8_t _status_bar_icon_sz; ///< Size of status bar icons, in pixels
255+
uint8_t
256+
_status_bar_icon_spacing; ///< Spacing between status bar icons, in pixels
257+
uint8_t
258+
_status_bar_icon_margin; ///< Right margin for status bar icons, in pixels
155259
};
156260

157261
#endif // WS_DISP_DRV_ST7789

src/components/display/drivers/dispDrvThinkInkGrayscale4Eaamfgn.h

Lines changed: 48 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818

1919
#include "dispDrvBase.h"
2020

21-
#define STATUS_BAR_HEIGHT 20 ///< Height of the status bar in pixels, assumes 16px icons
22-
#define STATUS_BAR_BORDER 1 ///< Border around the status bar in pixels
21+
#define STATUS_BAR_HEIGHT \
22+
20 ///< Height of the status bar in pixels, assumes 16px icons
23+
#define STATUS_BAR_BORDER 1 ///< Border around the status bar in pixels
2324
#define STATUS_BAR_ICON_SZ 16 ///< Size of status bar icons in pixels
2425

2526
/*!
@@ -115,84 +116,69 @@ class drvDispThinkInkGrayscale4Eaamfgn : public dispDrvBase {
115116
// Calculate icon positions and center vertically
116117
int iconSpacing = 4;
117118
int rightMargin = 5;
118-
int iconY = STATUS_BAR_BORDER + ((STATUS_BAR_HEIGHT - 2 * STATUS_BAR_BORDER - STATUS_BAR_ICON_SZ) / 2);
119+
int iconY =
120+
STATUS_BAR_BORDER +
121+
((STATUS_BAR_HEIGHT - 2 * STATUS_BAR_BORDER - STATUS_BAR_ICON_SZ) / 2);
119122
int batteryX = _display->width() - STATUS_BAR_ICON_SZ - rightMargin;
120123
int wifiX = batteryX - STATUS_BAR_ICON_SZ - iconSpacing;
121124
int cloudX = wifiX - STATUS_BAR_ICON_SZ - iconSpacing;
122125
// Draw icons on right side of the status bar
123-
_display->drawBitmap(cloudX, iconY, epd_bmp_cloud_online, STATUS_BAR_ICON_SZ, STATUS_BAR_ICON_SZ, EPD_BLACK);
124-
_display->drawBitmap(wifiX, iconY, epd_bmp_wifi_full, STATUS_BAR_ICON_SZ, STATUS_BAR_ICON_SZ, EPD_BLACK);
125-
_display->drawBitmap(batteryX, iconY, epd_bmp_bat_full, STATUS_BAR_ICON_SZ, STATUS_BAR_ICON_SZ, EPD_BLACK);
126+
_display->drawBitmap(cloudX, iconY, epd_bmp_cloud_online,
127+
STATUS_BAR_ICON_SZ, STATUS_BAR_ICON_SZ, EPD_BLACK);
128+
_display->drawBitmap(wifiX, iconY, epd_bmp_wifi_full, STATUS_BAR_ICON_SZ,
129+
STATUS_BAR_ICON_SZ, EPD_BLACK);
130+
_display->drawBitmap(batteryX, iconY, epd_bmp_bat_full, STATUS_BAR_ICON_SZ,
131+
STATUS_BAR_ICON_SZ, EPD_BLACK);
126132

127133
_display->display();
128134
}
129135

130-
/*!
131-
@brief Updates the status bar with current information (battery level,
132-
connectivity status, etc).
133-
@param rssi
134-
The current WiFi RSSI (signal strength) in dB.
135-
@param bat
136-
The current battery level as a percentage (0-100).
137-
@param mqtt_status
138-
The current MQTT connection status.
139-
*/
136+
/*!
137+
@brief Updates the status bar with current information (battery level,
138+
connectivity status, etc).
139+
@param rssi
140+
The current WiFi RSSI (signal strength) in dB.
141+
@param bat
142+
The current battery level as a percentage (0-100).
143+
@param mqtt_status
144+
The current MQTT connection status.
145+
*/
140146
void updateStatusBar(int8_t rssi, uint8_t bat, bool mqtt_status) override {
141147
if (!_display)
142148
return;
143149

144-
bool do_update = false;
145-
// Update cloud icon only if it changed
146-
if (mqtt_status != _statusbar_mqtt_connected) {
147-
int iconSpacing = 4;
148-
int rightMargin = 5;
149-
int iconY = STATUS_BAR_BORDER + ((STATUS_BAR_HEIGHT - 2 * STATUS_BAR_BORDER - STATUS_BAR_ICON_SZ) / 2);
150-
int batteryX = _display->width() - STATUS_BAR_ICON_SZ - rightMargin;
151-
int wifiX = batteryX - STATUS_BAR_ICON_SZ - iconSpacing;
152-
int cloudX = wifiX - STATUS_BAR_ICON_SZ - iconSpacing;
150+
bool do_update = false;
153151

154-
// Clear and draw the new cloud icon, based on MQTT connection status
155-
_display->fillRect(cloudX, iconY, STATUS_BAR_ICON_SZ, STATUS_BAR_ICON_SZ, EPD_WHITE);
156-
if (mqtt_status == 21) {
157-
_display->drawBitmap(cloudX, iconY, epd_bmp_cloud_online, STATUS_BAR_ICON_SZ, STATUS_BAR_ICON_SZ,
158-
EPD_BLACK);
159-
} else {
160-
_display->drawBitmap(cloudX, iconY, epd_bmp_cloud_offline, STATUS_BAR_ICON_SZ,
161-
STATUS_BAR_ICON_SZ, EPD_BLACK);
162-
}
163-
_statusbar_mqtt_connected = mqtt_status;
164-
do_update = true;
165-
}
152+
// For EPD - redraws take 1-2 seconds, so only update the cloud state
166153

167-
/* // Update WiFi icon only if it changed significantly (+/- 3 dB)
168-
if (abs(rssi - _statusbar_rssi) >= 3 || rssi == 0 || _statusbar_rssi == 0) {
154+
// Update cloud icon only if it changed state
155+
if (mqtt_status != _statusbar_mqtt_connected) {
169156
int iconSpacing = 4;
170157
int rightMargin = 5;
171-
int iconY = STATUS_BAR_BORDER + ((STATUS_BAR_HEIGHT - 2 * STATUS_BAR_BORDER - STATUS_BAR_ICON_SZ) / 2);
158+
int iconY =
159+
STATUS_BAR_BORDER +
160+
((STATUS_BAR_HEIGHT - 2 * STATUS_BAR_BORDER - STATUS_BAR_ICON_SZ) /
161+
2);
172162
int batteryX = _display->width() - STATUS_BAR_ICON_SZ - rightMargin;
173163
int wifiX = batteryX - STATUS_BAR_ICON_SZ - iconSpacing;
174-
175-
// Clear and draw the new WiFi icon, based on RSSI
176-
_display->fillRect(wifiX, iconY, STATUS_BAR_ICON_SZ, STATUS_BAR_ICON_SZ, EPD_WHITE);
177-
if (rssi == 0) {
178-
_display->drawBitmap(wifiX, iconY, epd_bmp_wifi_no_signal, STATUS_BAR_ICON_SZ, STATUS_BAR_ICON_SZ, EPD_BLACK);
179-
} else if (rssi > -50) {
180-
_display->drawBitmap(wifiX, iconY, epd_bmp_wifi_full, STATUS_BAR_ICON_SZ, STATUS_BAR_ICON_SZ, EPD_BLACK);
181-
} else if (rssi > -60) {
182-
_display->drawBitmap(wifiX, iconY, epd_bmp_wifi_fair, STATUS_BAR_ICON_SZ, STATUS_BAR_ICON_SZ, EPD_BLACK);
183-
} else if (rssi > -70) {
184-
_display->drawBitmap(wifiX, iconY, epd_bmp_wifi_weak, STATUS_BAR_ICON_SZ, STATUS_BAR_ICON_SZ, EPD_BLACK);
164+
int cloudX = wifiX - STATUS_BAR_ICON_SZ - iconSpacing;
165+
166+
// Clear and draw the new cloud icon, based on MQTT connection status
167+
_display->fillRect(cloudX, iconY, STATUS_BAR_ICON_SZ, STATUS_BAR_ICON_SZ,
168+
EPD_WHITE);
169+
if (mqtt_status == 21) {
170+
_display->drawBitmap(cloudX, iconY, epd_bmp_cloud_online,
171+
STATUS_BAR_ICON_SZ, STATUS_BAR_ICON_SZ, EPD_BLACK);
185172
} else {
186-
_display->drawBitmap(wifiX, iconY, epd_bmp_wifi_weak, STATUS_BAR_ICON_SZ, STATUS_BAR_ICON_SZ, EPD_BLACK);
173+
_display->drawBitmap(cloudX, iconY, epd_bmp_cloud_offline,
174+
STATUS_BAR_ICON_SZ, STATUS_BAR_ICON_SZ, EPD_BLACK);
187175
}
188-
_statusbar_rssi = rssi;
176+
_statusbar_mqtt_connected = mqtt_status;
189177
do_update = true;
190-
} */
191-
192-
// Temporarily removed while I get clarification on how often to refresh the epd
193-
/* if (do_update)
194-
_display->display(); */
178+
}
195179

180+
if (do_update)
181+
_display->display();
196182
}
197183

198184
/*!
@@ -206,9 +192,10 @@ class drvDispThinkInkGrayscale4Eaamfgn : public dispDrvBase {
206192
if (_display == nullptr)
207193
return;
208194

209-
// Start with a fresh display buffer
210-
_display->clearBuffer();
211-
int16_t y_idx = 0;
195+
// Clear only the area below the status bar
196+
_display->fillRect(0, STATUS_BAR_HEIGHT, _display->width(),
197+
_display->height() - STATUS_BAR_HEIGHT, EPD_WHITE);
198+
int16_t y_idx = STATUS_BAR_HEIGHT;
212199
_display->setCursor(0, y_idx);
213200

214201
// Calculate the line height based on the text size (NOTE: base height is

src/components/display/hardware.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ using FnCreateDispDrvEpd =
2323
// Factory for creating a new display drivers
2424
// NOTE: When you add a new display driver, make sure to add it to the factory!
2525
static const std::map<std::string, FnCreateDispDrvEpd> FactoryDrvDispEpd = {
26-
{"thinkink-gs4-eaamfgn",
26+
{"eink-29-grayscale-ssd1680",
2727
[](int16_t dc, int16_t rst, int16_t cs, int16_t sram_cs,
2828
int16_t busy) -> dispDrvBase * {
2929
return new drvDispThinkInkGrayscale4Eaamfgn(dc, rst, cs, sram_cs, busy);
@@ -216,8 +216,8 @@ bool DisplayHardware::beginEPD(
216216
return false;
217217
}
218218

219-
// For "magtag" component name, attempt to autodetect the driver type
220-
if (strncmp(_name, "magtag", 6) == 0) {
219+
/* // For "magtag" component name, attempt to autodetect the driver type
220+
if (strncmp(_name, "eink-29-grayscale-ssd1680", 6) == 0) {
221221
if (detect_ssd1680(cs, dc, rst)) {
222222
// Detected SSD1680, use EAAMFGN driver
223223
strncpy(_name, "thinkink-gs4-eaamfgn", sizeof(_name) - 1);
@@ -227,7 +227,7 @@ bool DisplayHardware::beginEPD(
227227
strncpy(_name, "thinkink-gs4-t5", sizeof(_name) - 1);
228228
_name[sizeof(_name) - 1] = '\0';
229229
}
230-
}
230+
} */
231231

232232
// Create display driver object using the factory function
233233
_drvDisp = CreateDrvDispEpd(_name, dc, rst, cs, srcs, busy);

src/components/register/Wippersnapper_Register.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ bool Wippersnapper::encodePubRegistrationReq() {
7777
/****************************************************************************/
7878
void Wippersnapper::pollRegistrationResp() {
7979
// Blocking loop, WDT reset upon failure.
80-
WS._boardStatus = WS_BOARD_DEF_OK;
80+
//WS._boardStatus = WS_BOARD_DEF_OK;
8181
while (WS._boardStatus != WS_BOARD_DEF_OK) {
8282
WS_DEBUG_PRINT("Polling for registration message response...");
8383
WS_DEBUG_PRINTLN(WS._boardStatus);

src/wippersnapper/description/v1/description.pb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Automatically generated nanopb constant definitions */
2-
/* Generated by nanopb-0.4.5-dev at Wed Sep 10 13:28:33 2025. */
2+
/* Generated by nanopb-0.4.5-dev at Wed Sep 10 20:43:29 2025. */
33

44
#include "wippersnapper/description/v1/description.pb.h"
55
#if PB_PROTO_HEADER_VERSION != 40

src/wippersnapper/description/v1/description.pb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Automatically generated nanopb header */
2-
/* Generated by nanopb-0.4.5-dev at Wed Sep 10 13:28:33 2025. */
2+
/* Generated by nanopb-0.4.5-dev at Wed Sep 10 20:43:29 2025. */
33

44
#ifndef PB_WIPPERSNAPPER_DESCRIPTION_V1_WIPPERSNAPPER_DESCRIPTION_V1_DESCRIPTION_PB_H_INCLUDED
55
#define PB_WIPPERSNAPPER_DESCRIPTION_V1_WIPPERSNAPPER_DESCRIPTION_V1_DESCRIPTION_PB_H_INCLUDED

src/wippersnapper/display/v1/display.pb.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Automatically generated nanopb constant definitions */
2-
/* Generated by nanopb-0.4.5-dev at Wed Sep 10 13:28:33 2025. */
2+
/* Generated by nanopb-0.4.5-dev at Wed Sep 10 20:43:29 2025. */
33

44
#include "wippersnapper/display/v1/display.pb.h"
55
#if PB_PROTO_HEADER_VERSION != 40
@@ -9,10 +9,10 @@
99
PB_BIND(wippersnapper_display_v1_EpdSpiConfig, wippersnapper_display_v1_EpdSpiConfig, AUTO)
1010

1111

12-
PB_BIND(wippersnapper_display_v1_EPDConfig, wippersnapper_display_v1_EPDConfig, AUTO)
12+
PB_BIND(wippersnapper_display_v1_EPDWriteOptions, wippersnapper_display_v1_EPDWriteOptions, AUTO)
1313

1414

15-
PB_BIND(wippersnapper_display_v1_EPDWriteOptions, wippersnapper_display_v1_EPDWriteOptions, AUTO)
15+
PB_BIND(wippersnapper_display_v1_EPDConfig, wippersnapper_display_v1_EPDConfig, AUTO)
1616

1717

1818
PB_BIND(wippersnapper_display_v1_TftSpiConfig, wippersnapper_display_v1_TftSpiConfig, AUTO)
@@ -39,3 +39,4 @@ PB_BIND(wippersnapper_display_v1_DisplayRemoved, wippersnapper_display_v1_Displa
3939

4040

4141

42+

0 commit comments

Comments
 (0)