Skip to content

feat(mqtt-data): show the screen title while connecting - #78

Merged
red77290 merged 1 commit into
red77290:mainfrom
TooncesToo:feat/mqtt-waiting-labels
Nov 29, 2026
Merged

red77290 merged 1 commit into
red77290:mainfrom
TooncesToo:feat/mqtt-waiting-labels

Conversation

@TooncesToo

@TooncesToo TooncesToo commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What. While an MQTT Data page is still waiting for its first payload, a screen with a title shows <TITLE> INCOMING... (for example WEATHER INCOMING...) instead of the generic CONNECTING notice. There is no new setting: it reuses the screen_title that every screen card already has. Screens with no title, or still titled with the engine's default name (MQTT DATA / DONNEES MQTT / DATOS MQTT), keep CONNECTING. RPi counterpart: red77290/ArcadeMatrix_RPI#41.

This replaces the earlier waiting_labels version, as suggested in review. topics is again the only ConfigField, and there are no WebUI, i18n or WebUI.h changes.

How.

  • mqd::makeWaitingLabel() builds the label into a fixed char[WAIT_LABEL_LEN] (32 bytes), with no allocation. It trims, uppercases ASCII and folds Latin-1 accents to their base letter (so it suits the 5x7 font). It cuts the title to 19 characters and appends INCOMING....
  • char m_waitingLabel[2][32] is double-buffered with m_topics. It is written to the spare slot in onConfigChanged and published by the existing m_topicsIdx release store. Core 1 reads it with an acquire load. A title-only change swaps the buffer without reconnecting.
  • panel_text::drawWaitingLabel() uses the CONNECTING layout and colour. If the label is wider than the panel in G1, it is drawn in the TINY font, clamped to x ≥ 0.
  • No heap, lock or floats on the render path.

Tests. pio run -e esp32s3_waveshare and -e esp32dev build. run_native_tests.py passes, including the new test_mqttdata_waiting_label_from_screen_title. validate_ui_and_i18n.py, validate_docs.py, validate_webinstaller.py and test_companion_sync.py pass.

Hardware verification (ESP32-S3 Waveshare, 256×64). Installed by OTA on top of v4.3.3. A weather instance titled "Weather" shows WEATHER INCOMING... on every slot activation until the retained payload arrives, then the weather page. Untitled instances still show CONNECTING. The rotation was byte-identical after the OTA, and heap was stable (about 130 KB free).

🤖 Generated with Claude Code

Copy link
Copy Markdown
Owner

Thanks @TooncesToo! The Core 1 implementation here is really clean—double-buffering m_waitingLabels behind m_topicsIdx with zero heap on the render path and swapping without reconnecting when only labels change is super neat.

Before adding a new schema field though, I'm not 100% sure I'm grasping the underlying problem you're running into—please correct me if I'm missing a scenario! Since MQTT Data payloads are published with retain: true, my understanding is that the only moment we are actually waiting is the brief handshake right on slot entry (on Topic 0) while the fresh session connects and receives the retained snapshot—because once CONNACK arrives, all retained topics land within a few hundred ms while Topic 0 stays up for ~10 s, and after the 3 s NO_DATA_AFTER window any empty topic shows NO DATA rather than CONNECTING.

If that's indeed what we're solving, wouldn't it be much simpler—and keep mqttdata faithful to having topics as its only setting—to handle it automatically the way we already do on the Showcase engines (ShowcaseCardRenderer::drawWaitingPixelArt / media_showcase.rs)?
Specifically, during Notice::Connecting we could:

  • Automatically pick up the label directly from the topic itself (e.g. arcadematrix/weather/local -> WEATHER / LOCAL, or humanizing the last segment) or from the screen_title that every screen tab already has in instance.config,
  • Pair it with a nice little zero-allocation waiting animation (e.g. pulsing MQTT waves / tiny topic hint + animated ... dots, dropping right back to 0-redraw static mode as soon as the retained payload arrives).

That way users get a clean, contextual waiting screen out of the box without having to configure or keep a comma-aligned waiting_labels list in sync. Let me know what you think, or if there's another use case I missed!

By the way, if you haven't tried them yet, definitely give the new Showcase engines a spin paired with https://github.com/red77290/dmd_media_showcase on your 256×64 and 128×32 signs—it's well worth checking out!

@TooncesToo

TooncesToo commented Nov 27, 2026 via email

Copy link
Copy Markdown
Contributor Author

@TooncesToo

Copy link
Copy Markdown
Contributor Author

Just read your entire comment again. Yes, we could do it automatically by what service is connecting. Really the only time this is obvious is when the host is slow (pi2) or if you happen to lose connectivity during the rotation. Any way you'd want to do it is good. I was just wanting to know what I was connecting to.

Copy link
Copy Markdown
Owner

Awesome, glad we're on the same page!

Looking at how the WebUI already works, every screen card actually already has a free-form Screen Title / Label input right at the top (saved in instance.config.screen_title, e.g. "Weather"), which ConfigSanitizer preserves and passes straight into onConfigChanged() (cfg->getString("screen_title", "") on ESP32 / config.get_string("screen_title", "") on RPi)! And since MQTT topics themselves are free-form in the contract (only the JSON "type" picks the renderer), using screen_title avoids any fragile topic-path guessing too.

If you're up for updating #78 and #41 in that direction, the core change becomes super small:

1. Drop waiting_labels (keep topics as the sole ConfigField)

Zero new schema fields, WebUI keys, or contract doc rewrites—the user just names their screen tab as usual (e.g. Weather).

2. Use screen_title during Notice::Connecting

  • Read screen_title in onConfigChanged / read_config (on ESP32, a single double-buffered char m_waitingLabel[2][32] published behind m_topicsIdx—much simpler than per-topic arrays!).
  • Trim and uppercase ASCII:
    • If screen_title is non-empty and isn't just the default engine name ("MQTT DATA", "DONNEES MQTT", "DONNÉES MQTT", "DATOS MQTT"), show <SCREEN_TITLE> INCOMING... (e.g. WEATHER INCOMING...).
    • Otherwise, fall back to the localized CONNECTING notice.
  • If the text width in 5×7 exceeds panel width (e.g. 64×32 or TATE 64×128), fall back to the 3×5 TINY font (or clamp x >= 0) so nothing clips.

3. Totally optional bonus (only if you feel like it!)

No obligation at all—plain static text from screen_title is already great! If you do want to dress up the connecting state, we already have zero-RAM sprites ready to call in both repos (ClockSpriteBank::drawPacman in src/engines/clocks/ClockSpriteBank.h on ESP32 / pacman_frame in crate::engines::clocks::sprite_bank on RPi, or the 11×8 Space Invader + animated . -> .. -> ... dots from ShowcaseCardRenderer / media_showcase.rs). If you animate it, just keep redraw ticks active only while Notice::Connecting is shown so connected pages stay 100% static.

(Quick Pi 2 tip too: app.rs sleeps 200 ms per frame when is_realtime() == false, so returning is_realtime() == true while Notice::Connecting is shown will shave up to 200 ms off slot entry. Also, if your data_mqtt.broker uses a .local hostname rather than a static IP, switching to the broker's LAN IP avoids a cold mDNS lookup on every slot activation—plus on cheap nano USB Wi-Fi dongles next to HUB75 ribbon noise, a single dropped SYN/UDP packet hits Linux's 1.0 s initial TCP RTO.)

Let me know if you'd like to run with this—happy to review as soon as it's ready!

While a page is still waiting for its first payload, a screen with a
title shows "<TITLE> INCOMING..." (e.g. WEATHER INCOMING...) instead of
the generic CONNECTING notice. No new setting: it reuses the
screen_title every screen card already has. Screens with no title, or
still titled with the engine's default name, keep CONNECTING.

mqd::makeWaitingLabel() builds the label into a fixed 32-byte buffer
(trimmed, uppercased, Latin-1 accents folded, title cut to 19
characters). It is double-buffered with m_topics and published by the
m_topicsIdx release store; a title-only change swaps the buffer without
reconnecting. A label too wide for G1 on the panel is drawn in the tiny
font. No heap or lock on the render path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TooncesToo
TooncesToo force-pushed the feat/mqtt-waiting-labels branch from 27f2d7e to cbd0271 Compare November 29, 2026 07:50
@TooncesToo TooncesToo changed the title feat(mqtt-data): per-topic waiting labels feat(mqtt-data): show the screen title while connecting Nov 29, 2026
@TooncesToo

Copy link
Copy Markdown
Contributor Author

Done. I've updated both #78 and red77290/ArcadeMatrix_RPI#41 to work the way you suggested:

  • waiting_labels is gone, and topics is the only field again. There are no WebUI or i18n changes.
  • During Notice::Connecting, a screen with a screen_title shows <TITLE> INCOMING.... If it has no title, or still has the default engine name, it shows CONNECTING.
  • On ESP32 the label is a single char m_waitingLabel[2][32] published behind m_topicsIdx. It falls back to the TINY font when it's too wide for the panel.
  • On RPi I added your is_realtime() tip, but only while CONNECTING is shown. My data broker was already a LAN IP, so the .local tip didn't apply here.

I went with plain text and left out the animation.

One thing I found along the way: on RPi, ConfigSanitizer prunes every instance key that isn't in the engine schema, so screen_title was being dropped on save for every engine. The custom title from a screen card never survived on Pi; the ESP32 keeps unknown keys. #41 has a separate first commit that keeps screen_title as a UI-level key, with a test. Without it, this feature wouldn't work on RPi.

Both are tested on my signs: the Pi 2 at 128×32 and the Waveshare S3 at 256×64. The weather screen titled "Weather" shows WEATHER INCOMING... until the retained payload lands.

Thanks for the Showcase pointer too. I tried games and movies on both signs and it's impressive work.

@red77290 red77290 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super clean! Dropping waiting_labels in favor of a single double-buffered char m_waitingLabel[2][32] derived from screen_title keeps the mqttdata contract completely untouched, stays 100% zero-allocation on Core 1, and handles Latin-1 accent folding + the TINY font fallback on narrow panels very neatly. Great unit test coverage in test_native_core.cpp too.

And really glad you enjoyed trying out the Showcase engines on both of your signs! LGTM, merging.

@red77290
red77290 merged commit ebb32bc into red77290:main Nov 29, 2026
4 checks passed
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.

2 participants