Drive on other screens (field test on a 26″): the cells at most the profile's 80 px, on a bigger screen only the map's columns and rows stretch (the right column, the menus and the map keys stay cell-sized, a list shows more rows), on a smaller one everything — cells, type, icons — scaled by one factor so a 7″ keeps the same elements; a menu now lies over the cells of the area it opens in (Next stop and the rest covered Terrain), the dials sized by the cell; the simulation's roll and pitch always from the terrain under it, not the IMU of the car standing at home; the dashboard's card over the map hidden while driving (Terrain instead)
This commit is contained in:
1 parent
f73badd107
commit
d39e3b5edd
4 files changed
+84
-64
No files matched your search
@@ -213,7 +213,7 @@ export class DashboardControl {
|
||||
if (this._values.alt == null) {
|
||||
this._values.alt = await elevationAt(lon, lat, offline, { zoom: TILT_ZOOM, smooth: true });
|
||||
}
|
||||
if (this._course == null || this._values.pitch != null || this._values.roll != null) return;
|
||||
if (this._course == null) return;
|
||||
const [front, back, right, left] = await Promise.all([0, 180, 90, 270].map((b) => at(this._course + b)));
|
||||
if ([front, back, right, left].includes(null)) return;
|
||||
const deg = (rise) => Math.atan(rise / (2 * TILT_HALF_M)) / rad;
|
||||
@@ -391,7 +391,11 @@ export class DashboardControl {
|
||||
this._updateCourse(this._values);
|
||||
this._simRunning = !!data.simulated; // /sim.html runs it
|
||||
this._actions = data.actions || []; // can.json's SDO actions (levelling), POST /api/can/actions/<n>
|
||||
if (this._simRunning) await this._simulateTerrain();
|
||||
if (this._simRunning) {
|
||||
// simulated driving: the tilt of the terrain under it, not the IMU of the car standing at home
|
||||
this._values.pitch = this._values.roll = null;
|
||||
await this._simulateTerrain();
|
||||
}
|
||||
this._navigate();
|
||||
this._status.textContent = this._simRunning ? "Simulated GNSS" : data.available ? "" : "CAN is off on this server";
|
||||
this._status.hidden = !this._status.textContent;
|
||||
|
||||
+16
-3
@@ -503,13 +503,26 @@ export function setupDriving(map, nightButton, routePanel, gpxPanel) {
|
||||
|
||||
fetch(PROFILE_URL, { cache: "no-cache" }).then((r) => r.json()).then((p) => {
|
||||
profile = p;
|
||||
app.style.setProperty("--drive-cols", p.columns);
|
||||
app.style.setProperty("--drive-rows", p.rows);
|
||||
// Cells of p.cell px at most; on a bigger screen only the map's columns
|
||||
// and rows (beside an open menu) stretch, the rest stays cell-sized.
|
||||
const [mr1, mc1, mr2, mc2] = p.menu.map.split("/").map(Number);
|
||||
const track = (n, from, to) => Array.from({ length: n }, (_, i) => (i + 1 >= from && i + 1 < to ? "minmax(0, 1fr)" : "var(--cell)")).join(" ");
|
||||
// One scale for everything (--s): the cells, the type, the icons — the
|
||||
// same elements on a 7″ as on the 16″, only smaller; never bigger than drawn.
|
||||
const fit = () => {
|
||||
const scale = Math.min(1, window.innerWidth / (p.columns * (p.cell || 80)), window.innerHeight / (p.rows * (p.cell || 80)));
|
||||
app.style.setProperty("--s", scale.toFixed(3));
|
||||
app.style.setProperty("--cell", `${((p.cell || 80) * scale).toFixed(1)}px`);
|
||||
};
|
||||
fit();
|
||||
window.addEventListener("resize", fit);
|
||||
app.style.setProperty("--drive-columns", track(p.columns, mc1, mc2));
|
||||
app.style.setProperty("--drive-row-sizes", track(p.rows, mr1, mr2));
|
||||
app.style.setProperty("--drive-map", openPanel ? p.menu.map : p.map);
|
||||
app.style.setProperty("--drive-menu", p.menu.area);
|
||||
const [r1, c1, r2, c2] = p.menu.area.split("/").map(Number);
|
||||
app.style.setProperty("--drive-menu-cols", c2 - c1);
|
||||
app.style.setProperty("--drive-menu-rows", r2 - r1);
|
||||
app.style.setProperty("--drive-menu-mid", r2 - r1 - 4); // the list rows between the 3 on top and the foot
|
||||
for (const cell of p.cells) {
|
||||
const el = make(cell);
|
||||
app.append(el);
|
||||
|
||||
Reference in new issue
Block a user