mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 16:33:57 +08:00
WifiUi: tune wifi strengths (#36923)
* tune wifi strengths * android nor ios show none or slash. it's always 1, 2, or 3 bars * match here * clean up
This commit is contained in:
@@ -36,8 +36,6 @@ class WifiIcon(Widget):
|
||||
super().__init__()
|
||||
self.set_rect(rl.Rectangle(0, 0, 89, 64))
|
||||
|
||||
self._wifi_slash_txt = gui_app.texture("icons_mici/settings/network/wifi_strength_slash.png", 89, 64)
|
||||
self._wifi_none_txt = gui_app.texture("icons_mici/settings/network/wifi_strength_none.png", 89, 64)
|
||||
self._wifi_low_txt = gui_app.texture("icons_mici/settings/network/wifi_strength_low.png", 89, 64)
|
||||
self._wifi_medium_txt = gui_app.texture("icons_mici/settings/network/wifi_strength_medium.png", 89, 64)
|
||||
self._wifi_full_txt = gui_app.texture("icons_mici/settings/network/wifi_strength_full.png", 89, 64)
|
||||
@@ -57,17 +55,13 @@ class WifiIcon(Widget):
|
||||
return
|
||||
|
||||
# Determine which wifi strength icon to use
|
||||
strength = round(self._network.strength / 100 * 4)
|
||||
if strength == 4:
|
||||
strength = round(self._network.strength / 100 * 2)
|
||||
if strength == 2:
|
||||
strength_icon = self._wifi_full_txt
|
||||
elif strength == 3:
|
||||
elif strength == 1:
|
||||
strength_icon = self._wifi_medium_txt
|
||||
elif strength == 2:
|
||||
strength_icon = self._wifi_low_txt
|
||||
elif self._network.strength < 0:
|
||||
strength_icon = self._wifi_slash_txt
|
||||
else:
|
||||
strength_icon = self._wifi_none_txt
|
||||
strength_icon = self._wifi_low_txt
|
||||
|
||||
icon_x = int(self._rect.x + (self._rect.width - strength_icon.width * self._scale) // 2)
|
||||
icon_y = int(self._rect.y + (self._rect.height - strength_icon.height * self._scale) // 2)
|
||||
|
||||
@@ -631,7 +631,7 @@ class WifiManager:
|
||||
known_connections = self._get_connections()
|
||||
networks = [Network.from_dbus(ssid, ap_list, ssid in known_connections) for ssid, ap_list in aps.items()]
|
||||
# sort with quantized strength to reduce jumping
|
||||
networks.sort(key=lambda n: (-n.is_connected, -round(n.strength / 100 * 4), n.ssid.lower()))
|
||||
networks.sort(key=lambda n: (-n.is_connected, -round(n.strength / 100 * 2), n.ssid.lower()))
|
||||
self._networks = networks
|
||||
|
||||
self._update_ipv4_address()
|
||||
|
||||
Reference in New Issue
Block a user