Skip to content

Commit 37904f3

Browse files
committed
Almost full circle display add
1 parent fc41a7d commit 37904f3

5 files changed

Lines changed: 61 additions & 12 deletions

File tree

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/tmpkb6hfvfs"
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: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,35 @@ DisplayController::DisplayController() {
2828
// TODO
2929
}
3030

31+
/*!
32+
@brief Handles a Display_AddOrReplace message.
33+
@param msgAdd
34+
Pointer to a DisplayAddOrReplace message structure.
35+
@return True if the display was added or replaced successfully, false otherwise.
36+
*/
3137
bool DisplayController::Handle_Display_AddOrReplace(wippersnapper_display_v1_DisplayAddOrReplace *msgAdd) {
32-
DisplayHardware *display = new DisplayHardware();
38+
DisplayHardware *display = new DisplayHardware(msgAdd->name);
39+
3340
// Configure display type
3441
display->setType(msgAdd->type);
35-
// Configure display based on config type
42+
43+
// Attempt to initialize display hardware instance
44+
bool did_begin = false;
3645
if (msgAdd->which_config == wippersnapper_display_v1_DisplayAddOrReplace_epd_config_tag) {
37-
display->configureEPD(&msgAdd->config.epd_config, &msgAdd->interface_type.spi_epd);
46+
did_begin = display->beginEPD(&msgAdd->config.epd_config, &msgAdd->interface_type.spi_epd);
47+
} else {
48+
WS_DEBUG_PRINTLN("[display] Unsupported display configuration type!");
49+
return false;
3850
}
51+
52+
// Check if the display began successfully
53+
if (!did_begin) {
54+
WS_DEBUG_PRINTLN("[display] Failed to initialize display!");
55+
delete display; // Clean up if initialization failed
56+
return false;
57+
}
58+
59+
_hw_instances.push_back(display); // Store the display instance
60+
WS_DEBUG_PRINTLN("[display] Display added or replaced successfully!");
3961
return true; // Placeholder
4062
}

src/components/display/controller.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ class DisplayController {
3232
DisplayController();
3333
~DisplayController();
3434
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);
35+
//bool Handle_Display_Remove(...);
36+
//bool Handle_Display_Write(...);
3737
private:
38-
//DisplayHardware *_display_strands[MAX_DISPLAY_STRANDS] = {
38+
std::vector<DisplayHardware*> _hw_instances; ///< Holds pointers to DisplayHardware instances
3939
};
4040
extern Wippersnapper Ws; ///< Global WS instance
4141
#endif

src/components/display/hardware.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717
/*!
1818
@brief Constructs a new DisplayHardware object
1919
*/
20-
DisplayHardware::DisplayHardware() {
20+
DisplayHardware::DisplayHardware(const char *name) {
21+
_name = name; ///< Set the name of the hardware instance
2122
_type = wippersnapper_display_v1_DisplayType_DISPLAY_TYPE_UNSPECIFIED;
2223
}
2324

2425
/*!
2526
@brief Destructor
2627
*/
27-
DisplayHardware::DisplayHardware() {
28-
// TODO: Clean up display drivers
28+
DisplayHardware::~DisplayHardware() {
29+
// TODO
2930
}
3031

3132
/*!

src/components/display/hardware.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@
2828
/**************************************************************************/
2929
class DisplayHardware {
3030
public:
31-
DisplayHardware();
31+
DisplayHardware(const char *name);
3232
~DisplayHardware();
3333
// High-level API functions
3434
void setType(wippersnapper_display_v1_DisplayType type);
3535
wippersnapper_display_v1_DisplayType getType();
36-
void beginEPD(wippersnapper_display_v1_EPDConfig *config,
37-
wippersnapper_display_v1_EpdSpiConfig *spi_config);
36+
bool beginEPD(wippersnapper_display_v1_EPDConfig *config, wippersnapper_display_v1_EpdSpiConfig *spi_config);
3837
bool begin(bool reset = true);
3938
// API functions to abstract Adafruit_GFX
4039
void setTextSize(uint8_t sz);
4140

4241
private:
42+
const char *_name; ///< Identifies the hardware instance
4343
wippersnapper_display_v1_DisplayType _type; ///< Display type
4444
wippersnapper_display_v1_EPDThinkInkPanel
4545
_thinkink_driver; ///< ThinkInk driver type

0 commit comments

Comments
 (0)