Skip to content

feat: render_alert helper with auto word-wrap - #57

Merged
ojacques merged 4 commits into
mainfrom
feat/alert-helper
Jul 25, 2026
Merged

ojacques merged 4 commits into
mainfrom
feat/alert-helper

Conversation

@ojacques

Copy link
Copy Markdown
Contributor

Summary

New reusable PluginHelpers.render_alert() method that any plugin can use to display an alert with blinking border and auto-wrapped text.

Features

render_alert(text, frame_index, ...)

  • Blinking border (3px default, configurable color/width/rate)
  • Auto word-wrap at word boundaries based on font pixel width
  • Centered text inside the bordered area
  • Works on both SD (128x32) and HD (256x64) displays

_word_wrap(text, max_width, font_name)

  • Splits text at word boundaries to fit within pixel width
  • Preserves existing newlines
  • Handles single words wider than max_width gracefully

Changes

File Change
zeclock/plugins/helpers.py Add render_alert() and _word_wrap() methods
zeclock/plugins/reolink_alert_plugin.py Use render_alert() instead of inline rendering
tests/test_alert_helper.py 17 unit tests (border blink, word wrap, edge cases)
.github/workflows/build-rpi-image.yml Restrict artifact upload to main/tags only

Tests

670 passed in 26s (653 existing + 17 new)

New PluginHelpers.render_alert() method providing a reusable alert
display capability for any plugin:

- Blinking colored border (configurable color, width, blink rate)
- Auto word-wrap: text is split at word boundaries to fit the
  available width inside the border
- Centered text rendering inside the bordered area
- Used by reolink-alert plugin (replaces inline rendering logic)

Also:
- Add _word_wrap() helper for pixel-width-aware text wrapping
- 17 unit tests covering render_alert and word_wrap
- CI: restrict image artifact upload to main/tags only (saves GH storage)
@ojacques
ojacques force-pushed the feat/alert-helper branch from b02ac08 to 6417eb5 Compare July 25, 2026 09:28
New reusable alert system for zeClock:

1. PluginHelpers.render_alert() method:
   - Blinking colored border (3px, configurable)
   - Auto word-wrap based on font pixel width
   - Optional emoji icon (left-aligned, vertically centered)
   - Text rendered in MENU font, forced uppercase
   - Centered text in the bordered area

2. /api/alert REST endpoint:
   POST {"text": "...", "duration": 15, "icon": "person", "color": [255,0,0]}
   - Triggers rich alert rendering in the clock main loop
   - Takes priority over text overlay and normal plugins
   - Auto-expires after duration, resumes normal display

3. Alert icons (from Noto Color Emoji via scripts/emoji_to_icon.py):
   beacon 🚨, person 🚶, vehicle 🚗, animal 🐾,
   motion 💨, warning ⚠️, camera 📷, info ℹ️

4. Reolink plugin simplified:
   - Now calls /api/alert instead of force-plugin mechanism
   - Pure background listener, no render_frame complexity
   - cleanup() is a no-op (listener runs independently)

5. CI: restrict image artifact upload to main/tags only

Tests: 23 tests (render_alert, word_wrap, icons)
Tested on Pi: all 7 detection types validated visually
@ojacques
ojacques force-pushed the feat/alert-helper branch from 6417eb5 to d24bf0a Compare July 25, 2026 10:05
@ojacques
ojacques merged commit 6ce055d into main Jul 25, 2026
2 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.

1 participant