docs: design for second-screen (Casio weather clock + server stats views)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
commit
ec314bc5a6
3 files changed
+360
No files matched your search
@@ -0,0 +1,173 @@
|
||||
# Second screen: Casio-style weather clock and server stats
|
||||
|
||||
Date: 2026-10-22. Project folder name `second-screen` is the designer's call.
|
||||
|
||||
## Intent and why
|
||||
|
||||
A second 3.5" Turing Smart Screen is plugged into the Coolify home server, next
|
||||
to the one that shows the bus departure board (project `bus-department-schedule`).
|
||||
The owner wants it to be something nice to glance at and something to play with:
|
||||
|
||||
1. A **Casio digital-watch style** view combining time, date, current weather and
|
||||
today's forecast, with rain as the most important forecast item.
|
||||
2. A **server stats** view (CPU, memory, disk, running containers and processes).
|
||||
3. A way to **switch between views, and to add new views later**, by changing a
|
||||
variable in the repo, committing, and redeploying. This is the owner's chosen
|
||||
switching method and the reason for the design: views are cheap, throwaway-friendly
|
||||
plug-ins and the screen shows exactly one at a time.
|
||||
|
||||
## Goals
|
||||
|
||||
- One Docker container drives the second screen and shows exactly one view, chosen by
|
||||
the `VIEW` setting (`weather` or `server` to start).
|
||||
- Adding a view means adding one module and one registry entry; no changes to the
|
||||
serial/drawing plumbing.
|
||||
- The weather view looks like the approved mockup (`docs/reference/weather-mockup.png`,
|
||||
produced by the throwaway script `docs/reference/casio_spike.py`, which is a
|
||||
reference for the segment-drawing and layout, not code to ship as is).
|
||||
- Deployed through Coolify from a public Gitea repo, exactly like the bus board.
|
||||
- Develop and preview without the screen: a script renders each view to a PNG using
|
||||
fake data, like the bus board's `preview_board.py`.
|
||||
|
||||
## Non-goals
|
||||
|
||||
- No touch or button input (the screen has none). No switching at runtime, no web UI,
|
||||
no HTTP endpoint, no rotating through views automatically.
|
||||
- One view per container, one container per screen. Not driving the bus-board screen.
|
||||
- No alerting, history, graphs over time for server stats, or authentication.
|
||||
- Not a general dashboard framework. Keep the view interface as small as it needs to be.
|
||||
|
||||
## Anti-goals (a failure even if it technically works)
|
||||
|
||||
- A screen that shows frozen or stale data as if it were fresh (old weather without
|
||||
any sign it is old; a clock that stopped).
|
||||
- A crash loop that keeps grabbing the serial port and blocks the bus board's container
|
||||
or the owner's debugging.
|
||||
- Weather or server stats code that can bring the clock down: the time must keep running
|
||||
when the weather service is unreachable.
|
||||
|
||||
## Constraints
|
||||
|
||||
- Hardware: Turing Smart Screen Rev A (sub-revision TURING_3_5), 320x480 panel.
|
||||
**Orientation for this screen is `LANDSCAPE`** (480x320 image). The bus-board screen
|
||||
uses `REVERSE_LANDSCAPE`; this one is mounted the opposite way, verified on 2026-10-22.
|
||||
- Screen library: mathoudebine/turing-smart-screen-python, pinned by commit in the
|
||||
Dockerfile, same commit as the bus board (`2b33ab4f00a096916dd6a1174441a53a7ec33b03`).
|
||||
Needs `library/` and `res/` (fonts) from it. Python 3.12-slim, Pillow, numpy, pyserial.
|
||||
- Device: `/dev/serial/by-id/usb-Turing_UsbMonitor_USB35INCHIPSV2-if00` (currently
|
||||
`ttyACM1`). The bus board uses `/dev/serial/by-id/usb-2017-2-25_UsbMonitor_USB35INCHIPSV2-if00`.
|
||||
Always use by-id paths, never `ttyACM*`.
|
||||
- Server: reach with `ssh coolify` (user `rickzkm`, in the `docker` group, no passwordless sudo).
|
||||
Deploy via Coolify: public Gitea repo (`https://gitea.madeinzlin.cz/rickzkm/<repo>.git`,
|
||||
branch `main`; the repo must stay public because Gitea SSH is disabled), build pack
|
||||
Docker Compose, compose location `/docker-compose.yml`, press Deploy after `git push`
|
||||
(no webhook). Only one container can hold a serial port.
|
||||
- Time zone `Europe/Prague`. Czech day names: PO ÚT ST ČT PÁ SO NE. 24 hour clock.
|
||||
Date shown as `22.10.` (day.month.).
|
||||
- Weather source: Open-Meteo (free, no API key), location **Zlín** (about 49.2265 N,
|
||||
17.6627 E; builder confirms coordinates).
|
||||
- Currently on the server a manual container `apod-test` (NASA picture app, stopped) and
|
||||
directory `~/apod-test` exist. They are leftovers of the first attempt and should be
|
||||
removed once this is deployed.
|
||||
|
||||
## Switching views (decided by the owner)
|
||||
|
||||
`VIEW` is set in `docker-compose.yml` (for example `VIEW: weather`). To change view:
|
||||
edit the value, commit, push, press Deploy in Coolify. Other settings (orientation,
|
||||
brightness, device path) are also environment variables with defaults in the compose
|
||||
file, in the style of the bus board. An unknown `VIEW` value must be a loud, visible
|
||||
failure (log and an on-screen message naming the valid views), not a silent default.
|
||||
Adding a new view later = new module + registry entry + README line.
|
||||
|
||||
## Weather view (approved mockup)
|
||||
|
||||
Layout, 480x320, pale LCD green-grey background with dark ink, drawn as slanted
|
||||
7-segment digits with faint "ghost" unlit segments, as in the mockup:
|
||||
|
||||
- **Top row:** weekday strip, today inverted.
|
||||
- **Time row:** large `HH:MM` on the left; on the right a small seconds readout and
|
||||
the date (`22.10.`).
|
||||
- **Bottom left:** "ZLÍN NYNÍ", a weather icon, current temperature in segment digits
|
||||
with a degree sign, today's `MAX`/`MIN`, and the highest rain probability in the
|
||||
window as a segment readout with `%`.
|
||||
- **Bottom right:** a Casio-style segmented **bar graph of rain probability for the next
|
||||
12 hours**, one bar per hour, hour labels every 3 hours, and the total expected
|
||||
precipitation in mm for those hours in the corner.
|
||||
|
||||
Decisions and calls:
|
||||
|
||||
- The graph window is **the next 12 hours from now** (the designer's call; the owner said
|
||||
the mockup was perfect but never chose between this and fixed calendar hours of today).
|
||||
- Bars show probability, not amount; the mm total is the amount.
|
||||
- Weather data refreshed every 15 minutes (designer's call). Needed fields: current
|
||||
temperature and weather code, today's max and min, hourly precipitation probability
|
||||
and precipitation amount.
|
||||
- Weather icon set: sun, partly cloudy, cloudy, rain, snow, storm, fog, drawn in the
|
||||
mockup's chunky style; mapping from WMO weather codes is left to the builder.
|
||||
- The time must be correct to the minute; seconds should tick live if the screen can take
|
||||
partial updates fast enough (builder to measure; if not, drop seconds and say so).
|
||||
- When weather fetch fails: keep showing the last good data and mark it visibly as old
|
||||
after a threshold (builder picks, suggest 1 hour); with no data ever, show dashes in the
|
||||
weather areas. The clock and date are unaffected.
|
||||
|
||||
## Server stats view
|
||||
|
||||
Same Casio LCD style, same palette. Content in priority order:
|
||||
|
||||
1. CPU usage, memory usage, disk usage of the main volume, as segmented bar graphs with
|
||||
a number.
|
||||
2. Load average, CPU temperature (if the host exposes one), uptime.
|
||||
3. Docker containers: name and status (up, healthy, unhealthy, restarting, exited).
|
||||
Container names on this server carry Coolify-generated random suffixes
|
||||
(for example `n8n-ebe62bdjbp9f755kwh59lv8d`, `screen-pe28mpghgqnxaz12vyfyijrg-151725872213`);
|
||||
show a readable short name.
|
||||
4. Top host processes by CPU (name and percent).
|
||||
|
||||
The owner said "running processes and so on" and the designer interpreted that as both the
|
||||
containers and the busiest host processes, containers being the primary meaning
|
||||
(designer's guess). Refresh about every 5 seconds. How many rows fit and the exact layout
|
||||
are left to the builder, subject to legibility from across a desk.
|
||||
|
||||
How data is read (designer's recommendation, builder may refine): from inside the
|
||||
container, read the host's `/proc` and `/sys` mounted read-only, and talk to the Docker
|
||||
Engine API over the mounted socket `/var/run/docker.sock` (plain HTTP over a unix socket,
|
||||
no extra Python Docker library needed). Note for the README: the Docker socket gives the
|
||||
container full control of Docker on the server even when mounted read-only. The owner
|
||||
explicitly approved mounting the socket on 2026-10-22.
|
||||
Reading host processes may need `pid: host`; builder decides the narrowest setup that works.
|
||||
|
||||
## Fixed by the process, left to the builder
|
||||
|
||||
- Module structure and view interface, drawing helpers (the segment drawing, gap, slant
|
||||
and thickness values from `casio_spike.py` are a starting point), tests, preview script
|
||||
with fake data, graceful shutdown (release the serial port on SIGTERM, restart policy
|
||||
`unless-stopped`), logging, README in the style of the bus board's.
|
||||
- Throttling/diffing of screen pushes so the serial link is not saturated.
|
||||
- Whether views share one render loop or each own a small tick schedule.
|
||||
|
||||
## Out of scope but noted
|
||||
|
||||
- Brightness schedule at night, an automatic return to the bus board, more views
|
||||
(NASA picture, etc.): later, via the same view mechanism.
|
||||
|
||||
## Calls made after the builder check (designer's calls, owner to review)
|
||||
|
||||
- **Bad `VIEW` or other startup failure:** open the port, draw the error message, log once,
|
||||
and **stay running idle** holding the port. No exit, so no restart loop.
|
||||
- **Device missing at startup** (cable out, by-id path changed): do not exit. Log once,
|
||||
retry opening the port every 30 s, draw as soon as it appears.
|
||||
- **Seconds are optional.** If partial updates are too slow, drop them and leave the date
|
||||
alone in that space (the date may then be drawn larger).
|
||||
- **Stale marker applies to both views**, not only weather. For server stats, a failed
|
||||
read keeps the last numbers and marks them as old after a few missed refreshes.
|
||||
- **Weather layout authority:** `docs/reference/weather-mockup.png` and `casio_spike.py`
|
||||
(both in this repo) are final for the weather view. The server view has no mockup: the
|
||||
builder designs it in the same style and the owner reviews the preview PNG before deploy.
|
||||
- **Disk bar:** the host's root filesystem, via a read-only mount. Bars are plain level
|
||||
readouts, no warning thresholds.
|
||||
- **`pid: host`** (for host process names): the owner approved the Docker socket but did not
|
||||
answer the question about `pid: host`. The designer's call is to allow it, since socket
|
||||
access already gives the container full control of Docker. Owner can veto; the fallback is
|
||||
dropping the top-processes section.
|
||||
- **Gitea repo creation and removal of the `apod-test` leftovers** are not yet answered by the
|
||||
owner: do not create the remote repo, push, or delete anything on the server without asking.
|
||||
Reference in new issue
Block a user