From ec314bc5a6904f52276642a5c6f8c0bd17e5a115 Mon Sep 17 00:00:00 2001 From: Richard Kacerek Date: Thu, 22 Oct 2026 12:55:21 +0200 Subject: [PATCH] docs: design for second-screen (Casio weather clock + server stats views) Co-Authored-By: Claude Sonnet 5.5 --- docs/reference/casio_spike.py | 187 ++++++++++++++++++ docs/reference/weather-mockup.png | Bin 0 -> 12471 bytes .../specs/2026-10-22-second-screen-design.md | 173 ++++++++++++++++ 3 files changed, 360 insertions(+) create mode 100644 docs/reference/casio_spike.py create mode 100644 docs/reference/weather-mockup.png create mode 100644 docs/superpowers/specs/2026-10-22-second-screen-design.md diff --git a/docs/reference/casio_spike.py b/docs/reference/casio_spike.py new file mode 100644 index 0000000..6c64dbe --- /dev/null +++ b/docs/reference/casio_spike.py @@ -0,0 +1,187 @@ +"""THROWAWAY SPIKE: Casio-style clock mockup (static weather). Not production code.""" +import os +import sys +from datetime import datetime + +from PIL import Image, ImageDraw, ImageFont + +W, H = 480, 320 +BG = (170, 184, 154) +INK = (28, 36, 24) +GHOST = (158, 172, 143) # unlit segments, barely darker than the background +SLANT = 0.14 + +# mock forecast (spike): rain probability % for the next 12 h, and mm per hour +RAIN = [0, 0, 10, 20, 40, 70, 60, 50, 30, 20, 10, 0] +MM = [0, 0, 0, 0.1, 0.4, 1.2, 0.9, 0.5, 0.1, 0, 0, 0] + +SEGS = { + "0": "abcdef", "1": "bc", "2": "abdeg", "3": "abcdg", "4": "bcfg", + "5": "acdfg", "6": "acdefg", "7": "abc", "8": "abcdefg", "9": "abcdfg", +} + + +def slant(pts, base_y): + return [(x + SLANT * (base_y - y), y) for x, y in pts] + + +def hexseg(horizontal, c0, c1, c, t): + if horizontal: + pts = [(c0, c), (c0 + t / 2, c - t / 2), (c1 - t / 2, c - t / 2), + (c1, c), (c1 - t / 2, c + t / 2), (c0 + t / 2, c + t / 2)] + else: + pts = [(c, c0), (c + t / 2, c0 + t / 2), (c + t / 2, c1 - t / 2), + (c, c1), (c - t / 2, c1 - t / 2), (c - t / 2, c0 + t / 2)] + return pts + + +def digit(d, x, y, w, h, t, ch, ghost=True): + g = 1.5 + top, mid, bot = y + t / 2, y + h / 2, y + h - t / 2 + left, right = x + t / 2, x + w - t / 2 + geo = { + "a": hexseg(True, left + g, right - g, top, t), + "g": hexseg(True, left + g, right - g, mid, t), + "d": hexseg(True, left + g, right - g, bot, t), + "f": hexseg(False, top + g, mid - g, left, t), + "b": hexseg(False, top + g, mid - g, right, t), + "e": hexseg(False, mid + g, bot - g, left, t), + "c": hexseg(False, mid + g, bot - g, right, t), + } + on = SEGS.get(ch, "") + for name, pts in geo.items(): + lit = name in on + if lit or ghost: + d.polygon(slant(pts, y + h), fill=INK if lit else GHOST) + + +def number(d, text, x, y, w, h, t, gap, ghost=True): + """Draw digits and colons; returns x after the last glyph.""" + for ch in text: + if ch == ":": + s = t * 1.1 + cx = x + s + for cy in (y + h * 0.32, y + h * 0.68): + pts = [(cx - s / 2, cy - s / 2), (cx + s / 2, cy - s / 2), + (cx + s / 2, cy + s / 2), (cx - s / 2, cy + s / 2)] + d.polygon(slant(pts, y + h), fill=INK) + x += s * 2 + gap + elif ch == ".": + s = t * 1.0 + pts = [(x, y + h - s), (x + s, y + h - s), (x + s, y + h), (x, y + h)] + d.polygon(slant(pts, y + h), fill=INK) + x += s + gap + elif ch == "-": + c = y + h / 2 + d.polygon(slant(hexseg(True, x + t, x + w - t, c, t), y + h), fill=INK) + x += w + gap + else: + digit(d, x, y, w, h, t, ch, ghost) + x += w + gap + return x + + +def font(size): + for p in ("/opt/lcd/res/fonts/roboto/Roboto-Bold.ttf", + "/System/Library/Fonts/Supplemental/Arial Bold.ttf", + "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"): + if os.path.exists(p): + return ImageFont.truetype(p, size) + return ImageFont.load_default() + + +def sun_cloud(d, x, y, s): + """Partly-cloudy icon in a 'pixel LCD' feel, s = size.""" + cx, cy, r = x + s * 0.36, y + s * 0.36, s * 0.2 + d.ellipse((cx - r, cy - r, cx + r, cy + r), fill=INK) + for dx, dy in ((0, -1), (0, 1), (-1, 0), (1, 0), (-.7, -.7), (.7, -.7), (-.7, .7)): + d.line((cx + dx * r * 1.35, cy + dy * r * 1.35, cx + dx * r * 1.8, cy + dy * r * 1.8), + fill=INK, width=max(2, int(s / 16))) + # cloud with a light outline separating it from the sun + by = y + s * 0.82 + for pad, col in ((3, BG), (0, INK)): + d.ellipse((x + s * 0.30 - pad, by - s * 0.34 - pad, x + s * 0.68 + pad, by + pad), fill=col) + d.ellipse((x + s * 0.52 - pad, by - s * 0.26 - pad, x + s * 0.95 + pad, by + pad), fill=col) + d.rounded_rectangle((x + s * 0.18 - pad, by - s * 0.20 - pad, x + s * 0.95 + pad, by + pad), + radius=int(s * 0.1), fill=col) + + +def render(now): + img = Image.new("RGB", (W, H), BG) + d = ImageDraw.Draw(img) + f_small, f_tiny = font(15), font(12) + + # inner LCD window frame + d.rectangle((6, 6, W - 7, H - 7), outline=INK, width=2) + + # top: weekday row, current day inverted + days = ["PO", "ÚT", "ST", "ČT", "PÁ", "SO", "NE"] + cell = (W - 24) // 7 + for i, name in enumerate(days): + x0 = 12 + i * cell + if i == now.weekday(): + d.rectangle((x0, 14, x0 + cell - 6, 38), fill=INK) + col = BG + else: + col = INK + tw = d.textlength(name, font=f_small) + d.text((x0 + (cell - 6 - tw) / 2, 17), name, font=f_small, fill=col) + d.line((12, 46, W - 13, 46), fill=INK, width=2) + + # row A: time (left), seconds + date (right) + x = number(d, now.strftime("%H:%M"), 24, 54, 54, 96, 12, 9) + number(d, now.strftime("%S"), 378, 58, 24, 42, 6, 6) + number(d, now.strftime("%-d.%-m."), 372, 112, 14, 34, 4, 4, ghost=False) + + d.line((12, 160, W - 13, 160), fill=INK, width=2) + + # row B left: current weather + rain readout + d.text((22, 166), "ZLÍN NYNÍ", font=f_tiny, fill=INK) + sun_cloud(d, 20, 182, 56) + number(d, "14", 90, 184, 26, 46, 6, 7, ghost=False) + d.ellipse((160, 184, 170, 194), outline=INK, width=3) + d.text((22, 244), "MAX 16° MIN 7°", font=f_small, fill=INK) + d.text((22, 264), "DEŠŤ", font=f_tiny, fill=INK) + x = number(d, str(max(RAIN)), 22, 279, 18, 28, 4, 6, ghost=False) + d.text((x + 4, 288), "%", font=f_small, fill=INK) + + # divider + row B right: 12 h rain probability bar graph (LCD-style segments) + d.line((206, 168, 206, H - 14), fill=INK, width=2) + d.text((220, 166), "DEŠŤ % / HOD", font=f_tiny, fill=INK) + mm = f"{sum(MM):.1f} mm" + d.text((W - 18 - d.textlength(mm, font=f_small), 164), mm, font=f_small, fill=INK) + bar_w, pitch, seg_h, seg_gap, n_seg = 14, 21, 5, 1, 16 + gy1 = 282 + for i, pct in enumerate(RAIN): + bx = 222 + i * pitch + lit = round(pct / 100 * n_seg) + for k in range(n_seg): + y1 = gy1 - k * (seg_h + seg_gap) + d.rectangle((bx, y1 - seg_h, bx + bar_w, y1), + fill=INK if k < lit else GHOST) + hour = (now.hour + i) % 24 + if i % 3 == 0: + lab = f"{hour:02d}" + d.text((bx + bar_w / 2 - d.textlength(lab, font=f_tiny) / 2, 290), + lab, font=f_tiny, fill=INK) + return img + + +if __name__ == "__main__": + # fixed time for a stable preview; spike uses a Thursday afternoon + now = datetime(2026, 10, 22, 14, 32, 8) if "--fixed" in sys.argv else datetime.now() + img = render(now) + out = os.environ.get("OUT") + if out: + img.save(out) + print("saved", out) + if os.environ.get("PUSH"): + sys.path.insert(0, "/opt/lcd") + from library.lcd.lcd_comm import Orientation + from library.lcd.lcd_comm_rev_a import LcdCommRevA + lcd = LcdCommRevA(com_port=os.environ["PORT"]) + lcd.InitializeComm() + lcd.SetOrientation(Orientation.LANDSCAPE) + lcd.SetBrightness(50) + lcd.DisplayPILImage(img, x=0, y=0) + print("pushed") diff --git a/docs/reference/weather-mockup.png b/docs/reference/weather-mockup.png new file mode 100644 index 0000000000000000000000000000000000000000..7ad6b3d1513daad420660d69b269ef4cb01df0c1 GIT binary patch literal 12471 zcmb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Cvw;CxzAAi=DoC#?_;wlFBKYBrM^n` zO}5i8wCS30QXn|2!x^*_f`K?8Tqy@4tljWe9jFv3?KWj4)gru%&fbep!Tx7JMIYRJ zGBM=OO?7w_m7vLfw&cJ&i!}8@js4ck%{Fml0O1ihX)5vL{!wL(;;H+WFHKgmg6!JL zmb@72G9miW`5Dkz$k^=L?bQj7*ZFyR3YdjuMekv)X-Z7=pB@@z$mYb$GnAaH678S2 zUc#}DytgvV2$+=?J=+)Z5$(|H>B*;H(0~gQa>KU4-D@%w_NV1&K6-fG8+@FIL|hVl zaj&v2DmgKimX;2QiWH3~aHWMG^_@&OF<*APB-r*s`4}7mQpKrauIvS-ZzLthVocDm zgo8&0e;Of=YYVwoJD@@7f@u@^_9{7K_RrQX@G8OHgqyn(E-s?T63_C`4m(&M^nZ7J zcq=83X((ODHt28d}`0(4XZGWNmy*uatt@@+P^oj5wjOEXE8)U}*b}C^w?|3Lt9QM5J zvVR=TK%`)b^J_D;G{p^8ShBZF?{Z7eJ+`jQ^Qe|GGuI-dfOi9QS_~OXSYH*5q2nF1 zzTY~`hi@XQ+%u?Ku2q-rO!w)5jECf*otD_!ej{%_F#rxWZj{ga28%(@eNrL)Y9bd< zO~m6?Rn@2Z3IIxSI5USNgwQ0mY0aL7#ttiW=8yo7^J#c~KLYdwUs;2Kr~iMcq&0jS zq)Vk30KoT`dl3#~1iugO-*nLb^y)uxx$?XH6r-X)d1Md%AOTQ#sVq|__2$F>0;j^F A`v3p{ literal 0 HcmV?d00001 diff --git a/docs/superpowers/specs/2026-10-22-second-screen-design.md b/docs/superpowers/specs/2026-10-22-second-screen-design.md new file mode 100644 index 0000000..764fd9d --- /dev/null +++ b/docs/superpowers/specs/2026-10-22-second-screen-design.md @@ -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/.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.