Skip to content

Commit

Permalink
Enhanced the % RF signal calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinMueller2003 committed Dec 20, 2024
1 parent 9771ae8 commit 35b3655
Showing 1 changed file with 108 additions and 3 deletions.
111 changes: 108 additions & 3 deletions html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,111 @@ var ctx = canvas.getContext("2d");
ctx.font = "20px Arial";
ctx.textAlign = "center";

const rssiToPercent =
[
/* -100 */ 0,
/* -99 */ 0,
/* -98 */ 0,
/* -97 */ 0,
/* -96 */ 0,
/* -95 */ 0,
/* -94 */ 4,
/* -93 */ 6,
/* -92 */ 8,
/* -91 */ 11,
/* -90 */ 13,
/* -89 */ 15,
/* -88 */ 17,
/* -87 */ 19,
/* -86 */ 21,
/* -85 */ 23,
/* -84 */ 26,
/* -83 */ 28,
/* -82 */ 30,
/* -81 */ 32,
/* -80 */ 34,
/* -79 */ 35,
/* -78 */ 37,
/* -77 */ 39,
/* -76 */ 41,
/* -75 */ 43,
/* -74 */ 45,
/* -73 */ 46,
/* -72 */ 48,
/* -71 */ 50,
/* -70 */ 52,
/* -69 */ 53,
/* -68 */ 55,
/* -67 */ 56,
/* -66 */ 58,
/* -65 */ 59,
/* -64 */ 61,
/* -63 */ 62,
/* -62 */ 64,
/* -61 */ 65,
/* -60 */ 67,
/* -59 */ 68,
/* -58 */ 69,
/* -57 */ 71,
/* -56 */ 72,
/* -55 */ 73,
/* -54 */ 75,
/* -53 */ 76,
/* -52 */ 77,
/* -51 */ 78,
/* -50 */ 79,
/* -49 */ 80,
/* -48 */ 81,
/* -47 */ 82,
/* -46 */ 83,
/* -45 */ 84,
/* -44 */ 85,
/* -43 */ 86,
/* -42 */ 87,
/* -41 */ 88,
/* -40 */ 89,
/* -39 */ 90,
/* -38 */ 90,
/* -37 */ 91,
/* -36 */ 92,
/* -35 */ 93,
/* -34 */ 93,
/* -33 */ 94,
/* -32 */ 95,
/* -31 */ 95,
/* -30 */ 96,
/* -29 */ 96,
/* -28 */ 97,
/* -27 */ 97,
/* -26 */ 98,
/* -25 */ 98,
/* -24 */ 99,
/* -23 */ 99,
/* -22 */ 99,
/* -21 */ 100,
/* -20 */ 100,
/* -19 */ 100,
/* -18 */ 100,
/* -17 */ 100,
/* -16 */ 100,
/* -15 */ 100,
/* -14 */ 100,
/* -13 */ 100,
/* -12 */ 100,
/* -11 */ 100,
/* -10 */ 100,
/* -9 */ 100,
/* -8 */ 100,
/* -7 */ 100,
/* -6 */ 100,
/* -5 */ 100,
/* -4 */ 100,
/* -3 */ 100,
/* -2 */ 100,
/* -1 */ 100,
/* 0 */ 100,
];

// Default modal properties
$.fn.modal.Constructor.DEFAULTS.backdrop = 'static';
$.fn.modal.Constructor.DEFAULTS.keyboard = false;
Expand Down Expand Up @@ -1934,19 +2039,19 @@ function ProcessReceivedJsonStatusMessage(JsonStat) {
let Ethernet = Network.wifi;

let rssi = Wifi.rssi;
let quality = 2 * (rssi + 100);
let quality = rssi + 100;

if (rssi <= -100) {
quality = 0;
}
else if (rssi >= -50) {
else if (rssi >= 0) {
quality = 100;
}

$('#w_connected').text((true === Wifi.connected) ? "Yes" : "No");
$('#w_hostname').text(Wifi.hostname);
$('#w_rssi').text(rssi);
$('#w_quality').text(quality);
$('#w_quality').text(rssiToPercent[quality]);
$('#w_ssid').text(Wifi.ssid);
$('#w_ip').text(Wifi.ip);
$('#w_subnet').text(Wifi.subnet);
Expand Down

0 comments on commit 35b3655

Please sign in to comment.