Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d25aba8
bring in new PBs, new drivers
brentru May 14, 2025
5265e25
compiles OK
brentru May 14, 2025
cc3a3c5
Add write commands for quadalphanum
brentru May 14, 2025
645fd4d
Add CharLCD
brentru May 15, 2025
00bb2bf
Add 7seg driver
brentru May 15, 2025
f6c406a
Clang
brentru May 15, 2025
a4d9e9d
clang again
brentru May 15, 2025
420d319
address @tyeth review
brentru May 16, 2025
3ae7029
Add new Pbs to match 6c842d81bf332dfc0fbfef4d2045c2d934e467f3
brentru May 16, 2025
c470fa3
Tie in enable/disable for charlcd writes
brentru May 16, 2025
6202eca
Fix LED matrix write
brentru May 16, 2025
c281ed8
push clang
brentru May 16, 2025
0e19aa0
add ssd driver
brentru May 19, 2025
092c796
Fully integrate SSD1306 driver, missing write func
brentru May 19, 2025
c1d9698
Integrate PR a1a0ab6..8e89fdf
brentru May 19, 2025
ff4a416
Add Write Msg
brentru May 19, 2025
8529924
Looking into SSD1306 not writing properly
brentru May 19, 2025
a86ead8
Test on 128x32, new PBs to match 8e89fdf
brentru May 20, 2025
47afeb7
Works on both display sizes
brentru May 20, 2025
fa0b3c6
Put back auto-config scaffolding
brentru May 20, 2025
c4c0fcd
Add deps.!
brentru May 20, 2025
9e1d677
Doxygen
brentru May 20, 2025
8689685
Turn display off before dtor'ing
brentru May 21, 2025
6e7daf9
fix SSD1306 bugs
brentru Jun 5, 2025
964760a
Add large OLED
brentru Jun 5, 2025
eed66c7
clear on ctor dtor
brentru Jun 5, 2025
050216d
alphanum - build degree symbol out of segement raw bitmask
brentru Jun 5, 2025
6bf8118
7seg- fix right justification bug, max chars
brentru Jun 6, 2025
67abbc6
Fix - do not publish i2c output write back to io, there is no matchin…
brentru Jun 6, 2025
6e9ce5c
Fix - degree symbol on 7seg display
brentru Jun 6, 2025
67b851f
Fix - Chardisplay 16x2
brentru Jun 9, 2025
5c61a83
Add 20x4
brentru Jun 9, 2025
dd97c84
Match 64972ad..1786350
brentru Jun 9, 2025
d784e8a
Clang
brentru Jun 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ paragraph=Arduino application for Adafruit.io WipperSnapper
category=Communication
url=https://github.com/adafruit/Adafruit_Wippersnapper_Arduino
architectures=*
depends=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
depends=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
5 changes: 3 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ lib_deps =
adafruit/Adafruit MQTT Library
bblanchon/ArduinoJson
adafruit/Adafruit LiquidCrystal
adafruit/Adafruit LED Backpack Library
adafruit/Adafruit PM25 AQI Sensor
adafruit/Adafruit SSD1306
https://github.com/pstolarz/OneWireNg.git
https://github.com/milesburton/Arduino-Temperature-Control-Library.git
https://github.com/Sensirion/arduino-sht.git
Expand All @@ -91,8 +94,6 @@ lib_deps =
https://github.com/adafruit/WiFiNINA.git
https://github.com/Starmbi/hp_BH1750.git
https://github.com/adafruit/Adafruit_TinyUSB_Arduino.git
https://github.com/adafruit/Adafruit_LED_Backpack.git
https://github.com/adafruit/Adafruit_PM25AQI.git



Expand Down
1 change: 0 additions & 1 deletion src/Wippersnapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2834,7 +2834,6 @@ void Wippersnapper::connect() {
#endif

// Configure hardware
WS.pinCfgCompleted = false;
while (!WS.pinCfgCompleted) {
WS_DEBUG_PRINTLN(
"Polling for message containing hardware configuration...");
Expand Down
31 changes: 27 additions & 4 deletions src/components/i2c/WipperSnapper_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
_charLcd = new WipperSnapper_I2C_Driver_Out_CharLcd(this->_i2c, i2cAddress);
_charLcd->ConfigureCharLcd(
msgDeviceInitReq->i2c_output_add.config.char_lcd_config.rows,
msgDeviceInitReq->i2c_output_add.config.char_lcd_config.columns, true);
msgDeviceInitReq->i2c_output_add.config.char_lcd_config.columns);
if (!_charLcd->begin()) {
WS_DEBUG_PRINTLN("ERROR: Failed to initialize Character LCD!");
_busStatusResponse =
Expand All @@ -867,9 +867,9 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
WS_DEBUG_PRINTLN("Char LCD Display Initialized Successfully!");
} else if (strcmp("7seg", msgDeviceInitReq->i2c_device_name) == 0) {
_sevenSeg = new WipperSnapper_I2C_Driver_Out_7Seg(this->_i2c, i2cAddress);
_sevenSeg->ConfigureCharLcd(
msgDeviceInitReq->i2c_output_add.config.char_lcd_config.rows,
msgDeviceInitReq->i2c_output_add.config.char_lcd_config.columns, true);
_sevenSeg->ConfigureI2CBackpack(
msgDeviceInitReq->i2c_output_add.config.led_backpack_config.brightness,
msgDeviceInitReq->i2c_output_add.config.led_backpack_config.alignment);
if (!_sevenSeg->begin()) {
WS_DEBUG_PRINTLN("ERROR: Failed to initialize 7-Segement LED Matrix!");
_busStatusResponse =
Expand All @@ -878,6 +878,24 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
}
_drivers_out.push_back(_sevenSeg);
WS_DEBUG_PRINTLN("7-Segement LED Matrix Initialized Successfully!");
} else if (strcmp("ssd1306", msgDeviceInitReq->i2c_device_name) == 0) {
WS_DEBUG_PRINTLN("SSD1306 display detected!");
_ssd1306 = new WipperSnapper_I2C_Driver_Out_Ssd1306(this->_i2c, i2cAddress);
WS_DEBUG_PRINTLN("Configuring SSD1306 display...");
_ssd1306->ConfigureSSD1306(
(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);
if (!_ssd1306->begin()) {
WS_DEBUG_PRINTLN("ERROR: Failed to initialize ssd1306!");
_busStatusResponse =
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
return false;
}
WS_DEBUG_PRINTLN("SSD1306 display configured successfully!");
_drivers_out.push_back(_ssd1306);
WS_DEBUG_PRINTLN("SSD1306 display initialized Successfully!");
} else {
WS_DEBUG_PRINTLN("ERROR: I2C device type not found!")
_busStatusResponse =
Expand Down Expand Up @@ -1150,6 +1168,7 @@ bool WipperSnapper_Component_I2C::Handle_I2cDeviceOutputWrite(
// Create a ptr to the base driver out
WipperSnapper_I2C_Driver_Out *driver_out = nullptr;
// Find the matching driver by address in the _drivers_out vector
// TODO: Refactor this outwards
WS_DEBUG_PRINT("Searching for i2c output driver with address: ");
WS_DEBUG_PRINT(msgDeviceWrite->i2c_device_address);
for (size_t i = 0; i < _drivers_out.size(); i++) {
Expand All @@ -1172,6 +1191,10 @@ bool WipperSnapper_Component_I2C::Handle_I2cDeviceOutputWrite(
} else if (msgDeviceWrite->which_output_msg ==
wippersnapper_i2c_v1_I2CDeviceOutputWrite_write_char_lcd_tag) {
driver_out->WriteMessageCharLCD(&msgDeviceWrite->output_msg.write_char_lcd);
} else if (msgDeviceWrite->which_output_msg ==
wippersnapper_i2c_v1_I2CDeviceOutputWrite_write_ssd1306_tag) {
driver_out->WriteMessageSSD1306(
msgDeviceWrite->output_msg.write_ssd1306.message);
} else {
WS_DEBUG_PRINTLN("ERROR: Unknown output message type!");
return false;
Expand Down
2 changes: 2 additions & 0 deletions src/components/i2c/WipperSnapper_I2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,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_Ssd1306.h"
#include "drivers/WipperSnapper_I2C_Driver_PCT2075.h"
#include "drivers/WipperSnapper_I2C_Driver_PM25.h"
#include "drivers/WipperSnapper_I2C_Driver_SCD30.h"
Expand Down Expand Up @@ -203,6 +204,7 @@ class WipperSnapper_Component_I2C {
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_Ssd1306 *_ssd1306 = nullptr;
};
extern Wippersnapper WS;

Expand Down
77 changes: 31 additions & 46 deletions src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,26 @@ class WipperSnapper_I2C_Driver_Out : public WipperSnapper_I2C_Driver {
}

/*!
@brief Writes a floating point value to an i2c output device.
@param value
The value to be displayed. Only the first four digits are
displayed.
@brief Configures a SSD1306 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 display's text size.
*/
virtual void WriteValue(float value) {
virtual void ConfigureSSD1306(uint8_t width, uint8_t height,
uint8_t text_size) {
// noop
}

/*!
@brief Writes a floating point value to an i2c output device.
@param value
The value to be displayed. Only the first four digits are
displayed.
@brief Writes a message to the SSD1306 display.
@param message
The message to be displayed.
*/
virtual void WriteValue(int32_t value) {
virtual void WriteMessageSSD1306(const char *message) {
// noop
}

Expand Down Expand Up @@ -97,33 +101,9 @@ class WipperSnapper_I2C_Driver_Out : public WipperSnapper_I2C_Driver {
@brief Writes a message to the LED backpack.
@param msg_write
Pointer to a wippersnapper_i2c_v1_LedBackpackWrite message.
@returns True if the message was written successfully, False otherwise.
*/
bool WriteLedBackpack(wippersnapper_i2c_v1_LedBackpackWrite *msg_write) {
// Check if we should adjust brightness
if (msg_write->adjust_brightness)
SetLedBackpackBrightness((uint8_t)msg_write->brightness);

// Write the message to a LED backpack
switch (msg_write->which_message) {
case wippersnapper_i2c_v1_LedBackpackWrite_text_tag:
WS_DEBUG_PRINTLN("[i2c] Writing text to LED backpack...");
WriteMessage(msg_write->message.text);
break;
case wippersnapper_i2c_v1_LedBackpackWrite_number_int_tag:
WS_DEBUG_PRINTLN("[i2c] Writing int to LED backpack...");
WriteValue(msg_write->message.number_int);
break;
case wippersnapper_i2c_v1_LedBackpackWrite_number_float_tag:
WS_DEBUG_PRINTLN("[i2c] Writing float to LED backpack...");
WriteValue(msg_write->message.number_float);
break;
default:
WS_DEBUG_PRINTLN("[i2c] ERROR: Unable to determine message type!");
return false;
break;
}
return true;
void WriteLedBackpack(wippersnapper_i2c_v1_LEDBackpackWrite *msg_write) {
WriteMessage(msg_write->message);
}

/*!
Expand All @@ -132,26 +112,31 @@ class WipperSnapper_I2C_Driver_Out : public WipperSnapper_I2C_Driver {
The number of rows in the LCD.
@param cols
The number of columns in the LCD.
@param enable_backlight
True if the backlight is enabled, False otherwise.
*/
virtual void ConfigureCharLcd(uint32_t rows, uint32_t cols,
bool enable_backlight) {
virtual void ConfigureCharLcd(uint32_t rows, uint32_t cols) {
// noop
}

/*!
@brief Turns the character LCD backlight on or off.
@param enable
True to enable the backlight, false to disable it.
*/
void EnableCharLcdBacklight(bool enable) {
// noop
}

/*!
@brief Writes a message to the LCD.
@param write_char_lcd
Points to a CharLCDWrite message.
@returns True if the message was written successfully, False otherwise.
@param enable_backlight
True if the backlight should be enabled, false otherwise.
*/
bool WriteMessageCharLCD(wippersnapper_i2c_v1_CharLCDWrite *write_char_lcd) {
void WriteMessageCharLCD(wippersnapper_i2c_v1_CharLCDWrite *write_char_lcd,
bool enable_backlight = true) {
EnableCharLcdBacklight(enable_backlight);
WriteMessage(write_char_lcd->message);
// NOTE: While this isn't calling any other funcs in here and ret'ing true,
// I want to keep this function high-level for when we implement backlight
// color and scrolling.
return true;
}
};

Expand Down
25 changes: 0 additions & 25 deletions src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_7Seg.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,31 +170,6 @@ class WipperSnapper_I2C_Driver_Out_7Seg : public WipperSnapper_I2C_Driver_Out {
_matrix->writeDisplay();
}

/*!
@brief Writes a floating point value to the 7-segment display.
@param value
The value to be displayed. Only the first four digits are
displayed.
*/
void WriteValue(float value) {
char message[8 + 1];
snprintf(message, sizeof(message), "%.2f",
value); // Less precision for 7-segment
WriteMessage(message);
}

/*!
@brief Writes an integer value to the 7-segment display.
@param value
The value to be displayed. Only the first four digits are
displayed.
*/
void WriteValue(int32_t value) {
char message[LED_MAX_CHARS + 1];
snprintf(message, sizeof(message), "%ld", value);
WriteMessage(message);
}

protected:
Adafruit_7segment *_matrix =
nullptr; ///< ptr to a 7-segment LED matrix object
Expand Down
37 changes: 21 additions & 16 deletions src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_CharLcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@ class WipperSnapper_I2C_Driver_Out_CharLcd
: public WipperSnapper_I2C_Driver_Out {

public:
/*******************************************************************************/
/*!
@brief Constructor for a LCD character display.
@param i2c
The I2C interface.
@param sensorAddress
7-bit device address.
*/
/*******************************************************************************/
WipperSnapper_I2C_Driver_Out_CharLcd(TwoWire *i2c, uint16_t sensorAddress)
: WipperSnapper_I2C_Driver_Out(i2c, sensorAddress) {
_i2c = i2c;
Expand All @@ -59,7 +57,7 @@ class WipperSnapper_I2C_Driver_Out_CharLcd
bool begin() {
_lcd = new Adafruit_LiquidCrystal(_sensorAddress, _i2c);
bool did_begin = _lcd->begin(_cols, _rows);
if (did_begin && _enable_backlight) {
if (did_begin) {
_lcd->setBacklight(HIGH);
}
return did_begin;
Expand All @@ -72,13 +70,26 @@ class WipperSnapper_I2C_Driver_Out_CharLcd
The number of rows in the LCD.
@param cols
The number of columns in the LCD.
@param enable_backlight
True if the backlight is enabled, False otherwise.
*/
void ConfigureCharLcd(uint8_t rows, uint8_t cols, bool enable_backlight) {
void ConfigureCharLcd(uint8_t rows, uint8_t cols) {
_rows = rows;
_cols = cols;
_enable_backlight = enable_backlight;
}

/*!
@brief Turns the character LCD backlight on or off.
@param enable
True to enable the backlight, false to disable it.
*/
void EnableCharLcdBacklight(bool enable = true) {
if (_lcd == nullptr)
return;

if (enable) {
_lcd->setBacklight(HIGH);
} else {
_lcd->setBacklight(LOW);
}
}

/*!
Expand All @@ -93,11 +104,6 @@ class WipperSnapper_I2C_Driver_Out_CharLcd
// Before writing, let's clear the display
_lcd->clear();

// TODO: Remove all the prints!
// Print the message to the serial
Serial.print("Writing message to Char. LCD: ");
Serial.println(message);

size_t message_length = strlen(message);
size_t cur_idx = 0; // Current index in the message

Expand Down Expand Up @@ -128,10 +134,9 @@ class WipperSnapper_I2C_Driver_Out_CharLcd

protected:
Adafruit_LiquidCrystal *_lcd =
nullptr; ///< Pointer to the Adafruit_LiquidCrystal object
uint8_t _rows; ///< Number of rows in the display
uint8_t _cols; ///< Number of columns in the display
bool _enable_backlight; ///< Flag to enable/disable backlight
nullptr; ///< Pointer to the Adafruit_LiquidCrystal object
uint8_t _rows; ///< Number of rows in the display
uint8_t _cols; ///< Number of columns in the display
};

#endif // WIPPERSNAPPER_I2C_DRIVER_OUT_CHARLCD_H
Original file line number Diff line number Diff line change
Expand Up @@ -157,30 +157,6 @@ class WipperSnapper_I2C_Driver_Out_QuadAlphaNum
_alpha4->writeDisplay();
}

/*!
@brief Writes a floating point value to the quad alphanumeric display.
@param value
The value to be displayed. Only the first four digits are
displayed.
*/
void WriteValue(float value) {
char message[8 + 1];
snprintf(message, sizeof(message), "%.5f", value);
WriteMessage(message);
}

/*!
@brief Writes an integer value to the quad alphanumeric display.
@param value
The value to be displayed. Only the first four digits are
displayed.
*/
void WriteValue(int32_t value) {
char message[LED_MAX_CHARS + 1];
snprintf(message, sizeof(message), "%ld", value);
WriteMessage(message);
}

protected:
Adafruit_AlphaNum4 *_alpha4 =
nullptr; ///< ptr to a 4-digit alphanumeric display object
Expand Down
Loading
Loading