Skip to content

Commit 8d03bdb

Browse files
committed
Revert all changes after bfb1d3a
1 parent 9b5da3d commit 8d03bdb

33 files changed

+1229
-534
lines changed

src/Wippersnapper.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,25 @@ bool cbDecodeSignalRequestI2C(pb_istream_t *stream, const pb_field_t *field,
834834
if (!encodeI2CResponse(&msgi2cResponse)) {
835835
return false;
836836
}
837+
} else if (field->tag ==
838+
wippersnapper_signal_v1_I2CRequest_req_i2c_device_out_write_tag) {
839+
WS_DEBUG_PRINTLN("[app] I2C Device Output Write");
840+
// Decode stream into an I2CDeviceDeinitRequest
841+
wippersnapper_i2c_v1_I2CDeviceOutputWrite msgDeviceWrite =
842+
wippersnapper_i2c_v1_I2CDeviceOutputWrite_init_zero;
843+
// Decode stream into struct, msgI2CDeviceDeinitRequest
844+
if (!ws_pb_decode(stream, wippersnapper_i2c_v1_I2CDeviceOutputWrite_fields,
845+
&msgDeviceWrite)) {
846+
WS_DEBUG_PRINTLN(
847+
"[app] ERROR: Failed decoding I2CDeviceOutputWrite message.");
848+
return false;
849+
}
850+
851+
if (!WS._i2cPort0->Handle_I2cDeviceOutputWrite(&msgDeviceWrite)) {
852+
WS_DEBUG_PRINTLN("[app] ERROR: Failed to write to I2C output device.");
853+
return false; // fail out if we can't decode, we don't have a response to
854+
// publish
855+
}
837856
WS_DEBUG_PRINTLN("[app] I2C Device Output Write Done");
838857
return true; // we successfully wrote to the device, this subtype has no
839858
// response to publish to IO

src/components/display/controller.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,11 @@ bool DisplayController::Handle_Display_AddOrReplace(
5151
if (msgAdd->which_config ==
5252
wippersnapper_display_v1_DisplayAddOrReplace_config_epd_tag) {
5353
did_begin = display->beginEPD(&msgAdd->config.config_epd,
54-
&msgAdd->interface_type.cfg_spi);
54+
&msgAdd->interface_type.spi_epd);
5555
} else if (msgAdd->which_config ==
5656
wippersnapper_display_v1_DisplayAddOrReplace_config_tft_tag) {
5757
did_begin = display->beginTft(&msgAdd->config.config_tft,
58-
&msgAdd->interface_type.cfg_spi);
59-
} else if (msgAdd->which_config ==
60-
wippersnapper_display_v1_DisplayAddOrReplace_config_oled_tag) {
61-
did_begin = display->beginOled(&msgAdd->config.config_oled,
62-
&msgAdd->interface_type.cfg_i2c);
63-
} else if (
64-
msgAdd->which_config ==
65-
wippersnapper_display_v1_DisplayAddOrReplace_config_led_backpack_tag) {
66-
WS_DEBUG_PRINTLN("[display] LED Backpack support coming soon!");
67-
delete display;
68-
return false;
69-
} else if (msgAdd->which_config ==
70-
wippersnapper_display_v1_DisplayAddOrReplace_config_char_lcd_tag) {
71-
WS_DEBUG_PRINTLN("[display] Character LCD support coming soon!");
72-
delete display;
73-
return false;
58+
&msgAdd->interface_type.spi_tft);
7459
} else {
7560
WS_DEBUG_PRINTLN("[display] Unsupported display configuration type!");
7661
delete display;

src/components/display/drivers/dispDrvBase.h

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,6 @@ class dispDrvBase {
6363
: _pin_cs(cs), _pin_dc(dc), _pin_mosi(mosi), _pin_sck(sck), _pin_rst(rst),
6464
_pin_miso(miso) {}
6565

66-
/*!
67-
@brief Creates a new I2C output component driver.
68-
@param i2c
69-
The I2C hardware interface, default is Wire.
70-
@param sensorAddress
71-
The I2C sensor's unique address.
72-
*/
73-
dispDrvBase(TwoWire *i2c, uint16_t sensorAddress) {
74-
// No-op constructor
75-
}
76-
7766
/*!
7867
@brief Destructor for the base display driver.
7968
This destructor is virtual to allow derived classes to clean up
@@ -124,7 +113,7 @@ class dispDrvBase {
124113
@param r
125114
The rotation of the display (0-3).
126115
*/
127-
virtual void setRotation(uint8_t r) { _rotation = r; }
116+
void setRotation(uint8_t r) { _rotation = r; }
128117

129118
/*!
130119
@brief Sets the text size for the display.
@@ -135,42 +124,19 @@ class dispDrvBase {
135124
*/
136125
virtual void setTextSize(uint8_t s) { _text_sz = s; }
137126

138-
/*!
139-
@brief Sets the brightness for the display (if supported).
140-
@param brightness
141-
The brightness level to set.
142-
@note This method can be overridden by derived classes to provide
143-
specific functionality.
144-
*/
145-
virtual void setBrightness(int32_t brightness) { _brightness = brightness; }
146-
147-
/*!
148-
@brief Sets the alignment for the display (if supported).
149-
@param alignment
150-
The alignment to set.
151-
@note This method can be overridden by derived classes to provide
152-
specific functionality.
153-
*/
154-
virtual void setAlignment(uint32_t alignment) { _alignment = alignment; }
155-
156127
protected:
157-
int16_t _pin_dc; ///< Data/Command pin
158-
int16_t _pin_rst; ///< Reset pin
159-
int16_t _pin_cs; ///< Chip Select pin
160-
int16_t _pin_busy; ///< Optional Busy pin
161-
int16_t _pin_sram_cs; ///< Optional EPD SRAM chip select pin
162-
uint16_t _pin_mosi; ///< Optional MOSI pin for SPI TFT displays
163-
uint16_t _pin_miso; ///< Optional MISO pin for SPI TFT displays
164-
uint16_t _pin_sck; ///< Optional SCK pin for SPI TFT displays
165-
TwoWire *_i2c; ///< Optional pointer to the I2C driver's Wire object
166-
uint16_t _sensorAddress; ///< Optional I2C sensor address
167-
uint8_t _text_sz = 1; ///< Optional Text size for displaying a message
168-
int16_t _height; ///< Optional Height of the display
169-
int16_t _width; ///< Optional Width of the display
170-
uint8_t _rotation; ///< Optional Rotation of the display
171-
int32_t _brightness; ///< Optional Brightness of the display (if supported)
172-
uint32_t _alignment; ///< Optional Alignment of the display (specific to
173-
///< drivers like LED backpacks)
128+
int16_t _pin_dc; ///< Data/Command pin
129+
int16_t _pin_rst; ///< Reset pin
130+
int16_t _pin_cs; ///< Chip Select pin
131+
int16_t _pin_busy; ///< Optional Busy pin
132+
int16_t _pin_sram_cs; ///< Optional EPD SRAM chip select pin
133+
uint16_t _pin_mosi; ///< Optional MOSI pin for SPI TFT displays
134+
uint16_t _pin_miso; ///< Optional MISO pin for SPI TFT displays
135+
uint16_t _pin_sck; ///< Optional SCK pin for SPI TFT displays
136+
uint8_t _text_sz = 1; ///< Text size for displaying a message
137+
int16_t _height; ///< Height of the display
138+
int16_t _width; ///< Width of the display
139+
uint8_t _rotation; ///< Rotation of the display
174140
};
175141

176142
#endif // WS_DISP_DRV_BASE_H

src/components/display/hardware.cpp

Lines changed: 6 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,9 @@ int16_t DisplayHardware::parsePin(const char *pinStr) {
173173
Pointer to the SPI configuration structure for EPD.
174174
@return True if configuration was successful, False otherwise.
175175
*/
176-
bool DisplayHardware::beginEPD(wippersnapper_display_v1_EPDConfig *config,
177-
wippersnapper_display_v1_SpiConfig *spi_config) {
176+
bool DisplayHardware::beginEPD(
177+
wippersnapper_display_v1_EPDConfig *config,
178+
wippersnapper_display_v1_EpdSpiConfig *spi_config) {
178179
// Validate pointers
179180
if (config == nullptr || spi_config == nullptr) {
180181
WS_DEBUG_PRINTLN("[display] EPD config or SPI config is null!");
@@ -272,8 +273,9 @@ void DisplayHardware::removeSuffix(const char *suffix) {
272273
Pointer to the SPI configuration structure for TFT.
273274
@return True if configuration was successful, False otherwise.
274275
*/
275-
bool DisplayHardware::beginTft(wippersnapper_display_v1_TftConfig *config,
276-
wippersnapper_display_v1_SpiConfig *spi_config) {
276+
bool DisplayHardware::beginTft(
277+
wippersnapper_display_v1_TftConfig *config,
278+
wippersnapper_display_v1_TftSpiConfig *spi_config) {
277279
// Validate pointers
278280
if (config == nullptr || spi_config == nullptr) {
279281
WS_DEBUG_PRINTLN("[display] EPD config or SPI config is null!");
@@ -331,133 +333,6 @@ bool DisplayHardware::beginTft(wippersnapper_display_v1_TftConfig *config,
331333
return true;
332334
}
333335

334-
/*!
335-
@brief Attempts to configure and initialize an OLED display
336-
@param config
337-
Pointer to the OLED's configuration structure.
338-
@param i2c_config
339-
Pointer to the I2C configuration structure.
340-
@return True if configuration was successful, False otherwise.
341-
*/
342-
bool DisplayHardware::beginOled(
343-
wippersnapper_display_v1_OledConfig *config,
344-
wippersnapper_display_v1_I2cConfig *i2c_config) {
345-
// Validate pointers
346-
if (config == nullptr || i2c_config == nullptr || !i2c_config->has_i2c)
347-
return false;
348-
349-
// If we already have a display driver assigned to this hardware instance,
350-
// clean it up!
351-
if (_drvDisp) {
352-
delete _drvDisp;
353-
_drvDisp = nullptr;
354-
}
355-
356-
// Initialize OLED display driver based on device name
357-
if (strnlen(i2c_config->i2c.i2c_device_name,
358-
sizeof(i2c_config->i2c.i2c_device_name)) <
359-
sizeof(i2c_config->i2c.i2c_device_name) &&
360-
strcmp(i2c_config->i2c.i2c_device_name, "SSD1306") == 0) {
361-
_drvDisp = new dispDrvSsd1306(WS._i2cPort0->getBus(),
362-
i2c_config->i2c.i2c_device_address);
363-
} else if (strnlen(i2c_config->i2c.i2c_device_name,
364-
sizeof(i2c_config->i2c.i2c_device_name)) <
365-
sizeof(i2c_config->i2c.i2c_device_name) &&
366-
strcmp(i2c_config->i2c.i2c_device_name, "SH1107") == 0) {
367-
_drvDisp = new dispDrvSh1107(WS._i2cPort0->getBus(),
368-
i2c_config->i2c.i2c_device_address);
369-
} else {
370-
WS_DEBUG_PRINTLN("[display] Unsupported OLED driver!");
371-
return false;
372-
}
373-
374-
// Validate that the display driver was created successfully
375-
if (!_drvDisp) {
376-
WS_DEBUG_PRINTLN("[display] Failed to create display driver!");
377-
_drvDisp = nullptr;
378-
return false;
379-
}
380-
381-
// Configure display dimensions and text size
382-
_drvDisp->setWidth(config->width);
383-
_drvDisp->setHeight(config->height);
384-
_drvDisp->setTextSize(config->text_size);
385-
386-
// Initialize the display driver
387-
if (!_drvDisp->begin()) {
388-
WS_DEBUG_PRINTLN("[display] Failed to begin display driver!");
389-
delete _drvDisp;
390-
_drvDisp = nullptr;
391-
return false;
392-
}
393-
394-
WS_DEBUG_PRINTLN("[display] OLED initialized successfully.");
395-
return true;
396-
}
397-
398-
/*!
399-
@brief Attempts to configure and initialize an LED Backpack display
400-
@param config
401-
Pointer to the LED Backpack's configuration structure.
402-
@param i2c_config
403-
Pointer to the I2C configuration structure.
404-
@return True if configuration was successful, False otherwise.
405-
*/
406-
bool DisplayHardware::beginLedBackpack(
407-
wippersnapper_display_v1_LEDBackpackConfig *config,
408-
wippersnapper_display_v1_I2cConfig *i2c_config) {
409-
// Validate pointers
410-
if (config == nullptr || i2c_config == nullptr || !i2c_config->has_i2c)
411-
return false;
412-
413-
// If we already have a display driver assigned to this hardware instance,
414-
// clean it up!
415-
if (_drvDisp) {
416-
delete _drvDisp;
417-
_drvDisp = nullptr;
418-
}
419-
420-
// Initialize OLED display driver based on device name
421-
if (strnlen(i2c_config->i2c.i2c_device_name,
422-
sizeof(i2c_config->i2c.i2c_device_name)) <
423-
sizeof(i2c_config->i2c.i2c_device_name) &&
424-
strcmp(i2c_config->i2c.i2c_device_name, "7seg") == 0) {
425-
_drvDisp = new dispDrv7Seg(WS._i2cPort0->getBus(),
426-
i2c_config->i2c.i2c_device_address);
427-
} else if (strnlen(i2c_config->i2c.i2c_device_name,
428-
sizeof(i2c_config->i2c.i2c_device_name)) <
429-
sizeof(i2c_config->i2c.i2c_device_name) &&
430-
strcmp(i2c_config->i2c.i2c_device_name, "quadalphanum") == 0) {
431-
_drvDisp = new dispDrvQuadAlphaNum(WS._i2cPort0->getBus(),
432-
i2c_config->i2c.i2c_device_address);
433-
} else {
434-
WS_DEBUG_PRINTLN("[display] Unsupported OLED driver!");
435-
return false;
436-
}
437-
438-
// Validate that the display driver was created successfully
439-
if (!_drvDisp) {
440-
WS_DEBUG_PRINTLN("[display] Failed to create display driver!");
441-
_drvDisp = nullptr;
442-
return false;
443-
}
444-
445-
// Configure display dimensions and text size
446-
_drvDisp->setAlignment(config->alignment);
447-
_drvDisp->setBrightness(config->brightness);
448-
449-
// Initialize the display driver
450-
if (!_drvDisp->begin()) {
451-
WS_DEBUG_PRINTLN("[display] Failed to begin driver!");
452-
delete _drvDisp;
453-
_drvDisp = nullptr;
454-
return false;
455-
}
456-
457-
WS_DEBUG_PRINTLN("[display] LED backpack initialized successfully.");
458-
return true;
459-
}
460-
461336
/*!
462337
@brief Gets the name of the display hardware instance.
463338
@return The name of the display hardware instance.

src/components/display/hardware.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
#ifndef WS_DISPLAY_HARDWARE_H
1616
#define WS_DISPLAY_HARDWARE_H
1717
#include "Wippersnapper.h"
18-
#include "drivers/dispDrv7Seg.h"
1918
#include "drivers/dispDrvBase.h"
20-
#include "drivers/dispDrvQuadAlphaNum.h"
21-
#include "drivers/dispDrvSh1107.h"
22-
#include "drivers/dispDrvSsd1306.h"
2319
#include "drivers/dispDrvSt7789.h"
2420
#include "drivers/dispDrvThinkInkGrayscale4Eaamfgn.h"
2521
#include "drivers/dispDrvThinkInkGrayscale4T5.h"
@@ -44,13 +40,9 @@ class DisplayHardware {
4440
void setType(wippersnapper_display_v1_DisplayType type);
4541
wippersnapper_display_v1_DisplayType getType();
4642
bool beginEPD(wippersnapper_display_v1_EPDConfig *config,
47-
wippersnapper_display_v1_SpiConfig *spi_config);
43+
wippersnapper_display_v1_EpdSpiConfig *spi_config);
4844
bool beginTft(wippersnapper_display_v1_TftConfig *config,
49-
wippersnapper_display_v1_SpiConfig *spi_config);
50-
bool beginOled(wippersnapper_display_v1_OledConfig *config,
51-
wippersnapper_display_v1_I2cConfig *i2c_config);
52-
bool beginLedBackpack(wippersnapper_display_v1_LEDBackpackConfig *config,
53-
wippersnapper_display_v1_I2cConfig *i2c_config);
45+
wippersnapper_display_v1_TftSpiConfig *spi_config);
5446

5547
//
5648
// API for Adafruit_GFX that abstracts hardware functionality

0 commit comments

Comments
 (0)