diff --git a/CODING_STYLE.md b/CODING_STYLE.md index 1dfb4311..11578c30 100644 --- a/CODING_STYLE.md +++ b/CODING_STYLE.md @@ -26,9 +26,11 @@ Like `some_feature_i.h` Names are snake-case. -Public functions are prefixed with `tt_` for `tactility-core` and `tactility` projects. +The `tt_` prefix is used for public functions that are part of `tactility/` or `tactility-core/` Internal/static functions don't have prefix requirements, but prefixes are allowed. +The prefix is **not** used for drivers, services and apps. + Public functions have the feature name after `tt_`. If a feature has setters or getters, it's added after the feature name part. @@ -36,7 +38,7 @@ If a feature has setters or getters, it's added after the feature name part. Example: ```c -void tt_feature_get_name() { +void tt_counter_get_limit() { // ... } ``` diff --git a/boards/lilygo_tdeck/keyboard.c b/boards/lilygo_tdeck/keyboard.c index be209ec6..fa049a9d 100644 --- a/boards/lilygo_tdeck/keyboard.c +++ b/boards/lilygo_tdeck/keyboard.c @@ -36,7 +36,16 @@ void keyboard_wait_for_response() { TT_LOG_I(TAG, "awake"); } -static void keyboard_read_callback(struct _lv_indev_drv_t* indev_drv, lv_indev_data_t* data) { +/** + * The callback simulates press and release events, because the T-Deck + * keyboard only publishes press events on I2C. + * LVGL currently works without those extra release events, but they + * are implemented for correctness and future compatibility. + * + * @param indev_drv + * @param data + */ +static void keyboard_read_callback(TT_UNUSED struct _lv_indev_drv_t* indev_drv, lv_indev_data_t* data) { static uint8_t last_buffer = 0x00; uint8_t read_buffer = 0x00; diff --git a/docs/ideas.md b/docs/ideas.md index 210d8fed..1c8560d8 100644 --- a/docs/ideas.md +++ b/docs/ideas.md @@ -4,6 +4,9 @@ - Replace FreeRTOS semaphore from `Loader` with internal `Mutex` - Create unit tests for `tactility-core` and `tactility` (PC-only for now) - Have a way to deinit LVGL drivers that are created from `HardwareConfig` +- Thread is broken: `tt_thread_join()` always hangs because `tt_thread_cleanup_tcb_event()` +is not automatically called. This is normally done by a hook in `FreeRTOSConfig.h` +but that seems to not work with ESP32. I should investigate task cleanup hooks further. # Core Ideas - Make a HAL? It would mainly be there to support PC development. It's a lot of effort for supporting what's effectively a dev-only feature. @@ -15,4 +18,5 @@ - BadUSB - IR transceiver app - GPIO status viewer -- BlueTooth keyboard app \ No newline at end of file +- BlueTooth keyboard app +- Investigate CSI https://stevenmhernandez.github.io/ESP32-CSI-Tool/ \ No newline at end of file diff --git a/tactility/src/services/gui/gui.c b/tactility/src/services/gui/gui.c index e5a2dbf4..2b317100 100644 --- a/tactility/src/services/gui/gui.c +++ b/tactility/src/services/gui/gui.c @@ -101,7 +101,7 @@ void gui_keyboard_hide() { } bool gui_keyboard_is_enabled() { - return !tt_lvgl_keypad_is_available() || FORCE_ONSCREEN_KEYBOARD; + return !tt_lvgl_keypad_is_available() || TT_CONFIG_FORCE_ONSCREEN_KEYBOARD; } void gui_hide_app() { diff --git a/tactility/src/services/gui/gui.h b/tactility/src/services/gui/gui.h index f78c4f2f..f9ed7226 100644 --- a/tactility/src/services/gui/gui.h +++ b/tactility/src/services/gui/gui.h @@ -11,14 +11,41 @@ extern "C" { typedef struct Gui Gui; +/** + * Set the app viewport in the gui state and request the gui to draw it. + * + * @param app + * @param on_show + * @param on_hide + */ void gui_show_app(App app, ViewPortShowCallback on_show, ViewPortHideCallback on_hide); +/** + * Hide the current app's viewport. + * Does not request a re-draw because after hiding the current app, + * we always show the previous app, and there is always at least 1 app running. + */ void gui_hide_app(); +/** + * Show the on-screen keyboard. + * @param textarea the textarea to focus the input for + */ void gui_keyboard_show(lv_obj_t* textarea); +/** + * Hide the on-screen keyboard. + * Has no effect when the keyboard is not visible. + */ void gui_keyboard_hide(); +/** + * This function is to facilitate hardware keyboards like the one on Lilygo T-Deck. + * The software keyboard is only shown when both of these conditions are true: + * - there is no hardware keyboard + * - TT_CONFIG_FORCE_ONSCREEN_KEYBOARD is set to true in tactility_config.h + * @return if we should show a keyboard for text input inside our apps + */ bool gui_keyboard_is_enabled(); #ifdef __cplusplus diff --git a/tactility/src/tactility_config.h b/tactility/src/tactility_config.h index e7abeed3..0623560d 100644 --- a/tactility/src/tactility_config.h +++ b/tactility/src/tactility_config.h @@ -1,3 +1,3 @@ #pragma once -#define FORCE_ONSCREEN_KEYBOARD false \ No newline at end of file +#define TT_CONFIG_FORCE_ONSCREEN_KEYBOARD false \ No newline at end of file