Skip to content

Commit

Permalink
feat: free context in general submenus
Browse files Browse the repository at this point in the history
  • Loading branch information
Otrebor671 committed Oct 29, 2024
1 parent abb42d2 commit b85a8ea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions firmware/main/general/general_submenu/general_submenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion firmware/main/modules/keyboard/keyboard_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
void keyboard_module_set_secondary_input_callback(input_callback_t input_cb);
11 changes: 6 additions & 5 deletions firmware/main/modules/oled_screen/oled_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit b85a8ea

Please sign in to comment.