mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2025-07-09 23:25:45 +00:00
Add connection icons for signal strength
This commit is contained in:
parent
e3bc5f8bdc
commit
b5999364e2
3 changed files with 41 additions and 2 deletions
|
@ -1,3 +1,5 @@
|
|||
import { data } from "./load-data.js";
|
||||
|
||||
const statusDialog = document.querySelector(".dialog-status");
|
||||
const expandButton = document.querySelector(".expand-status");
|
||||
|
||||
|
@ -30,6 +32,10 @@ function setStatus(status) {
|
|||
setValue("sdk-version", status.sdkVersion);
|
||||
|
||||
setValue("rssi", status.connection.signalStrength);
|
||||
const icon = selectConnectionIcon(status.connection.signalStrength);
|
||||
document.querySelectorAll(".connection-icon").forEach((img) => {
|
||||
img.src = `/icons/${icon}`;
|
||||
});
|
||||
|
||||
setValue("cpu-freq", status.chip.cpuFreqMHz);
|
||||
setValue("cpu-cycle-count", status.chip.cycleCount);
|
||||
|
@ -86,4 +92,28 @@ function formatBytes(bytes) {
|
|||
return `${Math.round(value * 10) / 10} ${units[index]}`;
|
||||
}
|
||||
|
||||
function selectConnectionIcon(signalStrength) {
|
||||
// access point
|
||||
if (data.connection == 1) {
|
||||
return "hotspot.svg";
|
||||
}
|
||||
|
||||
// ethernet
|
||||
if (data.connection == 2) {
|
||||
return "lan.svg";
|
||||
}
|
||||
|
||||
// station
|
||||
if (signalStrength >= -50) {
|
||||
return "signal4.svg";
|
||||
}
|
||||
if (signalStrength >= -60) {
|
||||
return "signal3.svg";
|
||||
}
|
||||
if (signalStrength >= -70) {
|
||||
return "signal2.svg";
|
||||
}
|
||||
return "signal1.svg";
|
||||
}
|
||||
|
||||
setStatus(await loadStatus());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue