Skip to content

feat(cardputer): define GROVE_SDA/SCL and add Glass2 secondary OLED support#2468

Open
Swissola wants to merge 3 commits into
BruceDevices:mainfrom
Swissola:feat/glass2-cardputer
Open

feat(cardputer): define GROVE_SDA/SCL and add Glass2 secondary OLED support#2468
Swissola wants to merge 3 commits into
BruceDevices:mainfrom
Swissola:feat/glass2-cardputer

Conversation

@Swissola

@Swissola Swissola commented May 24, 2026

Copy link
Copy Markdown

Summary

Two related changes for the M5Stack Cardputer board target.

Fix: Define GROVE_SDA / GROVE_SCL in pins_arduino.h

The Cardputer board definition had no GROVE_SDA or GROVE_SCL macros, so bruceConfigPins.i2c_bus (initialised from these in configPins.h:174) defaulted to -1. This meant any Grove I2C accessory would fail to initialise without manually setting pins in the config menu.

// Grove HY2.0-4P port I2C pins (GPIO1=SCL, GPIO2=SDA)
#define GROVE_SDA 2
#define GROVE_SCL 1

These are distinct from the EXT header SDA=13/SCL=15 (used by the GPS cap on Cardputer ADV).

Feature: Glass2 secondary OLED display

Adds support for the M5Stack Glass2 Unit (1.51" transparent OLED, SSD1309 driver, 128×64, I2C 0x3C) via the Grove port.

  • Adds glass2.h using M5UnitGLASS2 from M5GFX — the official M5Stack driver, already a transitive dependency via M5Unified. No additional library required.
  • glass2Init() called in _post_setup_gpio() for both standard Cardputer and ADV variants
  • _g2_ready flag means all calls are safe no-ops if no Glass2 is connected
  • On ADV: Grove GPIO1/2 are free — the LoRa/GPS cap uses EXT header GPIO13/15, and TCA8418 uses Wire1. No conflicts.

Test plan

  • Builds for Cardputer target without errors
  • bruceConfigPins.i2c_bus resolves to GPIO2/1 by default (no longer -1)
  • Glass2 on Grove: startup splash visible on both standard Cardputer and ADV
  • No Glass2 connected: no crash, _g2_ready guard prevents any I2C traffic

🤖 Generated with Claude Code

Swissola and others added 3 commits May 24, 2026 02:01
… path

run_bjs_script_headless() called strndup(filename.c_str(), slash) where
slash = filename.lastIndexOf('/') returns -1 when no path separator is
present. strndup takes size_t, so -1 coerces to SIZE_MAX (~4 GB) and the
allocator either panics on the heap assertion or returns NULL. The
subsequent JS_NewString(ctx, scriptDirpath) then dereferences NULL,
crashing the interpreter before the script runs.

The same bug bites when the path is at root level (slash == 0):
strndup(p, 0) produces an empty string, making __dirpath "" instead of
"/" and breaking any relative path resolution inside the script.

Fix: handle the no-slash and root-slash cases explicitly before falling
through to the normal strndup path.

Likely root cause of issue BruceDevices#2450 (crash launching the app store on
Cardputer ADV), where the app store script path may be constructed
without a leading slash depending on the invocation path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Define GROVE_SDA=2 / GROVE_SCL=1 in pins_arduino.h (Grove HY2.0-4P;
  distinct from EXT header SDA=13/SCL=15 used for GPS on ADV)
- Add glass2.h (SSD1309/Adafruit_SSD1306 wrapper, Wire on GPIO1/2)
- Call glass2Init() in _post_setup_gpio() for both standard Cardputer
  and ADV variants; shows startup splash on each path
- Add Adafruit SSD1306 ^2.5.13 to both lib_deps blocks in platformio.ini

Grove GPIO1/2 are free on standard Cardputer (not used by keyboard or
SPI). On ADV, GPIO13/15 serve the GPS cap leaving Grove for Glass2.
All glass2Show() calls are no-ops if no Glass2 is connected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
M5UnitGLASS2.h ships with M5GFX, already a transitive dependency via
M5Unified — no extra library required. Removes the Adafruit SSD1306
entry added in error from both lib_deps blocks in platformio.ini.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant