Merge remote-tracking branch 'upstream/main' into omron-D6T

This commit is contained in:
Tyeth Gundry 2025-07-11 13:28:12 +01:00
commit 999bd73547
17 changed files with 392 additions and 28 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,13 +20,27 @@ jobs:
build-esp32sx-esptool:
name: 🏗ESP32-Sx(lvgl)
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
arduino-platform: ["funhouse_noota"]
arduino-platform:
[
"funhouse_noota",
"esp32s3_devkitc_1_n8"
]
include:
- offset: "0x0"
- offset: "0x1000"
arduino-platform: "funhouse_noota"
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"
@ -105,6 +124,7 @@ jobs:
mv examples/Wippersnapper_demo/build/*/Wippersnapper_demo.ino.elf wippersnapper.${{ matrix.arduino-platform }}.fatfs.${{ env.WS_VERSION }}.elf
mv examples/Wippersnapper_demo/build/*/Wippersnapper_demo.ino.map wippersnapper.${{ matrix.arduino-platform }}.fatfs.${{ env.WS_VERSION }}.map
mv examples/Wippersnapper_demo/build/*/Wippersnapper_demo.ino.bootloader.bin wippersnapper.${{ matrix.arduino-platform }}.fatfs.${{ env.WS_VERSION }}.bootloader.bin
mv examples/Wippersnapper_demo/build/*/Wippersnapper_demo.ino.merged.bin wippersnapper.${{ matrix.arduino-platform }}.fatfs.${{ env.WS_VERSION }}.merged_auto.bin
mv examples/Wippersnapper_demo/build/*/Wippersnapper_demo.ino.partitions.bin wippersnapper.${{ matrix.arduino-platform }}.fatfs.${{ env.WS_VERSION }}.partitions.bin
- name: Get Board Flash Parameters
id: get_board_json
@ -174,6 +194,7 @@ jobs:
build-esp32sx:
name: 🏗ESP32-Sx
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
@ -194,6 +215,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 +306,7 @@ jobs:
build-esp32:
name: 🏗ESP32/Cx
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
@ -299,6 +328,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 +455,7 @@ jobs:
build-samd:
name: 🏗SAMD
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
@ -429,6 +466,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 +542,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 +621,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,11 +707,13 @@ jobs:
build-esp32sx-dev:
name: 🏗ESP32-Sx(DEV)
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
arduino-platform:
[
"esp32s3_devkitc_1_n8_debug",
"feather_esp32s2_debug",
"feather_esp32s2_tft_debug",
"feather_esp32s3_debug",
@ -662,6 +724,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 +815,7 @@ jobs:
build-esp32-dev:
name: 🏗ESP32/Cx(DEV)
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
@ -758,6 +828,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

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -1,5 +1,5 @@
name=Adafruit WipperSnapper
version=1.0.0-beta.103
version=1.0.0-beta.104
author=Adafruit
maintainer=Adafruit <adafruitio@adafruit.com>
sentence=Arduino application for Adafruit.io WipperSnapper
@ -7,4 +7,4 @@ paragraph=Arduino application for Adafruit.io WipperSnapper
category=Communication
url=https://github.com/adafruit/Adafruit_Wippersnapper_Arduino
architectures=*
depends=OmronD6T - Community Fork, SdFat - Adafruit Fork, Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit HDC302x, Adafruit INA219, Adafruit INA260 Library, Adafruit LTR329 and LTR303, Adafruit LTR390 Library, Adafruit MCP3421, Adafruit NAU7802 Library, Adafruit SleepyDog Library, Adafruit TMP117, Adafruit TinyUSB Library, Adafruit AHTX0, Adafruit BME280 Library, Adafruit BMP280 Library, Adafruit BMP3XX Library, Adafruit DPS310, Adafruit DS248x, Adafruit SCD30, Adafruit SGP30 Sensor, Adafruit SGP40 Sensor, Sensirion I2C SCD4x, Sensirion I2C SEN5X, Sensirion I2C SEN66, arduino-sht, Adafruit Si7021 Library, Adafruit MQTT Library, Adafruit MS8607, Adafruit MCP9808 Library, Adafruit MCP9600 Library, Adafruit MPL115A2, Adafruit MPRLS Library, Adafruit TSL2591 Library, Adafruit_VL53L0X, Adafruit VL53L1X, STM32duino VL53L4CD, STM32duino VL53L4CX, Adafruit_VL6180X, Adafruit PM25 AQI Sensor, Adafruit VCNL4020 Library, Adafruit VCNL4040, Adafruit VCNL4200 Library, Adafruit VEML7700 Library, Adafruit LC709203F, Adafruit LPS2X, Adafruit LPS28, Adafruit LPS35HW, Adafruit seesaw Library, Adafruit BME680 Library, Adafruit MAX1704X, Adafruit ADT7410 Library, Adafruit HTS221, Adafruit HTU21DF Library, Adafruit HTU31D Library, Adafruit PCT2075, hp_BH1750, ENS160 - Adafruit Fork, Adafruit BusIO, Adafruit Unified Sensor, Sensirion Core, Adafruit GFX Library, Adafruit LED Backpack Library, Adafruit LiquidCrystal, Adafruit SSD1306
depends=OmronD6T - Community Fork, SdFat - Adafruit Fork, Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit HDC302x, Adafruit INA219, Adafruit INA260 Library, Adafruit LTR329 and LTR303, Adafruit LTR390 Library, Adafruit MCP3421, Adafruit NAU7802 Library, Adafruit SleepyDog Library, Adafruit TMP117, Adafruit TinyUSB Library, Adafruit AHTX0, Adafruit BME280 Library, Adafruit BMP280 Library, Adafruit BMP3XX Library, Adafruit DPS310, Adafruit DS248x, Adafruit SCD30, Adafruit SGP30 Sensor, Adafruit SGP40 Sensor, Sensirion I2C SCD4x, Sensirion I2C SEN5X, Sensirion I2C SEN66, arduino-sht, Adafruit Si7021 Library, Adafruit MQTT Library, Adafruit MS8607, Adafruit MCP9808 Library, Adafruit MCP9600 Library, Adafruit MPL115A2, Adafruit MPRLS Library, Adafruit TSL2591 Library, Adafruit_VL53L0X, Adafruit VL53L1X, STM32duino VL53L4CD, STM32duino VL53L4CX, Adafruit_VL6180X, Adafruit PM25 AQI Sensor, Adafruit VCNL4020 Library, Adafruit VCNL4040, Adafruit VCNL4200 Library, Adafruit VEML7700 Library, Adafruit LC709203F, Adafruit LPS2X, Adafruit LPS28, Adafruit LPS35HW, Adafruit seesaw Library, Adafruit BME680 Library, Adafruit MAX1704X, Adafruit ADT7410 Library, Adafruit HTS221, Adafruit HTU21DF Library, Adafruit HTU31D Library, Adafruit PCT2075, hp_BH1750, ENS160 - Adafruit Fork, Adafruit BusIO, Adafruit Unified Sensor, Sensirion Core, Adafruit GFX Library, Adafruit LED Backpack Library, Adafruit LiquidCrystal, Adafruit SH110X, Adafruit SSD1306

View file

@ -84,6 +84,7 @@ lib_deps =
adafruit/Adafruit LiquidCrystal
adafruit/Adafruit LED Backpack Library
adafruit/Adafruit PM25 AQI Sensor
adafruit/Adafruit SH110X
adafruit/Adafruit SSD1306
https://github.com/tyeth/omron-devhub_d6t-arduino.git
https://github.com/pstolarz/OneWireNg.git
@ -101,6 +102,8 @@ lib_deps =
; Common build environment for ESP32 platform
[common:esp32]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/53.03.13/platform-espressif32.zip
;;Funhouse uses 3.0.7 of arduino-esp32 for now:
; platform = https://github.com/pioarduino/platform-espressif32/releases/download/51.03.07/platform-espressif32.zip
; This is needed for occasional new features and bug fixes
; platform = https://github.com/pioarduino/platform-espressif32#develop
lib_ignore = WiFiNINA, WiFi101, OneWire
@ -409,8 +412,10 @@ extra_scripts = pre:rename_usb_config.py
[env:espressif_esp32s3_devkitc_1_n8]
extends = common:esp32
board = esp32-s3-devkitc-1
build_flags = -DARDUINO_ESPRESSIF_ESP32S3_DEVKITC_1_N8
extra_scripts = pre:rename_usb_config.py
build_flags = -DARDUINO_ESPRESSIF_ESP32S3_DEVKITC_1_N8 -DUSE_TINYUSB=1 -DARDUINO_USB_MODE=0 -DARDUINO_USB_CDC_ON_BOOT=1
board_build.partitions = noota_ffat.csv
; board_build.partitions = tinyuf2-partitions-8MB.csv
; extra_scripts = pre:rename_usb_config.py
; Espressif ESP32-S3 NO PSRAM espressif_esp32s3_devkitc_1_n8 (DEBUG)
[env:espressif_esp32s3_devkitc_1_n8_debug]
@ -419,17 +424,17 @@ board = esp32-s3-devkitc-1
build_type = debug
build_flags =
-DUSE_TINYUSB=1
-DARDUINO_USB_MODE=0
-DARDUINO_USB_CDC_ON_BOOT=1
-DARDUINO_ESPRESSIF_ESP32S3_DEVKITC_1_N8
-DNDEBUG=1
-DDEBUG=1
-DESP_LOG_LEVEL=5
-DARDUINO_CORE_DEBUG_LEVEL=5
-DARDUINO_DEBUG_LEVEL=5
-DARDUINO_CORE_LOG_LEVEL=5
-DARDUINO_LOG_LEVEL=5
-DCORE_DEBUG_LEVEL=5
-DARDUHAL_LOG_LEVEL=5
board_build.partitions = tinyuf2-partitions-8MB.csv
extra_scripts = pre:rename_usb_config.py
; board_build.partitions = tinyuf2-partitions-8MB.csv
board_build.partitions = noota_ffat.csv
; extra_scripts = pre:rename_usb_config.py
; ESP8266 Boards

View file

@ -108,7 +108,9 @@ void Wippersnapper::provision() {
#ifdef USE_DISPLAY
// Initialize the display
displayConfig config;
WS._fileSystem->parseDisplayConfig(config);
if (!WS._fileSystem->parseDisplayConfig(config)) {
WS._fileSystem->parseDisplayConfig(config, true);
}
WS._display = new ws_display_driver(config);
// Begin display
if (!WS._display->begin()) {

View file

@ -142,7 +142,7 @@
#endif
#define WS_VERSION \
"1.0.0-beta.103" ///< WipperSnapper app. version (semver-formatted)
"1.0.0-beta.104" ///< WipperSnapper app. version (semver-formatted)
// Reserved Adafruit IO MQTT topics
#define TOPIC_IO_THROTTLE "/throttle" ///< Adafruit IO Throttle MQTT Topic

View file

@ -51,6 +51,15 @@
#define STATUS_NEOPIXEL_PIN 45
#define STATUS_NEOPIXEL_NUM 1
#define USE_PSRAM ///< Board has PSRAM, use it for dynamic memory allocation
#elif defined(ARDUINO_ESP32S3_DEV)
#define BOARD_ID "esp32s3-devkitc-1-n8"
#define USE_TINYUSB
#define USE_STATUS_NEOPIXEL
#define STATUS_NEOPIXEL_PIN 48
#define STATUS_NEOPIXEL_NUM 1
#ifdef BOARD_HAS_PSRAM
#define USE_PSRAM ///< Board has PSRAM, use it for dynamic memory allocation
#endif
#elif defined(ARDUINO_METRO_ESP32S3)
#define BOARD_ID "metroesp32s3"
#define USE_TINYUSB

View file

@ -892,7 +892,38 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
}
_drivers_out.push_back(_sevenSeg);
WS_DEBUG_PRINTLN("7-Segement LED Matrix Initialized Successfully!");
} else if (strcmp("oled128x32default", msgDeviceInitReq->i2c_device_name) ==
} else if (strcmp("fthrwingoled128x64", msgDeviceInitReq->i2c_device_name) ==
0 ||
strcmp("fthrwingoled128x64lg",
msgDeviceInitReq->i2c_device_name) == 0) {
WS_DEBUG_PRINTLN("SH1107 display detected!");
_sh1107 = new WipperSnapper_I2C_Driver_Out_SH1107(this->_i2c, i2cAddress);
WS_DEBUG_PRINTLN("Configuring SH1107 display...");
_sh1107->ConfigureSH1107(
(uint8_t)msgDeviceInitReq->i2c_output_add.config.ssd1306_config.width,
(uint8_t)msgDeviceInitReq->i2c_output_add.config.ssd1306_config.height,
(uint8_t)
msgDeviceInitReq->i2c_output_add.config.ssd1306_config.text_size,
OLED_128X64_WING_ROTATION_90); // fixed as currently the only screen is
// 128x64wing (needs a rotation of 1 / 90degrees and constructor w/h swap).
if (!_sh1107->begin()) {
WS_DEBUG_PRINTLN("ERROR: Failed to initialize sh1107!");
_busStatusResponse =
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
return false;
}
WS_DEBUG_PRINTLN("SH1107 display configured successfully!");
_drivers_out.push_back(_sh1107);
WS_DEBUG_PRINTLN("SH1107 display initialized Successfully!");
} else if (strcmp("oled32x64large", msgDeviceInitReq->i2c_device_name) == 0 ||
strcmp("oled64x32default", msgDeviceInitReq->i2c_device_name) ==
0 ||
strcmp("oled64x32large", msgDeviceInitReq->i2c_device_name) == 0 ||
strcmp("fthrwingoled128x32", msgDeviceInitReq->i2c_device_name) ==
0 ||
strcmp("fthrwingoled128x32lg",
msgDeviceInitReq->i2c_device_name) == 0 ||
strcmp("oled128x32default", msgDeviceInitReq->i2c_device_name) ==
0 ||
strcmp("oled128x32large", msgDeviceInitReq->i2c_device_name) ==
0 ||

View file

@ -55,6 +55,7 @@
#include "drivers/WipperSnapper_I2C_Driver_Out_7Seg.h"
#include "drivers/WipperSnapper_I2C_Driver_Out_CharLcd.h"
#include "drivers/WipperSnapper_I2C_Driver_Out_QuadAlphaNum.h"
#include "drivers/WipperSnapper_I2C_Driver_Out_Sh1107.h"
#include "drivers/WipperSnapper_I2C_Driver_Out_Ssd1306.h"
#include "drivers/WipperSnapper_I2C_Driver_PCT2075.h"
#include "drivers/WipperSnapper_I2C_Driver_PM25.h"
@ -206,6 +207,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

@ -62,9 +62,11 @@ public:
The height of the display in pixels.
@param text_size
The display's text size.
@param rotation
The rotation of the display in degrees, default is 0.
*/
virtual void ConfigureSSD1306(uint8_t width, uint8_t height,
uint8_t text_size) {
uint8_t text_size, uint8_t rotation = 0) {
// noop
}

View file

@ -0,0 +1,208 @@
/*!
* @file WipperSnapper_I2C_Driver_Out_SH1107.h
*
* Device driver for a SH1107 OLED Display
*
* Adafruit invests time and resources providing this open source code,
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
*
* Copyright (c) Tyeth Gundry for Adafruit Industries 2025
*
* MIT license, all text here must be included in any redistribution.
*
*/
#ifndef WIPPERSNAPPER_I2C_DRIVER_OUT_SH1107_H
#define WIPPERSNAPPER_I2C_DRIVER_OUT_SH1107_H
#include "WipperSnapper_I2C_Driver_Out.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
#include <Arduino.h>
#define WS_SH1107_DEFAULT_WIDTH \
128 ///< Default width for a sh1107 128x64 display
#define WS_SH1107_DEFAULT_HEIGHT \
64 ///< Default height for a sh1107 128x64 display
#define OLED_128X64_WING_WIDTH 128 ///< Width of the 128x64 OLED FeatherWing
#define OLED_128X64_WING_HEIGHT 64 ///< Height of the 128x64 OLED FeatherWing
#define OLED_128X64_WING_ROTATION_90 1 ///< Rotation of OLED FeatherWing 0-3
/*!
@brief Class that provides a driver interface for a SH1107
OLED Display
*/
class WipperSnapper_I2C_Driver_Out_SH1107
: public WipperSnapper_I2C_Driver_Out {
public:
/*******************************************************************************/
/*!
@brief Constructor for an SH1107 OLED display.
@param i2c
The I2C interface.
@param sensorAddress
7-bit device address.
*/
/*******************************************************************************/
WipperSnapper_I2C_Driver_Out_SH1107(TwoWire *i2c, uint16_t sensorAddress)
: WipperSnapper_I2C_Driver_Out(i2c, sensorAddress) {
_i2c = i2c;
_sensorAddress = sensorAddress;
_width = WS_SH1107_DEFAULT_WIDTH;
_height = WS_SH1107_DEFAULT_HEIGHT;
}
/*!
@brief Destructor for a SH1107 OLED display.
*/
~WipperSnapper_I2C_Driver_Out_SH1107() {
if (_display != nullptr) {
_display->clearDisplay();
_display->display();
_display->oled_command(SH110X_DISPLAYOFF);
delete _display;
_display = nullptr;
}
}
/*!
@brief Initializes the SH1107 display and begins I2C.
@returns True if initialized successfully, False otherwise.
*/
bool begin() {
if (_width == OLED_128X64_WING_WIDTH &&
_height == OLED_128X64_WING_HEIGHT &&
_rotation == OLED_128X64_WING_ROTATION_90) {
// featherwing needs to be rotated 90 degrees and swap w/h ctor args
_display = new Adafruit_SH1107(_height, _width, _i2c);
} else {
_display = new Adafruit_SH1107(_width, _height, _i2c);
}
if (!_display->begin(_sensorAddress, true))
return false;
// Clear the buffer.
_display->clearDisplay();
_display->display();
_display->setRotation(_rotation); // 0-3, not degrees for SH1107
// Configure the text size and color
_display->setTextSize(_text_sz);
_display->setTextColor(SH110X_WHITE);
_display->setCursor(0, 0);
// Clear the buffer
_display->clearDisplay();
_display->display();
return true;
}
/*!
@brief Configures a SH1107 OLED display. Must be called before driver
begin()
@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.
@param rotation
The rotation of the display in degrees, default is 0.
*/
void ConfigureSH1107(uint8_t width, uint8_t height, uint8_t text_size,
uint8_t rotation) {
_width = width;
_height = height;
_text_sz = text_size;
_rotation =
rotation % 90; // SH1107 requires rotation to be 0-3, not degrees
}
/*!
@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.
@param rotation
The rotation of the display in degrees, default is 0.
*/
void ConfigureSSD1306(uint8_t width, uint8_t height, uint8_t text_size,
uint8_t rotation) {
// This is a SH1107, not a SSD1306, so we don't need to do anything here.
ConfigureSH1107(width, height, text_size, rotation);
}
/*!
@brief Writes a message to the SH1107 display.
@param message
The message to be displayed.
*/
void WriteMessageSH1107(const char *message) {
if (_display == nullptr)
return;
// Start with a fresh display buffer
// and settings
int16_t y_idx = 0;
_display->clearDisplay();
_display->setTextSize(_text_sz);
_display->setTextColor(SH110X_WHITE);
_display->setCursor(0, y_idx);
_display->display();
// Calculate the line height based on the text size (NOTE: base height is
// 8px)
int16_t line_height = 8 * _text_sz;
uint16_t c_idx = 0;
size_t msg_size = strlen(message);
for (size_t i = 0; i < msg_size && c_idx < msg_size; i++) {
if (message[i] == '\\' && i + 1 < msg_size &&
(message[i + 1] == 'n' || message[i + 1] == 'r')) {
// Handle \r\n sequence as a single newline
if (message[i + 1] == 'r' && i + 3 < msg_size &&
message[i + 2] == '\\' && message[i + 3] == 'n') {
// Skip to the next line
y_idx += line_height;
_display->setCursor(0, y_idx);
i += 3;
} else if (message[i + 1] == 'n') {
// Skip to the next line
y_idx += line_height;
_display->setCursor(0, y_idx);
i++;
}
} else if (message[i] == 0xC2 && message[i + 1] == 0xB0) {
_display->write(char(248));
_display->display();
i++;
} else {
_display->print(message[i]);
_display->display();
}
}
}
/*!
@brief Writes a message to the fake "SSD1306" SH1107 display.
@param message
The message to be displayed.
*/
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
uint8_t _width; ///< Width of the display in pixels
uint8_t _height; ///< Height of the display in pixels
uint8_t _rotation; ///< Rotation of the display (0-3)
uint8_t _text_sz; ///< Text size of the display
};
#endif // WIPPERSNAPPER_I2C_DRIVER_OUT_SH1107_H

View file

@ -20,8 +20,10 @@
#include <Adafruit_SSD1306.h>
#include <Arduino.h>
#define DEFAULT_WIDTH 128 ///< Default width for a ssd1306 128x64 display
#define DEFAULT_HEIGHT 64 ///< Default height for a ssd1306 128x64 display
#define WS_SSD1306_DEFAULT_WIDTH \
128 ///< Default width for a ssd1306 128x64 display
#define WS_SSD1306_DEFAULT_HEIGHT \
64 ///< Default height for a ssd1306 128x64 display
/*!
@brief Class that provides a driver interface for a SSD1306
@ -44,8 +46,8 @@ public:
: WipperSnapper_I2C_Driver_Out(i2c, sensorAddress) {
_i2c = i2c;
_sensorAddress = sensorAddress;
_width = DEFAULT_WIDTH;
_height = DEFAULT_HEIGHT;
_width = WS_SSD1306_DEFAULT_WIDTH;
_height = WS_SSD1306_DEFAULT_HEIGHT;
}
/*!
@ -70,7 +72,8 @@ public:
_display = new Adafruit_SSD1306(_width, _height, _i2c);
if (!_display->begin(SSD1306_SWITCHCAPVCC, _sensorAddress))
return false;
// Configure the text size and color
// Configure the rotation, text size and color
_display->setRotation(_rotation);
_display->setTextSize(_text_sz);
_display->setTextColor(SSD1306_WHITE);
// Use full 256 char 'Code Page 437' font
@ -90,11 +93,15 @@ public:
The height of the display in pixels.
@param text_size
The magnification factor for the text size.
@param rotation
The rotation of the display in degrees, default is 0.
*/
void ConfigureSSD1306(uint8_t width, uint8_t height, uint8_t text_size) {
void ConfigureSSD1306(uint8_t width, uint8_t height, uint8_t text_size,
uint8_t rotation = 0) {
_width = width;
_height = height;
_text_sz = text_size;
_rotation = rotation;
}
/*!
@ -149,10 +156,11 @@ public:
protected:
Adafruit_SSD1306 *_display =
nullptr; ///< Pointer to the Adafruit_SSD1306 object
uint8_t _width; ///< Width of the display in pixels
uint8_t _height; ///< Height of the display in pixels
uint8_t _text_sz; ///< Text size of the display
nullptr; ///< Pointer to the Adafruit_SSD1306 object
uint8_t _width; ///< Width of the display in pixels
uint8_t _height; ///< Height of the display in pixels
uint8_t _rotation; ///< Rotation of the display in degrees
uint8_t _text_sz; ///< Text size of the display
};
#endif // WIPPERSNAPPER_I2C_DRIVER_OUT_SSD1306_H

View file

@ -24,7 +24,7 @@
defined(ARDUINO_ADAFRUIT_QTPY_ESP32S3_NOPSRAM) || \
defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S3) || \
defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S3_TFT) || \
defined(ARDUINO_ARCH_RP2040) || \
defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_ESP32S3_DEV) || \
defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S3_REVTFT) || \
defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2_REVTFT) || \
defined(ARDUINO_ADAFRUIT_QTPY_ESP32S3_N4R2)
@ -543,7 +543,16 @@ void Wippersnapper_FS::createDisplayConfig() {
delay(2500); // give FS some time to write the file
}
void Wippersnapper_FS::parseDisplayConfig(displayConfig &dispCfg) {
bool Wippersnapper_FS::parseDisplayConfig(displayConfig &dispCfg, bool force_recreate) {
if (force_recreate) {
if (wipperFatFs.exists("/display_config.json")) {
wipperFatFs.remove("/display_config.json");
}
#ifdef ARDUINO_FUNHOUSE_ESP32S2
createDisplayConfig();
#endif
}
// Check if display_config.json file exists, if not, generate it
if (!wipperFatFs.exists("/display_config.json")) {
WS_DEBUG_PRINTLN("Could not find display_config.json, generating...");
@ -556,6 +565,9 @@ void Wippersnapper_FS::parseDisplayConfig(displayConfig &dispCfg) {
// Attempt to open file for JSON parsing
File32 file = wipperFatFs.open("/display_config.json", FILE_READ);
if (!file) {
if (!force_recreate) {
return false;
}
fsHalt("FATAL ERROR: Unable to open display_config.json for parsing");
}
@ -563,6 +575,9 @@ void Wippersnapper_FS::parseDisplayConfig(displayConfig &dispCfg) {
JsonDocument doc;
DeserializationError error = deserializeJson(doc, file);
if (error) {
if (!force_recreate) {
return false;
}
fsHalt(String("FATAL ERROR: Unable to parse display_config.json - "
"deserializeJson() failed with code") +
error.c_str());
@ -571,6 +586,7 @@ void Wippersnapper_FS::parseDisplayConfig(displayConfig &dispCfg) {
file.close();
// Extract a displayConfig struct from the JSON document
dispCfg = doc.as<displayConfig>();
return true;
}
#endif // ARDUINO_FUNHOUSE_ESP32S2

View file

@ -59,7 +59,7 @@ public:
void parseSecrets();
#ifdef ARDUINO_FUNHOUSE_ESP32S2
void parseDisplayConfig(displayConfig &displayFile);
bool parseDisplayConfig(displayConfig &displayFile, bool force_recreate = false);
void createDisplayConfig();
#endif
private: