Skip to content

Commit 536ccd0

Browse files
committed
do experimental mode
1 parent c85be61 commit 536ccd0

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

selfdrive/ui/layouts/home.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def show_event(self):
6868
def _setup_callbacks(self):
6969
self.update_alert.set_dismiss_callback(lambda: self._set_state(HomeLayoutState.HOME))
7070
self.offroad_alert.set_dismiss_callback(lambda: self._set_state(HomeLayoutState.HOME))
71+
self._exp_mode_button.set_click_callback(lambda: self.settings_callback() if self.settings_callback else None)
7172

7273
def set_settings_callback(self, callback: Callable):
7374
self.settings_callback = callback

selfdrive/ui/layouts/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def _setup_callbacks(self):
5050
on_flag=self._on_bookmark_clicked,
5151
open_settings=lambda: self.open_settings(PanelType.TOGGLES))
5252
self._layouts[MainState.HOME]._setup_widget.set_open_settings_callback(lambda: self.open_settings(PanelType.FIREHOSE))
53+
self._layouts[MainState.HOME].set_settings_callback(lambda: self.open_settings(PanelType.TOGGLES))
5354
self._layouts[MainState.SETTINGS].set_callbacks(on_close=self._set_mode_for_state)
5455
self._layouts[MainState.ONROAD].set_click_callback(self._on_onroad_clicked)
5556
device.add_interactive_timeout_callback(self._set_mode_for_state)

selfdrive/ui/widgets/exp_mode_button.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pyray as rl
22
from openpilot.common.params import Params
3-
from openpilot.system.ui.lib.application import gui_app, FontWeight
3+
from openpilot.system.ui.lib.application import gui_app, FontWeight, FONT_SCALE
44
from openpilot.system.ui.widgets import Widget
55

66

@@ -9,7 +9,7 @@ def __init__(self):
99
super().__init__()
1010

1111
self.img_width = 80
12-
self.horizontal_padding = 50
12+
self.horizontal_padding = 25
1313
self.button_height = 125
1414

1515
self.params = Params()
@@ -31,11 +31,6 @@ def _draw_gradient_background(self, rect):
3131
rl.draw_rectangle_gradient_h(int(rect.x), int(rect.y), int(rect.width), int(rect.height),
3232
start_color, end_color)
3333

34-
def _handle_mouse_release(self, mouse_pos):
35-
self.experimental_mode = not self.experimental_mode
36-
# TODO: Opening settings for ExperimentalMode
37-
self.params.put_bool("ExperimentalMode", self.experimental_mode)
38-
3934
def _render(self, rect):
4035
rl.draw_rectangle_rounded(rect, 0.08, 20, rl.WHITE)
4136

@@ -51,7 +46,7 @@ def _render(self, rect):
5146
# Draw text label (left aligned)
5247
text = "EXPERIMENTAL MODE ON" if self.experimental_mode else "CHILL MODE ON"
5348
text_x = rect.x + self.horizontal_padding
54-
text_y = rect.y + rect.height / 2 - 45 // 2 # Center vertically
49+
text_y = rect.y + rect.height / 2 - 45 * FONT_SCALE // 2 # Center vertically
5550

5651
rl.draw_text_ex(gui_app.font(FontWeight.NORMAL), text, rl.Vector2(int(text_x), int(text_y)), 45, 0, rl.BLACK)
5752

0 commit comments

Comments
 (0)