diff --git a/TODO.adoc b/TODO.adoc index b79491c..8f0de65 100644 --- a/TODO.adoc +++ b/TODO.adoc @@ -94,6 +94,10 @@ plan from — the server does the heavy lifting. The UI is built for a mouse tod * [x] Side panels as an overlay in portrait instead of a pinned column — under 640 px the pin is ignored and the panel floats over the map at full width (a pinned 300 px panel left the phone a sliver of map); a real bottom sheet still open * [x] Driving mode (field test in the car, 2026-11): tiny icons and lists can't be hit while driving — a separate big-button UI for the few things needed on the road (navigate/follow, night mode, zoom, layer presets) rather than enlarging every planning panel. Done: "Drive" in the topbar (`driving.js`), per device — Follow, zoom, 2D/3D, night, route overview, exit down the left side; the sidebar and panels hidden ** [ ] Layer presets on the driving bar +** [x] The bar after the research (docs/design.adoc, "Buttons while driving"): four buttons + (zoom ±, view, overview), Follow and "Back to the position" one button shown only when not + following, 76×76 px; night and exit off the bar +** [ ] Softkeys: the CAN keypad's labels on the screen edge next to its keys (G1000 style) * [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 @@ -314,6 +318,13 @@ Planning in the NPS look, driving in the cockpit look, joined by the Unigrid bla the dark map; night mode sets Night, "◑" Dusk (the day map) . [ ] A Dusk map (between Park Tiles and `NightMap`), the map's palette following the UI's . [ ] Daylight: a full-opacity bezel preset for sun on the screen +. [ ] The display's backlight apart from the palette (as G1000/GPSMAP): the car's screen dimmed + for Night (DDC/CI or its own dimmer), the palette only picks the colors +. [ ] Auto night by the headlights (car CAN) or a light sensor on a node, with hysteresis + (not flipping in a tunnel) — the sun only as the fallback +. [ ] A red/black night palette (Garmin marine / Raymarine) for the darkest roads +. [ ] One night mode for every screen in the car (the server's, like Garmin over NMEA 2000) +. [ ] No flash back to Day at night: the palette switch eased in === HW integration diff --git a/docs/design.adoc b/docs/design.adoc index 4ee0a68..9b10583 100644 --- a/docs/design.adoc +++ b/docs/design.adoc @@ -100,6 +100,135 @@ The driving mode (`driving.js`, "Drive" in the topbar) is the cockpit's input side: big band-black buttons down the map's left — follow, zoom, 2D/3D, night, the route overview — and the planning sidebar hidden. +=== How others switch day and night (research, 2026-12-01) + +[cols="1,3"] +|=== +|Who |How + +|Garmin G1000 / G3X (aviation) +|Color scheme *Day / Night / Auto* apart from the *backlight*, which a +photocell sets on its own (a curve between a minimum and maximum, and a +time constant so it doesn't jump), or the aircraft's dimmer bus, or by +hand (down to 0.22 % on the PFD). + +|Garmin GPSMAP (boats) +|Color mode Day / Night / Auto (by the time of day or the light outside); +the night scheme itself selectable: *full color, red and black, or green +and black*; the backlight a setting of its own; display settings shared +with the other displays over NMEA 2000. Night charts "in muted tones +with enhanced contrast". + +|Raymarine (boats) +|Night mode: red text and icons on dark backgrounds; warns that going +back to Day at night jumps to full brightness and spoils night vision. + +|Garmin zūmo (motorbikes) +|Day / Night / Auto (by the time of day), brightness by hand — no +light sensor found in the manuals. + +|Ships (IMO MSC.191(79), IEC 62288, S-52) +|Colors and brightness for daylight, dusk and night, readable everywhere +on the bridge "with due consideration to the night vision" of the watch; +color never alone (size, shape, orientation too), red for alarms. +Furuno: Day / Dusk / Night palettes, each in a gray or blue variant, at +about 110 / 50 / 5 cd/m²; JRC: Day Bright, Day Whiteback, Day Blackback, +Dusk, Night. + +|Android Auto / CarPlay (cars) +|Automatic by the car's headlights or its light sensor, Day / Night by +hand; known to flip in tunnels and under bridges. +|=== + +What it means for us: + +* *Colors and brightness are two controls.* Everyone keeps the palette + (which colors) apart from the backlight (how bright); Night at ~5 cd/m² + is a backlight thing — CSS can't get a lit display that dim. The car's + display's backlight (DDC/CI or the panel's own dimmer) wanted for that. +* *Auto by what the vehicle knows:* the sun today; the headlights from + the car's CAN once they're on the bus (as Android Auto), a light sensor + on a node later (as the photocell) — with hysteresis, not flipping in a + tunnel. +* *A red night* (red/black) as Garmin's and Raymarine's option, for the + darkest roads. +* *One setting for all the car's screens* (Garmin shares it over NMEA + 2000): the night mode the server's, not each browser's, when they're in + the same car. +* *No flash on the way back to Day* at night: the switch eased in. + +Sources: Garmin G1000 manual (Display backlighting); Garmin G3X install +manual (photocell parameters); Garmin GPSMAP display settings and +"Changing the color mode" help pages; Garmin's "Navigate confidently in +the dark" blog; Raymarine display mode docs; Garmin zūmo 395/396 display +settings; IMO MSC.191(79) §5.3, §5.5; Furuno FAR-2107 / FE-800 and JRC +JAN-701B manuals; Google Maps / Waze help and 9to5Google on Android Auto. + +=== Buttons while driving: how others do it (research, 2026-12-01) + +Our driving bar (`driving.js`) came from OsmAnd's map buttons: seven +76×64 px buttons down the left (follow, zoom ±, 2D/3D, night, route +overview, exit). What the others do: + +[cols="1,3"] +|=== +|Who |How + +|Android Auto (Google's car design guidelines) +|Touch targets at least *76×76 dp* (the distance to the head unit, quick +taps); content readable in *2 s*, a response within 0.25 s; the map's +*action strip at most four buttons* (pan, recenter, zoom in/out). Google +Maps: *recenter only appears once the map was moved* and goes when +tapped; the compass toggles heading-up / north-up; route overview, +sound (mute / alerts only) and report on the edges. + +|Garmin zūmo XT (motorbikes) +|The rider *picks which buttons the map shows* (a wrench, top left); the +rest in a side panel from the bottom right; reviewers still find the +buttons small with gloves. + +|Garmin G1000 (aviation) +|*Softkeys*: a fixed row of physical keys along the display's bottom +bezel, their labels drawn on the screen right above them, changing with +the page; concentric knobs for values. Nothing to aim at — the hand finds +the key. + +|Garmin G3000 (aviation) +|Most input moved off the displays onto separate *touch controllers* +(GTC) on the pedestal, each driving a pane of the big displays; some +knobs and keys kept. + +|Ships (ECDIS, IMO S-Mode MSC.1/Circ.1609) +|Trackball and a key panel with *dedicated keys* (dimming up/down among +them); S-Mode standardizes the terms, icons and hot keys of the common +functions so every bridge works the same. +|=== + +What it means for us: + +* *Fewer buttons on the map*: four, not seven — zoom +, zoom −, the + view (2D/3D, heading-up/north-up), the route overview. Night is + automatic (and a topbar thing), "exit" is the topbar's Drive button + already. +* *Recenter only when needed*: "Follow" and "Back to the position" are the + same thing — one button, shown only while the map isn't following, in + one place. +* *76 px square* targets at least (ours are 76×64). +* *Softkeys for the CAN keypad* (Blink Marine style): its keys' labels + on the screen's edge next to them, changing with the screen — the G1000 + way, no aiming while driving. +* *A second screen as the controller* (G3000's GTC): the tablet or phone + drives the cab's display (the shared trip already works that way for + the route). +* *Pick your buttons* (zūmo) — later, if four fixed ones don't fit. + +Sources: Google's car design guidelines (sizing; map action strip); +Google Maps help and the Navigation SDK docs (recenter, compass, +overview); zūmo XT owner's manual and reviews (Motorcycle.com, Bennetts); +Garmin G1000 pilot's guide (softkeys, knobs); AIN and Aviation Consumer on +the G3000's GTCs; JRC JAN-701B and Kongsberg ECDIS manuals; IMO +MSC.1/Circ.1609. + == Typography * Planning UI: the system sans; *National Park* (the router-carved diff --git a/public/css/style.css b/public/css/style.css index 5b7c28f..f01bad1 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -3544,9 +3544,10 @@ html.driving #map .maplibregl-ctrl-top-left { display: none; } max-height: calc(100% - 24px); /* a low screen: the buttons shrink, to 44 px */ } .drive-bar[hidden] { display: none; } -.drive-bar button { +.drive-bar button, +.drive-bar__recenter { width: 76px; - flex: 0 1 64px; + flex: 0 1 76px; min-height: 44px; border: none; border-radius: 12px; @@ -3557,11 +3558,33 @@ html.driving #map .maplibregl-ctrl-top-left { display: none; } box-shadow: 0 2px 8px rgb(0 0 0 / 0.35); cursor: pointer; } -.drive-bar .drive-bar__follow, .drive-bar .drive-bar__overview { font-size: 16px; } -.drive-bar button:active { background: var(--accent); } +.drive-bar button:active, +.drive-bar__recenter:active { background: var(--accent); } +/* the one follow / back-to-the-position button, bottom left, only while + the map isn't following (driving.js); gnss.js's own one not meanwhile */ +.drive-bar__recenter { + position: absolute; + left: 12px; + bottom: 36px; + z-index: 4; + width: auto; + height: 76px; + padding: 0 22px; + border: none; + border-radius: 12px; + background: var(--band); + color: var(--band-fg); + font-size: 18px; + font-weight: 700; + box-shadow: 0 2px 8px rgb(0 0 0 / 0.35); + cursor: pointer; +} +.drive-bar__recenter[hidden], +html.driving .follow-resume { display: none; } .drive-bar button:disabled { opacity: 0.4; } html.follow-3d .maplibregl-ctrl-overview-map { display: none; } -.drive-bar .drive-bar__night { font-size: 30px; } /* npmap's home button draws its house in #333: the UI's text color instead */ .feather-home { fill: var(--ui-fg); } +:root[data-palette] .drive-bar button, +:root[data-palette] .drive-bar__recenter { box-shadow: 0 0 0 1px var(--ui-line), 0 2px 8px rgb(0 0 0 / 0.35); } diff --git a/public/js/driving.js b/public/js/driving.js index 781922b..6bb3988 100644 --- a/public/js/driving.js +++ b/public/js/driving.js @@ -1,12 +1,16 @@ import { LngLatBounds } from "/vendor/maplibre-gl/maplibre-gl.mjs"; import { requestGnssFollow, onRouteChanged } from "/js/panels.js"; -import { pauseFollow, resumeFollow } from "/js/gnss.js"; +import { pauseFollow, resumeFollow, isFollowing } from "/js/gnss.js"; -// Driving mode: the few things needed on the road as big buttons down the -// side of the map, the planning sidebar and panels out of the way (TODO: -// tiny icons can't be hit while driving). Per device (localStorage). +// Driving mode: the few things needed on the road as big buttons, the +// planning sidebar and panels out of the way. After the research in +// docs/design.adoc ("Buttons while driving"): four buttons on the map +// (Android Auto's action strip: at most four, 76 px), the recenter button +// only while the map isn't following (as Google Maps), night automatic and +// leaving by the topbar's Drive. Per device (localStorage). const KEY = "drivingMode"; const PITCH_3D = 60; // as map.js's 3D toggle +const CHECK_MS = 1000; // how often the recenter button looks whether the map follows export function setupDriving(map, nightButton) { let route = onRouteChanged((r) => (route = r)); @@ -17,47 +21,48 @@ export function setupDriving(map, nightButton) { toggle.textContent = "Drive"; nightButton.before(toggle); + const button = (name, label, title, action) => { + const el = document.createElement("button"); + el.type = "button"; + el.className = `drive-bar__${name}`; + el.textContent = label; + el.title = title; + el.setAttribute("aria-label", title); + el.addEventListener("click", action); + return el; + }; const bar = document.createElement("div"); bar.className = "drive-bar"; bar.hidden = true; - const buttons = { - follow: ["Follow", "Follow the position, heading up in 3D", () => { - requestGnssFollow(); - resumeFollow(map); - if (map.getPitch() === 0) map.easeTo({ pitch: PITCH_3D, duration: 300 }); - }], - zoomIn: ["+", "Zoom in", () => map.zoomIn()], - zoomOut: ["−", "Zoom out", () => map.zoomOut()], - pitch: ["2D", "2D / 3D", () => map.easeTo({ pitch: map.getPitch() > 0 ? 0 : PITCH_3D, ...(map.getPitch() > 0 && { bearing: 0 }), duration: 300 })], - night: ["", "Night mode", () => nightButton.click()], - overview: ["Route", "The whole route (the follow pauses)", () => { + bar.append( + button("zoomIn", "+", "Zoom in", () => map.zoomIn()), + button("zoomOut", "−", "Zoom out", () => map.zoomOut()), + button("pitch", "3D", "2D / 3D", () => map.easeTo({ pitch: map.getPitch() > 0 ? 0 : PITCH_3D, ...(map.getPitch() > 0 && { bearing: 0 }), duration: 300 })), + button("overview", "Route", "The whole route (the follow pauses)", () => { const coords = route?.geometry?.coordinates; if (!coords?.length) return; pauseFollow(map); map.fitBounds(coords.reduce((b, c) => b.extend(c), new LngLatBounds(coords[0], coords[0])), { padding: 80, pitch: 0, bearing: 0 }); - }], - exit: ["✕", "Leave driving mode", () => set(false)], - }; - for (const [name, [label, title, action]] of Object.entries(buttons)) { - const button = document.createElement("button"); - button.type = "button"; - button.className = `drive-bar__${name}`; - button.textContent = label; - button.title = title; - button.setAttribute("aria-label", title); - button.addEventListener("click", action); - bar.appendChild(button); - } - map.getContainer().appendChild(bar); + }), + ); + // the one "follow / back to the position", bottom left, only when needed + const recenter = button("recenter", "Follow", "Follow the position, heading up in 3D", () => { + requestGnssFollow(); + resumeFollow(map); + if (map.getPitch() === 0) map.easeTo({ pitch: PITCH_3D, duration: 300 }); + recenter.hidden = true; + }); + recenter.hidden = true; + map.getContainer().append(bar, recenter); const render = () => { bar.querySelector(".drive-bar__pitch").textContent = map.getPitch() > 0 ? "2D" : "3D"; - bar.querySelector(".drive-bar__night").textContent = nightButton.textContent; bar.querySelector(".drive-bar__overview").disabled = !route; + recenter.hidden = bar.hidden || isFollowing(map); }; map.on("pitchend", render); - nightButton.addEventListener("click", render); onRouteChanged(render); + setInterval(render, CHECK_MS); function set(on) { document.documentElement.classList.toggle("driving", on); diff --git a/public/js/gnss.js b/public/js/gnss.js index c14e422..a6e8f7a 100644 --- a/public/js/gnss.js +++ b/public/js/gnss.js @@ -57,6 +57,13 @@ export function pauseFollow(map) { state.timer = setTimeout(() => (state.button.hidden = true), FREE_LOOK_MS); } +// Is the map following a position right now (a follow step lately, not +// paused by hand)? For the driving bar's recenter button. +export function isFollowing(map) { + const state = freeLookState(map); + return Date.now() - state.followedAt <= FOLLOWING_MS && Date.now() >= state.until; +} + export function resumeFollow(map) { const state = freeLookState(map); state.until = 0;