Skip to content

Commit 967650e

Browse files
committed
Add display component, start handleAdd
1 parent 71cb68d commit 967650e

8 files changed

Lines changed: 202 additions & 1 deletion

File tree

src/Wippersnapper.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ Wippersnapper::Wippersnapper() {
6969

7070
// DallasSemi (OneWire)
7171
WS._ds18x20Component = new ws_ds18x20();
72+
73+
// Display controller
74+
WS._displayController = new DisplayController();
7275
};
7376

7477
/**************************************************************************/
@@ -1666,7 +1669,21 @@ void cbSignalUARTReq(char *data, uint16_t len) {
16661669
@returns True if decoded successfully, False otherwise.
16671670
*/
16681671
bool cbDecodeDisplayMsg(pb_istream_t *stream, const pb_field_t *field, void **arg) {
1669-
// TODO: Need to write deserializer logic here
1672+
if (field->tag == wippersnapper_signal_v1_DisplayRequest_display_add_tag) {
1673+
1674+
// Decode message into a DisplayAddRequest
1675+
wippersnapper_display_v1_DisplayAddOrReplace msgAddReq = wippersnapper_display_v1_DisplayAddOrReplace_init_zero;
1676+
if (!ws_pb_decode(stream,
1677+
wippersnapper_display_v1_DisplayAddOrReplace_fields,
1678+
&msgAddReq)) {
1679+
WS_DEBUG_PRINTLN("ERROR: Failure decoding DisplayAddOrReplace message!");
1680+
return false;
1681+
}
1682+
1683+
// Attempt to add or replace a display component
1684+
bool did_add = WS._displayController->Handle_Display_AddOrReplace(&msgAddReq);
1685+
// TODO: Add response handling and publishing here
1686+
16701687
return true;
16711688
}
16721689

src/Wippersnapper.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
#include "components/pwm/ws_pwm.h"
133133
#include "components/servo/ws_servo.h"
134134
#include "components/uart/ws_uart.h"
135+
#include "components/display/controller.h"
135136

136137
#if defined(USE_TINYUSB)
137138
#include "provisioning/tinyusb/Wippersnapper_FS.h"
@@ -246,6 +247,7 @@ class ws_pwm;
246247
class ws_ds18x20;
247248
class ws_pixels;
248249
class ws_uart;
250+
class DisplayController;
249251

250252
/**************************************************************************/
251253
/*!
@@ -369,6 +371,7 @@ class Wippersnapper {
369371
ws_servo *_servoComponent; ///< Instance of servo class
370372
ws_ds18x20 *_ds18x20Component; ///< Instance of DS18x20 class
371373
ws_uart *_uartComponent; ///< Instance of UART class
374+
DisplayController *_displayController; ///< Instance of display controller class
372375

373376
// TODO: does this really need to be global?
374377
uint8_t _macAddr[6]; /*!< Unique network iface identifier */
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*!
2+
* @file src/components/display/controller.cpp
3+
*
4+
* Implementation for the display API controller.
5+
*
6+
* Adafruit invests time and resources providing this open source code,
7+
* please support Adafruit and open-source hardware by purchasing
8+
* products from Adafruit!
9+
*
10+
* Copyright (c) Brent Rubell 2025 for Adafruit Industries.
11+
*
12+
* BSD license, all text here must be included in any redistribution.
13+
*
14+
*/
15+
#include "controller.h"
16+
17+
/*!
18+
@brief Constructs a new DisplayController object
19+
*/
20+
DisplayController::DisplayController() {
21+
// TODO
22+
}
23+
24+
/*!
25+
@brief Destructor
26+
*/
27+
DisplayController::DisplayController() {
28+
// TODO
29+
}
30+
31+
bool DisplayController::Handle_Display_AddOrReplace(wippersnapper_display_v1_DisplayAddOrReplace *msgAdd) {
32+
DisplayHardware *display = new DisplayHardware();
33+
// Configure display type
34+
display->setType(msgAdd->type);
35+
36+
return true; // Placeholder
37+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*!
2+
* @file src/components/display/controller.h
3+
*
4+
* Controller for the display API
5+
*
6+
* Adafruit invests time and resources providing this open source code,
7+
* please support Adafruit and open-source hardware by purchasing
8+
* products from Adafruit!
9+
*
10+
* Copyright (c) Brent Rubell 2025 for Adafruit Industries.
11+
*
12+
* BSD license, all text here must be included in any redistribution.
13+
*
14+
*/
15+
#ifndef WS_DISPLAY_CONTROLLER_H
16+
#define WS_DISPLAY_CONTROLLER_H
17+
#include "Wippersnapper.h"
18+
#include "hardware.h"
19+
20+
class Wippersnapper_V2; ///< Forward declaration
21+
class DisplayHardware; ///< Forward declaration
22+
23+
/**************************************************************************/
24+
/*!
25+
@brief Routes messages using the display.proto API to the
26+
appropriate hardware and model classes, controls and tracks
27+
the state of displays.
28+
*/
29+
/**************************************************************************/
30+
class DisplayController {
31+
public:
32+
DisplayController();
33+
~DisplayController();
34+
bool Handle_Display_AddOrReplace(wippersnapper_display_v1_DisplayAddOrReplace *msgAdd);
35+
//bool Handle_Display_Write(pb_istream_t *stream);
36+
//bool Handle_Display_Remove(pb_istream_t *stream);
37+
private:
38+
//DisplayHardware *_display_strands[MAX_DISPLAY_STRANDS] = {
39+
};
40+
extern Wippersnapper Ws; ///< Global WS instance
41+
#endif
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*!
2+
* @file src/components/display/hardware.cpp
3+
*
4+
* Implementation for the display hardware.
5+
*
6+
* Adafruit invests time and resources providing this open source code,
7+
* please support Adafruit and open-source hardware by purchasing
8+
* products from Adafruit!
9+
*
10+
* Copyright (c) Brent Rubell 2025 for Adafruit Industries.
11+
*
12+
* BSD license, all text here must be included in any redistribution.
13+
*
14+
*/
15+
#include "controller.h"
16+
17+
/*!
18+
@brief Constructs a new DisplayHardware object
19+
*/
20+
DisplayHardware::DisplayHardware() {
21+
_type = wippersnapper_display_v1_DisplayType_DISPLAY_TYPE_UNSPECIFIED;
22+
}
23+
24+
/*!
25+
@brief Destructor
26+
*/
27+
DisplayHardware::DisplayHardware() {
28+
// TODO: Clean up display drivers
29+
}
30+
31+
/*!
32+
@brief Sets the hardware's display type.
33+
@param type
34+
The display type to set.
35+
*/
36+
void DisplayHardware::setType(wippersnapper_display_v1_DisplayType type) {
37+
_type = type;
38+
}
39+
40+
/*!
41+
@brief Initializes the display hardware.
42+
@param reset
43+
Whether to reset the display hardware.
44+
@return True if initialization was successful, false otherwise.
45+
*/
46+
bool DisplayHardware::begin(bool reset) {
47+
return true; // Placeholder for actual initialization logic
48+
}
49+
50+
/*!
51+
@brief Sets the text size for the display.
52+
@param sz
53+
The size of the text to set.
54+
*/
55+
void setTextSize(uint8_t sz) {
56+
// Placeholder for setting text size on the display TODO
57+
}
58+

src/components/display/hardware.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*!
2+
* @file src/components/display/hardware.h
3+
*
4+
* Hardware interface for display components.
5+
*
6+
* Adafruit invests time and resources providing this open source code,
7+
* please support Adafruit and open-source hardware by purchasing
8+
* products from Adafruit!
9+
*
10+
* Copyright (c) Brent Rubell 2025 for Adafruit Industries.
11+
*
12+
* BSD license, all text here must be included in any redistribution.
13+
*
14+
*/
15+
#ifndef WS_DISPLAY_HARDWARE_H
16+
#define WS_DISPLAY_HARDWARE_H
17+
#include "Wippersnapper.h"
18+
19+
#include "Adafruit_ThinkInk.h"
20+
21+
/**************************************************************************/
22+
/*!
23+
@brief Interface for interacting with display hardware (TFT, eInk,
24+
OLED, etc.)
25+
This class provides methods to initialize, write to, and
26+
manage the state of display hardware.
27+
*/
28+
/**************************************************************************/
29+
class DisplayHardware {
30+
public:
31+
DisplayHardware();
32+
~DisplayHardware();
33+
// High-level API functions
34+
void setType(wippersnapper_display_v1_DisplayType type);
35+
bool begin(bool reset = true);
36+
// API functions to abstract Adafruit_GFX
37+
void setTextSize(uint8_t sz);
38+
39+
private:
40+
wippersnapper_display_v1_DisplayType _type; ///< Display type
41+
// TODO: Make these drivers instead?
42+
ThinkInk_290_Grayscale4_EAAMFGN *disp_thinkink_grayscale4_eaamfgn = nullptr; //< 2025 MagTag with SSD1680Z chipset
43+
ThinkInk_290_Grayscale4_T5 *disp_thinkink_grayscale4_t5 = nullptr; ///< Pre-2025 MagTag with IL0373 chipset
44+
};
45+
#endif // WS_DISPLAY_HARDWARE_H

src/provisioning/sdcard/ws_sdcard.cpp

Whitespace-only changes.

src/provisioning/sdcard/ws_sdcard.h

Whitespace-only changes.

0 commit comments

Comments
 (0)