Add four clock faces (Diagnostics, Battery/Uptime, Rainbow, Smiley), display performance/stability fixes, and per-machine PlatformIO config - #170
Open
0m4r wants to merge 7 commits into
Open
Conversation
- add a scrolling diagnostics face and a separate battery/uptime face - support smoother face refreshes and batched display updates - color BG trend arrows by glucose severity - add low-battery warning beeps - expose new clock faces in the web UI - make upload/reset scripts use platformio.ini port and speed settings
… override (#1) The tracked platformio.ini hardcoded a specific serial device path (upload_port) and a machine-tuned upload_speed, which broke flashing on other machines and created merge noise against upstream. Now: - platformio.ini drops the hardcoded upload_port (PlatformIO auto-detects it) and keeps a conservative universal upload_speed = 115200. It pulls per-machine values from an untracked platformio.local.ini via extra_configs. - platformio.local.ini.example documents the local file; .gitignore excludes platformio.local.ini so local settings never get committed. - scripts/upload.sh and scripts/reset.sh read platformio.local.ini first and fall back to platformio.ini, with a helpful message when upload_port is unset. - CONTRIBUTING.md and AGENTS.md updated to describe the new workflow. scripts/upload.sh and scripts/reset.sh now print which config file each value was read from (platformio.local.ini vs platformio.ini) and the resolved values, so it's obvious the correct settings are being used. read_ini emits "value|sourcefile" (the previous global-variable approach didn't work because the function runs in a command-substitution subshell).
Small, self-contained improvements to the shared display path and the new clock faces, plus a new face. Builds clean for ulanzi_debug. Performance & stabilization: - Avoid a blank-frame blit on each display refresh (clearMatrix(false) + single trailing update); removes a ~7-8ms WS2812 blit and a visible flash per frame. - Track refresh time in unit-specific fields (lastRefreshMillis / lastRefreshEpochSec) so a face switch never compares millis against epoch seconds and underflows. - Cache the Diagnostics date/time string: read the clock at most ~1x/sec and rebuild only on minute change, removing per-frame getLocalTime() stalls and String heap churn. - Halve Diagnostics redraw load (~60fps -> ~30fps, scroll step rescaled so on-screen speed is unchanged) and fall back to per-minute refresh when the content fits instead of redrawing 30x/s. - Use a single map find() in getTextWidth instead of count() + operator[] (avoids a double traversal and a non-const insert in the frame hot path). - Don't let the low-battery beep cut off an active melody: only beep when the shared MelodyPlayer is idle, retry on the next poll otherwise. - Fix standalone messages (showFatalError, the "To API" connecting text) appearing shifted to the top: pin FONT_TYPE::SMALL before rendering so the y=6 baseline stays centered even after a big-text face left the large font active. New feature: - Smiley clock face (ktomy#9): an 8x8 face whose mood reflects the reading vs the configured limits - happy/green in range, sad/blue below the low limit, angry/red above the high limit, neutral/grey when there's no data - with the numeric reading beside it. Added to the default-clock-face selector in the web UI.
Draw the smiley as a filled disc in the mood color (green/blue/red/grey) with the eyes and mouth punched out as dark cutouts, so it reads as a round face rather than loose features. Render the glucose value in the large font, centered in the space beside the face, instead of the small right-aligned text. Scale the disc's mood color down (~60%) via a small RGB565 fade helper so the round face reads as a soft badge behind the crisp cutout features and the reading, which stay at full brightness. The Smiley and big-text faces leave the large font active in the global currentFont. Diagnostics measured and drew its datetime line without setting a font, so the first frame after switching from one of those faces was computed and rendered in the large font (yAdvance 8) at the y=7 baseline and clipped. Pin FONT_TYPE::SMALL at the top of both render paths. Faces are constructed once and reused, so the Diagnostics contentScrolls flag (which gates needsFrequentRefresh) persisted across switches: if the face was last shown with static content it stayed false, so returning to it could schedule the first frame at the per-minute rate instead of the scroll rate. Add a virtual onActivate() hook, called from setFace, and re-arm contentScrolls=true in the Diagnostics override. The reading is centered in the ~24px beside the face. A 4-character mmol/L value (e.g. "22.3") in the large font (~27px) overflowed and was clipped off the right edge. Measure the value in the large font and, only when it does not fit, drop to the small font so it is always centered and fully visible. mg/dL and short mmol/L values keep the large font. Add the Smiley face to the clockfaces table and the feature list, and update the clockface count. The table image is left as a placeholder until a device screenshot is available.
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
This branch adds four new clock faces, a set of display performance and stability
fixes, and a per-machine PlatformIO configuration workflow so contributors don't
have to edit tracked files to flash their own board. It builds on
ulanzi_debug(
pio run -e ulanzi_debug) and has been verified on hardware (Ulanzi TC001).PlatformIO configuration
extra_configs—platformio.ininow merges anuntracked
platformio.local.inion top of the tracked config, so your serialport and upload speed never end up in a commit. (
platformio.ini)upload_port/upload_speedper OS; copy it toplatformio.local.inito get started. (platformio.local.ini.example)upload_speedlowered to a conservative115200(overrideto
921600locally once stable), and the hard-codedupload_portremoved soPlatformIO auto-detects the port. (
platformio.ini).gitignore)platformio.ini; added--fsand--allflows for filesystem/full-deviceflashing. (
scripts/build.sh,scripts/upload.sh,scripts/reset.sh)test values, and a curl equivalent for driving the device's API source.
(
scripts/ns_emulator.py)Code changes
Display performance
matrix->show()is a ~7–8 ms interrupts-disabled blit), eliminating a visibleflash and wasted work. (
src/BGDisplayManager.cpp,src/DisplayManager.cpp)scrolls, and fall back to a static, idle per-minute refresh when it fits.
(
src/BGDisplayFaceDiagnostics.cpp/.h,src/BGDisplayFaceTextBase.cpp/.h)(
src/BGDisplayFaceDiagnostics.cpp/.h); single map lookup ingetTextWidth(
src/DisplayManager.cpp); unit-specific refresh-time tracking(
src/BGDisplayManager.cpp/.h).Display correctness / shared state
pinning a font no longer inherit a leaked LARGE font and clip; added an
onActivate()hook to reset per-face view state on (re)selection, including theboot/default face. (
src/BGDisplayManager.cpp,src/BGDisplayFace.cpp/.h,src/BGDisplayFaceDiagnostics.cpp/.h)(
src/DisplayManager.cppfatal errors,src/BGSource.cpp"To API" prompt);fixed a missing
breakinsetFont. (src/DisplayManager.cpp)Peripherals
(
src/PeripheryManager.cpp)Docs
ns_emulator.pytesting flow. (README.md)platformio.local.iniworkflow and build/flash scripts.(
CONTRIBUTING.md)(
AGENTS.md)New screens
Four new clock faces, registered in
src/BGDisplayManager.cpp/.hand selectablevia the default-clock-face dropdown in the web UI (
data/index.html):6) — scrolling date/time alongside the BG value and trendarrow; scrolls only when the content overflows, otherwise static.
(
src/BGDisplayFaceDiagnostics.cpp/.h)7) — device battery percentage and uptime.(
src/BGDisplayFaceBatteryUptime.cpp/.h)8) — the large BG value cycling through rainbow colors.(
src/BGDisplayFaceBigTextRainbow.cpp/.h)9) — a round mood face beside a big centered reading: happy/greenin range, sad/blue below the low limit, angry/red above the high limit, and a
grey neutral face for no/stale data. Wide mmol/L readings fall back to a compact
font so they never clip. (
src/BGDisplayFaceSmiley.cpp/.h)