Terrain closes by itself again: the road's surface only off the route (back on it the last road's stayed, so the view never closed); while it's open the top row's Limit shows the surface. Navigated, the planned route behind the car thin and dashed under the trip log's track (the line and its casing clear there). The scale back over the map, bottom left. CAN recordings older than CAN_REC_KEEP_HOURS (24 by default, 0 keeps all) deleted when listed and every segment while recording. TODO tidied
CI / check (push) Successful in 23s
CI / deploy (push) Successful in 2m41s

This commit is contained in:
randy committed 2026-12-03 13:52:13 +01:00
1 parent 21ad6c0c21
commit f981b80599
9 files changed
+80 -34

No files matched your search

+14 -12
View File
@@ -121,9 +121,8 @@ plan from — the server does the heavy lifting. The UI is built for a mouse tod
route's next 2 km, Level here (can.json's levelling action, two taps), Road view; on by
itself on an unpaved surface (`/api/road` now gives Valhalla's `surface`, off a route only)
or roll / pitch past 10° for 10 s, back after 2 km of paved road; Menu: automatic / by
hand. Still to do: the surface while on a route (along the route's edges), Surface in the
top row in place of Limit while off-road,
the lanes in the manoeuvre cell, the profile served from `data/` once the editor exists
hand; while it's open the top row's Limit shows the surface. Still to do: the surface while
on a route (along the route's edges), the lanes in the manoeuvre cell, the profile served from `data/` once the editor exists
** [ ] Softkeys: the CAN keypad's labels on the screen edge next to its keys (G1000 style)
** [x] The Trip menu beside the map, not over it (Android Auto's side panel, seen again in
signalk-pypilot-newui): the map narrower, its buttons kept, its center (follow, crosshair,
@@ -152,11 +151,10 @@ plan from — the server does the heavy lifting. The UI is built for a mouse tod
Start / End, the line really driven (`--route-driven`). Stored crash-safe like a FIT: an
append-only journal per trip (`data/trip_log/<started>.ndjson`, fsynced every 5 s, a torn
last line skipped), a restart picks the running trip up from it; the library's track built
from it every 5 min and at the end. Still to do: the pictogram, the
planned route dashed behind, a walk from another device shown with it, visited points
** [ ] Colors: planned vs really driven — the planned route (magenta ahead, the part behind
from it every 5 min and at the end. Still to do: the pictogram, a walk from another device shown with it, visited points
** [x] Colors: planned vs really driven — the planned route (magenta ahead, the part behind
thin and dashed) and the recorded track solid on top (`--route-driven`), docs/design.adoc
** [ ] The menu while driving: showing routes and points, editing the trip — all of it on the
** [x] The menu while driving: showing routes and points, editing the trip — all of it on the
road, so simple: a few big tiles (Trip, Points, Layers, Search), one level deep, rows
≥ 76 px, a handful per screen, the action a big button (add a stop here / at a point,
skip the next one, move one up/down, show / hide a layer) — no drag, no hover, no small
@@ -166,7 +164,7 @@ plan from — the server does the heavy lifting. The UI is built for a mouse tod
* [ ] Desktop (the Design canvas' Desktop, 2026-12-03): copy the position under the cursor
to the clipboard (a key or the right-click menu) — today only the map's center copies,
from the status bar, so the way around it is to put the center on the point first
* [ ] Desktop: the scale back over the map, not in the status bar
* [x] Desktop: the scale back over the map, not in the status bar
* [x] Night mode — topbar button cycles auto (sun below the horizon at the map center) / on / off. The map has its own night palette (`NightMap` in `public/js/map_themes.js`, switched live with setPaintProperty): dark blue-gray ground, roads a step lighter, muted ochre motorways, light-gray labels on dark halos; raster overlays dimmed, our own track/point colors kept
** [x] The rest of the UI is still one invert+dim filter — CSS color tokens and a real dark set instead
* [x] Tracker as a top-down vehicle (car / motorbike / bicycle from its icon) rotated by the GNSS course, kept while standing still; "Navigate" (tracker card or Overlays status) follows it heading-up, tilted 60°, vehicle in the lower third — panning by hand ends it
@@ -250,7 +248,8 @@ already reaches the home MQTT broker (`mqtt_ext`) from ESPHome nodes in `~/espho
`data/can_rec/` (a power cut loses at most the last segment), the CANedge `CAN_DataFrame`
layout — asammdf decodes it with a DBC (checked against candump: every frame, < 0.002 ms)
*** [ ] Checked with CSS Electronics' converters (mdf2csv) too, and in CANalyzer if at hand
*** [ ] Old recordings cleaned up (data/can_rec grows ~85 MB an hour at 1000 frames/s)
*** [x] Old recordings cleaned up (data/can_rec grows ~85 MB an hour at 1000 frames/s): segments
older than `CAN_REC_KEEP_HOURS` (24 by default, 0 keeps all) go — diagnostics only
** [ ] Nodes describing themselves — no hand-written signals for our own nodes:
*** [x] esphome-canopen nodes over SDO: on a node's first heartbeat read its TPDOs
(`0x1800+n`:1 COB-ID, `0x1A00+n` mapping), each mapped entity's type (`0x2001`:N) and
@@ -447,7 +446,9 @@ server into the car (on the car's Wi-Fi, next to the MQTT broker) makes everythi
already offline work on the road. The Pi only serves; heavy builds stay on brick.
* [ ] Run the existing docker-compose stack on the CM5 (arm64: our image handles it, check
that the Valhalla and kiwix-serve images have arm64 builds); data on NVMe, not the SD card
that the Valhalla and kiwix-serve images have arm64 builds); data on NVMe, not the SD card.
maptool itself runs on rpi-dev (podman, data in /srv/podman/maptool/data on the NVMe);
Valhalla and kiwix-serve there not checked
* [ ] Build on brick, ship to the Pi: `offline.pmtiles`, `terrain.pmtiles`, Valhalla
`tiles.tar`, `places/*.sqlite`, `hiking_trails/*.geojson`, the ZIM — an rsync (only when
refreshed, which is rare) instead of the Pi's own build buttons; hide/disable those there
@@ -477,8 +478,9 @@ already offline work on the road. The Pi only serves; heavy builds stay on brick
other version into `item_history` and flagged in the UI so it can be restored; a delete vs.
an edit keeps the edit
** Logged tracker positions: append-only, merged by timestamp, no conflicts
* [ ] Hardware buttons: keyboard shortcuts in the page (zoom, Navigate, night mode, …) — the
cheap way with any BLE/USB keypad that sends plain keys
* [x] Hardware buttons: keyboard shortcuts in the page (zoom, Navigate, night mode, …) — the
cheap way with any BLE/USB keypad that sends plain keys. Done in drive mode (the profile's
`key`s, see HW integration); the desktop has none yet
* [ ] … and the full way: a CANopen keypad (Blink Marine style) on the CAN bus wired straight
to the Pi, read by maptool's native CAN (see "Native CAN" above; NMT start, key bitmap
from `0x180+node` as `bit` signals, LEDs via `0x200+node` still to send) → the
+21 -2
View File
@@ -6,15 +6,19 @@ module Maptool
# writes every interface's frames into ASAM MDF4 files, one per segment
# (`<dir>/<UTC start>.mf4`, asammdf with a DBC, CSS Electronics' tools);
# this starts it, stops it (SIGTERM: the segment being recorded is
# written) and lists what it wrote.
# written) and lists what it wrote. Segments older than `keep` seconds
# go (it's diagnostics, ~85 MB an hour at 1000 frames/s): when listed and
# every segment while recording; `keep` nil keeps them all.
class Recorder
NAME = /\A\d{8}-\d{6}\.mf4\z/
STOP_WAIT = 10 # s for the last segment to be written
attr_reader :dir, :error, :started_at
def initialize(dir, interfaces, binary: ENV.fetch("CAN_RECORDER", "can-recorder"), segment: 300)
def initialize(dir, interfaces, binary: ENV.fetch("CAN_RECORDER", "can-recorder"), segment: 300,
keep: (ENV.fetch("CAN_REC_KEEP_HOURS", "24").to_f * 3600).then { |s| s.positive? ? s : nil })
@dir = dir
@keep = keep
@interfaces = interfaces
@binary = binary
@segment = segment
@@ -35,6 +39,8 @@ module Maptool
@pid = pid
@started_at = Time.now.to_f
@error = nil
waiter = @waiter
Thread.new { loop { prune; break if waiter.join(@segment) } }
rescue SystemCallError => e
@error = "#{@binary}: #{e.message}"
raise
@@ -57,12 +63,25 @@ module Maptool
def files
return [] unless Dir.exist?(@dir)
prune
Dir.children(@dir).grep(NAME).sort.reverse.map do |name|
stat = File.stat(File.join(@dir, name))
{ name: name, size: stat.size, at: stat.mtime.to_f }
end
end
def prune
return unless @keep && Dir.exist?(@dir)
old = Time.now - @keep
Dir.children(@dir).grep(NAME).each do |name|
path = File.join(@dir, name)
File.delete(path) if File.mtime(path) < old
rescue SystemCallError
nil # gone meanwhile
end
end
def path(name)
path = File.join(@dir, name)
path if NAME.match?(name) && File.file?(path)
-5
View File
@@ -3766,11 +3766,6 @@ html.driving .drive-panel { grid-area: var(--drive-menu, 2 / 10 / 10 / 17); }
overflow: hidden;
}
.statusbar__scale .maplibregl-ctrl-scale {
margin: 0;
font-size: 11px;
}
.statusbar__rev {
margin-left: auto;
}
+3 -1
View File
@@ -414,8 +414,10 @@ export class DashboardControl {
// ({ deg, live }), the road's surface (off a route, /api/road), the CAN
// actions, and the km along the route (null off it).
state() {
const onRoute = this._route && this._offFixes < OFF_ROUTE_FIXES;
// the road's surface only off the route: back on it the last road's would stay (the terrain view never closed)
return { values: this._values, nav: this._nav, heading: this._heading(), simulated: !!this._simRunning, actions: this._actions || [],
surface: this._road?.surface ?? null, course: this._course, atKm: this._route && this._offFixes < OFF_ROUTE_FIXES ? this._lastAt : null };
surface: onRoute ? null : this._road?.surface ?? null, course: this._course, atKm: onRoute ? this._lastAt : null };
}
// Driving, the GNSS course; standing, the compass — else the last of either, not live.
+8 -3
View File
@@ -43,11 +43,13 @@ const NOT_YET = new Set();
// TILT_DEG for TILT_S; back to the road view after PAVED_BACK_M on paved road.
// Closed by hand while still off-road: not again until back on the road.
const UNPAVED = new Set(["compacted", "dirt", "gravel", "path", "impassable"]);
// Valhalla's surfaces, shown in place of the limit while the terrain view is open
const SURFACES = { paved_smooth: "Paved", paved: "Paved", paved_rough: "Rough", compacted: "Compacted", dirt: "Dirt", gravel: "Gravel", path: "Track", impassable: "Impassable" };
const TILT_DEG = 10;
const TILT_S = 10;
const PAVED_BACK_M = 2000;
const TERRAIN_AUTO_KEY = "maptool.terrainAuto";
const FIELDS = { speed: "Speed", limit: "Limit", altitude: "Altitude", time: "Time", sun: "Sun", nextStop: "Next stop",
const FIELDS = { speed: "Speed", limit: "Limit", surface: "Surface", altitude: "Altitude", time: "Time", sun: "Sun", nextStop: "Next stop",
toNextStop: "To next stop", etaNextStop: "ETA next stop", toEnd: "To the end" };
const CARDINALS = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
@@ -422,6 +424,8 @@ export function setupDriving(map, nightButton, routePanel, gpxPanel) {
const next = nav?.next ? `· ${typeof nav.next.limit === "number" ? nav.next.limit : "∞"} in ${distance(nav.next.m)}` : "";
return [typeof limit === "number" ? limit : limit === "unlimited" ? "∞" : "—", next, "drive-cell--limit"];
}
case "surface":
return [SURFACES[dash?.surface] || "—", dash?.surface ? "" : "unknown", UNPAVED.has(dash?.surface) ? "drive-terrain--caution" : ""];
case "altitude":
return [v.alt == null ? "—" : Math.round(v.alt), "m"];
case "time":
@@ -490,8 +494,9 @@ export function setupDriving(map, nightButton, routePanel, gpxPanel) {
const a = ahead();
for (const { cell, el } of cells) {
if (cell.widget === "field") {
const [value, unit, cls = ""] = fieldValue(cell.value, a);
el.innerHTML = `<span class="drive-cell__label">${FIELDS[cell.value] || cell.value}</span><span class="drive-cell__value ${cls}">${escapeHtml(value)} <small>${escapeHtml(unit)}</small></span>`;
const name = cell.value === "limit" && openPanel === terrain.el ? "surface" : cell.value; // off-road the surface matters, not the limit
const [value, unit, cls = ""] = fieldValue(name, a);
el.innerHTML = `<span class="drive-cell__label">${FIELDS[name] || name}</span><span class="drive-cell__value ${cls}">${escapeHtml(value)} <small>${escapeHtml(unit)}</small></span>`;
} else if (cell.widget === "maneuver") renderManeuver(el);
else if (cell.widget === "status") {
el.innerHTML = `<b class="drive-status__brand">MAPTOOL</b><span class="drive-cell__muted"><span class="${navigator.onLine ? "drive-status--ok" : ""}">●</span> ${navigator.onLine ? "online" : "offline"}${log?.active ? ` · <span class="drive-status--rec">● rec</span>` : ""}</span>`;
+2 -2
View File
@@ -306,7 +306,7 @@ map.addControl(new HomeButton({ bounds: SLOVAKIA_BOUNDS }), "top-right");
}
// The status bar: the map's center (click to copy), the point under the
// mouse, the zoom level, the scale.
// mouse, the zoom level.
const cursorLabel = document.querySelector(".statusbar__cursor");
let terrainOffline = false; // set once /api/terrain-tiles answers (below)
let elevationTimer = null;
@@ -325,7 +325,7 @@ const zoomLabel = document.querySelector(".statusbar__zoom");
const updateZoom = () => (zoomLabel.textContent = `Zoom ${map.getZoom().toFixed(1)}`);
updateZoom();
map.on("zoom", updateZoom);
document.querySelector(".statusbar__scale").appendChild(new ScaleControl({ unit: "metric" }).onAdd(map));
map.addControl(new ScaleControl({ unit: "metric" }), "bottom-left"); // over the map, as in the canvas' Desktop
// A small inset map showing where the current view sits in context — NPS's
// own overview plugin (docs/nps-resources.adoc's "overview" entry, still on
+21 -8
View File
@@ -610,6 +610,15 @@ export class RoutePanelControl {
return;
}
this._map.addSource(SOURCE, { type: "geojson", data, lineMetrics: true }); // line-progress for _showProgress
// the part behind while navigated: thin and dashed, under the line, which goes clear there (_showProgress)
this._map.addLayer({
id: `${SOURCE}-behind`,
type: "line",
source: SOURCE,
filter: ["==", ["geometry-type"], "LineString"],
layout: { "line-join": "round", visibility: "none" },
paint: { "line-color": getComputedStyle(document.documentElement).getPropertyValue("--ui-muted").trim() || "#6b6b66", "line-width": 2.5, "line-dasharray": [2, 2] },
});
this._map.addLayer({
id: `${SOURCE}-casing`,
type: "line",
@@ -634,21 +643,25 @@ export class RoutePanelControl {
});
}
// Navigated (km along the route, docs/design.adoc): the driven part
// dimmed, the rest magenta (--route-active); null: the planned blue.
// Navigated (km along the route, docs/design.adoc): the part behind thin
// and dashed, the rest magenta (--route-active); null: the planned blue.
_showProgress(km) {
if (!this._map.getLayer(`${SOURCE}-line`)) return;
const total = this._route?.properties.distance_km;
if (km == null || !total) {
const navigated = km != null && !!total;
this._map.setLayoutProperty(`${SOURCE}-behind`, "visibility", navigated ? "visible" : "none");
if (!navigated) {
this._map.setPaintProperty(`${SOURCE}-line`, "line-gradient", undefined);
this._map.setPaintProperty(`${SOURCE}-casing`, "line-gradient", undefined);
return;
}
const css = getComputedStyle(document.documentElement);
const active = css.getPropertyValue("--route-active").trim() || "#a21caf";
const driven = css.getPropertyValue("--ui-muted").trim() || "#6b6b66";
const active = getComputedStyle(document.documentElement).getPropertyValue("--route-active").trim() || "#a21caf";
const clear = "rgba(0, 0, 0, 0)";
const fraction = Math.min(1, Math.max(0, km / total));
this._map.setPaintProperty(`${SOURCE}-line`, "line-gradient",
fraction > 0 ? ["step", ["line-progress"], driven, fraction, active] : ["step", ["line-progress"], active, 1, active]);
// behind the car the line and its casing go clear: the dashed layer under them shows, the log's track over it
const ahead = (color) => (fraction > 0 ? ["step", ["line-progress"], clear, fraction, color] : ["step", ["line-progress"], color, 1, color]);
this._map.setPaintProperty(`${SOURCE}-line`, "line-gradient", ahead(active));
this._map.setPaintProperty(`${SOURCE}-casing`, "line-gradient", ahead("#fff"));
}
// A route item in the library ("Routes" folder), keeping its points and
+11
View File
@@ -119,4 +119,15 @@ class CanTest < Minitest::Test
assert_raises(Errno::ENOENT) { Maptool::Can::Recorder.new(dir, [], binary: "/nonexistent").start }
end
end
def test_the_recorder_drops_segments_older_than_it_keeps
Dir.mktmpdir do |dir|
old, fresh = %w[20261201-100000.mf4 20261203-100000.mf4].map { |name| File.join(dir, name).tap { |p| File.write(p, "x") } }
File.utime(Time.now - 25 * 3600, Time.now - 25 * 3600, old)
File.write(File.join(dir, "notes.txt"), "kept: not a segment")
assert_equal ["20261203-100000.mf4"], Maptool::Can::Recorder.new(dir, [], keep: 24 * 3600).files.map { |f| f[:name] }
refute File.exist?(old)
assert File.exist?(fresh) && File.exist?(File.join(dir, "notes.txt"))
end
end
end
-1
View File
@@ -28,7 +28,6 @@
<span class="statusbar__coords"></span>
<span class="statusbar__cursor"></span>
<span class="statusbar__zoom"></span>
<span class="statusbar__scale"></span>
<span class="statusbar__rev">rev <%= revision %></span>
</footer>
</div>