Repository navigation
Button press implementation for CV1 - #3876
simpleedev wants to merge 13 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements single, double, and triple tap actions for the device button, both in the firmware and the app. The changes include adding a new preference for triple tap, UI for configuring it, and the logic in CaptureProvider to handle these new events. The firmware is also updated with a new state machine for detecting multi-taps. The implementation is mostly good, but I've found a few areas for improvement regarding code duplication and race condition handling in the CaptureProvider and DeviceSettings files. These are important for maintainability and correctness.
| if (_isPaused) { | ||
| resumeDeviceRecording().then((_) { | ||
| _isProcessingButtonEvent = false; | ||
| }).catchError((e) { | ||
| debugPrint("Error resuming device recording: $e"); | ||
| _isProcessingButtonEvent = false; | ||
| }); | ||
| } else { | ||
| pauseDeviceRecording().then((_) { | ||
| _isProcessingButtonEvent = false; | ||
| }).catchError((e) { | ||
| debugPrint("Error pausing device recording: $e"); | ||
| _isProcessingButtonEvent = false; | ||
| }); | ||
| } |
There was a problem hiding this comment.
The logic to reset _isProcessingButtonEvent to false is duplicated in both the resumeDeviceRecording and pauseDeviceRecording paths. This can be simplified and made safer by using a single Future and attaching catchError and whenComplete to it. This ensures _isProcessingButtonEvent is always reset and reduces code duplication.
final future = _isPaused ? resumeDeviceRecording() : pauseDeviceRecording();
future.catchError((e) {
debugPrint("Error toggling device recording: $e");
}).whenComplete(() {
_isProcessingButtonEvent = false;
});There was a problem hiding this comment.
Code Review
This pull request introduces triple-tap functionality across the application and firmware, along with significant refactoring of button handling and settings. The firmware (omi/firmware/omi/src/lib/core/button.c) now detects single, double, and triple taps, and extends the long-press duration to 3 seconds, moving the device power-off action to this long press. A new check_boot_long_press function ensures the device only boots after a 3-second button hold. The application's CaptureProvider (app/lib/providers/capture_provider.dart) implements new logic to handle single, double, and triple tap events, including a 10-second window for single-tap initiated voice commands, and refactors the asynchronous handling of conversation processing. The SharedPreferencesUtil (app/lib/backend/preferences.dart) is updated to store the user's preferred triple-tap action. The DeviceSettings UI (app/lib/pages/settings/device_settings.dart) is refactored to include a new section for configuring triple-tap actions, reusing a generic component for both double and triple tap settings. A review comment noted that a condition in the new check_button_level function in the firmware (omi/firmware/omi/src/lib/core/button.c) contained dead code related to BUTTON_EVENT_RELEASE and suggested simplifying the logic for resetting btn_last_event.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces triple-tap functionality, refactoring existing button handling across both the application and firmware. On the firmware side, the button event detection logic in omi/firmware/omi/src/lib/core/button.c was completely overhauled to accurately distinguish between single, double, and triple taps, as well as a 3-second long press. A new check_boot_long_press function was added to main.c to enforce a 3-second button hold for device power-on. In the application, app/lib/backend/preferences.dart was updated to store triple-tap preferences, and app/lib/pages/settings/device_settings.dart received UI changes to allow users to configure triple-tap actions by refactoring the double-tap settings into reusable components. The app/lib/providers/capture_provider.dart now includes logic to handle single and triple tap events, mirroring the existing double-tap actions (toggle recording, star conversation, or end/process conversation), and forceProcessingCurrentConversation was updated to use await with error handling. Review comments highlighted a compile-time error in CaptureProvider due to forceProcessingCurrentConversation being unindented, and raised a concern about check_boot_long_press blocking the main thread during boot, suggesting a non-blocking approach.
|
|
||
| // change boot logic to 3 seconds | ||
|
|
||
| void check_boot_long_press(void) |
There was a problem hiding this comment.
This function blocks the entire boot process for 3 seconds using k_msleep in a loop. While this enforces a long press to power on, blocking the main thread during initialization is generally poor practice in embedded systems. It can prevent other critical tasks from running and make the device unresponsive. Consider a non-blocking approach, for example, by using a delayed work item (k_work_delayable) or a timer (k_timer) to check the button state after a delay without halting the boot sequence.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
Any demos, sirs? No test means there's no way you can be confident with the PR, so there's no way you should request a review :) there's some guideline to make your pr better next time omi TODO / bounties |
|
Fair. Thanks for the reply |
PR for
#3812
#2825
please review