Feat/audit optimizations and features#1
Merged
Conversation
Build the frame URL with snprintf into a fixed buffer and defer the three timing-response-header reads to only when frame diagnostics are logged, reducing per-poll String allocation at ~20Hz. Force a one-shot have=0 full-frame repaint after a failed poll recovers so a stale offline banner is cleared. Remove the unreachable wait-loop in loadingUntilConnected and the dead overflow guard in parseHeaderMs.
Malformed JSON now returns 422 (was 500), non-object bodies fall through to 422, and request bodies over 16KB return 413, via a typed HttpError mapped in the top-level handler. Adds regression tests plus coverage for POST /input, GET /commands, and 404.
state.fullFrame is now a memoized getter computed only when a cold/resync client needs it, instead of re-encoding the whole screen on every partial/animation/game frame (byte-identical semantics). Idle device entries are swept after a TTL so arbitrary/preview ids cannot grow the registry unbounded. The snake Hamiltonian cycle is memoized per grid size.
…-rain game Home now shows a lunar/solar-term/festival subtitle from a self-contained calendar (1900-2100, no new dependency). Adds an optional Open-Meteo next-12h weather forecast for Hangzhou Xiaoshan (Settings -> Weather, quiet-failing, polled from main.ts), selectable clock themes (Settings -> Theme: Midnight/Sakura/Amber/Mono), and a deterministic digital-rain ambient game. Also: graceful SIGTERM/SIGINT shutdown, adaptive settings row spacing, and small UI cleanups (dead useMemo, nextFontKey dedup, unreachable brightness label).
CI runs vitest + typecheck + build for remote-render and pio test -e host + pio run -e esp12e for the firmware. Adds an npm run typecheck that also checks test files and a docker-compose healthcheck against /api/v1/health.
font/theme select+apply and rows-detail short_press no longer start animations that nothing renders, so they stop driving ~20fps re-render loops for 0.32s with no visible change (the font/theme change still renders once). tileChanged now diffs rows with native Buffer.compare instead of a per-pixel JS loop, encodeRgb565Rle writes into a preallocated Buffer instead of a number[], and render() reads the monotonic clock once.
Home shows the Gregorian date with Arabic numerals (e.g. 6月29日) and the lunar date with ordinary Chinese numerals (e.g. 五月十五, 正月初一) for visual contrast. Removed the now-unused Chinese-numeral helpers in home-copy.
Weather was buried two levels deep (Home -> Settings -> 5x scroll -> open). Reworked the information architecture so glanceable content lives on Home and Settings holds only config + diagnostics. Home now shows a current temp+condition chip on the date row and a thin 12-hour precipitation trend strip between the clock and the ambient game; the Settings 'Weather' detail page is removed. Added HEADER_REGION/FORECAST_REGION to the per-second home render so the weather elements refresh within ~1s of a cache update; nudged the ambient game down to open the forecast band.
The ambient game no longer runs on Home. Home is now a quiet clock + weather dashboard: current temp/condition chip on the date row and a full next-12h forecast (per-hour temperatures + precipitation bar strip) in the freed lower area. A short_press on Home starts a finite game show (new page 'game' / GameShowPage: a big clock with a large game below) that advances through snake/life/breakout/ants/pacman/rain on a dwell timer and on manual short_press, then returns to the calm home after the last game. double_press exits the show; long_press opens Settings. Games render larger in the show (cellSize/canvas ~216-224px). Adds GAME_TIME_REGION/GAME_AREA_REGION, removes the unused HOME_GAME_REGION and the home-ambient-game widget, and updates tests + docs.
The home forecast previously mixed metrics (precip-height bars with separate temperature numbers that did not line up). Replaced it with an Apple-Weather-style hourly row: each column is one hour with a drawn condition icon, precipitation % (blue, only when >=20%), and temperature, so everything in a column belongs to the same hour. Added weather icon kinds + a drawn WeatherIcon widget (sun/cloud/overcast/fog/rain/snow/thunder). The current-weather chip now shows an icon + temperature. Neutralized the default Midnight clock theme (clean white + cool gray instead of the green-tinted teal) and use white temps / blue precip / colored icons so the screen no longer looks monochrome. The panel is full-color RGB565; the earlier look was just palette choice.
… outlook Fixes the top-row overlap (date is left-aligned, current weather icon+temp sit on the right). Temperatures are now colour-coded cool->warm (current, hourly, and daily), precipitation stays blue, and condition icons are drawn in colour, so the screen is no longer monochrome. Adds a two-day outlook (明天/后天) below the hourly row, Apple-daily-style: condition icon, precipitation %, and a low->high temperature range bar; long-range forecasts are omitted. Open-Meteo now also fetches daily max/min/code/precip (forecast_days=3); weather.ts exposes days + tempColor.
Per the request, trims the outlook to the essentials and shrinks the footprint: a single hourly row (现在 + next hours: icon + colour-coded temperature) over a 今天/明天/后天 row (condition icon + high·low per day). Removed the multi-day range-bar rows and per-hour precipitation clutter; nothing beyond 后天 is shown. Keeps temperatures colour-coded and icons in colour; the clock stays the visual hero.
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.
No description provided.