Add 128x32 OLED featherwings as SSD1306

This commit is contained in:
Tyeth Gundry 2025-06-19 16:41:40 +01:00 committed by tyeth
parent ab3284ecb1
commit cdc6588e57
5 changed files with 145 additions and 17 deletions

View file

@ -5,6 +5,11 @@ name: WipperSnapper Build CI
on:
workflow_dispatch:
inputs:
board:
description: 'Build ONLY this board (must match a matrix entry exactly, or leave empty for all)'
required: false
default: ''
pull_request:
workflow_call:
secrets:
@ -15,6 +20,7 @@ jobs:
build-esp32sx-esptool:
name: 🏗ESP32-Sx(lvgl)
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
@ -22,6 +28,13 @@ jobs:
include:
- offset: "0x1000"
steps:
- name: "skip if unwanted"
if: |
github.event_name == 'workflow_dispatch' &&
github.event.inputs.board != '' &&
matrix.arduino-platform != github.event.inputs.board
run: |
echo "don't build this one!"; exit 1
- uses: actions/setup-python@v5
with:
python-version: "3.x"
@ -174,6 +187,7 @@ jobs:
build-esp32sx:
name: 🏗ESP32-Sx
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
@ -194,6 +208,13 @@ jobs:
"qtpy_esp32s3_n4r2",
]
steps:
- name: "skip if unwanted"
if: |
github.event_name == 'workflow_dispatch' &&
github.event.inputs.board != '' &&
matrix.arduino-platform != github.event.inputs.board
run: |
echo "don't build this one!"; exit 1
- uses: actions/setup-python@v5
with:
python-version: "3.x"
@ -278,6 +299,7 @@ jobs:
build-esp32:
name: 🏗ESP32/Cx
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
@ -299,6 +321,13 @@ jobs:
- offset: "0x0"
arduino-platform: "wippersnapper_feather_esp32c6"
steps:
- name: "skip if unwanted"
if: |
github.event_name == 'workflow_dispatch' &&
github.event.inputs.board != '' &&
matrix.arduino-platform != github.event.inputs.board
run: |
echo "don't build this one!"; exit 1
- uses: actions/setup-python@v5
with:
python-version: "3.x"
@ -419,6 +448,7 @@ jobs:
build-samd:
name: 🏗SAMD
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
@ -429,6 +459,13 @@ jobs:
"metro_m4_airliftlite_tinyusb",
]
steps:
- name: "skip if unwanted"
if: |
github.event_name == 'workflow_dispatch' &&
github.event.inputs.board != '' &&
matrix.arduino-platform != github.event.inputs.board
run: |
echo "don't build this one!"; exit 1
- uses: actions/setup-python@v5
with:
python-version: "3.x"
@ -498,11 +535,19 @@ jobs:
build-rp2040:
name: 🏗RP2040
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
arduino-platform: ["picow_rp2040_tinyusb", "picow_rp2350_tinyusb"]
steps:
- name: "skip if unwanted"
if: |
github.event_name == 'workflow_dispatch' &&
github.event.inputs.board != '' &&
matrix.arduino-platform != github.event.inputs.board
run: |
echo "don't build this one!"; exit 1
- uses: actions/setup-python@v5
with:
python-version: "3.x"
@ -569,11 +614,19 @@ jobs:
build-esp8266:
name: 🏗ESP8266
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
arduino-platform: ["feather_esp8266"]
steps:
- name: "skip if unwanted"
if: |
github.event_name == 'workflow_dispatch' &&
github.event.inputs.board != '' &&
matrix.arduino-platform != github.event.inputs.board
run: |
echo "don't build this one!"; exit 1
- uses: actions/setup-python@v5
with:
python-version: "3.x"
@ -647,6 +700,7 @@ jobs:
build-esp32sx-dev:
name: 🏗ESP32-Sx(DEV)
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
@ -662,6 +716,13 @@ jobs:
"metro_esp32s3_debug",
]
steps:
- name: "skip if unwanted"
if: |
github.event_name == 'workflow_dispatch' &&
github.event.inputs.board != '' &&
matrix.arduino-platform != github.event.inputs.board
run: |
echo "don't build this one!"; exit 1
- uses: actions/setup-python@v5
with:
python-version: "3.x"
@ -746,6 +807,7 @@ jobs:
build-esp32-dev:
name: 🏗ESP32/Cx(DEV)
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
@ -758,6 +820,13 @@ jobs:
- offset: "0x0"
arduino-platform: "wippersnapper_feather_esp32c6_debug"
steps:
- name: "skip if unwanted"
if: |
github.event_name == 'workflow_dispatch' &&
github.event.inputs.board != '' &&
matrix.arduino-platform != github.event.inputs.board
run: |
echo "don't build this one!"; exit 1
- uses: actions/setup-python@v5
with:
python-version: "3.x"

View file

@ -881,12 +881,8 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
}
_drivers_out.push_back(_sevenSeg);
WS_DEBUG_PRINTLN("7-Segement LED Matrix Initialized Successfully!");
} else if (strcmp("oled128x32wingdefault", msgDeviceInitReq->i2c_device_name) ==
0 ||
strcmp("oled128x32winglarge", msgDeviceInitReq->i2c_device_name) ==
0 ||
strcmp("oled128x64wingdefault", msgDeviceInitReq->i2c_device_name) ==
0 ||
} else if (strcmp("oled128x64wingdefault",
msgDeviceInitReq->i2c_device_name) == 0 ||
strcmp("oled128x64winglarge", msgDeviceInitReq->i2c_device_name) ==
0) {
WS_DEBUG_PRINTLN("SH1107 display detected!");
@ -906,7 +902,11 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
WS_DEBUG_PRINTLN("SH1107 display configured successfully!");
_drivers_out.push_back(_sh1107);
WS_DEBUG_PRINTLN("SH1107 display initialized Successfully!");
} else if (strcmp("oled128x32default", msgDeviceInitReq->i2c_device_name) ==
} else if (strcmp("oled128x32wingdefault",
msgDeviceInitReq->i2c_device_name) == 0 ||
strcmp("oled128x32winglarge", msgDeviceInitReq->i2c_device_name) ==
0 ||
strcmp("oled128x32default", msgDeviceInitReq->i2c_device_name) ==
0 ||
strcmp("oled128x32large", msgDeviceInitReq->i2c_device_name) ==
0 ||

View file

@ -205,6 +205,7 @@ private:
WipperSnapper_I2C_Driver_Out_QuadAlphaNum *_quadAlphaNum = nullptr;
WipperSnapper_I2C_Driver_Out_CharLcd *_charLcd = nullptr;
WipperSnapper_I2C_Driver_Out_7Seg *_sevenSeg = nullptr;
WipperSnapper_I2C_Driver_Out_SH1107 *_sh1107 = nullptr;
WipperSnapper_I2C_Driver_Out_Ssd1306 *_ssd1306 = nullptr;
};
extern Wippersnapper WS;

View file

@ -17,7 +17,9 @@
#define WIPPERSNAPPER_I2C_DRIVER_OUT_SH1107_H
#include "WipperSnapper_I2C_Driver_Out.h"
#include <Adafruit_SH110x.h>
// #include <Adafruit_GrayOLED.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
#include <Arduino.h>
#define DEFAULT_WIDTH 128 ///< Default width for a sh1107 128x64 display
@ -33,7 +35,7 @@ class WipperSnapper_I2C_Driver_Out_SH1107
public:
/*******************************************************************************/
/*!
@brief Constructor for a SH1107 OLED display.
@brief Constructor for a OLED display.
@param i2c
The I2C interface.
@param sensorAddress
@ -55,7 +57,7 @@ public:
if (_display != nullptr) {
_display->clearDisplay();
_display->display();
_display->sh1107_command(SH1107_DISPLAYOFF);
_display->oled_command(SH110X_DISPLAYOFF);
delete _display;
_display = nullptr;
}
@ -66,18 +68,35 @@ public:
@returns True if initialized successfully, False otherwise.
*/
bool begin() {
// Attempt to create and allocate a SH1107 obj.
_display = new Adafruit_SH1107(_width, _height, _i2c);
// Attempt to create and allocate a SH1107 obj, backwards w/h
_display = new Adafruit_SH1107(_height, _width, _i2c);
if (!_display->begin(_sensorAddress, true))
return false;
// Show image buffer on the display hardware.
// Since the buffer is intialized with an Adafruit splashscreen
// internally, this will display the splashscreen.
_display->display();
delay(1700);
// Clear the buffer.
_display->clearDisplay();
_display->display();
_display->setRotation(1);
// Configure the text size and color
_display->setTextSize(_text_sz);
_display->setTextColor(SH1107_WHITE);
_display->setTextColor(SH110X_WHITE);
_display->setCursor(0, 0);
// Use full 256 char 'Code Page 437' font
_display->cp437(true);
// _display->cp437(true);
// Clear the buffer
_display->clearDisplay();
_display->display();
_display->print(char('a'));
delay(500);
_display->write(char('b'));
_display->display();
return true;
}
@ -95,7 +114,25 @@ public:
_width = width;
_height = height;
_text_sz = text_size;
WS_DEBUG_PRINT("SH1107 text size: ");
WS_DEBUG_PRINTLN(text_size);
}
/*!
@brief Configures a SSD1306 OLED display. Must be called before driver
begin() - This is a fake function to match the SSD1306 interface.
@param width
The width of the display in pixels.
@param height
The height of the display in pixels.
@param text_size
The magnification factor for the text size.
*/
void ConfigureSSD1306(uint8_t width, uint8_t height,
uint8_t text_size) {
// This is a SH1107, not a SSD1306, so we don't need to do anything here.
ConfigureSH1107(width, height, text_size);
}
/*!
@brief Writes a message to the SH1107 display.
@ -105,13 +142,14 @@ public:
void WriteMessageSH1107(const char *message) {
if (_display == nullptr)
return;
WS_DEBUG_PRINT("SH1107 Message:");
WS_DEBUG_PRINTLN(message);
// Start with a fresh display buffer
// and settings
int16_t y_idx = 0;
_display->clearDisplay();
_display->setTextSize(_text_sz);
_display->setTextColor(SH1107_WHITE);
_display->setTextColor(SH110X_WHITE);
_display->setCursor(0, y_idx);
_display->display();
@ -128,11 +166,15 @@ public:
message[i + 2] == '\\' && message[i + 3] == 'n') {
// Skip to the next line
y_idx += line_height;
WS_DEBUG_PRINT("SH1107 Newline at: ");
WS_DEBUG_PRINTLN(y_idx);
_display->setCursor(0, y_idx);
i += 3;
} else if (message[i + 1] == 'n') {
// Skip to the next line
y_idx += line_height;
WS_DEBUG_PRINT("SH1107 Newline at: ");
WS_DEBUG_PRINTLN(y_idx);
_display->setCursor(0, y_idx);
i++;
}
@ -147,6 +189,17 @@ public:
}
}
/*!
@brief Writes a message to the fake "SSD1306" SH1107 display.
@param msg_write
Pointer to a wippersnapper_i2c_v1_SSD1306Write message.
*/
void WriteMessageSSD1306(const char *message) {
// This is a SH1107, not a SSD1306, so we just call the SH1107 write
WriteMessageSH1107(message);
}
protected:
Adafruit_SH1107 *_display =
nullptr; ///< Pointer to the Adafruit_SH1107 object
@ -155,4 +208,4 @@ protected:
uint8_t _text_sz; ///< Text size of the display
};
#endif // WIPPERSNAPPER_I2C_DRIVER_OUT_SH1107_H
#endif // WIPPERSNAPPER_I2C_DRIVER_OUT_SH1107_H

View file

@ -95,6 +95,8 @@ public:
_width = width;
_height = height;
_text_sz = text_size;
WS_DEBUG_PRINT("SSD1306 text size: ");
WS_DEBUG_PRINTLN(text_size);
}
/*!
@ -106,6 +108,9 @@ public:
if (_display == nullptr)
return;
WS_DEBUG_PRINT("SSD1306 Message:");
WS_DEBUG_PRINTLN(message);
// Start with a fresh display buffer
// and settings
int16_t y_idx = 0;