Skip to content

Commit c308694

Browse files
committed
Routing epd begin thru
1 parent 14ef634 commit c308694

23 files changed

Lines changed: 83 additions & 35 deletions

File tree

src/components/display/controller.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ bool DisplayController::Handle_Display_AddOrReplace(wippersnapper_display_v1_Dis
3232
DisplayHardware *display = new DisplayHardware();
3333
// Configure display type
3434
display->setType(msgAdd->type);
35-
35+
// Configure display based on config type
36+
if (msgAdd->which_config == wippersnapper_display_v1_DisplayAddOrReplace_epd_config_tag) {
37+
display->configureEPD(&msgAdd->config.epd_config, &msgAdd->interface_type.spi_epd);
38+
}
3639
return true; // Placeholder
3740
}

src/components/display/hardware.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,55 @@ void DisplayHardware::setType(wippersnapper_display_v1_DisplayType type) {
3737
_type = type;
3838
}
3939

40+
/*!
41+
@brief Gets the hardware's display type.
42+
@return The current display type.
43+
*/
44+
wippersnapper_display_v1_DisplayType DisplayHardware::getType() {
45+
return _type;
46+
}
47+
48+
/*!
49+
@brief Configures the EPD display with the provided configuration.
50+
@param config
51+
Pointer to the EPD configuration structure.
52+
@param spi_config
53+
Pointer to the SPI configuration structure for EPD.
54+
@return True if configuration was successful, False otherwise.
55+
*/
56+
bool DisplayHardware::beginEPD(wippersnapper_display_v1_EPDConfig *config, wippersnapper_display_v1_EpdSpiConfig *spi_config) {
57+
// Convert pins in config to int16_t instances
58+
int16_t dc = -1, rst = -1, cs = -1, srcs = -1, busy = -1;
59+
dc = (int16_t)atoi(spi_config->pin_dc+ 1);
60+
rst = (int16_t)atoi(spi_config->pin_rst+ 1);
61+
cs = (int16_t)atoi(spi_config->pin_cs+ 1);
62+
srcs = (int16_t)atoi(spi_config->pin_sram_cs+ 1);
63+
busy = (int16_t)atoi(spi_config->pin_busy+ 1);
64+
65+
// Configure EPD mode
66+
thinkinkmode_t epd_mode;
67+
if (config->mode == wippersnapper_display_v1_EPDMode_EPD_MODE_GRAYSCALE4) {
68+
epd_mode = THINKINK_GRAYSCALE4;
69+
} else if (config->mode == wippersnapper_display_v1_EPDMode_EPD_MODE_MONO) {
70+
epd_mode = THINKINK_MONO;
71+
} else {
72+
epd_mode = THINKINK_MONO; // Default to mono
73+
}
74+
75+
// Assign driver instance based on panel type
76+
if (config->panel == wippersnapper_display_v1_EPDThinkInkPanel_EPD_THINK_INK_PANEL_213_GRAYSCALE4_MFGN) {
77+
_disp_thinkink_grayscale4_eaamfgn = new ThinkInk_290_Grayscale4_EAAMFGN(dc, rst, cs, srcs, busy);
78+
_disp_thinkink_grayscale4_eaamfgn->begin(epd_mode);
79+
} else if (config->panel == wippersnapper_display_v1_EPDThinkInkPanel_EPD_THINK_INK_PANEL_213_GRAYSCALE4_T5) {
80+
_disp_thinkink_grayscale4_t5 = new ThinkInk_290_Grayscale4_T5(dc, rst, cs, srcs, busy);
81+
_disp_thinkink_grayscale4_t5->begin(epd_mode);
82+
} else {
83+
return false; // Unsupported panel type
84+
}
85+
86+
return true; // Configuration successful
87+
}
88+
4089
/*!
4190
@brief Initializes the display hardware.
4291
@param reset

src/components/display/hardware.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@ class DisplayHardware {
3232
~DisplayHardware();
3333
// High-level API functions
3434
void setType(wippersnapper_display_v1_DisplayType type);
35+
wippersnapper_display_v1_DisplayType getType();
36+
void beginEPD(wippersnapper_display_v1_EPDConfig *config, wippersnapper_display_v1_EpdSpiConfig *spi_config);
3537
bool begin(bool reset = true);
3638
// API functions to abstract Adafruit_GFX
3739
void setTextSize(uint8_t sz);
3840

3941
private:
4042
wippersnapper_display_v1_DisplayType _type; ///< Display type
4143
// 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+
ThinkInk_290_Grayscale4_EAAMFGN *_disp_thinkink_grayscale4_eaamfgn = nullptr; //< 2025 MagTag with SSD1680Z chipset
45+
ThinkInk_290_Grayscale4_T5 *_disp_thinkink_grayscale4_t5 = nullptr; ///< Pre-2025 MagTag with IL0373 chipset
4446
};
4547
#endif // WS_DISPLAY_HARDWARE_H

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 Fri Aug 15 16:07:24 2025. */
2+
/* Generated by nanopb-0.4.5-dev at Fri Aug 15 16:18:27 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 Fri Aug 15 16:07:24 2025. */
2+
/* Generated by nanopb-0.4.5-dev at Fri Aug 15 16:18:27 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: 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 Fri Aug 15 16:07:24 2025. */
2+
/* Generated by nanopb-0.4.5-dev at Fri Aug 15 16:18:27 2025. */
33

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

src/wippersnapper/display/v1/display.pb.h

Lines changed: 6 additions & 12 deletions
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 Fri Aug 15 16:07:24 2025. */
2+
/* Generated by nanopb-0.4.5-dev at Fri Aug 15 16:18:27 2025. */
33

44
#ifndef PB_WIPPERSNAPPER_DISPLAY_V1_WIPPERSNAPPER_DISPLAY_V1_DISPLAY_PB_H_INCLUDED
55
#define PB_WIPPERSNAPPER_DISPLAY_V1_WIPPERSNAPPER_DISPLAY_V1_DISPLAY_PB_H_INCLUDED
@@ -59,8 +59,6 @@ typedef struct _wippersnapper_display_v1_EPDConfig {
5959
wippersnapper_display_v1_EPDThinkInkPanel panel;
6060
int32_t width;
6161
int32_t height;
62-
char pin_busy[6];
63-
char pin_reset[6];
6462
} wippersnapper_display_v1_EPDConfig;
6563

6664
typedef struct _wippersnapper_display_v1_EPDWriteOptions {
@@ -124,15 +122,15 @@ extern "C" {
124122

125123
/* Initializer values for message structs */
126124
#define wippersnapper_display_v1_EpdSpiConfig_init_default {0, "", "", "", "", ""}
127-
#define wippersnapper_display_v1_EPDConfig_init_default {_wippersnapper_display_v1_EPDMode_MIN, _wippersnapper_display_v1_EPDThinkInkPanel_MIN, 0, 0, "", ""}
125+
#define wippersnapper_display_v1_EPDConfig_init_default {_wippersnapper_display_v1_EPDMode_MIN, _wippersnapper_display_v1_EPDThinkInkPanel_MIN, 0, 0}
128126
#define wippersnapper_display_v1_EPDWriteOptions_init_default {0, _wippersnapper_display_v1_EPDColors_MIN}
129127
#define wippersnapper_display_v1_DisplayAddOrReplace_init_default {_wippersnapper_display_v1_DisplayType_MIN, "", 0, {wippersnapper_display_v1_EpdSpiConfig_init_default}, 0, {wippersnapper_display_v1_EPDConfig_init_default}}
130128
#define wippersnapper_display_v1_DisplayRemove_init_default {""}
131129
#define wippersnapper_display_v1_DisplayWrite_init_default {"", "", 0, {wippersnapper_display_v1_EPDWriteOptions_init_default}}
132130
#define wippersnapper_display_v1_DisplayAddedorReplaced_init_default {0}
133131
#define wippersnapper_display_v1_DisplayRemoved_init_default {0}
134132
#define wippersnapper_display_v1_EpdSpiConfig_init_zero {0, "", "", "", "", ""}
135-
#define wippersnapper_display_v1_EPDConfig_init_zero {_wippersnapper_display_v1_EPDMode_MIN, _wippersnapper_display_v1_EPDThinkInkPanel_MIN, 0, 0, "", ""}
133+
#define wippersnapper_display_v1_EPDConfig_init_zero {_wippersnapper_display_v1_EPDMode_MIN, _wippersnapper_display_v1_EPDThinkInkPanel_MIN, 0, 0}
136134
#define wippersnapper_display_v1_EPDWriteOptions_init_zero {0, _wippersnapper_display_v1_EPDColors_MIN}
137135
#define wippersnapper_display_v1_DisplayAddOrReplace_init_zero {_wippersnapper_display_v1_DisplayType_MIN, "", 0, {wippersnapper_display_v1_EpdSpiConfig_init_zero}, 0, {wippersnapper_display_v1_EPDConfig_init_zero}}
138136
#define wippersnapper_display_v1_DisplayRemove_init_zero {""}
@@ -148,8 +146,6 @@ extern "C" {
148146
#define wippersnapper_display_v1_EPDConfig_panel_tag 2
149147
#define wippersnapper_display_v1_EPDConfig_width_tag 3
150148
#define wippersnapper_display_v1_EPDConfig_height_tag 4
151-
#define wippersnapper_display_v1_EPDConfig_pin_busy_tag 5
152-
#define wippersnapper_display_v1_EPDConfig_pin_reset_tag 6
153149
#define wippersnapper_display_v1_EPDWriteOptions_text_size_tag 1
154150
#define wippersnapper_display_v1_EPDWriteOptions_color_tag 2
155151
#define wippersnapper_display_v1_EpdSpiConfig_bus_tag 1
@@ -181,9 +177,7 @@ X(a, STATIC, SINGULAR, STRING, pin_busy, 6)
181177
X(a, STATIC, SINGULAR, UENUM, mode, 1) \
182178
X(a, STATIC, SINGULAR, UENUM, panel, 2) \
183179
X(a, STATIC, SINGULAR, INT32, width, 3) \
184-
X(a, STATIC, SINGULAR, INT32, height, 4) \
185-
X(a, STATIC, SINGULAR, STRING, pin_busy, 5) \
186-
X(a, STATIC, SINGULAR, STRING, pin_reset, 6)
180+
X(a, STATIC, SINGULAR, INT32, height, 4)
187181
#define wippersnapper_display_v1_EPDConfig_CALLBACK NULL
188182
#define wippersnapper_display_v1_EPDConfig_DEFAULT NULL
189183

@@ -247,9 +241,9 @@ extern const pb_msgdesc_t wippersnapper_display_v1_DisplayRemoved_msg;
247241

248242
/* Maximum encoded size of messages (where known) */
249243
#define wippersnapper_display_v1_EpdSpiConfig_size 46
250-
#define wippersnapper_display_v1_EPDConfig_size 40
244+
#define wippersnapper_display_v1_EPDConfig_size 26
251245
#define wippersnapper_display_v1_EPDWriteOptions_size 13
252-
#define wippersnapper_display_v1_DisplayAddOrReplace_size 157
246+
#define wippersnapper_display_v1_DisplayAddOrReplace_size 143
253247
#define wippersnapper_display_v1_DisplayRemove_size 7
254248
#define wippersnapper_display_v1_DisplayWrite_size 29
255249
#define wippersnapper_display_v1_DisplayAddedorReplaced_size 2

src/wippersnapper/ds18x20/v1/ds18x20.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 Fri Aug 15 16:07:24 2025. */
2+
/* Generated by nanopb-0.4.5-dev at Fri Aug 15 16:18:27 2025. */
33

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

src/wippersnapper/ds18x20/v1/ds18x20.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 Fri Aug 15 16:07:24 2025. */
2+
/* Generated by nanopb-0.4.5-dev at Fri Aug 15 16:18:27 2025. */
33

44
#ifndef PB_WIPPERSNAPPER_DS18X20_V1_WIPPERSNAPPER_DS18X20_V1_DS18X20_PB_H_INCLUDED
55
#define PB_WIPPERSNAPPER_DS18X20_V1_WIPPERSNAPPER_DS18X20_V1_DS18X20_PB_H_INCLUDED

src/wippersnapper/i2c/v1/i2c.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 Fri Aug 15 16:07:24 2025. */
2+
/* Generated by nanopb-0.4.5-dev at Fri Aug 15 16:18:27 2025. */
33

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

0 commit comments

Comments
 (0)