From 62f1f2094228e446d94aa7819a8efc922e79edd7 Mon Sep 17 00:00:00 2001 From: Sassan Haradji Date: Sat, 20 Jul 2024 20:44:18 +0400 Subject: [PATCH] fix(keypad): keypad becoming unresponsive if a key was pressed while the app was loading - closes #118 --- CHANGELOG.md | 1 + pyproject.toml | 8 ++++---- ubo_app/load_services.py | 2 -- ubo_app/services/{020-keypad => 000-keypad}/setup.py | 2 ++ ubo_app/services/{020-keypad => 000-keypad}/ubo_handle.py | 0 5 files changed, 7 insertions(+), 6 deletions(-) rename ubo_app/services/{020-keypad => 000-keypad}/setup.py (99%) rename ubo_app/services/{020-keypad => 000-keypad}/ubo_handle.py (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae84e91f..eafb5fcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - refactor(system): generate the hostname of the device based on a hash of its serial number - feat(core): show hostname of device on the home page - closes #128 - feat(core): long-pressing the reset button for 3 seconds or more reboots the device - closes #116 +- fix(keypad): keypad becoming unresponsive if a key was pressed while the app was loading - closes #118 ## Version 0.15.4 diff --git a/pyproject.toml b/pyproject.toml index b540dbf4..5dd75332 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -132,6 +132,10 @@ profile = "black" [tool.pyright] exclude = ["typings"] +[[tool.pyright.executionEnvironments]] +root = "ubo_app/services/000-keypad" +extraPaths = ["."] + [[tool.pyright.executionEnvironments]] root = "ubo_app/services/000-sound" extraPaths = ["."] @@ -148,10 +152,6 @@ extraPaths = ["."] root = "ubo_app/services/020-keyboard" extraPaths = ["."] -[[tool.pyright.executionEnvironments]] -root = "ubo_app/services/020-keypad" -extraPaths = ["."] - [[tool.pyright.executionEnvironments]] root = "ubo_app/services/030-ethernet" extraPaths = ["."] diff --git a/ubo_app/load_services.py b/ubo_app/load_services.py index 2bddeda7..31017b9f 100644 --- a/ubo_app/load_services.py +++ b/ubo_app/load_services.py @@ -319,7 +319,6 @@ def stop(self: UboServiceThread) -> None: def load_services(service_ids: Sequence[str] | None = None) -> None: WHITE_LIST.extend(service_ids or []) - import time services = [] for services_directory_path in [ @@ -339,4 +338,3 @@ def load_services(service_ids: Sequence[str] | None = None) -> None: for service in services: service.initiate() - time.sleep(0.02) diff --git a/ubo_app/services/020-keypad/setup.py b/ubo_app/services/000-keypad/setup.py similarity index 99% rename from ubo_app/services/020-keypad/setup.py rename to ubo_app/services/000-keypad/setup.py index 112882a1..06a981b6 100644 --- a/ubo_app/services/020-keypad/setup.py +++ b/ubo_app/services/000-keypad/setup.py @@ -145,6 +145,8 @@ def init_i2c(self: Keypad) -> None: status='released' if is_mic_active else 'pressed', ) + self.clear_interrupt_flags(new_i2c) + def key_press_cb(self: Keypad, _: object) -> None: """Handle key press dispatched by GPIO interrupt. diff --git a/ubo_app/services/020-keypad/ubo_handle.py b/ubo_app/services/000-keypad/ubo_handle.py similarity index 100% rename from ubo_app/services/020-keypad/ubo_handle.py rename to ubo_app/services/000-keypad/ubo_handle.py