|
|
@ -29,6 +29,8 @@ BUTTON_SPACING = 50 |
|
|
|
OPENPILOT_URL = "https://openpilot.comma.ai" |
|
|
|
OPENPILOT_URL = "https://openpilot.comma.ai" |
|
|
|
USER_AGENT = f"AGNOSSetup-{HARDWARE.get_os_version()}" |
|
|
|
USER_AGENT = f"AGNOSSetup-{HARDWARE.get_os_version()}" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OPENPILOT_CACHE_PATH = "/data/openpilot.cache" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SetupState(IntEnum): |
|
|
|
class SetupState(IntEnum): |
|
|
|
LOW_VOLTAGE = 0 |
|
|
|
LOW_VOLTAGE = 0 |
|
|
@ -135,21 +137,19 @@ class Setup(Widget): |
|
|
|
self.state = SetupState.SOFTWARE_SELECTION |
|
|
|
self.state = SetupState.SOFTWARE_SELECTION |
|
|
|
|
|
|
|
|
|
|
|
def _custom_software_warning_continue_button_callback(self): |
|
|
|
def _custom_software_warning_continue_button_callback(self): |
|
|
|
self.state = SetupState.CUSTOM_SOFTWARE |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _getting_started_button_callback(self): |
|
|
|
|
|
|
|
self.state = SetupState.NETWORK_SETUP |
|
|
|
self.state = SetupState.NETWORK_SETUP |
|
|
|
self.stop_network_check_thread.clear() |
|
|
|
self.stop_network_check_thread.clear() |
|
|
|
self.start_network_check() |
|
|
|
self.start_network_check() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _getting_started_button_callback(self): |
|
|
|
|
|
|
|
self.state = SetupState.SOFTWARE_SELECTION |
|
|
|
|
|
|
|
|
|
|
|
def _software_selection_back_button_callback(self): |
|
|
|
def _software_selection_back_button_callback(self): |
|
|
|
self.state = SetupState.NETWORK_SETUP |
|
|
|
self.state = SetupState.GETTING_STARTED |
|
|
|
self.stop_network_check_thread.clear() |
|
|
|
|
|
|
|
self.start_network_check() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _software_selection_continue_button_callback(self): |
|
|
|
def _software_selection_continue_button_callback(self): |
|
|
|
if self._software_selection_openpilot_button.selected: |
|
|
|
if self._software_selection_openpilot_button.selected: |
|
|
|
self.download(OPENPILOT_URL) |
|
|
|
self.use_openpilot() |
|
|
|
else: |
|
|
|
else: |
|
|
|
self.state = SetupState.CUSTOM_SOFTWARE_WARNING |
|
|
|
self.state = SetupState.CUSTOM_SOFTWARE_WARNING |
|
|
|
|
|
|
|
|
|
|
@ -157,11 +157,14 @@ class Setup(Widget): |
|
|
|
self.state = SetupState.GETTING_STARTED |
|
|
|
self.state = SetupState.GETTING_STARTED |
|
|
|
|
|
|
|
|
|
|
|
def _network_setup_back_button_callback(self): |
|
|
|
def _network_setup_back_button_callback(self): |
|
|
|
self.state = SetupState.GETTING_STARTED |
|
|
|
self.state = SetupState.SOFTWARE_SELECTION |
|
|
|
|
|
|
|
|
|
|
|
def _network_setup_continue_button_callback(self): |
|
|
|
def _network_setup_continue_button_callback(self): |
|
|
|
self.state = SetupState.SOFTWARE_SELECTION |
|
|
|
|
|
|
|
self.stop_network_check_thread.set() |
|
|
|
self.stop_network_check_thread.set() |
|
|
|
|
|
|
|
if self._software_selection_openpilot_button.selected: |
|
|
|
|
|
|
|
self.download(OPENPILOT_URL) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
self.state = SetupState.CUSTOM_SOFTWARE |
|
|
|
|
|
|
|
|
|
|
|
def render_low_voltage(self, rect: rl.Rectangle): |
|
|
|
def render_low_voltage(self, rect: rl.Rectangle): |
|
|
|
rl.draw_texture(self.warning, int(rect.x + 150), int(rect.y + 110), rl.WHITE) |
|
|
|
rl.draw_texture(self.warning, int(rect.x + 150), int(rect.y + 110), rl.WHITE) |
|
|
@ -298,6 +301,14 @@ class Setup(Widget): |
|
|
|
self.keyboard.set_title("Enter URL", "for Custom Software") |
|
|
|
self.keyboard.set_title("Enter URL", "for Custom Software") |
|
|
|
gui_app.set_modal_overlay(self.keyboard, callback=handle_keyboard_result) |
|
|
|
gui_app.set_modal_overlay(self.keyboard, callback=handle_keyboard_result) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def use_openpilot(self): |
|
|
|
|
|
|
|
if os.path.isdir(OPENPILOT_CACHE_PATH): |
|
|
|
|
|
|
|
gui_app.request_close() |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
self.state = SetupState.NETWORK_SETUP |
|
|
|
|
|
|
|
self.stop_network_check_thread.clear() |
|
|
|
|
|
|
|
self.start_network_check() |
|
|
|
|
|
|
|
|
|
|
|
def download(self, url: str): |
|
|
|
def download(self, url: str): |
|
|
|
# autocomplete incomplete URLs |
|
|
|
# autocomplete incomplete URLs |
|
|
|
if re.match("^([^/.]+)/([^/]+)$", url): |
|
|
|
if re.match("^([^/.]+)/([^/]+)$", url): |
|
|
@ -305,9 +316,10 @@ class Setup(Widget): |
|
|
|
|
|
|
|
|
|
|
|
self.download_url = url |
|
|
|
self.download_url = url |
|
|
|
self.state = SetupState.DOWNLOADING |
|
|
|
self.state = SetupState.DOWNLOADING |
|
|
|
|
|
|
|
print("DOWNLOADING : " + url) |
|
|
|
|
|
|
|
|
|
|
|
self.download_thread = threading.Thread(target=self._download_thread, daemon=True) |
|
|
|
#self.download_thread = threading.Thread(target=self._download_thread, daemon=True) |
|
|
|
self.download_thread.start() |
|
|
|
#self.download_thread.start() |
|
|
|
|
|
|
|
|
|
|
|
def _download_thread(self): |
|
|
|
def _download_thread(self): |
|
|
|
try: |
|
|
|
try: |
|
|
|