Skip to content

Commit

Permalink
docs and readability
Browse files Browse the repository at this point in the history
  • Loading branch information
KenVanHoeylandt committed Jan 27, 2024
1 parent 9cfcb16 commit a2946ed
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 6 deletions.
6 changes: 4 additions & 2 deletions CODING_STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@ 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.

Example:

```c
void tt_feature_get_name() {
void tt_counter_get_limit() {
// ...
}
```
Expand Down
11 changes: 10 additions & 1 deletion boards/lilygo_tdeck/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 5 additions & 1 deletion docs/ideas.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -15,4 +18,5 @@
- BadUSB
- IR transceiver app
- GPIO status viewer
- BlueTooth keyboard app
- BlueTooth keyboard app
- Investigate CSI https://stevenmhernandez.github.io/ESP32-CSI-Tool/
2 changes: 1 addition & 1 deletion tactility/src/services/gui/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
27 changes: 27 additions & 0 deletions tactility/src/services/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tactility/src/tactility_config.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once

#define FORCE_ONSCREEN_KEYBOARD false
#define TT_CONFIG_FORCE_ONSCREEN_KEYBOARD false

0 comments on commit a2946ed

Please sign in to comment.