Skip to content

Commit

Permalink
fix: zigbee crash when displaying info card
Browse files Browse the repository at this point in the history
  • Loading branch information
Otrebor671 committed Aug 27, 2024
1 parent cf5f4e4 commit 973a4ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 7 additions & 1 deletion firmware/main/general/general_screens.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ static void* (*menu_restore_function)(void);
static void general_screen_display_scrolling();
static void general_screen_cb_modal(uint8_t button_name, uint8_t button_event);
static void general_screen_cb_scroll(uint8_t button_name, uint8_t button_event);
static const general_menu_t card_info_menu_ctx = {
.menu_items = NULL,
.menu_count = 0,
.menu_level = GENERAL_TREE_APP_SUBMENU,
};

char** general_screen_truncate_text(char* p_text, int* num_lines) {
char** lines = NULL;
Expand Down Expand Up @@ -84,7 +89,7 @@ static void general_screen_decrement_option() {
}

static void general_screen_display_breadcrumb() {
if (current_menu_ctx->menu_level == 0) {
if (current_menu_ctx->menu_level == GENERAL_TREE_APP_MENU) {
oled_screen_display_text("< Exit", 0, 0, OLED_DISPLAY_NORMAL);
} else {
oled_screen_display_text("< Back", 0, 0, OLED_DISPLAY_NORMAL);
Expand Down Expand Up @@ -201,6 +206,7 @@ void general_screen_display_card_information_handler(char* title,
}

void genera_screen_display_card_information(char* title, char* body) {
general_register_menu(&card_info_menu_ctx);
general_clear_screen();
general_screen_display_breadcrumb();
oled_screen_display_card_border();
Expand Down
13 changes: 3 additions & 10 deletions firmware/main/modules/zigbee/zigbee_screens_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ void zigbee_screens_module_creating_network_failed() {
void zigbee_screens_module_waiting_for_devices() {
static uint8_t dots = 0;
dots = ++dots > 3 ? 0 : dots;
oled_screen_clear_line(80, 3, OLED_DISPLAY_NORMAL);
genera_screen_display_card_information("Waiting for", "devices");
// Print dots from lef to right
for (int i = 0; i < dots; i++) {
oled_screen_display_text(".", 80 + (i * 8), 3, OLED_DISPLAY_NORMAL);
for (int i = 0; i < 3; i++) {
oled_screen_display_text(i < dots ? "." : "", 56 + (i * 8), 4,
OLED_DISPLAY_NORMAL);
}
}

Expand All @@ -49,31 +49,24 @@ void zigbee_screens_module_closing_network() {
void zigbee_screens_module_display_status(uint8_t status) {
switch (status) {
case CREATING_NETWORK:
printf("LINE: %d\n", __LINE__);
zigbee_screens_module_creating_network();
break;
case CREATING_NETWORK_FAILED:
printf("LINE: %d\n", __LINE__);
zigbee_screens_module_creating_network_failed();
break;
case WAITING_FOR_DEVICES:
printf("LINE: %d\n", __LINE__);
zigbee_screens_module_waiting_for_devices();
break;
case NO_DEVICES_FOUND:
printf("LINE: %d\n", __LINE__);
zigbee_screens_module_no_devices_found();
break;
case CLOSING_NETWORK:
printf("LINE: %d\n", __LINE__);
zigbee_screens_module_closing_network();
break;
case LIGHT_PRESSED:
printf("LINE: %d\n", __LINE__);
zigbee_screens_module_toogle_pressed();
break;
case LIGHT_RELASED:
printf("LINE: %d\n", __LINE__);
zigbee_screens_module_toggle_released();
default:
break;
Expand Down

0 comments on commit 973a4ef

Please sign in to comment.