Skip to content

Commit 6513956

Browse files
committed
PR Feedback
1 parent 02223db commit 6513956

File tree

3 files changed

+27
-45
lines changed

3 files changed

+27
-45
lines changed

src/components/i2c/WipperSnapper_I2C.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -881,9 +881,8 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
881881
}
882882
_drivers_out.push_back(_sevenSeg);
883883
WS_DEBUG_PRINTLN("7-Segement LED Matrix Initialized Successfully!");
884-
} else if (strcmp("oled128x64wingdefault",
885-
msgDeviceInitReq->i2c_device_name) == 0 ||
886-
strcmp("oled128x64winglarge", msgDeviceInitReq->i2c_device_name) ==
884+
} else if (strcmp("oled128x64wdefault", msgDeviceInitReq->i2c_device_name) == 0 ||
885+
strcmp("oled128x64wlarge", msgDeviceInitReq->i2c_device_name) ==
887886
0) {
888887
WS_DEBUG_PRINTLN("SH1107 display detected!");
889888
_sh1107 = new WipperSnapper_I2C_Driver_Out_SH1107(this->_i2c, i2cAddress);
@@ -893,8 +892,8 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
893892
(uint8_t)msgDeviceInitReq->i2c_output_add.config.ssd1306_config.height,
894893
(uint8_t)
895894
msgDeviceInitReq->i2c_output_add.config.ssd1306_config.text_size,
896-
90); // fixed as currently the only screen is 128x64 featherwing which
897-
// needs a rotation of 1 / 90degrees, and constructor w/h swap.
895+
OLED_128X64_WING_ROTATION_90); // fixed as currently the only screen is
896+
// 128x64wing (needs a rotation of 1 / 90degrees and constructor w/h swap).
898897
if (!_sh1107->begin()) {
899898
WS_DEBUG_PRINTLN("ERROR: Failed to initialize sh1107!");
900899
_busStatusResponse =
@@ -908,9 +907,9 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
908907
strcmp("oled64x32default", msgDeviceInitReq->i2c_device_name) ==
909908
0 ||
910909
strcmp("oled64x32large", msgDeviceInitReq->i2c_device_name) == 0 ||
911-
strcmp("oled128x32wingdefault",
912-
msgDeviceInitReq->i2c_device_name) == 0 ||
913-
strcmp("oled128x32winglarge", msgDeviceInitReq->i2c_device_name) ==
910+
strcmp("oled128x32wdefault", msgDeviceInitReq->i2c_device_name) ==
911+
0 ||
912+
strcmp("oled128x32wlarge", msgDeviceInitReq->i2c_device_name) ==
914913
0 ||
915914
strcmp("oled128x32default", msgDeviceInitReq->i2c_device_name) ==
916915
0 ||
@@ -927,8 +926,7 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
927926
(uint8_t)msgDeviceInitReq->i2c_output_add.config.ssd1306_config.width,
928927
(uint8_t)msgDeviceInitReq->i2c_output_add.config.ssd1306_config.height,
929928
(uint8_t)
930-
msgDeviceInitReq->i2c_output_add.config.ssd1306_config.text_size,
931-
0); // TODO: add rotation to protobuf and IO UI for adapted max len
929+
msgDeviceInitReq->i2c_output_add.config.ssd1306_config.text_size);
932930
if (!_ssd1306->begin()) {
933931
WS_DEBUG_PRINTLN("ERROR: Failed to initialize ssd1306!");
934932
_busStatusResponse =

src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_Sh1107.h

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* please support Adafruit and open-source hardware by purchasing
88
* products from Adafruit!
99
*
10-
* Copyright (c) Brent Rubell for Adafruit Industries 2025
10+
* Copyright (c) Tyeth Gundry for Adafruit Industries 2025
1111
*
1212
* MIT license, all text here must be included in any redistribution.
1313
*
@@ -17,13 +17,16 @@
1717
#define WIPPERSNAPPER_I2C_DRIVER_OUT_SH1107_H
1818

1919
#include "WipperSnapper_I2C_Driver_Out.h"
20-
// #include <Adafruit_GrayOLED.h>
2120
#include <Adafruit_GFX.h>
2221
#include <Adafruit_SH110X.h>
2322
#include <Arduino.h>
2423

25-
#define DEFAULT_WIDTH 128 ///< Default width for a sh1107 128x64 display
26-
#define DEFAULT_HEIGHT 64 ///< Default height for a sh1107 128x64 display
24+
#define WS_SH1107_DEFAULT_WIDTH 128 ///< Default width for a sh1107 128x64 display
25+
#define WS_SH1107_DEFAULT_HEIGHT 64 ///< Default height for a sh1107 128x64 display
26+
27+
#define OLED_128X64_WING_WIDTH 128 ///< Width of the 128x64 OLED FeatherWing
28+
#define OLED_128X64_WING_HEIGHT 64 ///< Height of the 128x64 OLED FeatherWing
29+
#define OLED_128X64_WING_ROTATION_90 1 ///< Rotation of OLED FeatherWing 0-3
2730

2831
/*!
2932
@brief Class that provides a driver interface for a SH1107
@@ -35,7 +38,7 @@ class WipperSnapper_I2C_Driver_Out_SH1107
3538
public:
3639
/*******************************************************************************/
3740
/*!
38-
@brief Constructor for a OLED display.
41+
@brief Constructor for an SH1107 OLED display.
3942
@param i2c
4043
The I2C interface.
4144
@param sensorAddress
@@ -46,8 +49,8 @@ class WipperSnapper_I2C_Driver_Out_SH1107
4649
: WipperSnapper_I2C_Driver_Out(i2c, sensorAddress) {
4750
_i2c = i2c;
4851
_sensorAddress = sensorAddress;
49-
_width = DEFAULT_WIDTH;
50-
_height = DEFAULT_HEIGHT;
52+
_width = WS_SH1107_DEFAULT_WIDTH;
53+
_height = WS_SH1107_DEFAULT_HEIGHT;
5154
}
5255

5356
/*!
@@ -68,8 +71,10 @@ class WipperSnapper_I2C_Driver_Out_SH1107
6871
@returns True if initialized successfully, False otherwise.
6972
*/
7073
bool begin() {
71-
if (_width == 128 && _height == 64 && _rotation == 1) {
72-
// featherwing needs to be rotated 90 degrees and swap w/h
74+
if (_width == OLED_128X64_WING_WIDTH &&
75+
_height == OLED_128X64_WING_HEIGHT &&
76+
_rotation == OLED_128X64_WING_ROTATION_90) {
77+
// featherwing needs to be rotated 90 degrees and swap w/h ctor args
7378
_display = new Adafruit_SH1107(_height, _width, _i2c);
7479
} else {
7580
_display = new Adafruit_SH1107(_width, _height, _i2c);
@@ -92,15 +97,9 @@ class WipperSnapper_I2C_Driver_Out_SH1107
9297
_display->setTextSize(_text_sz);
9398
_display->setTextColor(SH110X_WHITE);
9499
_display->setCursor(0, 0);
95-
// Use full 256 char 'Code Page 437' font
96-
// _display->cp437(true);
97100
// Clear the buffer
98101
_display->clearDisplay();
99102
_display->display();
100-
_display->print(char('a'));
101-
delay(500);
102-
_display->write(char('b'));
103-
_display->display();
104103
return true;
105104
}
106105

@@ -121,9 +120,7 @@ class WipperSnapper_I2C_Driver_Out_SH1107
121120
_width = width;
122121
_height = height;
123122
_text_sz = text_size;
124-
_rotation = rotation % 90;
125-
WS_DEBUG_PRINT("SH1107 text size: ");
126-
WS_DEBUG_PRINTLN(text_size);
123+
_rotation = rotation % 90; // SH1107 requires rotation to be 0-3, not degrees
127124
}
128125
/*!
129126
@brief Configures a SSD1306 OLED display. Must be called before driver
@@ -151,8 +148,6 @@ class WipperSnapper_I2C_Driver_Out_SH1107
151148
void WriteMessageSH1107(const char *message) {
152149
if (_display == nullptr)
153150
return;
154-
WS_DEBUG_PRINT("SH1107 Message:");
155-
WS_DEBUG_PRINTLN(message);
156151
// Start with a fresh display buffer
157152
// and settings
158153
int16_t y_idx = 0;
@@ -175,15 +170,11 @@ class WipperSnapper_I2C_Driver_Out_SH1107
175170
message[i + 2] == '\\' && message[i + 3] == 'n') {
176171
// Skip to the next line
177172
y_idx += line_height;
178-
WS_DEBUG_PRINT("SH1107 Newline at: ");
179-
WS_DEBUG_PRINTLN(y_idx);
180173
_display->setCursor(0, y_idx);
181174
i += 3;
182175
} else if (message[i + 1] == 'n') {
183176
// Skip to the next line
184177
y_idx += line_height;
185-
WS_DEBUG_PRINT("SH1107 Newline at: ");
186-
WS_DEBUG_PRINTLN(y_idx);
187178
_display->setCursor(0, y_idx);
188179
i++;
189180
}

src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_Ssd1306.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include <Adafruit_SSD1306.h>
2121
#include <Arduino.h>
2222

23-
#define DEFAULT_WIDTH 128 ///< Default width for a ssd1306 128x64 display
24-
#define DEFAULT_HEIGHT 64 ///< Default height for a ssd1306 128x64 display
23+
#define WS_SSD1306_DEFAULT_WIDTH 128 ///< Default width for a ssd1306 128x64 display
24+
#define WS_SSD1306_DEFAULT_HEIGHT 64 ///< Default height for a ssd1306 128x64 display
2525

2626
/*!
2727
@brief Class that provides a driver interface for a SSD1306
@@ -44,19 +44,17 @@ class WipperSnapper_I2C_Driver_Out_Ssd1306
4444
: WipperSnapper_I2C_Driver_Out(i2c, sensorAddress) {
4545
_i2c = i2c;
4646
_sensorAddress = sensorAddress;
47-
_width = DEFAULT_WIDTH;
48-
_height = DEFAULT_HEIGHT;
47+
_width = WS_SSD1306_DEFAULT_WIDTH;
48+
_height = WS_SSD1306_DEFAULT_HEIGHT;
4949
}
5050

5151
/*!
5252
@brief Destructor for a SSD1306 OLED display.
5353
*/
5454
~WipperSnapper_I2C_Driver_Out_Ssd1306() {
5555
if (_display != nullptr) {
56-
WS_DEBUG_PRINTLN("SSD1306 Destructor called, clearing display buffer.");
5756
_display->clearDisplay();
5857
_display->display();
59-
WS_DEBUG_PRINTLN("SSD1306 display cleared, turning off display.");
6058
_display->ssd1306_command(SSD1306_DISPLAYOFF);
6159
delete _display;
6260
_display = nullptr;
@@ -102,8 +100,6 @@ class WipperSnapper_I2C_Driver_Out_Ssd1306
102100
_height = height;
103101
_text_sz = text_size;
104102
_rotation = rotation;
105-
WS_DEBUG_PRINT("SSD1306 text size: ");
106-
WS_DEBUG_PRINTLN(text_size);
107103
}
108104

109105
/*!
@@ -115,9 +111,6 @@ class WipperSnapper_I2C_Driver_Out_Ssd1306
115111
if (_display == nullptr)
116112
return;
117113

118-
WS_DEBUG_PRINT("SSD1306 Message:");
119-
WS_DEBUG_PRINTLN(message);
120-
121114
// Start with a fresh display buffer
122115
// and settings
123116
int16_t y_idx = 0;

0 commit comments

Comments
 (0)