From b85a8ea792eb72ea5ea58f73881cd953bb7c0a3a Mon Sep 17 00:00:00 2001 From: Roberto Arellano Date: Tue, 29 Oct 2024 17:48:09 -0600 Subject: [PATCH] feat: free context in general submenus --- .../main/general/general_submenu/general_submenu.c | 5 +++++ firmware/main/modules/keyboard/keyboard_module.h | 2 +- firmware/main/modules/oled_screen/oled_screen.c | 11 ++++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/firmware/main/general/general_submenu/general_submenu.c b/firmware/main/general/general_submenu/general_submenu.c index ea2e131..65105a3 100644 --- a/firmware/main/general/general_submenu/general_submenu.c +++ b/firmware/main/general/general_submenu/general_submenu.c @@ -43,6 +43,7 @@ static void input_cb(uint8_t button_name, uint8_t button_event) { case BUTTON_LEFT: void (*exit_cb)() = general_radio_selection_ctx->exit_cb; free(general_radio_selection_ctx); + general_radio_selection_ctx = NULL; if (exit_cb) { exit_cb(); } @@ -74,6 +75,10 @@ static void input_cb(uint8_t button_name, uint8_t button_event) { } void general_submenu(general_submenu_menu_t radio_selection_menu) { + if (general_radio_selection_ctx) { + free(general_radio_selection_ctx); + } + general_radio_selection_ctx = NULL; general_radio_selection_ctx = calloc(1, sizeof(general_submenu_menu_t)); general_radio_selection_ctx->options = radio_selection_menu.options; general_radio_selection_ctx->options_count = diff --git a/firmware/main/modules/keyboard/keyboard_module.h b/firmware/main/modules/keyboard/keyboard_module.h index 4a87db1..7b336b8 100644 --- a/firmware/main/modules/keyboard/keyboard_module.h +++ b/firmware/main/modules/keyboard/keyboard_module.h @@ -55,4 +55,4 @@ void keyboard_module_reset_idle_timer(); void keyboard_module_set_lock(bool lock); void keyboard_module_set_input_callback(input_callback_t input_cb); -void keyboard_module_set_secondary_input_callback(input_callback_t input_cb); \ No newline at end of file +void keyboard_module_set_secondary_input_callback(input_callback_t input_cb); diff --git a/firmware/main/modules/oled_screen/oled_screen.c b/firmware/main/modules/oled_screen/oled_screen.c index 4f103b6..72ae53c 100644 --- a/firmware/main/modules/oled_screen/oled_screen.c +++ b/firmware/main/modules/oled_screen/oled_screen.c @@ -73,13 +73,14 @@ void oled_screen_display_text(char* text, int x, int page, bool invert) { return; } - uint8_t _x = x + (strlen(text) * 8) > 128 ? 0 : x; - if (_x != x) { - ESP_LOGW(TAG, "Text %s is too long for the screen, x offset: %d", text, _x); - } + // uint8_t _x = x + (strlen(text) * 8) > 128 ? 0 : x; + // if (_x != x) { + // ESP_LOGW(TAG, "Text %s is too long for the screen, x offset: %d", text, + // _x); + // } xSemaphoreTake(oled_mutex, portMAX_DELAY); - oled_driver_display_text(&dev, page, text, _x, invert); + oled_driver_display_text(&dev, page, text, x, invert); xSemaphoreGive(oled_mutex); }