From fbac6063b9189ed73ddabf8f8b2d7dce691023b6 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 3 Jun 2026 00:18:56 -0600 Subject: [PATCH] Add ignition-based screen sleep simulation --- simulator/static/style.css | 24 ++++++++++++++++++++++++ simulator/templates/index.html | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/simulator/static/style.css b/simulator/static/style.css index 68a082a..2626d8a 100644 --- a/simulator/static/style.css +++ b/simulator/static/style.css @@ -268,3 +268,27 @@ nav button { font-size: 1rem; color: #ccc; } + + +.sleep-overlay { + position: fixed; + inset: 0; + background: #000; + color: #777; + z-index: 10000; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + font-size: 2rem; +} + +.sleep-overlay.hidden { + display: none; +} + +.sleep-overlay small { + margin-top: 10px; + font-size: 1rem; + color: #555; +} diff --git a/simulator/templates/index.html b/simulator/templates/index.html index 8276763..20d256b 100644 --- a/simulator/templates/index.html +++ b/simulator/templates/index.html @@ -14,6 +14,11 @@ + +
@@ -129,6 +134,7 @@ let relayState = {}; let activeAlarmKey = null; let acknowledgedAlarms = new Set(); +let screenWakeTimeout = null; let alarmConfig = { rear_seat_warning: 85, @@ -289,6 +295,7 @@ async function loadStatus() { document.getElementById('sysWifi').textContent = data.network.wifi_enabled ? 'Enabled' : 'Disabled'; document.getElementById('sysWifiOverride').textContent = data.network.wifi_override_active ? 'Active' : 'Inactive'; document.getElementById('sysIgnition').textContent = data.vehicle.ignition_on ? 'ON' : 'OFF'; + updateSleepOverlay(data.vehicle.ignition_on); checkAlarms(data); } @@ -303,6 +310,33 @@ async function toggleRelay(name) { loadStatus(); } +function updateSleepOverlay(ignitionOn) { + const overlay = document.getElementById('sleepOverlay'); + + if (ignitionOn) { + overlay.classList.add('hidden'); + return; + } + + if (!screenWakeTimeout) { + overlay.classList.remove('hidden'); + } +} + +function wakeScreen() { + const overlay = document.getElementById('sleepOverlay'); + overlay.classList.add('hidden'); + + if (screenWakeTimeout) { + clearTimeout(screenWakeTimeout); + } + + screenWakeTimeout = setTimeout(() => { + screenWakeTimeout = null; + overlay.classList.remove('hidden'); + }, 10000); +} + async function toggleIgnition() { await fetch('/vehicle/ignition', { method: 'POST',