feat: Glass2 OLED support + three bug fixes#13
Open
Swissola wants to merge 2 commits into
Open
Conversation
Glass2 (Grove SSD1309, SDA=G2, SCL=G1): - glass2Init() in setup() — no-op if OLED not connected - showStation(): mirrors station name to OLED line 1 - audio_showstation(): adds now-playing stream title to OLED line 2 Bug fixes: - bgcolor(): add dh <= 0 guard to prevent division by zero if header_height were ever >= display height - loop(): remove duplicate else-if for 'f' key — dead code, second handler could never execute - audio_showstation(): buffer was declared as char[241] but only 24 bytes were ever written; corrected to char[25] to match actual use M5UnitGLASS2 is sourced from M5GFX, already in the transitive dep chain via M5Cardputer/M5Unified — no new library dependency required. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add glass2Spectrum() — 32 bars from FFT bins 0-127, station name on top 14px, bars filling bottom 48px. Driven by the existing updateFFT() 50ms tick (no extra I2C overhead when FFT is disabled). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds optional Grove Glass2 OLED (SSD1309, 128×64) display support, plus three pre-existing bug fixes found during review.
Glass2 OLED (
glass2.h)The Glass2 connects to the Grove port (SDA=G2, SCL=G1). Runtime-detected —
glass2Init()returns false if not connected, making all subsequent calls no-ops with no impact on devices without the OLED.setup(): initialises Glass2showStation(): station name on OLED line 1 when switching stationsaudio_showstation(): stream-reported station name on line 1, now-playing title on line 2M5UnitGLASS2is sourced from M5GFX, already in the transitive dependency chain via M5Cardputer/M5Unified — no new library entry required.Bug fixes
bgcolor()division by zero:dh = h - header_heightis used as a divisor with no guard. Ifheader_heightwere ever ≥ display height,dhwould be zero or negative causing a crash. Addedif (dh <= 0) return 0;guard.Duplicate
'f'key handler: Theloop()keyboard handler had two consecutiveelse if (isKeyPressed('f'))blocks. The second could never execute (dead code). Removed.audio_showstationbuffer size mismatch: Buffer was declaredchar limitedInfo[241](suggesting 240-char intent) but only 24 bytes were ever copied/used. Corrected tochar[25]to match actual behaviour and avoid misleading the reader.Test plan
audio_showstationfkey — toggles once per press (no double-fire)🤖 Generated with Claude Code