Skip to content

Commit d21bdc0

Browse files
committed
add WiFi manager to settings
1 parent 2e41d95 commit d21bdc0

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

selfdrive/ui/layouts/network.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pyray as rl
2+
from openpilot.system.ui.lib.wifi_manager import WifiManagerWrapper
3+
from openpilot.system.ui.widgets.network import WifiManagerUI
4+
5+
6+
class NetworkLayout:
7+
def __init__(self):
8+
self.wifi_manager = WifiManagerWrapper()
9+
self.wifi_ui = WifiManagerUI(self.wifi_manager)
10+
11+
def render(self, rect: rl.Rectangle):
12+
self.wifi_ui.render(rect)
13+
14+
@property
15+
def require_full_screen(self) -> bool:
16+
return self.wifi_ui.require_full_screen
17+
18+
def shutdown(self):
19+
self.wifi_manager.shutdown()

selfdrive/ui/layouts/settings/settings.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from openpilot.common.params import Params
66
from openpilot.system.ui.lib.application import gui_app, FontWeight
77
from openpilot.system.ui.lib.label import gui_text_box
8+
from openpilot.selfdrive.ui.layouts.network import NetworkLayout
89

910
# Import individual panels
1011

@@ -56,7 +57,7 @@ def __init__(self):
5657
PanelType.TOGGLES: PanelInfo("Toggles", None, rl.Rectangle(0, 0, 0, 0)),
5758
PanelType.SOFTWARE: PanelInfo("Software", None, rl.Rectangle(0, 0, 0, 0)),
5859
PanelType.FIREHOSE: PanelInfo("Firehose", None, rl.Rectangle(0, 0, 0, 0)),
59-
PanelType.NETWORK: PanelInfo("Network", None, rl.Rectangle(0, 0, 0, 0)),
60+
PanelType.NETWORK: PanelInfo("Network", NetworkLayout(), rl.Rectangle(0, 0, 0, 0)),
6061
PanelType.DEVELOPER: PanelInfo("Developer", None, rl.Rectangle(0, 0, 0, 0)),
6162
}
6263

@@ -132,14 +133,18 @@ def _draw_sidebar(self, rect: rl.Rectangle):
132133
def _draw_current_panel(self, rect: rl.Rectangle):
133134
content_rect = rl.Rectangle(rect.x + PANEL_MARGIN, rect.y + 25, rect.width - (PANEL_MARGIN * 2), rect.height - 50)
134135
rl.draw_rectangle_rounded(content_rect, 0.03, 30, PANEL_COLOR)
135-
gui_text_box(
136-
content_rect,
137-
f"Demo {self._panels[self._current_panel].name} Panel",
138-
font_size=170,
139-
color=rl.WHITE,
140-
alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER,
141-
alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE,
142-
)
136+
if self._panels[self._current_panel].instance:
137+
# Render the current panel instance
138+
self._panels[self._current_panel].instance.render(content_rect)
139+
else:
140+
gui_text_box(
141+
content_rect,
142+
f"Demo {self._panels[self._current_panel].name} Panel",
143+
font_size=170,
144+
color=rl.WHITE,
145+
alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER,
146+
alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE,
147+
)
143148

144149
def handle_mouse_release(self, mouse_pos: rl.Vector2) -> bool:
145150
# Check close button

0 commit comments

Comments
 (0)