Skip to content

Commit cdc6588

Browse files
committed
Add 128x32 OLED featherwings as SSD1306
1 parent ab3284e commit cdc6588

File tree

5 files changed

+145
-17
lines changed

5 files changed

+145
-17
lines changed

.github/workflows/build-clang-doxy.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ name: WipperSnapper Build CI
55

66
on:
77
workflow_dispatch:
8+
inputs:
9+
board:
10+
description: 'Build ONLY this board (must match a matrix entry exactly, or leave empty for all)'
11+
required: false
12+
default: ''
813
pull_request:
914
workflow_call:
1015
secrets:
@@ -15,13 +20,21 @@ jobs:
1520
build-esp32sx-esptool:
1621
name: 🏗️ESP32-Sx(lvgl)
1722
runs-on: ubuntu-latest
23+
continue-on-error: true
1824
strategy:
1925
fail-fast: false
2026
matrix:
2127
arduino-platform: ["funhouse_noota"]
2228
include:
2329
- offset: "0x1000"
2430
steps:
31+
- name: "skip if unwanted"
32+
if: |
33+
github.event_name == 'workflow_dispatch' &&
34+
github.event.inputs.board != '' &&
35+
matrix.arduino-platform != github.event.inputs.board
36+
run: |
37+
echo "don't build this one!"; exit 1
2538
- uses: actions/setup-python@v5
2639
with:
2740
python-version: "3.x"
@@ -174,6 +187,7 @@ jobs:
174187
build-esp32sx:
175188
name: 🏗️ESP32-Sx
176189
runs-on: ubuntu-latest
190+
continue-on-error: true
177191
strategy:
178192
fail-fast: false
179193
matrix:
@@ -194,6 +208,13 @@ jobs:
194208
"qtpy_esp32s3_n4r2",
195209
]
196210
steps:
211+
- name: "skip if unwanted"
212+
if: |
213+
github.event_name == 'workflow_dispatch' &&
214+
github.event.inputs.board != '' &&
215+
matrix.arduino-platform != github.event.inputs.board
216+
run: |
217+
echo "don't build this one!"; exit 1
197218
- uses: actions/setup-python@v5
198219
with:
199220
python-version: "3.x"
@@ -278,6 +299,7 @@ jobs:
278299
build-esp32:
279300
name: 🏗️ESP32/Cx
280301
runs-on: ubuntu-latest
302+
continue-on-error: true
281303
strategy:
282304
fail-fast: false
283305
matrix:
@@ -299,6 +321,13 @@ jobs:
299321
- offset: "0x0"
300322
arduino-platform: "wippersnapper_feather_esp32c6"
301323
steps:
324+
- name: "skip if unwanted"
325+
if: |
326+
github.event_name == 'workflow_dispatch' &&
327+
github.event.inputs.board != '' &&
328+
matrix.arduino-platform != github.event.inputs.board
329+
run: |
330+
echo "don't build this one!"; exit 1
302331
- uses: actions/setup-python@v5
303332
with:
304333
python-version: "3.x"
@@ -419,6 +448,7 @@ jobs:
419448
build-samd:
420449
name: 🏗️SAMD
421450
runs-on: ubuntu-latest
451+
continue-on-error: true
422452
strategy:
423453
fail-fast: false
424454
matrix:
@@ -429,6 +459,13 @@ jobs:
429459
"metro_m4_airliftlite_tinyusb",
430460
]
431461
steps:
462+
- name: "skip if unwanted"
463+
if: |
464+
github.event_name == 'workflow_dispatch' &&
465+
github.event.inputs.board != '' &&
466+
matrix.arduino-platform != github.event.inputs.board
467+
run: |
468+
echo "don't build this one!"; exit 1
432469
- uses: actions/setup-python@v5
433470
with:
434471
python-version: "3.x"
@@ -498,11 +535,19 @@ jobs:
498535
build-rp2040:
499536
name: 🏗️RP2040
500537
runs-on: ubuntu-latest
538+
continue-on-error: true
501539
strategy:
502540
fail-fast: false
503541
matrix:
504542
arduino-platform: ["picow_rp2040_tinyusb", "picow_rp2350_tinyusb"]
505543
steps:
544+
- name: "skip if unwanted"
545+
if: |
546+
github.event_name == 'workflow_dispatch' &&
547+
github.event.inputs.board != '' &&
548+
matrix.arduino-platform != github.event.inputs.board
549+
run: |
550+
echo "don't build this one!"; exit 1
506551
- uses: actions/setup-python@v5
507552
with:
508553
python-version: "3.x"
@@ -569,11 +614,19 @@ jobs:
569614
build-esp8266:
570615
name: 🏗️ESP8266
571616
runs-on: ubuntu-latest
617+
continue-on-error: true
572618
strategy:
573619
fail-fast: false
574620
matrix:
575621
arduino-platform: ["feather_esp8266"]
576622
steps:
623+
- name: "skip if unwanted"
624+
if: |
625+
github.event_name == 'workflow_dispatch' &&
626+
github.event.inputs.board != '' &&
627+
matrix.arduino-platform != github.event.inputs.board
628+
run: |
629+
echo "don't build this one!"; exit 1
577630
- uses: actions/setup-python@v5
578631
with:
579632
python-version: "3.x"
@@ -647,6 +700,7 @@ jobs:
647700
build-esp32sx-dev:
648701
name: 🏗️ESP32-Sx(DEV)
649702
runs-on: ubuntu-latest
703+
continue-on-error: true
650704
strategy:
651705
fail-fast: false
652706
matrix:
@@ -662,6 +716,13 @@ jobs:
662716
"metro_esp32s3_debug",
663717
]
664718
steps:
719+
- name: "skip if unwanted"
720+
if: |
721+
github.event_name == 'workflow_dispatch' &&
722+
github.event.inputs.board != '' &&
723+
matrix.arduino-platform != github.event.inputs.board
724+
run: |
725+
echo "don't build this one!"; exit 1
665726
- uses: actions/setup-python@v5
666727
with:
667728
python-version: "3.x"
@@ -746,6 +807,7 @@ jobs:
746807
build-esp32-dev:
747808
name: 🏗️ESP32/Cx(DEV)
748809
runs-on: ubuntu-latest
810+
continue-on-error: true
749811
strategy:
750812
fail-fast: false
751813
matrix:
@@ -758,6 +820,13 @@ jobs:
758820
- offset: "0x0"
759821
arduino-platform: "wippersnapper_feather_esp32c6_debug"
760822
steps:
823+
- name: "skip if unwanted"
824+
if: |
825+
github.event_name == 'workflow_dispatch' &&
826+
github.event.inputs.board != '' &&
827+
matrix.arduino-platform != github.event.inputs.board
828+
run: |
829+
echo "don't build this one!"; exit 1
761830
- uses: actions/setup-python@v5
762831
with:
763832
python-version: "3.x"

src/components/i2c/WipperSnapper_I2C.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -881,12 +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("oled128x32wingdefault", msgDeviceInitReq->i2c_device_name) ==
885-
0 ||
886-
strcmp("oled128x32winglarge", msgDeviceInitReq->i2c_device_name) ==
887-
0 ||
888-
strcmp("oled128x64wingdefault", msgDeviceInitReq->i2c_device_name) ==
889-
0 ||
884+
} else if (strcmp("oled128x64wingdefault",
885+
msgDeviceInitReq->i2c_device_name) == 0 ||
890886
strcmp("oled128x64winglarge", msgDeviceInitReq->i2c_device_name) ==
891887
0) {
892888
WS_DEBUG_PRINTLN("SH1107 display detected!");
@@ -906,7 +902,11 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
906902
WS_DEBUG_PRINTLN("SH1107 display configured successfully!");
907903
_drivers_out.push_back(_sh1107);
908904
WS_DEBUG_PRINTLN("SH1107 display initialized Successfully!");
909-
} else if (strcmp("oled128x32default", msgDeviceInitReq->i2c_device_name) ==
905+
} else if (strcmp("oled128x32wingdefault",
906+
msgDeviceInitReq->i2c_device_name) == 0 ||
907+
strcmp("oled128x32winglarge", msgDeviceInitReq->i2c_device_name) ==
908+
0 ||
909+
strcmp("oled128x32default", msgDeviceInitReq->i2c_device_name) ==
910910
0 ||
911911
strcmp("oled128x32large", msgDeviceInitReq->i2c_device_name) ==
912912
0 ||

src/components/i2c/WipperSnapper_I2C.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ class WipperSnapper_Component_I2C {
205205
WipperSnapper_I2C_Driver_Out_QuadAlphaNum *_quadAlphaNum = nullptr;
206206
WipperSnapper_I2C_Driver_Out_CharLcd *_charLcd = nullptr;
207207
WipperSnapper_I2C_Driver_Out_7Seg *_sevenSeg = nullptr;
208+
WipperSnapper_I2C_Driver_Out_SH1107 *_sh1107 = nullptr;
208209
WipperSnapper_I2C_Driver_Out_Ssd1306 *_ssd1306 = nullptr;
209210
};
210211
extern Wippersnapper WS;

src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_Sh1107.h

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
#define WIPPERSNAPPER_I2C_DRIVER_OUT_SH1107_H
1818

1919
#include "WipperSnapper_I2C_Driver_Out.h"
20-
#include <Adafruit_SH110x.h>
20+
// #include <Adafruit_GrayOLED.h>
21+
#include <Adafruit_GFX.h>
22+
#include <Adafruit_SH110X.h>
2123
#include <Arduino.h>
2224

2325
#define DEFAULT_WIDTH 128 ///< Default width for a sh1107 128x64 display
@@ -33,7 +35,7 @@ class WipperSnapper_I2C_Driver_Out_SH1107
3335
public:
3436
/*******************************************************************************/
3537
/*!
36-
@brief Constructor for a SH1107 OLED display.
38+
@brief Constructor for a OLED display.
3739
@param i2c
3840
The I2C interface.
3941
@param sensorAddress
@@ -55,7 +57,7 @@ class WipperSnapper_I2C_Driver_Out_SH1107
5557
if (_display != nullptr) {
5658
_display->clearDisplay();
5759
_display->display();
58-
_display->sh1107_command(SH1107_DISPLAYOFF);
60+
_display->oled_command(SH110X_DISPLAYOFF);
5961
delete _display;
6062
_display = nullptr;
6163
}
@@ -66,18 +68,35 @@ class WipperSnapper_I2C_Driver_Out_SH1107
6668
@returns True if initialized successfully, False otherwise.
6769
*/
6870
bool begin() {
69-
// Attempt to create and allocate a SH1107 obj.
70-
_display = new Adafruit_SH1107(_width, _height, _i2c);
71+
// Attempt to create and allocate a SH1107 obj, backwards w/h
72+
_display = new Adafruit_SH1107(_height, _width, _i2c);
7173
if (!_display->begin(_sensorAddress, true))
7274
return false;
75+
76+
// Show image buffer on the display hardware.
77+
// Since the buffer is intialized with an Adafruit splashscreen
78+
// internally, this will display the splashscreen.
79+
_display->display();
80+
delay(1700);
81+
82+
// Clear the buffer.
83+
_display->clearDisplay();
84+
_display->display();
85+
_display->setRotation(1);
86+
7387
// Configure the text size and color
7488
_display->setTextSize(_text_sz);
75-
_display->setTextColor(SH1107_WHITE);
89+
_display->setTextColor(SH110X_WHITE);
90+
_display->setCursor(0, 0);
7691
// Use full 256 char 'Code Page 437' font
77-
_display->cp437(true);
92+
// _display->cp437(true);
7893
// Clear the buffer
7994
_display->clearDisplay();
8095
_display->display();
96+
_display->print(char('a'));
97+
delay(500);
98+
_display->write(char('b'));
99+
_display->display();
81100
return true;
82101
}
83102

@@ -95,7 +114,25 @@ class WipperSnapper_I2C_Driver_Out_SH1107
95114
_width = width;
96115
_height = height;
97116
_text_sz = text_size;
117+
WS_DEBUG_PRINT("SH1107 text size: ");
118+
WS_DEBUG_PRINTLN(text_size);
98119
}
120+
/*!
121+
@brief Configures a SSD1306 OLED display. Must be called before driver
122+
begin() - This is a fake function to match the SSD1306 interface.
123+
@param width
124+
The width of the display in pixels.
125+
@param height
126+
The height of the display in pixels.
127+
@param text_size
128+
The magnification factor for the text size.
129+
*/
130+
void ConfigureSSD1306(uint8_t width, uint8_t height,
131+
uint8_t text_size) {
132+
// This is a SH1107, not a SSD1306, so we don't need to do anything here.
133+
ConfigureSH1107(width, height, text_size);
134+
}
135+
99136

100137
/*!
101138
@brief Writes a message to the SH1107 display.
@@ -105,13 +142,14 @@ class WipperSnapper_I2C_Driver_Out_SH1107
105142
void WriteMessageSH1107(const char *message) {
106143
if (_display == nullptr)
107144
return;
108-
145+
WS_DEBUG_PRINT("SH1107 Message:");
146+
WS_DEBUG_PRINTLN(message);
109147
// Start with a fresh display buffer
110148
// and settings
111149
int16_t y_idx = 0;
112150
_display->clearDisplay();
113151
_display->setTextSize(_text_sz);
114-
_display->setTextColor(SH1107_WHITE);
152+
_display->setTextColor(SH110X_WHITE);
115153
_display->setCursor(0, y_idx);
116154
_display->display();
117155

@@ -128,11 +166,15 @@ class WipperSnapper_I2C_Driver_Out_SH1107
128166
message[i + 2] == '\\' && message[i + 3] == 'n') {
129167
// Skip to the next line
130168
y_idx += line_height;
169+
WS_DEBUG_PRINT("SH1107 Newline at: ");
170+
WS_DEBUG_PRINTLN(y_idx);
131171
_display->setCursor(0, y_idx);
132172
i += 3;
133173
} else if (message[i + 1] == 'n') {
134174
// Skip to the next line
135175
y_idx += line_height;
176+
WS_DEBUG_PRINT("SH1107 Newline at: ");
177+
WS_DEBUG_PRINTLN(y_idx);
136178
_display->setCursor(0, y_idx);
137179
i++;
138180
}
@@ -147,6 +189,17 @@ class WipperSnapper_I2C_Driver_Out_SH1107
147189
}
148190
}
149191

192+
193+
/*!
194+
@brief Writes a message to the fake "SSD1306" SH1107 display.
195+
@param msg_write
196+
Pointer to a wippersnapper_i2c_v1_SSD1306Write message.
197+
*/
198+
void WriteMessageSSD1306(const char *message) {
199+
// This is a SH1107, not a SSD1306, so we just call the SH1107 write
200+
WriteMessageSH1107(message);
201+
}
202+
150203
protected:
151204
Adafruit_SH1107 *_display =
152205
nullptr; ///< Pointer to the Adafruit_SH1107 object
@@ -155,4 +208,4 @@ class WipperSnapper_I2C_Driver_Out_SH1107
155208
uint8_t _text_sz; ///< Text size of the display
156209
};
157210

158-
#endif // WIPPERSNAPPER_I2C_DRIVER_OUT_SH1107_H
211+
#endif // WIPPERSNAPPER_I2C_DRIVER_OUT_SH1107_H

src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_Ssd1306.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ class WipperSnapper_I2C_Driver_Out_Ssd1306
9595
_width = width;
9696
_height = height;
9797
_text_sz = text_size;
98+
WS_DEBUG_PRINT("SSD1306 text size: ");
99+
WS_DEBUG_PRINTLN(text_size);
98100
}
99101

100102
/*!
@@ -106,6 +108,9 @@ class WipperSnapper_I2C_Driver_Out_Ssd1306
106108
if (_display == nullptr)
107109
return;
108110

111+
WS_DEBUG_PRINT("SSD1306 Message:");
112+
WS_DEBUG_PRINTLN(message);
113+
109114
// Start with a fresh display buffer
110115
// and settings
111116
int16_t y_idx = 0;

0 commit comments

Comments
 (0)