Bigger next-pass panel with brightness on the ISS view, deploy on push

The map leaves out the polar caps (75° N to 60° S at the same scale) so the
next visible pass gets a 100 px panel: the time in 48 px type, the date, and
height, direction, estimated magnitude and clouds in 24 px. The magnitude is
the brightest moment of the pass by Matson's formula (standard magnitude -1.8).

A Gitea webhook now makes Coolify deploy every push to main, and Coolify
4.5.3 re-reads docker-compose.yml on each deploy, so no buttons are needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rickzkmandClaude Opus 5.5 committed 2026-10-29 22:48:19 +01:00
1 parent 0de68bfce0
commit 517f0868db
7 files changed
+136 -27

No files matched your search

+14 -4
View File
@@ -9,7 +9,7 @@ shapes, glitch numbers) for the server stats, a star chart of tonight's sky and
|---|---|
| `weather` | The week ahead in the Czech weekday strip (today first and inverted: icon, max and min for each day), big `HH:MM` with seconds, date, current temperature and feels-like (`POCIT`) for Zlín, and a 12-hour rain probability bar graph with the hour under every bar and the total mm. From sunset to sunrise the whole screen turns into a reverse LCD (light segments on black) |
| `sky` | Star chart of the sky over Zlín right now, as seen lying on your back (north up, east left): bright stars, a few constellations, the planets, the Moon in its real phase, and the sun by day. Beside it: the clock, tonight's full darkness, what is up (height and direction) or rising soon, the next 12 hours of cloud with a one-line summary, and the next visible ISS pass. Redrawn every minute |
| `iss` | Dotted world map with day and night: where the ISS is now, its ground track 40 minutes back and 95 ahead, Zlín, height, speed and position, and the next pass visible from Zlín with the cloud cover for that hour. Redrawn every 10 s |
| `iss` | Dotted world map with day and night (75° N to 60° S, the ISS never leaves ±51.6°): where the ISS is now, its ground track 40 minutes back and 95 ahead, Zlín, height, speed and position. Below it, in large type, the next pass visible from Zlín: time and date, highest point, direction, estimated brightness (magnitude) and the cloud cover for that hour. Redrawn every 10 s |
| `server` | Cyberpunk style: CPU / RAM / disk gauges (red from 80 %), load, CPU temperature, uptime, Docker containers (readable names and status chips) and the busiest processes. Refreshed every second; the container list every 5 s and the process ranking over 3 s windows |
Design: `docs/superpowers/specs/2026-10-22-second-screen-design.md`.
@@ -17,8 +17,8 @@ Plan: `docs/superpowers/plans/2026-10-22-second-screen.md`. Previews: `docs/prev
## Switching views
Edit `VIEW:` in `docker-compose.yml`, commit, `git push`, then in Coolify press **Reload Compose** on the app page
(it keeps its own copy of the compose file) and **Deploy**. An unknown or missing
Edit `VIEW:` in `docker-compose.yml`, commit and `git push`. Coolify deploys every push to `main` by itself and
reads `docker-compose.yml` from the repository again on each deploy (see Deployment). An unknown or missing
`VIEW` shows an error screen naming the valid views and keeps the container idle (no restart loop).
## Add a view
@@ -40,7 +40,13 @@ Edit `VIEW:` in `docker-compose.yml`, commit, `git push`, then in Coolify press
so Coolify cannot use a deploy key.
- Build pack **Docker Compose**, base directory `/`, **Docker Compose Location `/docker-compose.yml`**.
- No domain and no environment variables: the defaults in `docker-compose.yml` fit this server.
- **Update:** commit, `git push`, press **Reload Compose** if `docker-compose.yml` changed, then **Deploy** (no webhook).
- **Update:** commit and `git push`. A Gitea webhook (repository → Settings → Webhooks, "Coolify second-screen
deploy main") posts every push to `main` to `https://coolify.madeinzlin.cz/webhooks/source/gitea/events/manual`,
signed with the app's Gitea secret from Coolify (application → Webhooks → Manual Git webhooks → Gitea). Coolify
checks the signature and deploys. Since Coolify 4.5.3 every deploy reads `docker-compose.yml` from the repository
again, so **Reload Compose** is no longer needed. Check a deploy in Coolify → Deployment Logs (it says
**Webhook**) or with `ssh coolify 'docker ps'`. **Redeploy** in Coolify still works by hand.
- A push deploys nothing when every commit in it has `[skip ci]` or `[skip cd]` in its message.
- **Logs:** Coolify → the application → Logs, or `ssh coolify 'docker logs --tail 30 <container>'`.
- Only one container can hold a screen's serial port. Stop manual copies before deploying.
@@ -95,6 +101,10 @@ The screen library is pinned to one upstream commit in the `Dockerfile` (`LCD_CO
retried after 30 minutes because CelesTrak blocks eager clients) and the cloud cover (Open-Meteo, every 15 minutes)
come from the network. An ISS pass counts as visible when the station is sunlit while the sun here is more than 6°
below the horizon. By day the star chart still shows the stars where they stand.
- ISS brightness is an estimate: the brightest moment of the pass by Robert Matson's formula for a diffusely
reflecting sphere, from the distance and the sun–ISS–observer angle, with a standard magnitude of −1.8 at 1000 km
(`ISS_STD_MAG` in `astro.py`, observers quote −1.3 to −1.8). The real ISS is not a sphere and the angle of its
solar panels changes, so a pass can differ by about a magnitude.
- Server stats: process CPU is a share of the whole machine and grouped by command name; temperature is the CPU
package sensor if the host has one, else the hottest thermal zone.
- The screen's link moves about 150 KB/s (measured 2026-10-22: a full 480x320 frame takes 1.96 s, a 96x52 box 65 ms),
+39 -1
View File
@@ -20,6 +20,8 @@ BODIES = (("Měsíc", ephem.Moon), ("Merkur", ephem.Mercury), ("Venuše", ephem.
DARK_SUN_ALT = "-18" # astronomical darkness
VISIBLE_SUN_ALT = -6 # a satellite pass is visible once the sky is at least this dark
TRACK_BACK, TRACK_AHEAD = 40, 95 # minutes of ISS ground track around now
ISS_STD_MAG = -1.8 # brightness at 1000 km and a 90° phase angle; observers quote -1.3 to -1.8
PASS_STEP_S = 10 # how finely a pass is sampled to find its brightest moment
@dataclass(frozen=True)
@@ -45,6 +47,7 @@ class Pass:
az_from: float
az_to: float
visible: bool # the ISS is sunlit while the sky here is dark
mag: float # estimated magnitude at the brightest moment (lower is brighter)
@dataclass(frozen=True)
@@ -154,11 +157,46 @@ def next_visible_pass(tle: Tle, now: datetime, within_hours: float = 72) -> Pass
iss.compute(o)
sun.compute(o)
if not iss.eclipsed and math.degrees(sun.alt) < VISIBLE_SUN_ALT:
return Pass(_local(rise), math.degrees(top_alt), math.degrees(az_rise), math.degrees(az_set), True)
return Pass(_local(rise), math.degrees(top_alt), math.degrees(az_rise), math.degrees(az_set), True,
_brightest(iss, sun, o, rise, set_))
o.date = set_ + ephem.minute
return None
def magnitude(range_km: float, phase: float, std_mag: float = ISS_STD_MAG) -> float:
"""Estimated magnitude of a satellite seen as a diffusely reflecting sphere (Robert Matson's formula).
`phase` is the sun–satellite–observer angle in radians: 0 when fully lit as seen from here, π when only its
unlit side faces us.
"""
lit = max(1e-6, math.sin(phase) + (math.pi - phase) * math.cos(phase))
return std_mag - 15 + 5 * math.log10(range_km) - 2.5 * math.log10(lit)
def _unit(alt: float, az: float) -> tuple[float, float, float]:
return math.cos(alt) * math.sin(az), math.cos(alt) * math.cos(az), math.sin(alt)
def _phase(sat: ephem.EarthSatellite, sun: ephem.Sun) -> float:
"""The sun is so far away that its direction from the satellite is the same as from here."""
cos = -sum(a * b for a, b in zip(_unit(sat.alt, sat.az), _unit(sun.alt, sun.az)))
return math.acos(max(-1.0, min(1.0, cos)))
def _brightest(iss: ephem.EarthSatellite, sun: ephem.Sun, o: ephem.Observer, rise, set_) -> float:
"""The lowest magnitude while the ISS is above the horizon and sunlit."""
best = math.inf
t = rise
while t <= set_:
o.date = t
iss.compute(o)
sun.compute(o)
if iss.alt > 0 and not iss.eclipsed:
best = min(best, magnitude(iss.range / 1000, _phase(iss, sun)))
t += PASS_STEP_S * ephem.second
return best
def subsolar(now: datetime) -> tuple[float, float]:
"""Latitude and longitude where the sun is straight overhead."""
o = ephem.Observer()
+1 -1
View File
@@ -3,7 +3,7 @@ services:
build: .
restart: unless-stopped
environment:
# Which view to show: weather | server. To switch: edit, commit, push, press Deploy in Coolify.
# Which view to show: weather | server | sky | iss. To switch: edit, commit, push (Coolify deploys on push).
VIEW: iss
# Prefer the stable by-id path (see README); /dev/ttyACM1 can change after replug/reboot.
SCREEN_DEVICE: ${SCREEN_DEVICE:-/dev/serial/by-id/usb-Turing_UsbMonitor_USB35INCHIPSV2-if00}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 57 KiB

+42 -17
View File
@@ -8,7 +8,7 @@ from PIL import Image, ImageDraw
import astro
import skykit
from astro import direction
from astro import Pass, direction
from poller import Poller
from sky_data import CloudHour, Tle, cloud_at
from skykit import H, W, hm
@@ -20,13 +20,18 @@ MARKER, HOME = (255, 255, 255), (255, 110, 100)
LAND_DAY, LAND_NIGHT, SEA_DAY, SEA_NIGHT = (70, 168, 120), (26, 66, 50), (16, 32, 28), (8, 15, 13)
PAST, AHEAD = (50, 110, 96), ACCENT
STALE_BG = (240, 200, 90)
MAP_TOP, MAP_H, DOT = 40, 240, 4
CLEAR_SKY, SOME_CLOUD, OVERCAST = (120, 236, 160), (240, 200, 90), (255, 120, 100)
# The map leaves out the polar caps (the ISS stays within 51.6° of the equator) to make room for the next pass.
LAT_TOP, LAT_BOTTOM = 75, -60
MAP_TOP, MAP_H, DOT = 40, 180, 4 # 4/3 px per degree, the same scale as across
PANEL_TOP = MAP_TOP + MAP_H
GRID_X = (214, 344) # the two columns of height, direction, brightness and clouds
LAND_PATH = Path(__file__).parent / "assets" / "world_land.png"
EARTH_KM, GM = 6371.0, 398600.4418 # radius, and the gravitational parameter in km³/s²
def map_xy(lat: float, lon: float) -> tuple[float, float]:
return (lon + 180) / 360 * W, MAP_TOP + (90 - lat) / 180 * MAP_H
return (lon + 180) / 360 * W, MAP_TOP + (LAT_TOP - lat) / (LAT_TOP - LAT_BOTTOM) * MAP_H
def is_day(lat: float, lon: float, subsolar: tuple[float, float]) -> bool:
@@ -45,6 +50,27 @@ def _fmt(value: float) -> str:
return f"{abs(value):.1f}".replace(".", ",")
def mag_colour(mag: float):
"""How inviting a pass of this brightness is, as a colour (like the cloud cover)."""
# TODO(owner): pick the thresholds, e.g. CLEAR_SKY for a pass worth going out for.
return TEXT
def pass_cells(p: Pass, clouds: tuple[CloudHour, ...]) -> list[tuple[str, str, tuple]]:
"""(label, value, colour) for the grid beside the time of the next pass."""
pct = cloud_at(clouds, p.start)
if pct is None:
cloud = ("--", DIM)
else:
cloud = (f"{pct} %", OVERCAST if pct >= 60 else SOME_CLOUD if pct >= 25 else CLEAR_SKY)
return [
("VÝŠKA", f"{p.max_alt:.0f}°", TEXT),
("SMĚR", f"{direction(p.az_from)} → {direction(p.az_to)}", TEXT),
("JASNOST", f"{p.mag:.1f} mag".replace("-", "−").replace(".", ","), mag_colour(p.mag)),
("MRAKY", *cloud),
]
class IssView:
name = "iss"
TLE_STALE_AFTER = 3 * 86400.0
@@ -114,30 +140,29 @@ class IssView:
@staticmethod
def _map(d: ImageDraw.ImageDraw, now: datetime) -> None:
land = _land().load()
skip = round((90 - LAT_TOP) / 180 * _land().height) # rows of the whole-world mask above the map
sun = astro.subsolar(now)
for gy in range(DOT // 2, MAP_H, DOT):
lat = 90 - (gy + 1) / MAP_H * 180
lat = LAT_TOP - (gy + 1) / MAP_H * (LAT_TOP - LAT_BOTTOM)
for gx in range(DOT // 2, W, DOT):
day = is_day(lat, (gx + 1) / W * 360 - 180, sun)
if land[gx, gy]:
if land[gx, gy + skip]:
colour = LAND_DAY if day else LAND_NIGHT
else:
colour = SEA_DAY if day else SEA_NIGHT
d.rectangle((gx, MAP_TOP + gy, gx + 1, MAP_TOP + gy + 1), fill=colour)
def _next_pass(self, d: ImageDraw.ImageDraw, tle: Tle, now: datetime) -> None:
skykit.tracked(d, (14, 298), "DALŠÍ VIDITELNÝ PŘELET", skykit.font(10, 650), ACCENT)
y = PANEL_TOP + 20
skykit.tracked(d, (14, y), "DALŠÍ VIDITELNÝ PŘELET", skykit.font(12, 650), ACCENT)
p = astro.next_visible_pass(tle, now)
if p is None:
d.text((14, 316), "v příštích 3 dnech žádný", font=skykit.font(15, 700), fill=TEXT, anchor="ls")
d.text((14, y + 40), "v příštích 3 dnech žádný", font=skykit.font(24, 700), fill=TEXT, anchor="ls")
return
d.text((14, 316), f"{skykit.WEEKDAYS[p.start.weekday()]} {p.start.day}. {p.start.month}. v {hm(p.start)} · "
f"{p.max_alt:.0f}° · z {direction(p.az_from)} na {direction(p.az_to)}", font=skykit.font(15, 700),
fill=TEXT, anchor="ls")
pct = cloud_at(self._clouds.value or (), p.start)
if pct is not None:
label = f"mraky {pct} %"
colour = (255, 120, 100) if pct >= 60 else (240, 200, 90) if pct >= 25 else (120, 236, 160)
width = d.textlength(label, font=skykit.font(11, 700))
d.rounded_rectangle((466 - width - 16, 290, 466, 310), 10, fill=colour)
d.text((458, 304), label, font=skykit.font(11, 700), fill=BG, anchor="rs")
d.text((12, y + 50), hm(p.start), font=skykit.font(48, 800), fill=TEXT, anchor="ls")
d.text((14, y + 74), f"{skykit.WEEKDAYS[p.start.weekday()]} {p.start.day}. {p.start.month}.",
font=skykit.font(18, 650), fill=TEXT, anchor="ls")
for i, (label, value, colour) in enumerate(pass_cells(p, self._clouds.value or ())):
x, top = GRID_X[i % 2], y + i // 2 * 48
skykit.tracked(d, (x, top), label, skykit.font(12, 650), DIM)
d.text((x, top + 26), value, font=skykit.font(24, 750), fill=colour, anchor="ls")
+13
View File
@@ -1,3 +1,4 @@
import math
from datetime import datetime, timedelta
from pathlib import Path
@@ -85,6 +86,18 @@ def test_next_visible_iss_pass():
assert (direction(p.az_from), direction(p.az_to)) == ("Z", "JV")
def test_pass_brightness_is_that_of_a_typical_iss_pass():
p = astro.next_visible_pass(TLE, EVENING)
assert -4.2 < p.mag < -2.5 # a 40° pass: brighter than any star, short of the best overhead passes
def test_magnitude_formula():
assert astro.magnitude(1000, math.pi / 2) == pytest.approx(astro.ISS_STD_MAG)
assert astro.magnitude(500, math.pi / 2) == pytest.approx(astro.ISS_STD_MAG - 5 * math.log10(2))
assert astro.magnitude(1000, 0) == pytest.approx(astro.ISS_STD_MAG - 2.5 * math.log10(math.pi)) # fully lit
assert astro.magnitude(1000, math.pi) > 10 # only the dark side faces us: invisible, not an error
def test_no_visible_pass_within_the_window():
assert astro.next_visible_pass(TLE, EVENING, within_hours=6) is None
+27 -4
View File
@@ -6,7 +6,8 @@ import pytest
from PIL import ImageChops
import astro
from iss_view import MAP_TOP, MARKER, IssView, is_day, map_xy
from iss_view import LAT_BOTTOM, LAT_TOP, MAP_H, MAP_TOP, MARKER, PANEL_TOP, TEXT, IssView, is_day, map_xy, \
pass_cells
from sky_data import parse_clouds, parse_tle
from tests.helpers import count_near
@@ -59,9 +60,14 @@ def test_nothing_to_patch_between_frames():
def test_map_is_equirectangular_under_the_header():
assert map_xy(0, 0) == pytest.approx((240, MAP_TOP + 120))
assert map_xy(90, -180) == pytest.approx((0, MAP_TOP))
assert map_xy(-90, 180) == pytest.approx((480, MAP_TOP + 240))
assert map_xy(LAT_TOP, -180) == pytest.approx((0, MAP_TOP))
assert map_xy(LAT_BOTTOM, 180) == pytest.approx((480, MAP_TOP + MAP_H))
(x0, y0), (x1, y1) = map_xy(0, 0), map_xy(10, 10)
assert x1 - x0 == pytest.approx(y0 - y1) # degrees as wide as they are tall
def test_the_whole_orbit_fits_on_the_map():
assert MAP_TOP < map_xy(51.7, 0)[1] and map_xy(-51.7, 0)[1] < MAP_TOP + MAP_H
def test_day_and_night():
@@ -91,3 +97,20 @@ def test_stale_tag_only_when_the_orbit_is_old_and_only_in_the_header():
old = view(tle_age=4 * 86400).render(NOW)
bbox = ImageChops.difference(fresh, old).getbbox()
assert bbox is not None and bbox[3] <= MAP_TOP
def test_next_pass_grid_shows_height_direction_brightness_and_clouds():
p = astro.next_visible_pass(TLE, NOW)
cells = {label: value for label, value, _ in pass_cells(p, CLOUDS)}
assert cells["VÝŠKA"] == "40°"
assert cells["SMĚR"] == "Z → JV"
assert cells["JASNOST"].startswith("−") and cells["JASNOST"].endswith(" mag") and "," in cells["JASNOST"]
assert cells["MRAKY"] == "100 %"
assert {label: value for label, value, _ in pass_cells(p, ())}["MRAKY"] == "--"
def test_time_of_the_next_pass_is_large():
img = view().render(NOW).crop((0, PANEL_TOP, 200, 320))
mask = img.point(lambda v: 255 if v > 200 else 0).convert("L").point(lambda v: 255 if v == 255 else 0)
top, bottom = mask.getbbox()[1], mask.getbbox()[3]
assert bottom - top >= 50 # 48 px time over the date: readable across the room