Skip to content

Commit

Permalink
keira: add wifi icons
Browse files Browse the repository at this point in the history
  • Loading branch information
and3rson committed Mar 25, 2024
1 parent 7ef839e commit 36153fd
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions firmware/keira/src/apps/wifi_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include "servicemanager.h"
#include "services/network.h"

#include "icons/wifi_0.h"
#include "icons/wifi_1.h"
#include "icons/wifi_2.h"
#include "icons/wifi_3.h"

WiFiConfigApp::WiFiConfigApp() : App("WiFi") {
}

Expand Down Expand Up @@ -55,10 +60,29 @@ void WiFiConfigApp::run() {

lilka::Menu menu("Мережі");
for (int16_t i = 0; i < count; i++) {
// TODO: Add security (or signal strength) icon
const int8_t rssi = WiFi.RSSI();
uint8_t signalStrength;
if (rssi == 0) {
signalStrength = 0;
} else {
const int8_t excellent = -50;
const int8_t good = -70;
const int8_t fair = -80;

if (rssi >= excellent) {
signalStrength = 3;
} else if (rssi >= good) {
signalStrength = 2;
} else if (rssi >= fair) {
signalStrength = 1;
} else {
signalStrength = 0;
}
}
menu_icon_t* icons[] = {&wifi_0, &wifi_1, &wifi_2, &wifi_3};
menu.addItem(
networks[i],
0,
icons[signalStrength],
networkService->getPassword(networks[i]).length() ? lilka::display.color565(0, 255, 0)
: lilka::display.color565(255, 255, 255)
);
Expand Down

0 comments on commit 36153fd

Please sign in to comment.