From ffd681b0761dfbf068c0a9ca7705b093d14264c7 Mon Sep 17 00:00:00 2001 From: Djuri Baars Date: Tue, 21 Nov 2023 16:05:00 +0100 Subject: [PATCH] Added WiFi signal status and settings --- .vscode/settings.json | 9 ++++----- src/lib/locales/en.json | 10 ++++++++-- src/lib/locales/es.json | 9 +++++++-- src/lib/locales/nl.json | 10 ++++++++-- src/lib/style/app.scss | 1 + src/routes/Control.svelte | 10 ++++++---- src/routes/Settings.svelte | 34 ++++++++++++++++++++++++++++++++++ src/routes/Status.svelte | 25 +++++++++++++++++++++++++ 8 files changed, 93 insertions(+), 15 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index c0772af..2fcadf2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,5 @@ { - "i18n-ally.localesPaths": [ - "src/lib/locales" - ], - "i18n-ally.keystyle": "nested" -} \ No newline at end of file + "i18n-ally.localesPaths": ["src/lib/locales"], + "i18n-ally.keystyle": "nested", + "i18n-ally.sourceLanguage": "en" +} diff --git a/src/lib/locales/en.json b/src/lib/locales/en.json index 7521b3a..01d0fc5 100644 --- a/src/lib/locales/en.json +++ b/src/lib/locales/en.json @@ -20,7 +20,9 @@ "fetchEuroPrice": "Fetch € price", "shortAmountsWarning": "Short amounts might shorten lifespan.", "tzOffsetHelpText": "A restart is required to apply TZ offset.", - "screens": "Screens" + "screens": "Screens", + "wifiTxPowerText": "In most cases this does not need to be set.", + "wifiTxPower": "WiFi TX power" }, "control": { "systemInfo": "System info", @@ -41,7 +43,8 @@ "wsPriceConnection": "WS Price connection", "wsMempoolConnection": "WS Mempool.space connection", "fetchEuroNote": "If you use \"Fetch € price\" the WS Price connection will show ❌ since it uses another data source.", - "uptime": "Uptime" + "uptime": "Uptime", + "wifiSignalStrength": "WiFi Signal strength" } }, "colors": { @@ -67,5 +70,8 @@ "control": { "keepSameColor": "Keep same color" } + }, + "rssiBar": { + "tooltip": "Values > -67 dBm are considered good. > -30 dBm is amazing" } } diff --git a/src/lib/locales/es.json b/src/lib/locales/es.json index fb6e7bc..cc58628 100644 --- a/src/lib/locales/es.json +++ b/src/lib/locales/es.json @@ -20,7 +20,8 @@ "enableMdns": "mDNS", "hostnamePrefix": "Prefijo de nombre de host", "mempoolnstance": "Instancia de Mempool", - "otaUpdates": "Actualización por aire" + "otaUpdates": "Actualización por aire", + "wifiTxPowerText": "En la mayoría de los casos no es necesario configurar esto." }, "control": { "turnOff": "Apagar", @@ -41,7 +42,8 @@ "screenCycle": "Ciclo de pantalla", "uptime": "Tiempo de funcionamiento", "fetchEuroNote": "Si utiliza \"Obtener precio en €\", la conexión de Precio WS mostrará ❌ ya que utiliza otra fuente de datos.", - "title": "Estado" + "title": "Estado", + "wifiSignalStrength": "Fuerza de la señal WiFi" } }, "button": { @@ -67,5 +69,8 @@ "control": { "keepSameColor": "Mantén el mismo color" } + }, + "rssiBar": { + "tooltip": "Se consideran buenos valores > -67 dBm. > -30 dBm es increíble" } } diff --git a/src/lib/locales/nl.json b/src/lib/locales/nl.json index 77e4ad6..d957aa2 100644 --- a/src/lib/locales/nl.json +++ b/src/lib/locales/nl.json @@ -20,7 +20,9 @@ "screens": "Schermen", "hostnamePrefix": "Hostnaam voorvoegsel", "mempoolnstance": "Mempool instantie", - "otaUpdates": "OTA updates" + "otaUpdates": "OTA updates", + "wifiTxPower": "WiFi TX power", + "wifiTxPowerText": "Meestal hoeft dit niet aangepast te worden." }, "control": { "systemInfo": "Systeeminformatie", @@ -40,7 +42,8 @@ "wsPriceConnection": "WS Prijs verbinding", "wsMempoolConnection": "WS Mempool.space verbinding", "fetchEuroNote": "Wanneer je \"Toon € prijs\" aanzet, zal de prijsverbinding als ❌ verbroken getoond worden vanwege het gebruik van een andere bron.", - "uptime": "Uptime" + "uptime": "Uptime", + "wifiSignalStrength": "WiFi signaalsterkte" } }, "colors": { @@ -66,5 +69,8 @@ "control": { "keepSameColor": "Behoud zelfde kleur" } + }, + "rssiBar": { + "tooltip": "Waarden > -67 dBm zijn goed. > -30 dBm is verbazingwekkend" } } diff --git a/src/lib/style/app.scss b/src/lib/style/app.scss index 5adf8b8..a0364f1 100644 --- a/src/lib/style/app.scss +++ b/src/lib/style/app.scss @@ -38,6 +38,7 @@ $input-font-size-sm: $font-size-base * 0.875; @import '../node_modules/bootstrap/scss/nav'; @import '../node_modules/bootstrap/scss/card'; @import '../node_modules/bootstrap/scss/progress'; +@import '../node_modules/bootstrap/scss/tooltip'; @import '../node_modules/bootstrap/scss/helpers'; @import '../node_modules/bootstrap/scss/utilities/api'; diff --git a/src/routes/Control.svelte b/src/routes/Control.svelte index 6bdd1cb..904bbf8 100644 --- a/src/routes/Control.svelte +++ b/src/routes/Control.svelte @@ -83,8 +83,8 @@
- - + + LEDs - - + + {#if ledStatus} {#each ledStatus as led, i} @@ -116,6 +116,8 @@ {/each} {/if} + + ([ + ['Default', 80], + ['19.5dBm', 78], // 19.5dBm + ['19dBm', 76], // 19dBm + ['18.5dBm', 74], // 18.5dBm + ['17dBm', 68], // 17dBm + ['15dBm', 60], // 15dBm + ['13dBm', 52], // 13dBm + ['11dBm', 44], // 11dBm + ['8.5dBm', 34], // 8.5dBm + ['7dBm', 28], // 7dBm + ['5dBm', 20] // 5dBm + ]); + const onSave = async (e: Event) => { e.preventDefault(); let formSettings = $settings; @@ -170,6 +184,26 @@ > + + + + + {#each wifiTxPowerMap as [key, value]} + + {/each} + + {$_('section.settings.wifiTxPowerText')} + + { memoryFreePercent = Math.round((value.espFreeHeap / value.espHeapSize) * 100); + + rssiPercent = Math.round(((value.rssi + 120) / (-30 + 120)) * 100); + + if (value.rssi > -55) { + wifiStrengthColor = 'success'; + } else if (value.rssi < -87) { + wifiStrengthColor = 'warning'; + } else { + wifiStrengthColor = 'info'; + } }); settings.subscribe((value: object) => { @@ -130,6 +143,18 @@
+ {rssiPercent}% + {$_('rssiBar.tooltip')} + +
+
{$_('section.status.wifiSignalStrength')}
+
+ {$status.rssi} dBm +
+
+
{$_('section.status.uptime')}: {toUptimestring($status.espUptime)}