From 7394167a2778c661f2916ff2f05e55e8172f9217 Mon Sep 17 00:00:00 2001 From: Roberto Arellano Date: Thu, 19 Sep 2024 16:38:07 -0600 Subject: [PATCH 01/31] feat: add infected typography & encrypted text --- firmware/main/drivers/oled_driver/oled_driver.c | 14 +++++++++++++- firmware/main/drivers/oled_driver/oled_driver.h | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/firmware/main/drivers/oled_driver/oled_driver.c b/firmware/main/drivers/oled_driver/oled_driver.c index e0a3231..993dd8c 100644 --- a/firmware/main/drivers/oled_driver/oled_driver.c +++ b/firmware/main/drivers/oled_driver/oled_driver.c @@ -10,6 +10,9 @@ static const char* TAG = "oled_driver"; +static bool encrypt = 0; +static bool typography = 0; + typedef union out_column_t { uint32_t u32; uint8_t u8[4]; @@ -99,7 +102,8 @@ void oled_driver_display_text(oled_driver_t* dev, uint8_t seg = x; uint8_t image[8]; for (uint8_t i = 0; i < _text_len; i++) { - memcpy(image, font8x8_basic_tr[(uint8_t) text[i]], 8); + memcpy(image, font8x8_basic_tr[(uint8_t) text[i] + encrypt] + typography, + 8); if (invert) oled_driver_invert(image, 8); if (dev->_flip) @@ -801,3 +805,11 @@ void oled_driver_draw_modal_box(oled_driver_t* dev, // oled_driver_show_buffer(dev); } + +void oled_driver_set_encrypt_value(bool value) { + encrypt = value; +} + +void oled_driver_set_typography_value(bool value) { + typography = value; +} \ No newline at end of file diff --git a/firmware/main/drivers/oled_driver/oled_driver.h b/firmware/main/drivers/oled_driver/oled_driver.h index a7954af..8bb34e4 100644 --- a/firmware/main/drivers/oled_driver/oled_driver.h +++ b/firmware/main/drivers/oled_driver/oled_driver.h @@ -246,6 +246,9 @@ void spi_hardware_scroll(oled_driver_t* dev, oled_driver_scroll_type_t scroll); void oled_driver_draw_modal_box(oled_driver_t* dev, int pos_x, int modal_height); + +void oled_driver_set_encrypt_value(bool value); +void oled_driver_set_typography_value(bool value); #ifdef __cplusplus } #endif From 00711b9794855209821a720f0ed49e88033ce179 Mon Sep 17 00:00:00 2001 From: Roberto Arellano Date: Fri, 20 Sep 2024 10:36:24 -0600 Subject: [PATCH 02/31] refactor: y_n modal port --- .../main/modules/file_manager/file_manager_module.c | 2 +- firmware/main/modules/modals/modals_screens.c | 12 +++++++++--- .../modules/settings/flash_fs/flash_fs_screens.c | 7 +++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/firmware/main/modules/file_manager/file_manager_module.c b/firmware/main/modules/file_manager/file_manager_module.c index 7344a09..bf19fbd 100644 --- a/firmware/main/modules/file_manager/file_manager_module.c +++ b/firmware/main/modules/file_manager/file_manager_module.c @@ -194,7 +194,7 @@ static void file_options_handler(int8_t selection) { menus_module_set_app_state(true, file_manager_input_cb); break; case FM_ERASE_OPTION: - if (modals_module_get_user_y_n_selection(" Are You Sure ") == + if (modals_module_get_user_y_n_selection(" Are You Sure? ") == YES_OPTION) { if (remove(fm_ctx->file_items_arr[fm_ctx->selected_item]->path) == 0) { modals_module_show_info("Deleted", "File was deleted successfully", diff --git a/firmware/main/modules/modals/modals_screens.c b/firmware/main/modules/modals/modals_screens.c index c7dd883..79437ff 100644 --- a/firmware/main/modules/modals/modals_screens.c +++ b/firmware/main/modules/modals/modals_screens.c @@ -4,14 +4,20 @@ #include "freertos/task.h" #include "oled_screen.h" -#define MAX_OPTIONS_NUM 7 +#ifdef CONFIG_RESOLUTION_128X64 + #define MAX_OPTIONS_NUM 8 + #define ITEMOFFSET 1 +#else // CONFIG_RESOLUTION_128X32 + #define MAX_OPTIONS_NUM 4 + #define ITEMOFFSET 0 +#endif void modals_screens_list_y_n_options_cb(modal_get_user_selection_t* ctx) { oled_screen_clear_buffer(); oled_screen_display_text(ctx->banner, 0, 0, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center(ctx->options[0], 3, + oled_screen_display_text_center(ctx->options[0], MAX_OPTIONS_NUM / 2 - 1, ctx->selected_option == 0); - oled_screen_display_text_center(ctx->options[1], 4, + oled_screen_display_text_center(ctx->options[1], MAX_OPTIONS_NUM / 2, ctx->selected_option == 1); oled_screen_display_show(); } diff --git a/firmware/main/modules/settings/flash_fs/flash_fs_screens.c b/firmware/main/modules/settings/flash_fs/flash_fs_screens.c index 4ceaa28..663d34b 100644 --- a/firmware/main/modules/settings/flash_fs/flash_fs_screens.c +++ b/firmware/main/modules/settings/flash_fs/flash_fs_screens.c @@ -1,11 +1,14 @@ #include "flash_fs_screens.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "general_screens.h" #include "keyboard_module.h" #include "modals_module.h" static void show_mounting_banner() { - modals_module_show_info( - "Mounting Flash", "Mounting Flash File System, please wait", 2000, false); + genera_screen_display_card_information("Mounting flash", "file system"); + vTaskDelay(pdMS_TO_TICKS(2000)); } static void show_result_banner(esp_err_t err) { From df004c66f955b3b40948e3b576ec3058c2433450 Mon Sep 17 00:00:00 2001 From: Roberto Arellano Date: Fri, 20 Sep 2024 11:03:07 -0600 Subject: [PATCH 03/31] refactor: radio selction & user selection screens port --- .../general_radio_selection.c | 15 +++++++++++---- firmware/main/modules/modals/modals_screens.c | 9 +++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/firmware/main/general/general_radio_selection/general_radio_selection.c b/firmware/main/general/general_radio_selection/general_radio_selection.c index a0eb165..a4b353d 100644 --- a/firmware/main/general/general_radio_selection/general_radio_selection.c +++ b/firmware/main/general/general_radio_selection/general_radio_selection.c @@ -5,7 +5,13 @@ #include "menus_module.h" #include "oled_screen.h" -#define MAX_OPTIONS_NUM 6 +#ifdef CONFIG_RESOLUTION_128X64 + #define MAX_OPTIONS_NUM 8 + #define ITEMOFFSET 1 +#else // CONFIG_RESOLUTION_128X32 + #define MAX_OPTIONS_NUM 4 + #define ITEMOFFSET 1 +#endif static const uint32_t SOUND_DURATION = 100; static general_radio_selection_t* general_radio_selection_ctx; @@ -20,8 +26,9 @@ static void (*list_radio_options)() = NULL; static void list_radio_options_old_style() { general_radio_selection_t* ctx = general_radio_selection_ctx; static uint8_t items_offset = 0; - items_offset = MAX(ctx->selected_option - 4, items_offset); - items_offset = MIN(MAX(ctx->options_count - 4, 0), items_offset); + items_offset = MAX(ctx->selected_option - MAX_OPTIONS_NUM + 2, items_offset); + items_offset = + MIN(MAX(ctx->options_count - MAX_OPTIONS_NUM + 2, 0), items_offset); items_offset = MIN(ctx->selected_option, items_offset); oled_screen_clear_buffer(); char* str = malloc(20); @@ -31,7 +38,7 @@ static void list_radio_options_old_style() { bool is_current = i + items_offset == ctx->current_option; char state = is_current ? 'x' : ' '; sprintf(str, "[%c] %s", state, ctx->options[i + items_offset]); - oled_screen_display_text(str, 0, i + 2, is_selected); + oled_screen_display_text(str, 0, i + ITEMOFFSET, is_selected); } oled_screen_display_show(); free(str); diff --git a/firmware/main/modules/modals/modals_screens.c b/firmware/main/modules/modals/modals_screens.c index 79437ff..d97796b 100644 --- a/firmware/main/modules/modals/modals_screens.c +++ b/firmware/main/modules/modals/modals_screens.c @@ -24,12 +24,17 @@ void modals_screens_list_y_n_options_cb(modal_get_user_selection_t* ctx) { void modals_screens_default_list_options_cb(modal_get_user_selection_t* ctx) { static uint8_t items_offset = 0; - items_offset = MAX(ctx->selected_option - 6, items_offset); + items_offset = MAX(ctx->selected_option - MAX_OPTIONS_NUM + 1 + ITEMOFFSET, + items_offset); + items_offset = + MIN(MAX(ctx->options_count - MAX_OPTIONS_NUM + 1 + ITEMOFFSET, 0), + items_offset); items_offset = MIN(ctx->selected_option, items_offset); oled_screen_clear_buffer(); oled_screen_display_text(ctx->banner, 0, 0, OLED_DISPLAY_NORMAL); for (uint8_t i = 0; i < (MIN(ctx->options_count, MAX_OPTIONS_NUM - 1)); i++) { - oled_screen_display_text_center(ctx->options[i + items_offset], i + 2, + oled_screen_display_text_center(ctx->options[i + items_offset], + i + 1 + ITEMOFFSET, ctx->selected_option == i + items_offset); } oled_screen_display_show(); From 05f6f3df4f6dbec160fd6df2a463e3a51f8d6ad9 Mon Sep 17 00:00:00 2001 From: Roberto Arellano Date: Fri, 20 Sep 2024 11:15:09 -0600 Subject: [PATCH 04/31] refactor: file manager list files port --- .../modules/file_manager/file_manager_screens.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/firmware/main/modules/file_manager/file_manager_screens.c b/firmware/main/modules/file_manager/file_manager_screens.c index 458313a..c5e3d8b 100644 --- a/firmware/main/modules/file_manager/file_manager_screens.c +++ b/firmware/main/modules/file_manager/file_manager_screens.c @@ -1,12 +1,19 @@ #include "file_manager_screens.h" #include "oled_screen.h" -#define MAX_ITEMS_NUM 7 +#ifdef CONFIG_RESOLUTION_128X64 + #define MAX_ITEMS_NUM 8 + #define ITEMOFFSET 1 +#else // CONFIG_RESOLUTION_128X32 + #define MAX_ITEMS_NUM 4 + #define ITEMOFFSET 1 +#endif static void update_list(file_manager_context_t* ctx) { static uint8_t items_offset = 0; - items_offset = MAX(ctx->selected_item - 6, items_offset); - items_offset = MIN(MAX(ctx->items_count - 7, 0), items_offset); + items_offset = MAX(ctx->selected_item - MAX_ITEMS_NUM + 2, items_offset); + items_offset = + MIN(MAX(ctx->items_count - MAX_ITEMS_NUM + 1, 0), items_offset); items_offset = MIN(ctx->selected_item, items_offset); oled_screen_clear_buffer(); oled_screen_display_text("< Back", 0, 0, OLED_DISPLAY_NORMAL); @@ -14,7 +21,7 @@ static void update_list(file_manager_context_t* ctx) { oled_screen_display_text(" Empty folder ", 0, 3, OLED_DISPLAY_NORMAL); oled_screen_display_text("No files to show", 0, 4, OLED_DISPLAY_NORMAL); } else { - for (uint8_t i = 0; i < (MIN(ctx->items_count, MAX_ITEMS_NUM)); i++) { + for (uint8_t i = 0; i < (MIN(ctx->items_count, MAX_ITEMS_NUM - 1)); i++) { char* str = (char*) malloc(30); sprintf(str, "%s%s", ctx->file_items_arr[i + items_offset]->name, ctx->file_items_arr[i + items_offset]->is_dir ? ">" : ""); From 0af35f73a2b60cb9f3a92c609965bb31f1e78d47 Mon Sep 17 00:00:00 2001 From: Roberto Arellano Date: Fri, 20 Sep 2024 11:26:41 -0600 Subject: [PATCH 05/31] refactor: broadcast screen port --- .../open_thread/open_thread_screens_module.c | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/firmware/main/modules/open_thread/open_thread_screens_module.c b/firmware/main/modules/open_thread/open_thread_screens_module.c index dd75201..cd8411d 100644 --- a/firmware/main/modules/open_thread/open_thread_screens_module.c +++ b/firmware/main/modules/open_thread/open_thread_screens_module.c @@ -1,22 +1,32 @@ #include #include "oled_screen.h" +#ifdef CONFIG_RESOLUTION_128X64 + #define MAX_ITEMS_NUM 8 + #define ITEMOFFSET 1 +#else // CONFIG_RESOLUTION_128X32 + #define MAX_ITEMS_NUM 4 + #define ITEMOFFSET 1 +#endif + void open_thread_screens_display_broadcast_mode(uint8_t ch) { - oled_screen_clear(); + oled_screen_clear_buffer(); oled_screen_display_text(" BroadCast Mode ", 0, 0, OLED_DISPLAY_NORMAL); char* str = (char*) malloc(18); sprintf(str, " Channel %d ", ch); - oled_screen_display_text(str, 0, 7, OLED_DISPLAY_NORMAL); + oled_screen_display_text(str, 0, MAX_ITEMS_NUM - 1, OLED_DISPLAY_NORMAL); + oled_screen_display_show(); free(str); } void open_thread_screens_show_new_message(char* msg) { - oled_screen_clear_line(0, 2, OLED_DISPLAY_NORMAL); - oled_screen_display_text(" New Message ", 0, 2, OLED_DISPLAY_INVERT); + oled_screen_clear_line(0, MAX_ITEMS_NUM / 4, OLED_DISPLAY_NORMAL); + oled_screen_display_text(" New Message ", 0, MAX_ITEMS_NUM / 4, + OLED_DISPLAY_INVERT); char* str = (char*) malloc(18); sprintf(str, "%s", msg); - oled_screen_clear_line(0, 4, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center(str, 4, OLED_DISPLAY_NORMAL); + oled_screen_clear_line(0, MAX_ITEMS_NUM / 2, OLED_DISPLAY_NORMAL); + oled_screen_display_text_center(str, MAX_ITEMS_NUM / 2, OLED_DISPLAY_NORMAL); free(str); } From 62696bf0615949f0a83b83df6af6971aada9ab87 Mon Sep 17 00:00:00 2001 From: Roberto Arellano Date: Fri, 20 Sep 2024 12:19:55 -0600 Subject: [PATCH 06/31] refactor: thread sniffer screens port --- .../main/apps/thread_sniffer/thread_sniffer.c | 2 - .../thread_sniffer/thread_sniffer_screens.c | 37 ++++++++++++++++++- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/firmware/main/apps/thread_sniffer/thread_sniffer.c b/firmware/main/apps/thread_sniffer/thread_sniffer.c index 7033fa2..2ac77d6 100644 --- a/firmware/main/apps/thread_sniffer/thread_sniffer.c +++ b/firmware/main/apps/thread_sniffer/thread_sniffer.c @@ -83,7 +83,6 @@ void thread_sniffer_init() { void thread_sniffer_run() { pcap_start(); - printf("START SESSION\n"); packets_count = 0; thread_sniffer_show_event(THREAD_SNIFFER_START_EV, NULL); thread_sniffer_show_event_cb(THREAD_SNIFFER_NEW_PACKET_EV, packets_count); @@ -91,7 +90,6 @@ void thread_sniffer_run() { } void thread_sniffer_stop() { - printf("STOP SESSION\n"); pcap_stop(); thread_sniffer_show_event(THREAD_SNIFFER_STOP_EV, NULL); openthread_disable_promiscous_mode(); diff --git a/firmware/main/apps/thread_sniffer/thread_sniffer_screens.c b/firmware/main/apps/thread_sniffer/thread_sniffer_screens.c index f714c5c..0e766c9 100644 --- a/firmware/main/apps/thread_sniffer/thread_sniffer_screens.c +++ b/firmware/main/apps/thread_sniffer/thread_sniffer_screens.c @@ -8,26 +8,58 @@ #include "open_thread_module.h" #include "thread_sniffer_bitmaps.h" +#ifdef CONFIG_RESOLUTION_128X64 +#else // CONFIG_RESOLUTION_128X32 +#endif + static void thread_sniffer_scanning_animation() { static uint8_t frame = 0; - oled_screen_display_bitmap(thread_sniffer_bitmap_arr[frame], 40, 8, 32, 32, +#ifdef CONFIG_RESOLUTION_128X64 + uint8_t x = 48; + uint8_t y = 8; +#else // CONFIG_RESOLUTION_128X32 + uint8_t x = 0; + uint8_t y = 0; +#endif + oled_screen_display_bitmap(thread_sniffer_bitmap_arr[frame], x, y, 32, 32, OLED_DISPLAY_NORMAL); frame = ++frame > 3 ? 0 : frame; } +#ifdef CONFIG_RESOLUTION_128X64 static void thread_sniffer_show_destination(bool* save_in_sd) { char* str = (char*) malloc(17); sprintf(str, "Dest: %s", *save_in_sd ? "SD card" : "Internal"); - oled_screen_display_text_center(str, 7, OLED_DISPLAY_INVERT); + oled_screen_display_text_center(str, 7, OLED_DISPLAY_NORMAL); + free(str); +} +#else // CONFIG_RESOLUTION_128X32 +static void thread_sniffer_show_destination(bool* save_in_sd) { + char* str = (char*) malloc(17); + oled_screen_display_text("Dest:", 40, 0, OLED_DISPLAY_INVERT); + oled_screen_display_text(*save_in_sd ? "SD card" : "Internal", 40, 1, + OLED_DISPLAY_NORMAL); free(str); } +#endif +#ifdef CONFIG_RESOLUTION_128X64 static void thread_sniffer_show_new_packet(uint32_t packets_count) { char* str = (char*) malloc(17); sprintf(str, "Packets: %lu", packets_count); oled_screen_display_text_center(str, 6, OLED_DISPLAY_INVERT); free(str); } +#else // CONFIG_RESOLUTION_128X32 +static void thread_sniffer_show_new_packet(uint32_t packets_count) { + char* str = (char*) malloc(10); + sprintf(str, "%lu", packets_count); + oled_screen_display_text("Packets:", 40, 2, OLED_DISPLAY_INVERT); + oled_screen_display_text(str, 40, 3, OLED_DISPLAY_INVERT); + free(str); +} + +#endif static void thread_sniffer_show_fatal_error(const char* error) { int page = 2; @@ -57,6 +89,7 @@ void thread_sniffer_show_event_handler(thread_sniffer_events_t event, thread_sniffer_show_fatal_error(context); break; case THREAD_SNIFFER_DESTINATION_EV: + oled_screen_clear(); thread_sniffer_show_destination(context); break; case THREAD_SNIFFER_NEW_PACKET_EV: From 61eb86e9d4dc6d7eeb247f5027c75fb6b15fc3ac Mon Sep 17 00:00:00 2001 From: Roberto Arellano Date: Fri, 20 Sep 2024 12:25:10 -0600 Subject: [PATCH 07/31] refactor: modal display banner port --- firmware/main/modules/modals/modals_screens.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/main/modules/modals/modals_screens.c b/firmware/main/modules/modals/modals_screens.c index d97796b..f9fee4a 100644 --- a/firmware/main/modules/modals/modals_screens.c +++ b/firmware/main/modules/modals/modals_screens.c @@ -74,7 +74,7 @@ void modals_screens_show_banner(char* text) { #ifdef CONFIG_RESOLUTION_128X64 uint8_t page = 3; #else // CONFIG_RESOLUTION_128X32 - uint8_t page = 2; + uint8_t page = 1; #endif oled_screen_clear(); oled_screen_display_text_center(text, page, OLED_DISPLAY_NORMAL); From 4b95f536d81324f6acc93e62a6fc8e0d28e813ef Mon Sep 17 00:00:00 2001 From: Roberto Arellano Date: Fri, 20 Sep 2024 12:35:51 -0600 Subject: [PATCH 08/31] refactor: sd card info screens port --- .../sd_card/sd_card_settings_screens_module.c | 55 +++++++++++++------ 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/firmware/main/modules/settings/sd_card/sd_card_settings_screens_module.c b/firmware/main/modules/settings/sd_card/sd_card_settings_screens_module.c index 85381a4..ac45482 100644 --- a/firmware/main/modules/settings/sd_card/sd_card_settings_screens_module.c +++ b/firmware/main/modules/settings/sd_card/sd_card_settings_screens_module.c @@ -1,43 +1,62 @@ #include "oled_screen.h" +#ifdef CONFIG_RESOLUTION_128X64 + #define screen_64 1 +#else // CONFIG_RESOLUTION_128X32 + #define screen_64 0 +#endif + void sd_card_settings_screens_module_no_sd_card() { oled_screen_clear(); - oled_screen_display_text_center("No SD Card", 2, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center("detected!", 3, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center("Ok", 5, OLED_DISPLAY_INVERT); + oled_screen_display_text_center("No SD Card", screen_64 ? 2 : 0, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("detected!", screen_64 ? 3 : 1, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("Ok", screen_64 ? 5 : 3, OLED_DISPLAY_INVERT); } void sd_card_settings_screens_module_sd_card_ok() { oled_screen_clear(); - oled_screen_display_text_center("SD Card can", 2, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center("be used safety", 3, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center("Ok", 5, OLED_DISPLAY_INVERT); + oled_screen_display_text_center("SD Card can", screen_64 ? 2 : 0, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("be used safety", screen_64 ? 3 : 1, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("Ok", screen_64 ? 5 : 3, OLED_DISPLAY_INVERT); } void sd_card_settings_screens_module_format_question() { oled_screen_clear(); - oled_screen_display_text_center("SD Card is not", 1, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center("in FAT32,", 2, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center("Format?", 3, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center("Ok", 5, OLED_DISPLAY_INVERT); + oled_screen_display_text_center("SD Card is not", screen_64 ? 1 : 0, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("in FAT32,", screen_64 ? 2 : 1, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("Format?", screen_64 ? 3 : 2, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("Ok", screen_64 ? 5 : 3, OLED_DISPLAY_INVERT); } void sd_card_settings_screens_module_formating_sd_card() { oled_screen_clear(); - oled_screen_display_text_center("Formating SD", 2, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center("Card... don't", 3, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center("remove it!", 4, OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("Formating SD", screen_64 ? 2 : 0, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("Card... don't", screen_64 ? 3 : 1, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("remove it!", screen_64 ? 4 : 2, + OLED_DISPLAY_NORMAL); } void sd_card_settings_screens_module_failed_format_sd_card() { oled_screen_clear(); - oled_screen_display_text_center("Failed to", 2, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center("format SD Card", 3, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center("Ok", 5, OLED_DISPLAY_INVERT); + oled_screen_display_text_center("Failed to", screen_64 ? 2 : 0, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("format SD Card", screen_64 ? 3 : 1, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("Ok", screen_64 ? 5 : 3, OLED_DISPLAY_INVERT); } void sd_card_settings_screens_module_format_done() { oled_screen_clear(); - oled_screen_display_text_center("Format done!", 3, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center("Ok", 5, OLED_DISPLAY_INVERT); + oled_screen_display_text_center("Format done!", screen_64 ? 3 : 1, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("Ok", screen_64 ? 3 : 0, OLED_DISPLAY_INVERT); } From 257c376afc719372558e6cc11e9d973ca7323e7a Mon Sep 17 00:00:00 2001 From: Roberto Arellano Date: Fri, 20 Sep 2024 12:57:45 -0600 Subject: [PATCH 09/31] refactor: some screens of wifi settings port --- .../modules/settings/wifi/wifi_settings.c | 39 +++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/firmware/main/modules/settings/wifi/wifi_settings.c b/firmware/main/modules/settings/wifi/wifi_settings.c index 9645d2c..1eb48d4 100644 --- a/firmware/main/modules/settings/wifi/wifi_settings.c +++ b/firmware/main/modules/settings/wifi/wifi_settings.c @@ -4,11 +4,20 @@ #include "esp_log.h" #include "led_events.h" #include "menus_module.h" +#include "modals_module.h" #include "oled_screen.h" #include "preferences.h" #define TAG_CONFIG_MODULE "CONFIG_MODULE" +#ifdef CONFIG_RESOLUTION_128X64 + #define START_PAGE 2 + #define Y_N_OFFSET 2 +#else // CONFIG_RESOLUTION_128X32 + #define START_PAGE 0 + #define Y_N_OFFSET 1 +#endif + static int selected_item = 0; static int total_items = 0; static int max_items = 6; @@ -62,10 +71,14 @@ static void config_module_wifi_display_selected_item_center( static void config_module_wifi_display_not_wifi() { oled_screen_clear(); - oled_screen_display_text_center("No saved APs", 2, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center("Add new AP", 3, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center("From our serial", 4, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center("Console", 5, OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("No saved APs", START_PAGE, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("Add new AP", START_PAGE + 1, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("From our serial", START_PAGE + 2, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("Console", START_PAGE + 3, + OLED_DISPLAY_NORMAL); } static int validate_wifi_count() { @@ -79,12 +92,12 @@ static int validate_wifi_count() { static void config_module_wifi_display_connecting() { oled_screen_clear(); - oled_screen_display_text_center("Connecting", 4, OLED_DISPLAY_NORMAL); + modals_module_show_banner("Connecting"); } static void config_module_wifi_display_disconnected() { oled_screen_clear(); - oled_screen_display_text_center("Disconnected", 4, OLED_DISPLAY_NORMAL); + modals_module_show_banner("Disconnected"); wifi_config_state.state = WIFI_SETTING_IDLE; selected_item = 0; vTaskDelay(2000 / portTICK_PERIOD_MS); @@ -94,7 +107,7 @@ static void config_module_wifi_display_disconnected() { static void config_module_wifi_display_connected() { oled_screen_clear(); - oled_screen_display_text_center("Connected", 4, OLED_DISPLAY_NORMAL); + modals_module_show_banner("Connected"); vTaskDelay(2000 / portTICK_PERIOD_MS); cmd_wifi_unregister_callback(); menus_module_exit_app(); @@ -175,11 +188,15 @@ static void config_module_wifi_display_forget_modal() { oled_screen_clear(); oled_screen_display_text_center("Forget this AP?", 1, OLED_DISPLAY_NORMAL); if (selected_item == 0) { - config_module_wifi_display_selected_item_center("YES", 4); - oled_screen_display_text_center("NO", 5, OLED_DISPLAY_NORMAL); + config_module_wifi_display_selected_item_center("YES", + START_PAGE + Y_N_OFFSET); + oled_screen_display_text_center("NO", START_PAGE + Y_N_OFFSET + 1, + OLED_DISPLAY_NORMAL); } else { - oled_screen_display_text_center("YES", 4, OLED_DISPLAY_NORMAL); - config_module_wifi_display_selected_item_center("NO", 5); + oled_screen_display_text_center("YES", START_PAGE + Y_N_OFFSET, + OLED_DISPLAY_NORMAL); + config_module_wifi_display_selected_item_center( + "NO", START_PAGE + Y_N_OFFSET + 1); } } From 8f5de52af65e13543c82793aed5a902c77dfdfd7 Mon Sep 17 00:00:00 2001 From: Roberto Arellano Date: Fri, 20 Sep 2024 13:12:29 -0600 Subject: [PATCH 10/31] refactor: screen saver time config screen port --- .../settings/display/display_settings.c | 26 +++++++++++++------ .../modules/settings/wifi/wifi_settings.c | 14 ++++------ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/firmware/main/modules/settings/display/display_settings.c b/firmware/main/modules/settings/display/display_settings.c index 83f755d..b833647 100644 --- a/firmware/main/modules/settings/display/display_settings.c +++ b/firmware/main/modules/settings/display/display_settings.c @@ -4,6 +4,7 @@ #include "esp_log.h" #include "led_events.h" #include "menus_module.h" +#include "modals_module.h" #include "oled_screen.h" #include "preferences.h" @@ -12,6 +13,14 @@ #define TIMER_MAX_TIME 360 #define TIMER_MIN_TIME 30 +#ifdef CONFIG_RESOLUTION_128X64 + #define TIME_PAGE 4 + #define Y_N_OFFSET 4 +#else // CONFIG_RESOLUTION_128X32 + #define TIME_PAGE 3 + #define Y_N_OFFSET 1 +#endif + typedef enum { DISPLAY_MENU, DISPLAY_LIST, DISPLAY_COUNT } display_menu_t; static char* display_settings_menu_items[] = {"Screen Logo", "Screen Time", @@ -88,7 +97,7 @@ static void display_config_display_time_selection() { oled_screen_display_text_center("Min:30 - Max:360", 2, OLED_DISPLAY_NORMAL); char time_text[18]; sprintf(time_text, "Time: %d", time_default_time); - oled_screen_display_text_center(time_text, 4, OLED_DISPLAY_NORMAL); + oled_screen_display_text_center(time_text, TIME_PAGE, OLED_DISPLAY_INVERT); oled_screen_display_show(); } @@ -100,13 +109,14 @@ void display_config_module_begin() { static void display_settings_show_modal() { oled_screen_clear_buffer(); - oled_screen_display_text_center("Apply this config?", 1, OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("Apply this config?", TIME_PAGE - 3, + OLED_DISPLAY_NORMAL); if (selected_item == 0) { - config_module_wifi_display_selected_item_center("YES", 3); - oled_screen_display_text_center("NO", 4, OLED_DISPLAY_NORMAL); + config_module_wifi_display_selected_item_center("YES", Y_N_OFFSET); + oled_screen_display_text_center("NO", Y_N_OFFSET + 1, OLED_DISPLAY_NORMAL); } else { - oled_screen_display_text_center("YES", 3, OLED_DISPLAY_NORMAL); - config_module_wifi_display_selected_item_center("NO", 4); + oled_screen_display_text_center("YES", Y_N_OFFSET, OLED_DISPLAY_NORMAL); + config_module_wifi_display_selected_item_center("NO", Y_N_OFFSET + 1); } oled_screen_display_show(); } @@ -166,7 +176,7 @@ static void display_config_module_state_machine_menu_time( ESP_LOGI(TAG_DISPLAY_CONFIG, "Selected item: %d", selected_item); preferences_put_int("dp_time", time_default_time); oled_screen_clear(); - oled_screen_display_text_center("Saved", 3, OLED_DISPLAY_NORMAL); + modals_module_show_banner("Saved"); keyboard_module_reset_idle_timer(); vTaskDelay(2000 / portTICK_PERIOD_MS); menus_module_set_app_state(true, display_config_module_state_machine); @@ -241,7 +251,7 @@ static void display_config_module_state_machine_modal(uint8_t button_name, ESP_LOGI(TAG_DISPLAY_CONFIG, "Selected item: %d", selected_item); preferences_put_int("dp_select", screen_selected); oled_screen_clear(); - oled_screen_display_text_center("Saved", 3, OLED_DISPLAY_NORMAL); + modals_module_show_banner("Saved"); vTaskDelay(2000 / portTICK_PERIOD_MS); } menus_module_set_app_state(true, display_config_module_state_machine); diff --git a/firmware/main/modules/settings/wifi/wifi_settings.c b/firmware/main/modules/settings/wifi/wifi_settings.c index 1eb48d4..c816c31 100644 --- a/firmware/main/modules/settings/wifi/wifi_settings.c +++ b/firmware/main/modules/settings/wifi/wifi_settings.c @@ -12,7 +12,7 @@ #ifdef CONFIG_RESOLUTION_128X64 #define START_PAGE 2 - #define Y_N_OFFSET 2 + #define Y_N_OFFSET 4 #else // CONFIG_RESOLUTION_128X32 #define START_PAGE 0 #define Y_N_OFFSET 1 @@ -188,15 +188,11 @@ static void config_module_wifi_display_forget_modal() { oled_screen_clear(); oled_screen_display_text_center("Forget this AP?", 1, OLED_DISPLAY_NORMAL); if (selected_item == 0) { - config_module_wifi_display_selected_item_center("YES", - START_PAGE + Y_N_OFFSET); - oled_screen_display_text_center("NO", START_PAGE + Y_N_OFFSET + 1, - OLED_DISPLAY_NORMAL); + config_module_wifi_display_selected_item_center("YES", Y_N_OFFSET); + oled_screen_display_text_center("NO", Y_N_OFFSET + 1, OLED_DISPLAY_NORMAL); } else { - oled_screen_display_text_center("YES", START_PAGE + Y_N_OFFSET, - OLED_DISPLAY_NORMAL); - config_module_wifi_display_selected_item_center( - "NO", START_PAGE + Y_N_OFFSET + 1); + oled_screen_display_text_center("YES", Y_N_OFFSET, OLED_DISPLAY_NORMAL); + config_module_wifi_display_selected_item_center("NO", Y_N_OFFSET + 1); } } From d381f4ea2a9b6f231e334c4c86b5bf84434d724b Mon Sep 17 00:00:00 2001 From: Roberto Arellano Date: Fri, 20 Sep 2024 15:04:13 -0600 Subject: [PATCH 11/31] refactor: zigbee sniffer screens port --- firmware/main/modules/zigbee/zigbee_bitmaps.h | 227 ++++-------------- .../modules/zigbee/zigbee_screens_module.c | 28 ++- 2 files changed, 74 insertions(+), 181 deletions(-) diff --git a/firmware/main/modules/zigbee/zigbee_bitmaps.h b/firmware/main/modules/zigbee/zigbee_bitmaps.h index 9ce6939..b227054 100644 --- a/firmware/main/modules/zigbee/zigbee_bitmaps.h +++ b/firmware/main/modules/zigbee/zigbee_bitmaps.h @@ -1,3 +1,4 @@ +#pragma once // 'toggle_btn_pressed', 128x64px static const unsigned char epd_bitmap_toggle_btn_pressed[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -176,190 +177,62 @@ static const unsigned char epd_bitmap_toggle_btn_released[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -// 'zigbee_loading-1', 128x32px +// 'zigbee_loading-1', 32x32px const unsigned char zigbee_bitmap_loading_1[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf0, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x07, - 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x80, 0x07, 0x80, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, - 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0xff, 0xfc, 0x00, 0x10, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x07, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0f, 0xff, 0x01, 0xf0, 0x06, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x3f, 0xfc, - 0x07, 0xf0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x3f, 0xf0, 0x1f, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xf0, 0x3f, 0xc0, 0x7f, 0xf0, 0x7f, 0xf8, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x3f, 0x81, - 0xff, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x1e, 0x07, 0xff, 0xf0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x10, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x07, 0xc0, - 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x06, 0x00, 0xff, 0xfc, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xc0, 0x00, - 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x30, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x06, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, - 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x20, 0x07, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x87, 0x84, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -// 'zigbee_loading-2', 128x32px + 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, + 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x7d, 0xbe, 0x00, 0x00, 0xe1, 0x87, 0x00, + 0x01, 0x8d, 0x81, 0x80, 0x03, 0x38, 0x00, 0xc0, 0x06, 0x63, 0xe0, 0x60, + 0x0c, 0xcf, 0xf8, 0x30, 0x0d, 0x9f, 0xfc, 0x30, 0x19, 0x00, 0x0e, 0x18, + 0x1b, 0x7f, 0x86, 0x18, 0x1a, 0xff, 0x0f, 0x18, 0x10, 0xfe, 0x1f, 0x08, + 0xfe, 0xfc, 0x3f, 0x7f, 0xfe, 0xf8, 0x7f, 0x7f, 0x10, 0xf0, 0xff, 0x08, + 0x18, 0xe1, 0xff, 0x18, 0x18, 0x63, 0xfe, 0x18, 0x18, 0x70, 0x00, 0x18, + 0x0c, 0x3f, 0xfc, 0x30, 0x0c, 0x0f, 0xf8, 0x30, 0x06, 0x03, 0xe0, 0x60, + 0x03, 0x00, 0x00, 0xc0, 0x01, 0x81, 0x81, 0x80, 0x00, 0xe1, 0x87, 0x00, + 0x00, 0x7d, 0xbe, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x01, 0x80, 0x00, + 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00}; +// 'zigbee_loading-2', 32x32px const unsigned char zigbee_bitmap_loading_2[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf0, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x07, - 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x80, 0x07, 0x80, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, - 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0xff, 0xfc, 0x00, 0x10, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x07, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0f, 0xff, 0x01, 0xf0, 0x06, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x3f, 0xfc, - 0x07, 0xf0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x3f, 0xf0, 0x1f, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xf0, 0x3f, 0xc0, 0x7f, 0xf0, 0x7f, 0xf8, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x3f, 0x81, - 0xff, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x1e, 0x07, 0xff, 0xf0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x22, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0xc0, - 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0xff, 0xfc, 0x01, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x02, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, - 0x00, 0x0c, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x00, 0x00, 0x00, 0x30, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, - 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x20, 0x07, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x87, 0x84, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -// 'zigbee_loading-3', 128x32px + 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, + 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x7d, 0xbe, 0x00, 0x00, 0xe1, 0x87, 0x00, + 0x01, 0x81, 0x81, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x06, 0x03, 0xe0, 0x60, + 0x0c, 0x0f, 0xf8, 0x30, 0x0c, 0x1f, 0xfc, 0x30, 0x18, 0x00, 0x0e, 0x18, + 0x18, 0x7f, 0x86, 0x18, 0x18, 0xff, 0x0f, 0x18, 0x10, 0xfe, 0x1f, 0x08, + 0xfe, 0xfc, 0x3f, 0x7f, 0xfe, 0xf8, 0x7f, 0x7f, 0x10, 0xf0, 0xff, 0x08, + 0x1a, 0xe1, 0xff, 0x18, 0x1b, 0x63, 0xfe, 0x18, 0x19, 0x70, 0x00, 0x18, + 0x0d, 0xbf, 0xfc, 0x30, 0x0c, 0xcf, 0xf8, 0x30, 0x06, 0x63, 0xe0, 0x60, + 0x03, 0x38, 0x00, 0xc0, 0x01, 0x8d, 0x81, 0x80, 0x00, 0xe1, 0x87, 0x00, + 0x00, 0x7d, 0xbe, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x01, 0x80, 0x00, + 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00}; +// 'zigbee_loading-3', 32x32px const unsigned char zigbee_bitmap_loading_3[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf0, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x07, - 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x80, 0x07, 0x80, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x06, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, - 0x00, 0x60, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x20, 0x00, 0x00, 0x00, 0x18, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0xff, 0xfc, 0x06, 0x10, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x07, 0x81, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0f, 0xff, 0x01, 0xf0, 0x26, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x3f, 0xfc, - 0x07, 0xf0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x3f, 0xf0, 0x1f, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xf0, 0x3f, 0xc0, 0x7f, 0xf0, 0x7f, 0xf8, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x3f, 0x81, - 0xff, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x1e, 0x07, 0xff, 0xf0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0xc0, - 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, - 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x20, 0x07, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x87, 0x84, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -// 'zigbee_loading-4', 128x32px + 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, + 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x7d, 0xbe, 0x00, 0x00, 0xe1, 0x87, 0x00, + 0x01, 0x81, 0x81, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x06, 0x03, 0xe0, 0x60, + 0x0c, 0x0f, 0xf8, 0x30, 0x0c, 0x1f, 0xfc, 0x30, 0x18, 0x00, 0x0e, 0x18, + 0x18, 0x7f, 0x86, 0x18, 0x18, 0xff, 0x0f, 0x18, 0x10, 0xfe, 0x1f, 0x08, + 0xfe, 0xfc, 0x3f, 0x7f, 0xfe, 0xf8, 0x7f, 0x7f, 0x10, 0xf0, 0xff, 0x08, + 0x18, 0xe1, 0xff, 0x58, 0x18, 0x63, 0xfe, 0xd8, 0x18, 0x70, 0x00, 0x98, + 0x0c, 0x3f, 0xfd, 0xb0, 0x0c, 0x0f, 0xfb, 0x30, 0x06, 0x03, 0xe6, 0x60, + 0x03, 0x00, 0x1c, 0xc0, 0x01, 0x81, 0xb1, 0x80, 0x00, 0xe1, 0x87, 0x00, + 0x00, 0x7d, 0xbe, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x01, 0x80, 0x00, + 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00}; +// 'zigbee_loading-4', 32x32px const unsigned char zigbee_bitmap_loading_4[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf0, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x07, - 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x80, 0x07, 0x80, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x18, 0x00, - 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x20, 0xc0, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x00, 0xff, 0xfc, 0x00, 0x10, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, - 0x07, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x08, 0x00, 0x00, 0x01, 0xc0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x10, 0x0f, 0xff, 0x01, 0xf0, 0x06, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x3f, 0xfc, - 0x07, 0xf0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x3f, 0xf0, 0x1f, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0xf0, 0x3f, 0xc0, 0x7f, 0xf0, 0x7f, 0xf8, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x3f, 0x81, - 0xff, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x1e, 0x07, 0xff, 0xf0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0xc0, - 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, - 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x20, 0x07, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x87, 0x84, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, + 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x7d, 0xbe, 0x00, 0x00, 0xe1, 0x87, 0x00, + 0x01, 0x81, 0xb1, 0x80, 0x03, 0x00, 0x1c, 0xc0, 0x06, 0x03, 0xe6, 0x60, + 0x0c, 0x0f, 0xfb, 0x30, 0x0c, 0x1f, 0xfd, 0xb0, 0x18, 0x00, 0x0e, 0x98, + 0x18, 0x7f, 0x86, 0xd8, 0x18, 0xff, 0x0f, 0x58, 0x10, 0xfe, 0x1f, 0x08, + 0xfe, 0xfc, 0x3f, 0x7f, 0xfe, 0xf8, 0x7f, 0x7f, 0x10, 0xf0, 0xff, 0x08, + 0x18, 0xe1, 0xff, 0x18, 0x18, 0x63, 0xfe, 0x18, 0x18, 0x70, 0x00, 0x18, + 0x0c, 0x3f, 0xfc, 0x30, 0x0c, 0x0f, 0xf8, 0x30, 0x06, 0x03, 0xe0, 0x60, + 0x03, 0x00, 0x00, 0xc0, 0x01, 0x81, 0x81, 0x80, 0x00, 0xe1, 0x87, 0x00, + 0x00, 0x7d, 0xbe, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x01, 0x80, 0x00, + 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00}; // Array of all bitmaps for convenience. (Total bytes used to store images in = // 2112) const int zigbee_bitmap_allArray_LEN = 4; -const unsigned char* zigbee_bitmap_allArray[4] = { +static const unsigned char* zigbee_bitmap_allArray[4] = { zigbee_bitmap_loading_1, zigbee_bitmap_loading_2, zigbee_bitmap_loading_3, zigbee_bitmap_loading_4}; diff --git a/firmware/main/modules/zigbee/zigbee_screens_module.c b/firmware/main/modules/zigbee/zigbee_screens_module.c index 5f73b5d..6285c73 100644 --- a/firmware/main/modules/zigbee/zigbee_screens_module.c +++ b/firmware/main/modules/zigbee/zigbee_screens_module.c @@ -80,28 +80,48 @@ void zigbee_screens_display_device_ad() { oled_screen_display_text_splited("Use our", &index_page, OLED_DISPLAY_NORMAL); oled_screen_display_text_splited("PyCatSniffer", &index_page, OLED_DISPLAY_NORMAL); - oled_screen_display_text_splited("to communicate with", &index_page, + oled_screen_display_text_splited("to communicate", &index_page, OLED_DISPLAY_NORMAL); - oled_screen_display_text_splited("Wireshark", &index_page, + oled_screen_display_text_splited("with Wireshark", &index_page, OLED_DISPLAY_NORMAL); } void zigbee_screens_display_zigbee_sniffer_text() { oled_screen_clear(OLED_DISPLAY_NORMAL); +#ifdef CONFIG_RESOLUTION_128X64 oled_screen_display_text_center("ZIGBEE SNIFFER", 0, OLED_DISPLAY_NORMAL); +#else // CONFIG_RESOLUTION_128X32 + oled_screen_display_text("ZIGBEE", 52, 0, OLED_DISPLAY_NORMAL); + oled_screen_display_text("SNIFFER", 48, 1, OLED_DISPLAY_NORMAL); +#endif } void zigbee_screens_display_scanning_animation() { +#ifdef CONFIG_RESOLUTION_128X64 + uint8_t x = 48; + uint8_t y = 12; +#else // CONFIG_RESOLUTION_128X32 + uint8_t x = 0; + uint8_t y = 0; +#endif static uint8_t frame = 0; - oled_screen_display_bitmap(zigbee_bitmap_allArray[frame], 0, 16, 128, 32, + oled_screen_display_bitmap(zigbee_bitmap_allArray[frame], x, y, 32, 32, OLED_DISPLAY_NORMAL); frame = ++frame > zigbee_bitmap_allArray_LEN - 1 ? 0 : frame; } void zigbee_screens_display_scanning_text(int count) { - oled_screen_clear_line(0, 6, OLED_DISPLAY_NORMAL); + oled_screen_clear_buffer(); char* packets_count = (char*) malloc(17); +#ifdef CONFIG_RESOLUTION_128X64 sprintf(packets_count, "Packets: %d", count); oled_screen_display_text_center(packets_count, 6, OLED_DISPLAY_INVERT); +#else // CONFIG_RESOLUTION_128X32 + sprintf(packets_count, "Packets:"); + oled_screen_display_text(packets_count, 40, 2, OLED_DISPLAY_INVERT); + sprintf(packets_count, "%d", count); + oled_screen_display_text(packets_count, 40, 3, OLED_DISPLAY_NORMAL); +#endif + oled_screen_display_show(); free(packets_count); } From 4ff0e8960d6973ccef46ec752c7bc5bbb50d811a Mon Sep 17 00:00:00 2001 From: Roberto Arellano Date: Fri, 20 Sep 2024 15:26:30 -0600 Subject: [PATCH 12/31] refactor: no files screen port --- firmware/main/modules/file_manager/file_manager_screens.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/firmware/main/modules/file_manager/file_manager_screens.c b/firmware/main/modules/file_manager/file_manager_screens.c index c5e3d8b..44cf021 100644 --- a/firmware/main/modules/file_manager/file_manager_screens.c +++ b/firmware/main/modules/file_manager/file_manager_screens.c @@ -18,8 +18,10 @@ static void update_list(file_manager_context_t* ctx) { oled_screen_clear_buffer(); oled_screen_display_text("< Back", 0, 0, OLED_DISPLAY_NORMAL); if (ctx->items_count == 0) { - oled_screen_display_text(" Empty folder ", 0, 3, OLED_DISPLAY_NORMAL); - oled_screen_display_text("No files to show", 0, 4, OLED_DISPLAY_NORMAL); + oled_screen_display_text(" Empty folder ", 0, MAX_ITEMS_NUM / 2 - 1, + OLED_DISPLAY_NORMAL); + oled_screen_display_text("Nothing to show", 0, MAX_ITEMS_NUM / 2, + OLED_DISPLAY_NORMAL); } else { for (uint8_t i = 0; i < (MIN(ctx->items_count, MAX_ITEMS_NUM - 1)); i++) { char* str = (char*) malloc(30); From 4ae7a2f01ae28fdda317e5c1cd0ae66bf16c9cce Mon Sep 17 00:00:00 2001 From: Roberto Arellano Date: Fri, 20 Sep 2024 15:38:00 -0600 Subject: [PATCH 13/31] refactor: keyboard modal screen port --- .../modals/keyboard/keyboard_screens.c | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/firmware/main/modules/modals/keyboard/keyboard_screens.c b/firmware/main/modules/modals/keyboard/keyboard_screens.c index 1ab6695..3053551 100644 --- a/firmware/main/modules/modals/keyboard/keyboard_screens.c +++ b/firmware/main/modules/modals/keyboard/keyboard_screens.c @@ -5,19 +5,26 @@ #define MAX_CHARS 16 +#ifdef CONFIG_RESOLUTION_128X64 + #define TEXT_PAGE 2 +#else // CONFIG_RESOLUTION_128X32 + #define TEXT_PAGE 1 +#endif + void keyboard_screens_update_text(keyboard_modal_ctx_t* ctx) { static uint8_t chars_offset = 0; chars_offset = MAX(ctx->current_char - 14, chars_offset); chars_offset = MIN(ctx->current_char, chars_offset); - oled_screen_clear_line(0, 2, OLED_DISPLAY_NORMAL); + oled_screen_clear_line(0, TEXT_PAGE, OLED_DISPLAY_NORMAL); for (uint8_t i = 0; i < (MIN(ctx->text_length, MAX_CHARS - 1)); i++) { char a_char[2]; snprintf(a_char, sizeof(a_char), "%c", ctx->new_text[i + chars_offset]); - oled_screen_display_text(&a_char, i * 8, 2, + oled_screen_display_text(&a_char, i * 8, TEXT_PAGE, ctx->current_char == i + chars_offset); } } +#ifdef CONFIG_RESOLUTION_128X64 void keyboard_screens_show(keyboard_modal_ctx_t* ctx) { oled_screen_clear(); oled_screen_display_text(ctx->banner, 0, 0, OLED_DISPLAY_NORMAL); @@ -25,4 +32,12 @@ void keyboard_screens_show(keyboard_modal_ctx_t* ctx) { oled_screen_display_text("----------------", 0, 3, OLED_DISPLAY_NORMAL); oled_screen_display_text("Hold > to Save", 0, 5, OLED_DISPLAY_NORMAL); oled_screen_display_text("Hold < to Cancel", 0, 6, OLED_DISPLAY_NORMAL); -} \ No newline at end of file +} +#else // CONFIG_RESOLUTION_128X32 +void keyboard_screens_show(keyboard_modal_ctx_t* ctx) { + oled_screen_clear(); + oled_screen_display_text(ctx->banner, 0, 0, OLED_DISPLAY_NORMAL); + oled_screen_display_text("Hold > to Save", 0, 2, OLED_DISPLAY_NORMAL); + oled_screen_display_text("Hold < to Cancel", 0, 3, OLED_DISPLAY_NORMAL); +} +#endif From fbf3cc91ab05f22e9d1aed9d40b70bfd99a0a112 Mon Sep 17 00:00:00 2001 From: Kevin Jahaziel Leon Morales Date: Sat, 21 Sep 2024 15:24:30 -0600 Subject: [PATCH 14/31] feat: Adapt Display settings --- .../main/apps/ble/hid_device/hid_screens.c | 2 +- firmware/main/general/general_screens.c | 6 ++++- .../settings/display/display_settings.c | 25 +++++++++++++------ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/firmware/main/apps/ble/hid_device/hid_screens.c b/firmware/main/apps/ble/hid_device/hid_screens.c index 413f3aa..a755307 100644 --- a/firmware/main/apps/ble/hid_device/hid_screens.c +++ b/firmware/main/apps/ble/hid_device/hid_screens.c @@ -63,7 +63,7 @@ void hid_module_display_notify_play_pause() { void hid_module_display_device_pairing() { led_control_run_effect(led_control_ble_spam_breathing); - genera_screen_display_notify_information("Pairing", "Waiting for connection"); + genera_screen_display_notify_information("Pairing", "Waiting conn"); } void hid_module_display_device_connection(bool status) { diff --git a/firmware/main/general/general_screens.c b/firmware/main/general/general_screens.c index 92e14fe..2096ba4 100644 --- a/firmware/main/general/general_screens.c +++ b/firmware/main/general/general_screens.c @@ -61,6 +61,10 @@ static void general_screen_decrement_option() { } static void general_screen_display_breadcrumb() { + if (current_menu_ctx == NULL) { + oled_screen_display_text("< Back", 0, 0, OLED_DISPLAY_NORMAL); + return; + } if (current_menu_ctx->menu_level == GENERAL_TREE_APP_MENU) { oled_screen_display_text("< Exit", 0, 0, OLED_DISPLAY_NORMAL); } else { @@ -197,7 +201,7 @@ void genera_screen_display_card_information(char* title, char* body) { void genera_screen_display_notify_information(char* title, char* body) { general_clear_screen(); - // general_screen_display_breadcrumb(); + general_screen_display_breadcrumb(); int page = ITEM_PAGE_OFFSET; oled_screen_display_card_border(); oled_screen_display_text_center(title, page, OLED_DISPLAY_NORMAL); diff --git a/firmware/main/modules/settings/display/display_settings.c b/firmware/main/modules/settings/display/display_settings.c index b833647..fa9fce7 100644 --- a/firmware/main/modules/settings/display/display_settings.c +++ b/firmware/main/modules/settings/display/display_settings.c @@ -14,11 +14,15 @@ #define TIMER_MIN_TIME 30 #ifdef CONFIG_RESOLUTION_128X64 - #define TIME_PAGE 4 - #define Y_N_OFFSET 4 + #define ITEMOFFSET 2 + #define ITEMSPERSCREEN 4 + #define TIME_PAGE 4 + #define Y_N_OFFSET 4 #else // CONFIG_RESOLUTION_128X32 - #define TIME_PAGE 3 - #define Y_N_OFFSET 1 + #define ITEMOFFSET 1 + #define ITEMSPERSCREEN 2 + #define TIME_PAGE 3 + #define Y_N_OFFSET 1 #endif typedef enum { DISPLAY_MENU, DISPLAY_LIST, DISPLAY_COUNT } display_menu_t; @@ -73,19 +77,22 @@ static void display_config_display_list_logo() { oled_screen_clear_buffer(); oled_screen_display_text("< Back", 0, 0, OLED_DISPLAY_NORMAL); int current_scren = preferences_get_int("dp_select", 0); - for (int i = 0; epd_bitmaps_list[i] != NULL; i++) { + int position = 1; + uint16_t start_item = (selected_item / ITEMSPERSCREEN) * ITEMSPERSCREEN; + for (uint16_t i = start_item; + i < start_item + ITEMSPERSCREEN && epd_bitmaps_list[i] != NULL; i++) { char display_text[18]; if (i == current_scren) { sprintf(display_text, "%s..[Curr]", epd_bitmaps_list[i]); } else { sprintf(display_text, "%s", epd_bitmaps_list[i]); } - int page = (i + 1); if (selected_item == i) { - config_module_wifi_display_selected_item(display_text, page); + config_module_wifi_display_selected_item(display_text, position); } else { - oled_screen_display_text(display_text, 0, page, OLED_DISPLAY_NORMAL); + oled_screen_display_text(display_text, 0, position, OLED_DISPLAY_NORMAL); } + position = position + ITEMOFFSET; } oled_screen_display_show(); } @@ -169,6 +176,7 @@ static void display_config_module_state_machine_menu_time( } switch (button_name) { case BUTTON_LEFT: + selected_item = 0; menus_module_set_app_state(true, display_config_module_state_machine); display_config_display_menu_item(); break; @@ -209,6 +217,7 @@ static void display_config_module_state_machine_menu_logo( } switch (button_name) { case BUTTON_LEFT: + selected_item = 0; menus_module_set_app_state(true, display_config_module_state_machine); display_config_display_menu_item(); break; From 2da61281a4f8d9bbf7fa7c8749ab994c5cb1b411 Mon Sep 17 00:00:00 2001 From: deimos Date: Mon, 23 Sep 2024 07:51:17 -0600 Subject: [PATCH 15/31] feat: add zigbee switch for 128x32 --- firmware/main/modules/zigbee/zigbee_bitmaps.h | 99 ++++++++++++++++++ .../modules/zigbee/zigbee_screens_module.c | 22 +++- firmware/resources/zigbee_switch_128x32.png | Bin 0 -> 1271 bytes firmware/resources/zigbee_switch_128x32.xcf | Bin 0 -> 10452 bytes .../resources/zigbee_switch_128x32_dark.png | Bin 0 -> 1582 bytes 5 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 firmware/resources/zigbee_switch_128x32.png create mode 100644 firmware/resources/zigbee_switch_128x32.xcf create mode 100644 firmware/resources/zigbee_switch_128x32_dark.png diff --git a/firmware/main/modules/zigbee/zigbee_bitmaps.h b/firmware/main/modules/zigbee/zigbee_bitmaps.h index 9ce6939..aa96f2b 100644 --- a/firmware/main/modules/zigbee/zigbee_bitmaps.h +++ b/firmware/main/modules/zigbee/zigbee_bitmaps.h @@ -1,3 +1,4 @@ +#ifdef CONFIG_RESOLUTION_128X64 // 'toggle_btn_pressed', 128x64px static const unsigned char epd_bitmap_toggle_btn_pressed[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -175,6 +176,101 @@ static const unsigned char epd_bitmap_toggle_btn_released[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +#endif + +#ifdef CONFIG_RESOLUTION_128X32 +// 'zigbee_switch_128x32_dark', 128x32px +static const unsigned char epd_bitmap_toggle_btn_released[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x07, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x7f, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, + 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, + 0x00, 0xff, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x60, 0x00, 0xff, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x18, 0x3c, 0x3a, + 0x3a, 0x10, 0x18, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, + 0x00, 0x18, 0x66, 0x66, 0x66, 0x10, 0x24, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x00, 0x18, 0x42, 0x46, 0x46, 0x10, 0x42, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x18, 0x42, 0x46, + 0x46, 0x10, 0x7e, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, + 0x00, 0x18, 0x42, 0x66, 0x66, 0x10, 0x40, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x40, 0x00, 0x18, 0x66, 0x3e, 0x3e, 0x10, 0x66, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x18, 0x3c, 0x06, + 0x06, 0x0e, 0x18, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, + 0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x00, + 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfc, 0x00, + 0x00, 0x7f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x07, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +// 'zigbee_switch_128x32', 128x32px +static const unsigned char epd_bitmap_toggle_btn_pressed[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x07, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, + 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0xff, 0x00, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7f, 0xff, 0x00, 0xff, 0xff, 0xff, 0xef, 0xff, 0xff, + 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xe7, 0xc3, 0xc5, + 0xc5, 0xef, 0xe7, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xe7, 0x99, 0x99, 0x99, 0xef, 0xdb, 0xff, 0xfe, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xe7, 0xbd, 0xb9, 0xb9, 0xef, 0xbd, 0xff, + 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe7, 0xbd, 0xb9, + 0xb9, 0xef, 0x81, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xe7, 0xbd, 0x99, 0x99, 0xef, 0xbf, 0xff, 0xfe, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x7f, 0xff, 0xe7, 0x99, 0xc1, 0xc1, 0xef, 0x99, 0xff, + 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xe7, 0xc3, 0xf9, + 0xf9, 0xf1, 0xe7, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0xff, 0xff, 0xff, 0xfb, 0xfb, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xc7, 0xc7, 0xff, 0xff, 0xff, + 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, + 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x07, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +#endif // 'zigbee_loading-1', 128x32px const unsigned char zigbee_bitmap_loading_1[] = { @@ -221,6 +317,7 @@ const unsigned char zigbee_bitmap_loading_1[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + // 'zigbee_loading-2', 128x32px const unsigned char zigbee_bitmap_loading_2[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -266,6 +363,7 @@ const unsigned char zigbee_bitmap_loading_2[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + // 'zigbee_loading-3', 128x32px const unsigned char zigbee_bitmap_loading_3[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -311,6 +409,7 @@ const unsigned char zigbee_bitmap_loading_3[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + // 'zigbee_loading-4', 128x32px const unsigned char zigbee_bitmap_loading_4[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/firmware/main/modules/zigbee/zigbee_screens_module.c b/firmware/main/modules/zigbee/zigbee_screens_module.c index 5f73b5d..d081ba0 100644 --- a/firmware/main/modules/zigbee/zigbee_screens_module.c +++ b/firmware/main/modules/zigbee/zigbee_screens_module.c @@ -5,13 +5,29 @@ #include "zigbee_switch.h" void zigbee_screens_module_toogle_pressed() { - oled_screen_display_bitmap(epd_bitmap_toggle_btn_pressed, 0, 0, 128, 64, +#ifdef CONFIG_RESOLUTION_128X64 + uint8_t width = 128; + uint8_t height = 64; +#else + uint8_t width = 128; + uint8_t height = 32; +#endif + + oled_screen_display_bitmap(epd_bitmap_toggle_btn_pressed, 0, 0, width, height, OLED_DISPLAY_NORMAL); } void zigbee_screens_module_toggle_released() { - oled_screen_display_bitmap(epd_bitmap_toggle_btn_released, 0, 0, 128, 64, - OLED_DISPLAY_NORMAL); +#ifdef CONFIG_RESOLUTION_128X64 + uint8_t width = 128; + uint8_t height = 64; +#else + uint8_t width = 128; + uint8_t height = 32; +#endif + + oled_screen_display_bitmap(epd_bitmap_toggle_btn_released, 0, 0, width, + height, OLED_DISPLAY_NORMAL); } void zigbee_screens_module_creating_network() { diff --git a/firmware/resources/zigbee_switch_128x32.png b/firmware/resources/zigbee_switch_128x32.png new file mode 100644 index 0000000000000000000000000000000000000000..1d4bccf1ad6420e726bb3d19dcf6b66024e2d06f GIT binary patch literal 1271 zcmVEX>4Tx04R}tkv&MmKpe$iTcs)$2MZN($WWcyMMWHI6^c+H)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfc5qU3krMxx6k5c1aNLh~_a1le0DrT}RI?`msG4PD zQb{3~UloF{=tl%0#1N5~sn3aG8lL0p9zMR_#d((Zxj)CCQZO0d6NnQ`H!R`};+aiL z=e$oGW@SksJ|~VDbV1@ruFEdJaV|OR=b2$6o0%sL6APs-mb;jh4V8GBII5@`<@<9k zE1b7DtJOMd-;=*ERM1wIxlVHoDJ)_MA_T~&qk<|d#A($?F_EGDq=$dh@r&e=$yEU( z#{z0lAvu2VKlt6PS)7`5lR`K2d-P^xs+Wq|ivp90VFgb{*00006VoOIv00000008+zyMF)x010qNS#tmY zE+YT{E+YYWr9XB6000McNliru=m{4M111OMdvyQ+02y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{00PfRL_t(|+U;9SZ<|06eK;15P1CA?8@4IQslDX?H-9Bk z(t|5C>m*WQ3%7Pi?DRl!H<%BzzyiCBw8-zVGs0h z2y8YT0MPG){Q2Fk3@;H3bo>dJ&lLoKWxcKIG6#N-GC|*e09GqC0HB#BoGDc^@F_r` zA5CDn6kZy{0l;-Zeq5`Y_4~4c;AT+_08URquCKTPPxV2np7>9dEWTlf6U-#N&jHr6 zoX@>E9fW>z9AG-F{sdlm_TT)f{5;PBBMd4V(5OBNmMs0gYY3m86v^Iyej-07Vy<9h z>803gj$?={>MladoljzOg*KfdNB77P3ybjiNkcC$Z8#E^PY}VH}AX4u@h+%+)Y!H(bG6x+{c_1XM zNt6i;Nh4vF9ZV57K-x1D+6F+RO$nP8uvj#1$;}=M*LC3ND0?it4sc}Hq^=9x-8cSQ zf%bhEVi?fIHk`{#?rbdmUcnv*Gkv~~wn@7Hkhlx&f2Ktn%d&!e@&%a9fahnadQ&+7 h&jZ3 literal 0 HcmV?d00001 diff --git a/firmware/resources/zigbee_switch_128x32.xcf b/firmware/resources/zigbee_switch_128x32.xcf new file mode 100644 index 0000000000000000000000000000000000000000..592c3bc518b000c98ebbcc5869fccde2191d6393 GIT binary patch literal 10452 zcmeHMU2I&%6+ZW_*MIBZIEj57JHB3T634-f^J^zIZWJC6v`9Qu3Lq4;u{X{Z|3vmC zP5KaTq^eSckWe4mN+2X2D0yh5R)X?Sgm{W7UQm^g2l`M6Aqp*00mr+Z+4W4nGjs3y z+Bksdk7$*f%$zebXU?4O?99D$j;FFS=lx3)XZ?#q2M!RPJc^IP&(Bd>Q5*+V8%pg1 z=;DHBD@qkg3(EF@XSr=CODK&~P(3&?H#3u&&7n;^xaEQQOgfjD^naAio%0`j=#fWx zq{WD4XVO!d!KwM|B=@oOulpBrm!~uS!rXLra&LYA*{O-S>A88o-;lxisWWMR$oxC7 z7sF>Z89v~fe>{9?;e2``J3Hkc7((mvx>nE_yfB;1`PtctbD0I6F?aUtLMG=M`3P^> z^}=j(1F=AdDQrAP`IC;I+T!4M)UmxN92%m`X4H3RE!Z(BG^}?qH46n!fcLh8MrI^=v zK>H$mxOaG7IK_j@7!uRK{LR)XVj#gh5qZ zBi2xf02Qb~B~-$q5&CSsEr2A?6gBM?V`%^tcD{o!gPpOF)ZyzRc`^o@~Uwh{$$v2*$ z{`{?BD&2UTPQE-sC6R9!`PDHh-8xl$WeGp+&F>9d$M5*qzE@E{Pp`nt6O+JP|7KWm zlSfcP3cu&ghX<~Y1sX;JjcA({#_W<;Z;e*07+o{%_@?B+f}8C zmnQqof+Q@!zm=-A$*yCu$>}dd5 zt&x08;0N;ZE=1h8DEMuRALR4(AzC493G1bTiK!#0V-ip z31Lt{j!_9=PzgRJalxqg_{74>!Tv|TK_vuGH44F~Fq=^cVNqc%iwbK2)t0812vCU- zl~CJ5R4|)Si3qCCoOohO*WQtbPUoJze&a)3MOqKg-{hT7-hcPTYcD-Be`=(Inh&48 z_WDO!AE7(?)3;x`_~3TxPrvZqaay_k;zWw}UwjL@_nm9wG;rniD9Kw_`{{`{@I$_Q zk{-W-9saA4hO0s!r_$1u>QlFX{`$bfH-SmNy6-W-e}$e0^vM&b-mFLa&3cVfHF<(1 zFoqu%a%k`@oJ6B!grqiVaYW5B!{NF|E2bP?vu}u&qL%C3^vPxr_t8dwEYeTO(f#~w zI)TFXCVqxc%q0u7{s(hYQ@HT-nXA~h=}XUM^Vj;De(B?w+lj(oa~B1-MCTBwz53-c zmvV#C;SC3$8mGN~CO!Z3h4X%L%rfI+xTDSb3)vrM?te0Q=)keVPbSB$yTN? zKr)G|+u6C`9?xeiXJXQwXUj_M~fvx762SksyGLS}F>JD-`zW#?x7>D)XzH(pZLuAo1> zu#n51z3fkC&gOXb+@-;pxyg(_d3iQHlbr~<%q6s9#knlZz^&ET0FOnV#2+KAa3cj5 zro;!EjG-%04*M7B1JY`MN=hqI4R}?@ab#muRz%9hP*`HL3V|3o$|0q6EtPPgQy5-P ztBjaSg4N-FEiG%lrm{LxcCk?7G{)zLB-bD8~uh*nKFY83@`LDm(ha(R&|tYWQ* z!Qg6?8lw`rjg1L|NNX4CYP^!TW|S_iXr2!%TFKQVV}+|3XRjG%tSsiJ^LS@(aFo2~ zsITWJanDhAanxH>quVK_6Nd8jS~ubIP=&4-Hl)J6+!E|-U5yd#RH4Qp)XpY_rQ-O= zL5&qN2br7L!kA&UGG_A`;2|!o?MuYs5s`nergbG$Rcq9QM!`s447DA%{k#+d(@q>5 zmnvYxkp!xC=&i;nba3n(7b1+_1iE>=r+gH+hPExtq^GB!I+L4yYC1c0F6U3ooxhBJ z^DSZeZTeQSJ^XyrZzV_Ok*D=HkwzZ8j}pA(TmJ+ePy02*@d^JtgXLAy<9r#)V@g#9eTvUV2FXFaTs z^|F4BzgxY-cZ-Qz>D7HV8!$gG1mN(3ghJt-^vAy3i~PcyMjPfEP}oT^R7_ z+aU~iaNUBz3sLA120Xfa!Qj!A1cMm4&?gwYD5OC5Y$&!rlwz5i`)G&uX{X*vzV4!= z?!-GlB{jB_#?~?gw&V5i#S)IQY%q;AuqM{Xnt26YX^5KiB5@{$BiJL%49oHyp36E|7wcr*yvBwI_7L%A zFcIv1)C86z*nVmQ$02NrwqqA@4BJZ{I1Vg(s0*XuYP)HtEEPGB-9bIJFV;!DyxC;T z1LG7O?A<=OT9h3y7Y86E75I>FPZCl}HZTJ*h}-#&7g5=5H0hqMaA~(2=4dty<^(1- z_R<#g0YF2F8ZpDfx_hYQZgDQKV=vTjoD1w==*^d z*hQ(p;V!V-KE}>_O)z#$aBvLz#A-n>cI^L@P~bztJxNF@!Pr?0;&wh`uc+)cnhbW^ z$JoKaFvgBi4u^pqeE`7N(H9qph=F~RXt)XAIF5g}>Alph_fV%!QMc};9^FH|x|>qi zx?FadEsxz++4db~%ZKf7oMrnob{*!j4%WpwJFwT=^ggrCH;pgzc=P)x{26W8@EJwd zSAIEp-v3HIIru6vEPgsFUp+MPC_YLc<8huFPtQ**HFX}fZ#eSyS=#lurR%?(_wvd2 z^2uMFPmXCv70Ys^P(aog?*dn^C{fhQQmHx|TSwzHt(VIx#yMoIgf1dFMGje`yQDR8 z$cSRmha57Pl173`t7WN?xq`F;Eo-%+k=0TXwadA#RfXKwvJR^S&OYC<+3gcbREIYT2W=Ra5BOzh@Fo=7wJ-odzr(gR%TmcLxZkrx$JU|*c=kx z^~JK0Q!Bw~P^yFjqL*2-L&Mnbs8W;pp1^i>h=fAc&2uV#Z8%e`#yzdIY;dpo?UfNsbJ z_kO;~7`l>`WWypMC4~?_=4n-LIL-@usu6#(i*cUFvw2~!q&%ceT~8^Gv#Op=45P{U zB6NMMJsv|qxt>~KlOE=Ao@S+ySAt6P5Mrp1R;1C7WG+lF(nbnb=DSF16%Qq~7wWav zz#_IP)C;~UFrg3{iX^p%>=kO4mh8I05U*~Xz=}kQC z7G@D)JuON~u&0Gmg3T7z(`d4%(e<$wJSJ!ZwZg{JJkHasGIH8+jgCTSC_F8Ur_s4&*A0evb?b!C)2xX-jo6w! zEsUqJMBr%#!=4t_(<1ORXyEDpOhS9<|1F`-Z{ozs^u*Is^K%zwC%O4;`na<_{Cv~& wHUD`x^7Kzf8hP+ON(=>0|8oJ2{v9)qK0oOHZ9w0!6hV0H<^|&?P+C~-pU%4v_5c6? literal 0 HcmV?d00001 diff --git a/firmware/resources/zigbee_switch_128x32_dark.png b/firmware/resources/zigbee_switch_128x32_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..c53b349c495d71d534684195cd576db9eb3541ee GIT binary patch literal 1582 zcmV+}2GRM6P)EX>4Tx04R}tkv&MmKpe$iTcs)$2MZN($WWcyMMWHI6^c+H)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfc5qU3krMxx6k5c1aNLh~_a1le0DrT}RI?`msG4PD zQb{3~UloF{=tl%0#1N5~sn3aG8lL0p9zMR_#d((Zxj)CCQZO0d6NnQ`H!R`};+aiL z=e$oGW@SksJ|~VDbV1@ruFEdJaV|OR=b2$6o0%sL6APs-mb;jh4V8GBII5@`<@<9k zE1b7DtJOMd-;=*ERM1wIxlVHoDJ)_MA_T~&qk<|d#A($?F_EGDq=$dh@r&e=$yEU( z#{z0lAvu2VKlt6PS)7`5lR`K2d-P^xs+Wq|ivp90VFgb{*00006VoOIv00000008+zyMF)x010qNS#tmY zE+YT{E+YYWr9XB6000McNliru=m{4M1QKZw83zCW02y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{00ag}L_t(|+U;9gZ`w!{{$>m&V4P4et!JC`^052R{Qupb z(n!r}S83XT?6ys0;|nmJJ`C8D5K^4_hB?wmh>?Ac=X~etV*)_pK(!@$ID&dpV=taU z)70wsLC??e;;%o||5CVA7fq*5V( zQXq;zS~_gU0fc}AKr{_-|i(H4QjDg?;f}fgAuIJ_qjZY6yVA0E~Z* z6Dw{W1G8CuYOh`oY{Zj<_4ot`f_eae^!s>m{SkyxWdV*;-y(bg1Q|sb4W9$PpL=M? z4*+LpV1HjGNs-<^)W#Vbpu38c)8LUml)02g^z_-W2hE_28G* zxJen0S?cOO*IQuIaO1t#_njSNUf#nUSUX)8Qy79DpMXtVz_x+WsQLh4pB80ZhRNPK zFxWKwLBX5$AG|3|eUH5nKKu?y{_j2n8WF7+e z%Tx8E+04xX*R9bVSU=Q=_qs;&JRgF=_C zOBVRj_9haqUl$@nF|UJl9n5v&7AUtFaC=*ynsNPgaDf9N#SVlR2H3Z+al>e2bW1ZS z^ULYv1ZXy4f4n*jgxoJiH;jb6c?*ok)gHqh^nuy@{z%xsD$N{3b%sK#GC#18|K3n& ze*m~{>BKGfSh%jMp~{EG!rz?(S68ZeGMVHrn-JT_!f*a7y$7q_harXmGPGb{Tx|a^ zq}@@#m`>B>6_hF^&t}Q{`E4JD1cBmJF{%~-9()RtSlUWr`Aa_ydwHrVl|36?-46g9 gD7{lX96`P5I}~3)o%>>2iU0rr07*qoM6N<$g4Q6;O8@`> literal 0 HcmV?d00001 From a8799ab346fc80b0f071cad01fd9ef0713bfe362 Mon Sep 17 00:00:00 2001 From: Roberto Arellano Date: Mon, 23 Sep 2024 11:57:07 -0600 Subject: [PATCH 16/31] feat: optional sd card menus in menuconfig --- firmware/components/minino_config/Kconfig.projbuild | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/firmware/components/minino_config/Kconfig.projbuild b/firmware/components/minino_config/Kconfig.projbuild index 7152418..46ab71d 100644 --- a/firmware/components/minino_config/Kconfig.projbuild +++ b/firmware/components/minino_config/Kconfig.projbuild @@ -716,4 +716,12 @@ config FILE_MANAGER_WEB Enable or disable the Web File Manager Feature. endif # FILE_MANAGER_ENABLE +########################### SD_CARD ############################# + +config SD_CARD + bool "Enable SD Card Menus" + default true + help + Enable or disable SD Card Menus. + endmenu \ No newline at end of file From 3a5ed2f8e109630f0ee971798b2cc95c5e7556d2 Mon Sep 17 00:00:00 2001 From: deimos Date: Mon, 23 Sep 2024 13:22:52 -0600 Subject: [PATCH 17/31] feat: add wifi loading bitmap for 128x32 --- firmware/main/modules/wifi/wifi_bitmaps.h | 60 ++++++++++++++++++ .../main/modules/wifi/wifi_screens_module.c | 13 +++- firmware/resources/wifi-loading-1-128x32.png | Bin 0 -> 1147 bytes ...oading-1.png => wifi-loading-1-128x64.png} | Bin firmware/resources/wifi-loading-128x32.xcf | Bin 0 -> 5034 bytes firmware/resources/wifi-loading-2-128x32.png | Bin 0 -> 1152 bytes ...oading-2.png => wifi-loading-2-128x64.png} | Bin firmware/resources/wifi-loading-3-128x32.png | Bin 0 -> 1122 bytes ...oading-3.png => wifi-loading-3-128x64.png} | Bin firmware/resources/wifi-loading-4-128x32.png | Bin 0 -> 1137 bytes ...oading-4.png => wifi-loading-4-128x64.png} | Bin 11 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 firmware/resources/wifi-loading-1-128x32.png rename firmware/resources/{wifi-loading-1.png => wifi-loading-1-128x64.png} (100%) create mode 100644 firmware/resources/wifi-loading-128x32.xcf create mode 100644 firmware/resources/wifi-loading-2-128x32.png rename firmware/resources/{wifi-loading-2.png => wifi-loading-2-128x64.png} (100%) create mode 100644 firmware/resources/wifi-loading-3-128x32.png rename firmware/resources/{wifi-loading-3.png => wifi-loading-3-128x64.png} (100%) create mode 100644 firmware/resources/wifi-loading-4-128x32.png rename firmware/resources/{wifi-loading-4.png => wifi-loading-4-128x64.png} (100%) diff --git a/firmware/main/modules/wifi/wifi_bitmaps.h b/firmware/main/modules/wifi/wifi_bitmaps.h index bba2089..fa79225 100644 --- a/firmware/main/modules/wifi/wifi_bitmaps.h +++ b/firmware/main/modules/wifi/wifi_bitmaps.h @@ -153,6 +153,7 @@ unsigned char* wifi_bitmap_attackallArray[4] = { wifi_bitmap_attackattack_1, wifi_bitmap_attackattack_2, wifi_bitmap_attackattack_3, wifi_bitmap_attackattack_4}; +#ifdef CONFIG_RESOLUTION_128X64 // 'wifi-loading-1', 56x56px const unsigned char epd_bitmap_wifi_loading_1[] = { 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, @@ -296,6 +297,65 @@ const unsigned char epd_bitmap_wifi_loading_4[] = { 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00}; +#endif + +#ifdef CONFIG_RESOLUTION_128X32 +// 'wifi-loading-1-128x32', 32x32px +const unsigned char epd_bitmap_wifi_loading_1[] = { + 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x0f, 0xf0, 0x00, + 0x00, 0x39, 0x9c, 0x00, 0x00, 0xe1, 0x87, 0x00, 0x01, 0x80, 0x01, 0x80, + 0x03, 0x00, 0x00, 0xc0, 0x06, 0x00, 0x00, 0x60, 0x0c, 0x00, 0x00, 0x30, + 0x08, 0x07, 0xe0, 0x10, 0x18, 0x1f, 0xf8, 0x18, 0x10, 0x78, 0x1e, 0x08, + 0x31, 0xe0, 0x07, 0x8c, 0x23, 0x87, 0xe1, 0xc4, 0x27, 0x1f, 0xf8, 0xe4, + 0xfa, 0x3c, 0x3c, 0x5f, 0xf8, 0x70, 0x0e, 0x1f, 0x20, 0xe1, 0x87, 0x04, + 0x21, 0xc7, 0xe3, 0x84, 0x34, 0x8f, 0xf1, 0x0c, 0x12, 0x1c, 0x38, 0x08, + 0x1b, 0x09, 0x90, 0x18, 0x09, 0x83, 0xc0, 0x10, 0x0c, 0xc3, 0xc0, 0x30, + 0x06, 0x61, 0x80, 0x60, 0x03, 0x30, 0x00, 0xc0, 0x01, 0x98, 0x01, 0x80, + 0x00, 0xe1, 0x87, 0x00, 0x00, 0x39, 0x9c, 0x00, 0x00, 0x0f, 0xf0, 0x00, + 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00}; + +// 'wifi-loading-2-128x32', 32x32px +const unsigned char epd_bitmap_wifi_loading_2[] = { + 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x0f, 0xf0, 0x00, + 0x00, 0x39, 0x9c, 0x00, 0x00, 0xe1, 0x87, 0x00, 0x01, 0x80, 0x01, 0x80, + 0x03, 0x00, 0x00, 0xc0, 0x06, 0x00, 0x00, 0x60, 0x0c, 0x00, 0x00, 0x30, + 0x08, 0x07, 0xe0, 0x10, 0x18, 0x1f, 0xf8, 0x18, 0x10, 0x78, 0x1e, 0x08, + 0x31, 0xe0, 0x07, 0x8c, 0x23, 0x87, 0xe1, 0xc4, 0x27, 0x1f, 0xf8, 0xe4, + 0xfa, 0x3c, 0x3c, 0x5f, 0xf8, 0x70, 0x0e, 0x1f, 0x20, 0xe1, 0x87, 0x04, + 0x21, 0xc7, 0xe3, 0x84, 0x30, 0x8f, 0xf1, 0x2c, 0x10, 0x1c, 0x38, 0x48, + 0x18, 0x09, 0x90, 0xd8, 0x08, 0x03, 0xc1, 0x90, 0x0c, 0x03, 0xc3, 0x30, + 0x06, 0x01, 0x86, 0x60, 0x03, 0x00, 0x0c, 0xc0, 0x01, 0x80, 0x11, 0x80, + 0x00, 0xe1, 0x87, 0x00, 0x00, 0x39, 0x9c, 0x00, 0x00, 0x0f, 0xf0, 0x00, + 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00}; + +// 'wifi-loading-3-128x32', 32x32px +const unsigned char epd_bitmap_wifi_loading_3[] = { + 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x0f, 0xf0, 0x00, + 0x00, 0x39, 0x9c, 0x00, 0x00, 0xe1, 0x87, 0x00, 0x01, 0x80, 0x31, 0x80, + 0x03, 0x00, 0x1c, 0xc0, 0x06, 0x00, 0x06, 0x60, 0x0c, 0x00, 0x03, 0x30, + 0x08, 0x07, 0xe1, 0x90, 0x18, 0x1f, 0xf8, 0xd8, 0x10, 0x78, 0x1e, 0x28, + 0x31, 0xe0, 0x07, 0x8c, 0x23, 0x87, 0xe1, 0xc4, 0x27, 0x1f, 0xf8, 0xe4, + 0xfa, 0x3c, 0x3c, 0x5f, 0xf8, 0x70, 0x0e, 0x1f, 0x20, 0xe1, 0x87, 0x04, + 0x21, 0xc7, 0xe3, 0x84, 0x30, 0x8f, 0xf1, 0x0c, 0x10, 0x1c, 0x38, 0x08, + 0x18, 0x09, 0x90, 0x18, 0x08, 0x03, 0xc0, 0x10, 0x0c, 0x03, 0xc0, 0x30, + 0x06, 0x01, 0x80, 0x60, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x80, 0x01, 0x80, + 0x00, 0xe1, 0x87, 0x00, 0x00, 0x39, 0x9c, 0x00, 0x00, 0x0f, 0xf0, 0x00, + 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00}; + +// 'wifi-loading-4-128x32', 32x32px +const unsigned char epd_bitmap_wifi_loading_4[] = { + 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x0f, 0xf0, 0x00, + 0x00, 0x39, 0x9c, 0x00, 0x00, 0xe1, 0x87, 0x00, 0x01, 0x8c, 0x01, 0x80, + 0x03, 0x38, 0x00, 0xc0, 0x06, 0x60, 0x00, 0x60, 0x0c, 0xc0, 0x00, 0x30, + 0x0b, 0x87, 0xe0, 0x10, 0x1a, 0x1f, 0xf8, 0x18, 0x14, 0x78, 0x1e, 0x08, + 0x35, 0xe0, 0x07, 0x8c, 0x23, 0x87, 0xe1, 0xc4, 0x27, 0x1f, 0xf8, 0xe4, + 0xfa, 0x3c, 0x3c, 0x5f, 0xf8, 0x70, 0x0e, 0x1f, 0x20, 0xe1, 0x87, 0x04, + 0x21, 0xc7, 0xe3, 0x84, 0x30, 0x8f, 0xf1, 0x0c, 0x10, 0x1c, 0x38, 0x08, + 0x18, 0x09, 0x90, 0x18, 0x08, 0x03, 0xc0, 0x10, 0x0c, 0x03, 0xc0, 0x30, + 0x06, 0x01, 0x80, 0x60, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x80, 0x01, 0x80, + 0x00, 0xe1, 0x87, 0x00, 0x00, 0x39, 0x9c, 0x00, 0x00, 0x0f, 0xf0, 0x00, + 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00}; +#endif static const unsigned char* epd_bitmap_wifi_loading[4] = { epd_bitmap_wifi_loading_1, diff --git a/firmware/main/modules/wifi/wifi_screens_module.c b/firmware/main/modules/wifi/wifi_screens_module.c index 156cf43..00ae8ca 100644 --- a/firmware/main/modules/wifi/wifi_screens_module.c +++ b/firmware/main/modules/wifi/wifi_screens_module.c @@ -27,8 +27,19 @@ void wifi_screens_module_display_sniffer_cb(sniffer_runtime_t* sniffer) { } void wifi_screens_display_sniffer_animation_task() { +#ifdef CONFIG_RESOLUTION_128X64 + uint8_t width = 56; + uint8_t height = 56; + uint8_t x = 0; +#else + uint8_t width = 32; + uint8_t height = 32; + uint8_t x = (64 - width) / 2; + // uint8_t x = 0; +#endif + static uint8_t idx = 0; - oled_screen_display_bitmap(epd_bitmap_wifi_loading[idx], 0, 1, 56, 56, + oled_screen_display_bitmap(epd_bitmap_wifi_loading[idx], x, 1, width, height, OLED_DISPLAY_NORMAL); idx = ++idx > 3 ? 0 : idx; } diff --git a/firmware/resources/wifi-loading-1-128x32.png b/firmware/resources/wifi-loading-1-128x32.png new file mode 100644 index 0000000000000000000000000000000000000000..2d9d2d06b5c55f1c90bee29aab77daf7b5d05786 GIT binary patch literal 1147 zcmV->1cdvEP)EX>4Tx04R}tkv&MmKpe$iTg4A5f)*6%kf92KT~x%eR-p(LLaorMgUO{|(4-+r zad8w}3l4rPRvlcNb#-tR1i=pwX9p)m7b)?7NufoI2gm(*ckglc4)E8@Of@@VfT~$W zDiIel*;S$I6+IZj0LBrPn5oZ+ViKO?>mEM7-bHzq_qjhupOP~f;1h^rOgAjz4dR(i zOXs{#9AZUDAwDObFzABBk6f2se&bwl*v~UVMmjZ593mD9Z7jDjD;g^CG;u^xHOlvA zTvj-5aaPM!*1RWwVKAqyEOVV^7zr$52_gi@sG@{2EJSJ5NHLM3{kVsJ#PN&dlF3y9 zBgX_CX>@2HM@dakSAh-}0006~NklOy z_L8U%#H;}un{+!nQ)ZZ4WUM2dgDf!sgeNbd6#yVlvuC%!3}1Y)sTmNm0%m^PQ?n5b zKqv_?2HbAQU%ojhFuy^BJX=Nqn8)%=w;PIw<52WJUtb}#0!fKt`~CS02(5to9r^O* zDSr8>1Y0adpP&6J=KxS_wxGIh=$isSXw~re7tUJ{>kaOQ!-qaX6nsYHQ|NGtFy!19 z&DbkgY_`tlX8nyx%2CHY=P`DYa-fF}1wyNjD6$Mt${DdQQt!Ie3b53M5HT19nDi z8$X{=tT#OkJR-Fpyq9IidCRfGxl03int|$i0LIP^6Izj}-v&gUW&^H5IvBH?y<7tI z0*FavNQfbj9S!_C>|0?>-Eb;kTW_rf*nA%Cyw9~za&&D}M?`hqF78Jb-0(r23q(Hy z{CL3a?X6p&%>B^A;Jf{wxd%2So7-XY`2awJ(~wtJceGhHh{~oS&z1mVjcxAkb9i}d zUrT2OTv>2NwA(ed>Pq~4>aJldI(laYMtePT?f1=Rl7OXYFC6kVv#x_~<}0WCd>RE| ziz`?gWYrwWj{eZw6AG5{`usUr)qAY!_!;9Ot^5m#I81H{WC z*m4;KHaHg;^li1X1{3e_LKK~)$)lNRT N002ovPDHLkV1g9u@izbf literal 0 HcmV?d00001 diff --git a/firmware/resources/wifi-loading-1.png b/firmware/resources/wifi-loading-1-128x64.png similarity index 100% rename from firmware/resources/wifi-loading-1.png rename to firmware/resources/wifi-loading-1-128x64.png diff --git a/firmware/resources/wifi-loading-128x32.xcf b/firmware/resources/wifi-loading-128x32.xcf new file mode 100644 index 0000000000000000000000000000000000000000..881fea7006b1d5bb12110e4684ae7dd444525d7f GIT binary patch literal 5034 zcmds*&u=70700W)$MeHK#vVJyo?&-svLxCZys-&44oKv{A_XbjB5uxjc6Nx@v$7q? zCXt*A;U7R85JGU+11JXs9QYSNIb=C<25AvyB@=r$Rny&%&#UhC_K=kpj zu5Z$Cb?j4S9-iqJqUypyVxwU0zaRK#z3OXPN_*ntXm${^%Jp*dsyWk6jue??8 zF<2O~^hSSt^X6dhkiOBu<(Kyd+lPal_=lsz8}YZk{he2JWXV%UH@Am_jp6=iN3SXS zgDVGzw|58e!FYGH^TO%;zdcf228@n&Ox`1*Fd>HlrL!0_vj8QzNhKOKJS;MR73 zv^R{mHtF4->J^=hH}^(|@o2AqV{o7|#@DYO3=U(@ulTt;P1c+%E%;g9iEiX}=K0*# zliW7{oZI$%ZkLC-o%)UGDfC{pG)V_!#qS z#lKMTXDfbO@#iYOW~ggwTL7iMh_CU=*1*v*UH`el$C$6EFEs4sieElJ8mrR6pI16D zzM_a3{t>@yF^+;3ew15dj?4!p=zh_JAn0Bw{0m097r`ZP6uzCa94rtxSl)-_U^!Us zoMmBwz{2uAEDOuRvga&;1pJwFIweMFt zF}|YM&D#6;Ws7kXwAwFntGoF-cJLCrdC6P#b9~9~VEHo%t76&BlI71IEPp0pRV+K|S+|R`2+N;ISW{mFmo3Io(3<{HSMMksu$y}R%Cq?2_Q?D` zXE{BCj6N3UEUV`b)?;zb`qa6+SUIoCqQwPtHyi!Yet&m>_r!y#^rz)u>L1xkYyGLx ziSZT1R<{0*U$z)WL2ISCHKxr`)Fat5jqWN%Hoy-F#u4~ND*EQ?-8l!=)F*Ua4pt)#H znw#d>uH>y6NoKlc+p3x}6F5{mR6AH8bj)yM079o6R&=cFh~S9Cc;JZa$iShR zx#Ccb4IHW+89P*Cbq#T-E^O*h4X*`i#Hx-dC!d3AzXq!PnyAJKvGSN2TXWD{G$+kX zb40aYL-SS*r5;qHG1uxQEge#va%(DB@*L-C9*}eMKyE9 zq8b}mR9jSARAY4wv8XO=YEccZ1!}~qjwvUfgKED9s{NX%#tO0Wm>OGi&|EYp%}sMe zwO>Q?Rt=>dRHHHQTD@vs!vg6Unaqe}tL8Kn^3s>lOwx`?GkHiV5}EWba@^+PWWi+j zC-ZpR9CO+=G%rIl(58$?j!3`9toCUv7o~4>iC8?u!rE;7UdklVeTiq+>ES z(G*X7vYK{=fNat>sXLc;ELo?bJe8C+&yq;8c^`^Wx>$YxDaYV0UMnYrMiy#jhVs(# zw?UDN^g6AGM>K;zS zP=pm$2{}7ju9DaOK!WFW3q`+r<{B4J1VWdYO;*Ki_=z<$S@<6R@1Qe6H!(l?@z-mS zxxak%a?fZGh3Q>=zS%IR_#H=ZW9HqQNgEdko|@&_61C8)`!(vQA1&%wLQOFdg)E|g zWLGVrt$c#I)6jZ#*6IO%P@~r5HAeo0I(Y63g29Oxim<{eA!SR;Qt}$_BaiA6>VB!} zV9kKg=IU@8e&V@0AEl!1*`CoL3e($oPSxRetUbfbTh!H2XA5=g3T5n_yLX!s-IXi& z{lA^ICHqH@>~3`=(@&g)+VfytYFV9f7>T%Lk!!1xzIf-uj!b@g$C&Y)$VYszUu4#} zB}vK`EJW?TxFGUwC^A1|ni3?LyfJI!r51y8RFTArb&RgJc^;T?XQ{CMr6uO5D74Le zbG!e>aDV*f-i~&k^sfDRRu#=h+h?sR<=0@oidlKw_is^oR^Bg2YT^Qzl}F#d)SsgQ F{{iPO;-LTl literal 0 HcmV?d00001 diff --git a/firmware/resources/wifi-loading-2-128x32.png b/firmware/resources/wifi-loading-2-128x32.png new file mode 100644 index 0000000000000000000000000000000000000000..bb952fa513d3d14ee55c439d484f9e91446bbcd7 GIT binary patch literal 1152 zcmV-`1b_R9P)EX>4Tx04R}tkv&MmKpe$iTg4A5f)*6%kf92KT~x%eR-p(LLaorMgUO{|(4-+r zad8w}3l4rPRvlcNb#-tR1i=pwX9p)m7b)?7NufoI2gm(*ckglc4)E8@Of@@VfT~$W zDiIel*;S$I6+IZj0LBrPn5oZ+ViKO?>mEM7-bHzq_qjhupOP~f;1h^rOgAjz4dR(i zOXs{#9AZUDAwDObFzABBk6f2se&bwl*v~UVMmjZ593mD9Z7jDjD;g^CG;u^xHOlvA zTvj-5aaPM!*1RWwVKAqyEOVV^7zr$52_gi@sG@{2EJSJ5NHLM3{kVsJ#PN&dlF3y9 zBgX_CX>@2HM@dakSAh-}00074NklT2l6$bd zB-00i*MN;py46ZWvZ7>S&zU)g@eBh%c=8ci0RW0DfA$C@_~M66&47>AeI z@yky~u=#v+fAX)K139P>(BTwe$hj|? zu~)EMZ=Cy*{=p>WsAHe=7&}Qh&_jm;q18tec@8M$jMx{c_kYVJaJdY9*Z}zT0+yzo z0%D2}0D6B%xm?BZeK~{8=UpIK251d_*n^1h`^UBmKq%RD-WDK7F%i`jNYkJO?2Onp zemwuL{!&a9)kxysB?kn_X_;5 z$L;N{TcFzY(1Ujgt;`zOlx&vEX8qQ;4{k$VUER6Lb7xdW2l)bEtg%^i+F9YpgLy5T z8HmXO0K#_LWTLtfKcBjL7#n14?CfO9ZD*d{uK7$;uq^9^L+*Z2R?dqq@s(44K1KC^ zF|VhPRdXdf`a^F|D6|4;ZEE(j!wNs2nnq-#OAe|&s0k0pLMsxo8r>6|3)(@%)t37z zAwM3#7K^CT9h?i=_RLf}YcTN+FGSH3(&W*sZCvc@yH)?as+{-9rvmuzrsF>~K=JX^ Sim&EX>4Tx04R}tkv&MmKpe$iTg4A5f)*6%kf92KT~x%eR-p(LLaorMgUO{|(4-+r zad8w}3l4rPRvlcNb#-tR1i=pwX9p)m7b)?7NufoI2gm(*ckglc4)E8@Of@@VfT~$W zDiIel*;S$I6+IZj0LBrPn5oZ+ViKO?>mEM7-bHzq_qjhupOP~f;1h^rOgAjz4dR(i zOXs{#9AZUDAwDObFzABBk6f2se&bwl*v~UVMmjZ593mD9Z7jDjD;g^CG;u^xHOlvA zTvj-5aaPM!*1RWwVKAqyEOVV^7zr$52_gi@sG@{2EJSJ5NHLM3{kVsJ#PN&dlF3y9 zBgX_CX>@2HM@dakSAh-}0006xNklUnatN&e07aUuy#gEj=fRe0K*$!@gmEv`Ml=AS zB)}NZbtoPly%h9o5TVHOC;;17o~i3l-UZLS{`boZgjOIaQU3V3UIRia;Ce-oKddrH zURPkd-Q@WofF;6R5H=9r)He_ll#n}xRwR@p-(JiVT9MGote;=Y!P=f94Xk;23?(5t zya480$yW803;Mjo{bu7HASovWhlKm~UH2p@Z|)q@zyM*E0ZMsa9MaI#cm3V277PG> zeg{jEfwh|81Asn0P=0%g;-9}aV7uKANSXp#gP)EdBE0_E4*>`zhr%tjxxqxVXCO(U zZD151ni}QPcgF_qFSQR|t7;(JaO@EtvH`kWMqq61u)BW(Lg_4usMpZ;~xdeHfz3@(*4}_}$embIi zdy5D}OZn|19AmS0*!!c}innL~$t)Ya%BG^o@=xJgf1SgtlX1&nIu51H!QAg}DYrcn zZ|dP0#wOFW``>0swlm{!xcw#xSeiP|pEX>4Tx04R}tkv&MmKpe$iTg4A5f)*6%kf92KT~x%eR-p(LLaorMgUO{|(4-+r zad8w}3l4rPRvlcNb#-tR1i=pwX9p)m7b)?7NufoI2gm(*ckglc4)E8@Of@@VfT~$W zDiIel*;S$I6+IZj0LBrPn5oZ+ViKO?>mEM7-bHzq_qjhupOP~f;1h^rOgAjz4dR(i zOXs{#9AZUDAwDObFzABBk6f2se&bwl*v~UVMmjZ593mD9Z7jDjD;g^CG;u^xHOlvA zTvj-5aaPM!*1RWwVKAqyEOVV^7zr$52_gi@sG@{2EJSJ5NHLM3{kVsJ#PN&dlF3y9 zBgX_CX>@2HM@dakSAh-}0006=NklDmAPx1HebC6^Gu z_Jz0)5MqN3hO1PmNC=Qw?|62+yCwh>R$fdB06-QeYp1{l|M((H8DP8yHg4QY+3*Iy z1P2HKng-eShcyI`ZzzQM*xBB02Z(veDagO}(b3Fr03gCW6mTp%G zj}{k@C^GE50Suk@^e&7uy%sHqiIAw_&7@FFaPwOVW&79XetplK_9F&dEC0@3p9+Un zgju?sq+B2K-Gcf4V6_W}6D!UaJN6Z*;v7tHLk~s>m=wt3q7(m(YM(&>632t(C}%UP7dmGM`h0#Zyz;(RZs2uW zk}dt=WJ{)`>~r?&Mr5WXn{P_L(GA&}+QsLB$3eu_mb(Db%NZn1y}-|&3;N#hk?pjD ziSzKHls9XOk7l$gL4v?2-w*ZQ>)KjR{wjd~?sWVI*lElfo}gJd00000NkvXXu0mjf D(aHPa literal 0 HcmV?d00001 diff --git a/firmware/resources/wifi-loading-4.png b/firmware/resources/wifi-loading-4-128x64.png similarity index 100% rename from firmware/resources/wifi-loading-4.png rename to firmware/resources/wifi-loading-4-128x64.png From 28240de3af04cf43ecec4293f3a560b3bdce5ce9 Mon Sep 17 00:00:00 2001 From: Kevin Jahaziel Leon Morales Date: Mon, 23 Sep 2024 14:19:42 -0600 Subject: [PATCH 18/31] feat: Fix WiFi screens - Fix bugs with delete WIFI AP --- firmware/components/cmd_wifi/cmd_wifi.c | 26 ++++- firmware/main/general/general_screens.c | 1 + .../settings/display/display_settings.c | 2 +- .../modules/settings/wifi/wifi_settings.c | 97 +++++++++++++------ 4 files changed, 91 insertions(+), 35 deletions(-) diff --git a/firmware/components/cmd_wifi/cmd_wifi.c b/firmware/components/cmd_wifi/cmd_wifi.c index ab81c78..6fa556f 100644 --- a/firmware/components/cmd_wifi/cmd_wifi.c +++ b/firmware/components/cmd_wifi/cmd_wifi.c @@ -135,6 +135,27 @@ static void cmd_wifi_delete_crendentials(int argc, char** argv) { preferences_remove(wifi_ssid); ESP_LOGI(__func__, "Deleted AP %s", wifi_ssid); + // Restore the AP indexes + int counter = 0; + for (int i = 0; i < count - 1; i++) { + char wifi_ap[100]; + char wifi_ssid[100]; + sprintf(wifi_ap, "wifi%d", i); + esp_err_t err = preferences_get_string(wifi_ap, wifi_ssid, 100); + if (err != ESP_OK) { + continue; + } + char wifi_pass[100]; + err = preferences_get_string(wifi_ssid, wifi_pass, 100); + if (err != ESP_OK) { + continue; + } + char wifi_ap_new[100]; + sprintf(wifi_ap_new, "wifi%d", counter); + preferences_put_string(wifi_ap_new, wifi_ssid); + counter++; + } + preferences_put_int("count_ap", count - 1); } @@ -164,8 +185,7 @@ static int cmd_wifi_show_aps(int argc, char** argv) { sprintf(wifi_ap, "wifi%d", i); esp_err_t err = preferences_get_string(wifi_ap, wifi_ssid, 100); if (err != ESP_OK) { - ESP_LOGW(__func__, "Error getting AP"); - return 1; + continue; } printf("[%i][%s] SSID: %s\n", i, wifi_ap, wifi_ssid); } @@ -199,8 +219,8 @@ static void event_handler(void* arg, xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) { printf("Connected to AP"); - xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); preferences_put_bool("wifi_connected", true); + xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); } } diff --git a/firmware/main/general/general_screens.c b/firmware/main/general/general_screens.c index 2096ba4..7e19248 100644 --- a/firmware/main/general/general_screens.c +++ b/firmware/main/general/general_screens.c @@ -2,6 +2,7 @@ #include "general/bitmaps_general.h" #include "menus_module.h" #include "oled_screen.h" +#include "preferences.h" #define MAX_LINE_CHAR 16 diff --git a/firmware/main/modules/settings/display/display_settings.c b/firmware/main/modules/settings/display/display_settings.c index fa9fce7..f90c9e8 100644 --- a/firmware/main/modules/settings/display/display_settings.c +++ b/firmware/main/modules/settings/display/display_settings.c @@ -135,7 +135,7 @@ static void display_config_module_state_machine(uint8_t button_name, } switch (button_name) { case BUTTON_LEFT: - menus_module_restart(); + menus_module_exit_app(); break; case BUTTON_RIGHT: ESP_LOGI(TAG_DISPLAY_CONFIG, "Selected item: %d", selected_item); diff --git a/firmware/main/modules/settings/wifi/wifi_settings.c b/firmware/main/modules/settings/wifi/wifi_settings.c index c816c31..2809e86 100644 --- a/firmware/main/modules/settings/wifi/wifi_settings.c +++ b/firmware/main/modules/settings/wifi/wifi_settings.c @@ -2,6 +2,7 @@ #include "bitmaps_general.h" #include "cmd_wifi.h" #include "esp_log.h" +#include "general/general_screens.h" #include "led_events.h" #include "menus_module.h" #include "modals_module.h" @@ -11,11 +12,15 @@ #define TAG_CONFIG_MODULE "CONFIG_MODULE" #ifdef CONFIG_RESOLUTION_128X64 - #define START_PAGE 2 - #define Y_N_OFFSET 4 + #define START_PAGE 2 + #define Y_N_OFFSET 4 + #define ITEMOFFSET 2 + #define ITEMSPERSCREEN 4 #else // CONFIG_RESOLUTION_128X32 - #define START_PAGE 0 - #define Y_N_OFFSET 1 + #define START_PAGE 0 + #define Y_N_OFFSET 2 + #define ITEMOFFSET 1 + #define ITEMSPERSCREEN 3 #endif static int selected_item = 0; @@ -64,9 +69,11 @@ static void config_module_wifi_display_selected_item(char* item_text, static void config_module_wifi_display_selected_item_center( char* item_text, uint8_t item_number) { - oled_screen_display_bitmap(minino_face, 36, (item_number * 8), 8, 8, + uint8_t x = (128 - (strlen(item_text) * 8)) / 2; + + oled_screen_display_bitmap(minino_face, x - 12, (item_number * 8), 8, 8, OLED_DISPLAY_NORMAL); - oled_screen_display_text(item_text, 56, item_number, OLED_DISPLAY_INVERT); + oled_screen_display_text(item_text, x, item_number, OLED_DISPLAY_INVERT); } static void config_module_wifi_display_not_wifi() { @@ -129,12 +136,17 @@ static void config_module_wifi_display_list() { return; } + int position = 1; + uint16_t start_item = (selected_item / ITEMSPERSCREEN) * ITEMSPERSCREEN; + ESP_LOGI(__func__, "Selected item: %d", validate_wifi_count()); - int index = (wifi_config_state.total_items > max_items) ? selected_item : 0; - int limit = (wifi_config_state.total_items > max_items) - ? (max_items + selected_item) - : max_items; - for (int i = index; i < limit; i++) { + // int index = (wifi_config_state.total_items > max_items) ? selected_item : + // 0; int limit = (wifi_config_state.total_items > max_items) + // ? (max_items + selected_item) + // : max_items; + for (int i = start_item; + i < start_item + ITEMSPERSCREEN && i < wifi_config_state.total_items; + i++) { char wifi_ap[100]; char wifi_ssid[100]; sprintf(wifi_ap, "wifi%d", i); @@ -146,14 +158,15 @@ static void config_module_wifi_display_list() { if (strlen(wifi_ssid) > 16) { wifi_ssid[16] = '\0'; } - int page = (wifi_config_state.total_items > max_items) - ? (i + 1) - selected_item - : (i + 1); + // int page = (wifi_config_state.total_items > max_items) + // ? (i + 1) - selected_item + // : (i + 1); if (i == selected_item) { - config_module_wifi_display_selected_item(wifi_ssid, page); + config_module_wifi_display_selected_item(wifi_ssid, position); } else { - oled_screen_display_text(wifi_ssid, 0, page, OLED_DISPLAY_NORMAL); + oled_screen_display_text(wifi_ssid, 0, position, OLED_DISPLAY_NORMAL); } + position = position + ITEMOFFSET; } } @@ -169,16 +182,18 @@ static void config_module_wifi_display_sel_options() { if (strlen(wifi_ssid) > 16) { wifi_ssid[16] = '\0'; } - oled_screen_clear(); - oled_screen_display_text("< Back", 0, 0, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center(wifi_ssid, 1, OLED_DISPLAY_NORMAL); - int page = 3; + genera_screen_display_card_information(wifi_ssid, ""); + // oled_screen_clear(); + // oled_screen_display_text("< Back", 0, 0, OLED_DISPLAY_NORMAL); + // oled_screen_display_text_center(wifi_ssid, 1, OLED_DISPLAY_NORMAL); + int page = 2; for (int i = 0; options_wifi_menu[i] != NULL; i++) { if (i == selected_item) { - config_module_wifi_display_selected_item(options_wifi_menu[i], page); + config_module_wifi_display_selected_item_center(options_wifi_menu[i], + page); } else { - oled_screen_display_text(options_wifi_menu[i], 0, page, - OLED_DISPLAY_NORMAL); + oled_screen_display_text_center(options_wifi_menu[i], page, + OLED_DISPLAY_NORMAL); } page++; } @@ -197,14 +212,13 @@ static void config_module_wifi_display_forget_modal() { } static void config_module_wifi_display_connect_modal() { - oled_screen_clear(); - oled_screen_display_text_center("Connect this AP?", 1, OLED_DISPLAY_NORMAL); + genera_screen_display_card_information("Connect this AP?", ""); if (selected_item == 0) { - config_module_wifi_display_selected_item_center("YES", 4); - oled_screen_display_text_center("NO", 5, OLED_DISPLAY_NORMAL); + config_module_wifi_display_selected_item_center("YES", Y_N_OFFSET); + oled_screen_display_text_center("NO", Y_N_OFFSET + 1, OLED_DISPLAY_NORMAL); } else { - oled_screen_display_text_center("YES", 4, OLED_DISPLAY_NORMAL); - config_module_wifi_display_selected_item_center("NO", 5); + oled_screen_display_text_center("YES", Y_N_OFFSET, OLED_DISPLAY_NORMAL); + config_module_wifi_display_selected_item_center("NO", Y_N_OFFSET + 1); } } @@ -257,7 +271,6 @@ static void config_module_state_machine(uint8_t button_name, case BUTTON_UP: selected_item = (selected_item == 0) ? total_items - 1 : selected_item - 1; - config_module_wifi_display_list(); break; case BUTTON_DOWN: @@ -339,6 +352,7 @@ static void config_module_state_machine_config_modal_connect( connect_wifi(wifi_ssid, wifi_pass, config_module_wifi_handle_connection); menus_module_set_app_state(true, config_module_state_machine_config); + wifi_config_state.selected_item = 0; } else { selected_item = 0; wifi_config_state.state = WIFI_SETTING_IDLE; @@ -373,7 +387,7 @@ static void config_module_state_machine_config_modal_forget( ESP_LOGI(TAG_CONFIG_MODULE, "Selected item: %d", selected_item); if (selected_item == 0) { char wifi_ap[100]; - sprintf(wifi_ap, "wifi%d", selected_item); + sprintf(wifi_ap, "wifi%d", wifi_config_state.selected_item); char wifi_ssid[100]; preferences_get_string(wifi_ap, wifi_ssid, 100); esp_err_t err = preferences_remove(wifi_ssid); @@ -387,12 +401,33 @@ static void config_module_state_machine_config_modal_forget( return; } int count = preferences_get_int("count_ap", 0); + int counter = 0; + for (int i = 0; i < count - 1; i++) { + char wifi_ap[100]; + char wifi_ssid[100]; + sprintf(wifi_ap, "wifi%d", i); + esp_err_t err = preferences_get_string(wifi_ap, wifi_ssid, 100); + if (err != ESP_OK) { + continue; + } + char wifi_ap_new[100]; + sprintf(wifi_ap_new, "wifi%d", counter); + preferences_put_string(wifi_ap_new, wifi_ssid); + counter++; + } err = preferences_put_int("count_ap", count - 1); if (err != ESP_OK) { ESP_LOGW(__func__, "Error removing AP"); return; } } + int count = validate_wifi_count(); + if (count == 0) { + menus_module_set_app_state(true, only_exit_input_cb); + return; + } + wifi_config_state.total_items = count; + total_items = count; selected_item = 0; wifi_config_state.state = WIFI_SETTING_IDLE; menus_module_set_app_state(true, config_module_state_machine_config); From b5f053b7ba265b45bdee57f25ff76a5df64758b0 Mon Sep 17 00:00:00 2001 From: deimos Date: Mon, 23 Sep 2024 14:19:53 -0600 Subject: [PATCH 19/31] feat: directive to enable/disable the leds component --- firmware/components/leds/Kconfig.projbuild | 9 ++++++ firmware/components/leds/leds.c | 36 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 firmware/components/leds/Kconfig.projbuild diff --git a/firmware/components/leds/Kconfig.projbuild b/firmware/components/leds/Kconfig.projbuild new file mode 100644 index 0000000..1d93aa4 --- /dev/null +++ b/firmware/components/leds/Kconfig.projbuild @@ -0,0 +1,9 @@ +menu "LEDs Configuration" + + config LEDS_COMPONENT_ENABLED + bool "Enable LEDs component" + default true + help + Enable the LEDs component. + +endmenu \ No newline at end of file diff --git a/firmware/components/leds/leds.c b/firmware/components/leds/leds.c index 3123b28..fc3788a 100644 --- a/firmware/components/leds/leds.c +++ b/firmware/components/leds/leds.c @@ -14,6 +14,9 @@ static led_t *left_led, *right_led; void leds_begin() { +#ifndef CONFIG_LEDS_COMPONENT_ENABLED + return; +#endif left_led = (led_t*) malloc(sizeof(led_t)); right_led = (led_t*) malloc(sizeof(led_t)); *left_led = led_controller_led_new(LEFT_LED_IO, LEFT_LED_CHANNEL); @@ -23,6 +26,9 @@ void leds_begin() { } void leds_deinit() { +#ifndef CONFIG_LEDS_COMPONENT_ENABLED + return; +#endif if (!left_led || !right_led) { return; } @@ -35,32 +41,53 @@ void leds_deinit() { } void leds_on() { +#ifndef CONFIG_LEDS_COMPONENT_ENABLED + return; +#endif led_controller_led_on(left_led); led_controller_led_on(right_led); } void leds_off() { +#ifndef CONFIG_LEDS_COMPONENT_ENABLED + return; +#endif led_controller_led_off(left_led); led_controller_led_off(right_led); } void leds_set_brightness(uint8_t led, uint8_t brightness) { +#ifndef CONFIG_LEDS_COMPONENT_ENABLED + return; +#endif led_controller_set_duty(led == LED_LEFT ? left_led : right_led, brightness); } void led_left_on() { +#ifndef CONFIG_LEDS_COMPONENT_ENABLED + return; +#endif led_controller_led_on(left_led); } void led_left_off() { +#ifndef CONFIG_LEDS_COMPONENT_ENABLED + return; +#endif led_controller_led_off(left_led); } void led_right_on() { +#ifndef CONFIG_LEDS_COMPONENT_ENABLED + return; +#endif led_controller_led_on(right_led); } void led_right_off() { +#ifndef CONFIG_LEDS_COMPONENT_ENABLED + return; +#endif led_controller_led_off(right_led); } @@ -70,14 +97,23 @@ void led_start_blink(uint8_t led, uint32_t time_on, uint32_t time_off, uint32_t time_out) { +#ifndef CONFIG_LEDS_COMPONENT_ENABLED + return; +#endif led_controller_start_blink_effect(led == LED_LEFT ? left_led : right_led, duty, pulse_count, time_on, time_off, time_out); } void led_start_breath(uint8_t led, uint16_t period_ms) { +#ifndef CONFIG_LEDS_COMPONENT_ENABLED + return; +#endif led_controller_start_breath_effect(led == LED_LEFT ? left_led : right_led, period_ms); } void led_stop(uint8_t led) { +#ifndef CONFIG_LEDS_COMPONENT_ENABLED + return; +#endif led_controller_stop_any_effect(led == LED_LEFT ? left_led : right_led); } From 774991f2cc54024a1c6e72665cfb6e5e21530c2c Mon Sep 17 00:00:00 2001 From: deimos Date: Mon, 23 Sep 2024 14:37:16 -0600 Subject: [PATCH 20/31] feat: directive to enable/disable the buzzer component --- firmware/components/buzzer/Kconfig.projbuild | 9 +++++ firmware/components/buzzer/buzzer.c | 37 ++++++++++++++++++++ firmware/components/leds/leds.c | 12 +++++++ firmware/sdkconfig.defaults | 14 +++++++- 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 firmware/components/buzzer/Kconfig.projbuild diff --git a/firmware/components/buzzer/Kconfig.projbuild b/firmware/components/buzzer/Kconfig.projbuild new file mode 100644 index 0000000..572b663 --- /dev/null +++ b/firmware/components/buzzer/Kconfig.projbuild @@ -0,0 +1,9 @@ +menu "Buzzer Configuration" + + config BUZZER_COMPONENT_ENABLED + bool "Enable buzzer component" + default true + help + Enable the buzzer component. + +endmenu \ No newline at end of file diff --git a/firmware/components/buzzer/buzzer.c b/firmware/components/buzzer/buzzer.c index 522e68f..aaf7c66 100644 --- a/firmware/components/buzzer/buzzer.c +++ b/firmware/components/buzzer/buzzer.c @@ -24,19 +24,32 @@ typedef struct { static buzzer_t buzzer; void buzzer_enable() { +#ifndef CONFIG_BUZZER_COMPONENT_ENABLED + return; +#endif + buzzer.enabled = true; } + void buzzer_disable() { buzzer.enabled = false; } void buzzer_begin(uint8_t pin) { +#ifndef CONFIG_BUZZER_COMPONENT_ENABLED + return; +#endif + buzzer.pin = pin; buzzer.freq = BUZZER_DEFAULT_FREQUENCY_HZ; buzzer.duty = BUZZER_DEFAULT_DUTTY; } void buzzer_configure() { +#ifndef CONFIG_BUZZER_COMPONENT_ENABLED + return; +#endif + // Prepare and then apply the LEDC PWM timer configuration ledc_timer_config_t ledc_timer = {.speed_mode = LEDC_MODE, .duty_resolution = LEDC_DUTY_RES, @@ -57,14 +70,26 @@ void buzzer_configure() { } void buzzer_set_freq(uint32_t freq) { +#ifndef CONFIG_BUZZER_COMPONENT_ENABLED + return; +#endif + buzzer.freq = freq; } void buzzer_set_duty(uint32_t duty) { +#ifndef CONFIG_BUZZER_COMPONENT_ENABLED + return; +#endif + buzzer.duty = duty; } void buzzer_play() { +#ifndef CONFIG_BUZZER_COMPONENT_ENABLED + return; +#endif + if (!buzzer.enabled) { return; } @@ -75,6 +100,10 @@ void buzzer_play() { } void buzzer_play_for_task(void* duration) { +#ifndef CONFIG_BUZZER_COMPONENT_ENABLED + return; +#endif + uint32_t dur = *(uint32_t*) duration; buzzer_play(); vTaskDelay(*(uint32_t*) duration / portTICK_PERIOD_MS); @@ -83,6 +112,10 @@ void buzzer_play_for_task(void* duration) { } void buzzer_play_for(uint32_t duration) { +#ifndef CONFIG_BUZZER_COMPONENT_ENABLED + return; +#endif + if (!buzzer.enabled) { return; } @@ -93,6 +126,10 @@ void buzzer_play_for(uint32_t duration) { } void buzzer_stop() { +#ifndef CONFIG_BUZZER_COMPONENT_ENABLED + return; +#endif + ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, 0)); ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL)); diff --git a/firmware/components/leds/leds.c b/firmware/components/leds/leds.c index fc3788a..d73b8ab 100644 --- a/firmware/components/leds/leds.c +++ b/firmware/components/leds/leds.c @@ -17,6 +17,7 @@ void leds_begin() { #ifndef CONFIG_LEDS_COMPONENT_ENABLED return; #endif + left_led = (led_t*) malloc(sizeof(led_t)); right_led = (led_t*) malloc(sizeof(led_t)); *left_led = led_controller_led_new(LEFT_LED_IO, LEFT_LED_CHANNEL); @@ -29,6 +30,7 @@ void leds_deinit() { #ifndef CONFIG_LEDS_COMPONENT_ENABLED return; #endif + if (!left_led || !right_led) { return; } @@ -44,6 +46,7 @@ void leds_on() { #ifndef CONFIG_LEDS_COMPONENT_ENABLED return; #endif + led_controller_led_on(left_led); led_controller_led_on(right_led); } @@ -52,6 +55,7 @@ void leds_off() { #ifndef CONFIG_LEDS_COMPONENT_ENABLED return; #endif + led_controller_led_off(left_led); led_controller_led_off(right_led); } @@ -60,6 +64,7 @@ void leds_set_brightness(uint8_t led, uint8_t brightness) { #ifndef CONFIG_LEDS_COMPONENT_ENABLED return; #endif + led_controller_set_duty(led == LED_LEFT ? left_led : right_led, brightness); } @@ -67,6 +72,7 @@ void led_left_on() { #ifndef CONFIG_LEDS_COMPONENT_ENABLED return; #endif + led_controller_led_on(left_led); } @@ -74,6 +80,7 @@ void led_left_off() { #ifndef CONFIG_LEDS_COMPONENT_ENABLED return; #endif + led_controller_led_off(left_led); } @@ -81,6 +88,7 @@ void led_right_on() { #ifndef CONFIG_LEDS_COMPONENT_ENABLED return; #endif + led_controller_led_on(right_led); } @@ -88,6 +96,7 @@ void led_right_off() { #ifndef CONFIG_LEDS_COMPONENT_ENABLED return; #endif + led_controller_led_off(right_led); } @@ -100,6 +109,7 @@ void led_start_blink(uint8_t led, #ifndef CONFIG_LEDS_COMPONENT_ENABLED return; #endif + led_controller_start_blink_effect(led == LED_LEFT ? left_led : right_led, duty, pulse_count, time_on, time_off, time_out); @@ -108,6 +118,7 @@ void led_start_breath(uint8_t led, uint16_t period_ms) { #ifndef CONFIG_LEDS_COMPONENT_ENABLED return; #endif + led_controller_start_breath_effect(led == LED_LEFT ? left_led : right_led, period_ms); } @@ -115,5 +126,6 @@ void led_stop(uint8_t led) { #ifndef CONFIG_LEDS_COMPONENT_ENABLED return; #endif + led_controller_stop_any_effect(led == LED_LEFT ? left_led : right_led); } diff --git a/firmware/sdkconfig.defaults b/firmware/sdkconfig.defaults index 3f7e2bd..8dae4df 100644 --- a/firmware/sdkconfig.defaults +++ b/firmware/sdkconfig.defaults @@ -126,4 +126,16 @@ CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" CONFIG_PARTITION_TABLE_OFFSET=0x8000 CONFIG_PARTITION_TABLE_MD5=y -# end of Partition Table \ No newline at end of file +# end of Partition Table + +# +# Buzzer Configuration +# +CONFIG_BUZZER_COMPONENT_ENABLED=y +# end of Buzzer Configuration + +# +# LEDs Configuration +# +CONFIG_LEDS_COMPONENT_ENABLED=y +# end of LEDs Configuration From 3fe69c881716c5e9acd8a77be16fc88e1b7647be Mon Sep 17 00:00:00 2001 From: Roberto Arellano Date: Mon, 23 Sep 2024 16:43:53 -0600 Subject: [PATCH 21/31] fix: show analyzer packets on 32px screen --- firmware/main/modules/wifi/wifi_screens_module.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/firmware/main/modules/wifi/wifi_screens_module.c b/firmware/main/modules/wifi/wifi_screens_module.c index 00ae8ca..e6ae5c6 100644 --- a/firmware/main/modules/wifi/wifi_screens_module.c +++ b/firmware/main/modules/wifi/wifi_screens_module.c @@ -8,6 +8,12 @@ TaskHandle_t wifi_sniffer_animation_task_handle = NULL; +#ifdef CONFIG_RESOLUTION_128X64 +uint8_t pkts_offset = 3; +#else +uint8_t pkts_offset = 2; +#endif + void wifi_screens_module_display_sniffer_cb(sniffer_runtime_t* sniffer) { if (sniffer->is_running) { const char* packets_str = malloc(16); @@ -19,8 +25,10 @@ void wifi_screens_module_display_sniffer_cb(sniffer_runtime_t* sniffer) { uint8_t x_offset = 66; oled_screen_display_text("Packets", x_offset, 0, OLED_DISPLAY_INVERT); oled_screen_display_text(packets_str, x_offset, 1, OLED_DISPLAY_INVERT); - oled_screen_display_text("Channel", x_offset, 3, OLED_DISPLAY_INVERT); - oled_screen_display_text(channel_str, x_offset, 4, OLED_DISPLAY_INVERT); + oled_screen_display_text("Channel", x_offset, pkts_offset, + OLED_DISPLAY_INVERT); + oled_screen_display_text(channel_str, x_offset, pkts_offset + 1, + OLED_DISPLAY_INVERT); } else { ESP_LOGI(TAG_WIFI_SCREENS_MODULE, "sniffer task stopped"); } @@ -45,6 +53,7 @@ void wifi_screens_display_sniffer_animation_task() { } void wifi_screens_sniffer_animation_start() { + oled_screen_clear(); animations_task_run(&wifi_screens_display_sniffer_animation_task, 100, NULL); } From e68deea2e667c8d5bdb405b645af20c08743c337 Mon Sep 17 00:00:00 2001 From: Kevin Jahaziel Leon Morales Date: Mon, 23 Sep 2024 23:07:48 -0600 Subject: [PATCH 22/31] feat: Add dragoncin --- firmware/main/general/bitmaps_general.h | 31 +++++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/firmware/main/general/bitmaps_general.h b/firmware/main/general/bitmaps_general.h index d4edf66..56dff56 100644 --- a/firmware/main/general/bitmaps_general.h +++ b/firmware/main/general/bitmaps_general.h @@ -91,6 +91,20 @@ static const unsigned char epd_bitmap_electroniccats[] = { 0x7f, 0xff, 0xff, 0xfe, 0x7e, 0x7f, 0xfe, 0x7e, 0x78, 0x3f, 0xfc, 0x1e, 0x30, 0x0f, 0xf0, 0x0c, 0x30, 0x03, 0xc0, 0x0c}; +// 'baby-dragon', 32x32px +const unsigned char epd_bitmap_baby_dragon_ss[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x80, 0x00, + 0x00, 0x27, 0x40, 0x00, 0x00, 0x10, 0xf8, 0x00, 0x00, 0x08, 0x04, 0x00, + 0x00, 0x70, 0x02, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x20, 0x25, 0x00, + 0x00, 0x10, 0x25, 0x00, 0x00, 0x60, 0x24, 0x80, 0x00, 0x20, 0x00, 0x80, + 0x00, 0x18, 0x01, 0x00, 0x00, 0x07, 0xfe, 0x00, 0x00, 0x01, 0x10, 0x00, + 0x00, 0x01, 0x10, 0x00, 0x00, 0x02, 0x08, 0x00, 0x01, 0x02, 0x06, 0x00, + 0x02, 0x84, 0x05, 0x00, 0x02, 0x88, 0x02, 0x80, 0x04, 0x90, 0x02, 0x40, + 0x04, 0x51, 0x01, 0x40, 0x04, 0x52, 0x01, 0x80, 0x02, 0x2c, 0x01, 0x00, + 0x02, 0x14, 0x01, 0x00, 0x01, 0x08, 0x02, 0x00, 0x00, 0x88, 0x02, 0x00, + 0x00, 0x68, 0x72, 0x00, 0x00, 0x10, 0x89, 0x80, 0x00, 0x11, 0x08, 0x40, + 0x00, 0x0e, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00}; + // 'arrow_left', 16x16px static const unsigned char epd_bitmap_arrow_left[] = { 0x01, 0x80, 0x03, 0x80, 0x07, 0x80, 0x0f, 0x80, 0x1f, 0x80, 0x3f, @@ -162,19 +176,26 @@ const epd_bitmap_t minino_electroniccats_logo = { .height = 32, }; +const epd_bitmap_t minino_baby_dragon_bitmap = { + .bitmap = epd_bitmap_baby_dragon_ss, + .width = 32, + .height = 32, +}; + typedef enum { MININO_LETTERS, MININO_FACE, MININO_PWNLABS, MININO_ELECTRONICCATS, MININO_FACE_MINI, + MININO_BABY_DRAGON, MININO_COUNT } epd_bitmap_type_t; -epd_bitmap_t screen_savers[] = {minino_letters_bitmap, minino_face_logo, - minino_pwnlabs_logo, minino_electroniccats_logo, - minino_face_bitmap}; +extern epd_bitmap_t screen_savers[] = { + minino_letters_bitmap, minino_face_logo, minino_pwnlabs_logo, + minino_electroniccats_logo, minino_face_bitmap, minino_baby_dragon_bitmap}; -char* epd_bitmaps_list[] = {"Letters", "Face", "PwnLabs", - "EC", "Mini face", NULL}; +extern char* epd_bitmaps_list[] = {"Letters", "Face", "PwnLabs", "EC", + "Mini face", "Baby Dragon", NULL}; #endif // BITMAPS_GENERAL_H \ No newline at end of file From 800bd6d8b5ac9932fc641c43b85ad82cc6fd9655 Mon Sep 17 00:00:00 2001 From: Kevin Jahaziel Leon Morales Date: Tue, 24 Sep 2024 00:25:58 -0600 Subject: [PATCH 23/31] feat: Delete extern --- firmware/main/general/bitmaps_general.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware/main/general/bitmaps_general.h b/firmware/main/general/bitmaps_general.h index 56dff56..f0d60ff 100644 --- a/firmware/main/general/bitmaps_general.h +++ b/firmware/main/general/bitmaps_general.h @@ -192,10 +192,10 @@ typedef enum { MININO_COUNT } epd_bitmap_type_t; -extern epd_bitmap_t screen_savers[] = { +epd_bitmap_t screen_savers[] = { minino_letters_bitmap, minino_face_logo, minino_pwnlabs_logo, minino_electroniccats_logo, minino_face_bitmap, minino_baby_dragon_bitmap}; -extern char* epd_bitmaps_list[] = {"Letters", "Face", "PwnLabs", "EC", - "Mini face", "Baby Dragon", NULL}; +char* epd_bitmaps_list[] = {"Letters", "Face", "PwnLabs", "EC", + "Mini face", "Baby Dragon", NULL}; #endif // BITMAPS_GENERAL_H \ No newline at end of file From b06d19aed49d1191e76510f61931c8df0932ead2 Mon Sep 17 00:00:00 2001 From: deimos Date: Tue, 24 Sep 2024 09:00:19 -0600 Subject: [PATCH 24/31] fix: ec face logo bitmap --- firmware/main/general/bitmaps_general.h | 34 +++++++++++++----------- firmware/resources/ec-face-logo.png | Bin 0 -> 889 bytes firmware/resources/ec-face-logo.xcf | Bin 0 -> 3277 bytes 3 files changed, 19 insertions(+), 15 deletions(-) create mode 100644 firmware/resources/ec-face-logo.png create mode 100644 firmware/resources/ec-face-logo.xcf diff --git a/firmware/main/general/bitmaps_general.h b/firmware/main/general/bitmaps_general.h index d4edf66..12870d7 100644 --- a/firmware/main/general/bitmaps_general.h +++ b/firmware/main/general/bitmaps_general.h @@ -77,19 +77,23 @@ static const unsigned char epd_bitmap_pwn_02[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -// 'Isotipo-EC_Blanco', 32x32px -static const unsigned char epd_bitmap_electroniccats[] = { - 0x01, 0x00, 0x00, 0x80, 0x03, 0x80, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, - 0x03, 0xe0, 0x07, 0xc0, 0x03, 0xf0, 0x0f, 0xc0, 0x03, 0xf0, 0x1f, 0xc0, - 0x03, 0xfb, 0xdf, 0xc0, 0x03, 0xff, 0xff, 0xc0, 0x03, 0xff, 0xff, 0xc0, - 0x03, 0xff, 0xff, 0xc0, 0x03, 0xff, 0xff, 0xc0, 0x03, 0xff, 0xff, 0xc0, - 0x01, 0xff, 0xff, 0x80, 0x01, 0xff, 0xff, 0x80, 0x33, 0xff, 0xff, 0xcc, - 0x7b, 0xff, 0xff, 0xde, 0x7f, 0xcf, 0xf3, 0xfe, 0x7f, 0xcf, 0xf3, 0xfe, - 0x7f, 0xc7, 0xe3, 0xfe, 0x3f, 0xe7, 0xe7, 0xfc, 0x73, 0xf3, 0xcf, 0xce, - 0x7f, 0xfb, 0xdf, 0xfe, 0x7f, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xfe, - 0x71, 0xff, 0xff, 0x8e, 0x23, 0xff, 0xff, 0xc4, 0x3f, 0xff, 0xff, 0xfc, - 0x7f, 0xff, 0xff, 0xfe, 0x7e, 0x7f, 0xfe, 0x7e, 0x78, 0x3f, 0xfc, 0x1e, - 0x30, 0x0f, 0xf0, 0x0c, 0x30, 0x03, 0xc0, 0x0c}; +// 'ec-face-logo', 48x30px +const unsigned char epd_bitmap_electroniccats[] = { + 0x00, 0x30, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x3e, 0x00, + 0x00, 0x7e, 0x00, 0x00, 0x7e, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, + 0x00, 0xff, 0x80, 0x01, 0xff, 0x00, 0x00, 0xff, 0xc7, 0xe3, 0xff, 0x00, + 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0x00, + 0x00, 0x7f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfe, 0x00, + 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, + 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x30, 0x7f, 0xff, 0xff, 0xfc, 0x0c, + 0x78, 0x7c, 0x3f, 0xfc, 0x3e, 0x1e, 0x4c, 0xfc, 0x1f, 0xf8, 0x3e, 0x32, + 0x7f, 0xfc, 0x0f, 0xf0, 0x3f, 0xfe, 0x30, 0xfe, 0x0f, 0xf0, 0x7e, 0x0c, + 0x60, 0xfe, 0x07, 0xe0, 0x7e, 0x06, 0xf0, 0xff, 0x87, 0xe1, 0xfe, 0x0f, + 0x9f, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xf0, 0x3f, 0xff, 0xff, 0xfe, 0x0f, + 0x60, 0x1f, 0xff, 0xff, 0xfc, 0x06, 0x00, 0x1f, 0xff, 0xff, 0xf8, 0x00, + 0x30, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x7f, 0x83, 0xff, 0xff, 0xc1, 0xfe, + 0x4c, 0x00, 0xff, 0xff, 0x00, 0x32, 0x78, 0x00, 0x3f, 0xfc, 0x00, 0x1e, + 0x30, 0x00, 0x07, 0xe0, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // 'arrow_left', 16x16px static const unsigned char epd_bitmap_arrow_left[] = { @@ -158,8 +162,8 @@ const epd_bitmap_t minino_pwnlabs_logo = { const epd_bitmap_t minino_electroniccats_logo = { .bitmap = epd_bitmap_electroniccats, - .width = 32, - .height = 32, + .width = 48, + .height = 30, }; typedef enum { diff --git a/firmware/resources/ec-face-logo.png b/firmware/resources/ec-face-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..a4a237e0a8b5add1cb22c4d775292dd617b8c040 GIT binary patch literal 889 zcmV-<1BU#GP)EX>4Tx04R}tkv&MmKpe$iTg4Bm4pu1QkfFM07Zq`=RVYG*P%E_RU~=gfG-*gu zTpR`0f`cE6RR_Vdh;kxtDMhlqtj8_R9XiiS!&O&n2Fjq?2& zmle)ioYiubHSft^7|dxa%Uq{9f&><^1Q7ycR8c}17NWFjq?kz2e%!-9?D$1;$>b`5 zkz)ZBsE`~#_#gc4*33^$x=Fz}(D`E9AEQ9mF3_mi_V=-EH%@@SGjOG~{FOQ|`$>AO zrA3Z_fomKj!Ztv~iGtK^f0J9i!z+`CifB*mh24YJ`L;x88`T+Upf$}l{000SaNLh0L z04^f{04^f|c%?sf00007bV*G`2j~eH4m2aZt%1P+000?uMObu0Z*6U5Zgc=ca%Ew3 zWn>_CX>@2HM@dakSAh-}0003{NklvUE@>j6IgDh&En=CN;1VQa z literal 0 HcmV?d00001 diff --git a/firmware/resources/ec-face-logo.xcf b/firmware/resources/ec-face-logo.xcf new file mode 100644 index 0000000000000000000000000000000000000000..6d148f7c76ab250578e65159f482b5a870adeb43 GIT binary patch literal 3277 zcmds(-)|K~6vxm0x<7hvg;FG0q4X-6&@#AVB0%$_wM*TbN9AO;$Pr2XXng0 zXJ*cv`SkAg^!9Bp?CjcHcyVoeJE5(GtYii4ZAcTuFz{%GWY)i>CRv~_h1d`avMkn3 z^!G#VLK=Ip^qQ`LzP@7rFvi4-ELlHT>>Mt37hdWe-coq#>1Q{vXR!|L?d$9*uIU-< z?PeQCA6Y##JhH7=7#i5t+uhc%dUH?Lz_x+G!fM^E8SL5ASy-$8+S}mX^dIi_g8pOo z&Y|s{UA_H1h4!@=jodSe2Wxip_YN0&`@6Ojhj_-o=FLOJ;ew7&=r#4;V9q(wjKSI< zw>x31t6b<72%oWWL+20|*(mAguWu7 zHzf2zLeC}id_r$b=!>B9e)X1y!h7@jkHk7UdYE;EhJIB-Pci~?y_vh}8v1%McwIE} zy;`rIbsyW0*6nH{B@8lLlbVFMMdZ3MZ^4E#;s6Rl}=hGDktTPL79Xvi=7>}N;@dKV2xU1 zopV^Zpc^fTETT7PMRItOmh<+tZPS>@!#`6>l)TAB1}!mFWY{ceH~e)1C(8` zMy;`~d0fzgmP8KGXS5dX@x_ z*o=9UVIclM#X%laWY)$G8CViL##Uq;1Bq3pO*K2pX9%W(K$;uU%kQDPs zp3jI1b*LL>tuvLga@MCz!k5L)j;PXJ$}U)=)>zk2F6e$sB8zB0tw;{f&~n~B0VReL zH7Gaw{zhDDM=b@Gk%8< z<0bEg5WC^SHAHk&Lx~lT{Ur9QL3u%lmpw}WN^HhZiqJ1##bSUGDl%(hhwv={C}S%! zj-kXVf8$qDpWeUe`vSkjSB?Qno^)&sP~P$VG4IN2LcB5pC}B2yLxj5+N-WY0NsF={ z*Fi(+14^6$6_e)@MX*HV&)^ozfD&%CQA62*#4!D1T|^Bf`;IY`DC?nhX}ph@;6tH_ z(rOW8F{F_ipl4Jb@7u+YobH=Z!v>67wKUO6%wcK4{1(J2$3|~cWIGma!=!>T_zMKk zGPou+@|#}k3c8I&BhqGtuLBE13ue3}5RyTkK}ZI=p=~Gw`kL4}W(k%~VSbZR&SOd~ zgEaFCn{xmRW(HbLN3K$#jmtIZQ5B_d29uWR_3>q*vY78sh&NisQdN97+p2-`IF5y_ z(URZZxhFfjw)PAT?C9@i*Z=8ju>OV1=R(WxsrC9u24^_HXO Date: Tue, 24 Sep 2024 10:48:06 -0600 Subject: [PATCH 25/31] fix: pwnlabs logo bitmap --- firmware/main/general/bitmaps_general.h | 36 ++++++++---------------- firmware/resources/PWNlab-logo.png | Bin 0 -> 817 bytes firmware/resources/PWNlab-logo.xcf | Bin 0 -> 2817 bytes 3 files changed, 11 insertions(+), 25 deletions(-) create mode 100644 firmware/resources/PWNlab-logo.png create mode 100644 firmware/resources/PWNlab-logo.xcf diff --git a/firmware/main/general/bitmaps_general.h b/firmware/main/general/bitmaps_general.h index 12870d7..2289a81 100644 --- a/firmware/main/general/bitmaps_general.h +++ b/firmware/main/general/bitmaps_general.h @@ -52,30 +52,16 @@ static const unsigned char epd_bitmap_face_logo[] = { 0x00, 0xff, 0xff, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -// 'pwn-02', 64x32px -static const unsigned char epd_bitmap_pwn_02[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf3, 0x9c, 0xf7, - 0xdf, 0x80, 0x0c, 0x00, 0x07, 0xff, 0xde, 0xff, 0xff, 0xc0, 0x0c, 0x00, - 0x07, 0xff, 0xfe, 0xff, 0xff, 0xc0, 0x0c, 0x00, 0x07, 0xff, 0xfe, 0xff, - 0xff, 0xc3, 0xcf, 0x80, 0x07, 0xff, 0xfe, 0xff, 0xff, 0xc7, 0xef, 0xc0, - 0x07, 0xff, 0xfe, 0xff, 0xff, 0xcf, 0xff, 0xe0, 0x07, 0xff, 0xfe, 0xff, - 0xff, 0xcf, 0xfe, 0xe0, 0x07, 0xff, 0xfe, 0xff, 0xff, 0xce, 0x7c, 0xe0, - 0x07, 0xf3, 0xff, 0xff, 0xff, 0xce, 0x7c, 0xe0, 0x07, 0xe3, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xe0, 0x07, 0x83, 0xff, 0xef, 0xff, 0xff, 0xff, 0xe0, - 0x07, 0x00, 0xff, 0xce, 0x7c, 0xfb, 0xf7, 0xc0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00}; +// 'PWNlab-logo', 64x11px +const unsigned char epd_bitmap_pwn_02[] = { + 0xfe, 0x08, 0x20, 0x83, 0x04, 0x40, 0x00, 0x80, 0xff, 0x1c, 0x71, + 0xc7, 0x8e, 0x40, 0x00, 0x80, 0xeb, 0x9c, 0x71, 0xcf, 0xee, 0x40, + 0x00, 0x80, 0xc1, 0xdc, 0x71, 0xce, 0xee, 0x40, 0x78, 0xbc, 0xeb, + 0xdc, 0x71, 0xce, 0xee, 0x40, 0xcc, 0xe6, 0xc1, 0x9c, 0x71, 0xce, + 0xee, 0x41, 0x86, 0xc3, 0xeb, 0x1c, 0x71, 0xce, 0xee, 0x41, 0x02, + 0x81, 0xfe, 0x1e, 0xfb, 0xce, 0xee, 0x41, 0x02, 0x81, 0xf0, 0x1f, + 0xff, 0xce, 0xfe, 0x41, 0x86, 0xc3, 0xf0, 0x0f, 0xff, 0x8e, 0x7c, + 0x20, 0xce, 0x66, 0x60, 0x07, 0xcf, 0x04, 0x18, 0x1e, 0x7a, 0x3c}; // 'ec-face-logo', 48x30px const unsigned char epd_bitmap_electroniccats[] = { @@ -157,7 +143,7 @@ const epd_bitmap_t minino_face_logo = { const epd_bitmap_t minino_pwnlabs_logo = { .bitmap = epd_bitmap_pwn_02, .width = 64, - .height = 32, + .height = 11, }; const epd_bitmap_t minino_electroniccats_logo = { diff --git a/firmware/resources/PWNlab-logo.png b/firmware/resources/PWNlab-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..381c019350cdfccc4139146ad1d66acbe64dd66b GIT binary patch literal 817 zcmV-11J3-3P)EX>4Tx04R}tkv&MmKpe$iTcs+M4t6NwkfA!+MMWKJ6^c+H)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfc5qU3krMxx6k5c1aNLh~_a1le0DrT}RI?`msG4PD zQb{3~UloF{=tmS`05cLZ^*K>Y!*hJy!^hXVIM4Dv_vaW?3MK=50&#-rhDE$VJiTe@ zocD<%tSl+S=fvX%U6A;Z>$1yloJ$V-d1l1OX6A__#6qcyER!C{35wza#g^{ zv49#>NRA);4}N!R7AGg%q)-y*eX;G2Q6RVrv>LYkeQevU6Cm&mTxlJDtqIJ2lHTZO zu_GY74P0DzG6rkxZ7J>IO`ldWEbPEiuxxKabaryvcsjKu2aBv8W zl_-1Np-p)TFDuk5qP4@LrqIY2-<%CHWpTlZyFDVH8EZU!BNY ziYGt4HbYQUSz#E(F@VeH8f1UJk-l=Q$T39*tTlM)#)9)t%#VmHd7igAkXRChaVJ5u(PeXDNWKKG|?9kqHqIlstX4MzFPlWx~A zddR*M#?Q#RNRlwUkKB9uQ}{=Meuy-X6nRwYmh}VV4RSCh^zmSJeme>^-M&nKs{3H|HQVtIKs%onq>$?22!(P%uFoz3R? zQCyDa<7fT+B>uWjc>L^^$K5>s^!U}{qCc2S$9eaJ-Q~uv+#J7{PL}y(I(R-@$YVAd zEr!cH;%j=LZh}>FZ6xzzbN~06u~K^|>aosv`0czuU5sY)^Zs%&o92Vr#U*B=R%)~m zwK*UkO8@*vX08H}T`}&LI*a+Jra!Lf?V6s~bk(6a8Xct44{G{5=*m}(Jrv;-|I<=u zF`q~e4AzfpdYvkmt6^VP8fy=!)nb3S(KDqyz}TG6U=crY5@;0cERjg->EynSATmgfuo<>v82NO9~$;R7OS_w`<$VnBtkrA!Mu#vS+w%H(;kw8{PsmHhAHs1hc0T z2PzMtfv9CW$*#ca%H@=zGyrLRP=a+)G*?x<5inCVB6KrrvF*gl65LX5tva9%TnS}V zVX?hcD#4oZ2Gv|BP&BvY3r_gR32(%Sa`te-!wDZb;SHQ%Ykj=Ca)uKGfD_CB;RHB# zD}u^rQjuy0mLs96thu{80&Hi;^%oDTyP%91=P!^y%MthR?% z!HP(xU0^I_G=#Gu!5;C}n!L2={nrXD^I6z42k4KHCMRU{km`GF|BL?MyYYPXVtT4a n|EEs}s{`GP_MbQUx&`_YWwie));RZ=%l5RdD*F%i4^zp1=*2G- literal 0 HcmV?d00001 From 195c8554f53f885e7d814603d62e472d26ddae8b Mon Sep 17 00:00:00 2001 From: deimos Date: Thu, 26 Sep 2024 11:09:58 -0600 Subject: [PATCH 26/31] feat: add menu to format sd card --- firmware/components/sd_card/include/sd_card.h | 17 ++++- firmware/components/sd_card/sd_card.c | 75 ++++++++++++++++++- .../gps/wardriving/wardriving_module.c | 2 +- .../menus_module/menus_include/menus.h | 8 ++ .../display}/screen_saver/screen_saver.c | 0 .../display}/screen_saver/screen_saver.h | 0 .../sd_card/sd_card_settings_module.c | 69 ++++++++++++----- .../sd_card/sd_card_settings_screens_module.c | 15 +++- .../sd_card/sd_card_settings_screens_module.h | 2 + 9 files changed, 163 insertions(+), 25 deletions(-) rename firmware/main/modules/{ => settings/display}/screen_saver/screen_saver.c (100%) rename firmware/main/modules/{ => settings/display}/screen_saver/screen_saver.h (100%) diff --git a/firmware/components/sd_card/include/sd_card.h b/firmware/components/sd_card/include/sd_card.h index f8e5e05..a28a993 100644 --- a/firmware/components/sd_card/include/sd_card.h +++ b/firmware/components/sd_card/include/sd_card.h @@ -51,13 +51,24 @@ esp_err_t sd_card_mount(); esp_err_t sd_card_unmount(); /** - * Format the SD card if mount failed. + * Mount the SD card. * * @return esp_err_t * - * @note return ESP_ERR_NOT_MOUNTED if the SD card is not mounted. + * @note return ESP_ERR_NOT_FOUND if the SD card is not found. + * @note return ESP_ERR_NO_MEM if failed to initialize the spi bus. + * @note return ESP_ERR_NOT_SUPPORTED if the SD card is not formatted with FAT. + * @note return ESP_ERR_INVALID_ARG if the arguments are invalid. * @note return ESP_FAIL if the operation failed. - * @note return ESP_OK if the operation was successful. + * @note return ESP_OK if the operation was successful or the card is already + * mounted. + */ +esp_err_t sd_card_check_format(); + +/** + * Format the SD card. + * + * @return esp_err_t */ esp_err_t sd_card_format(); diff --git a/firmware/components/sd_card/sd_card.c b/firmware/components/sd_card/sd_card.c index 0a67b01..1a4ecf8 100644 --- a/firmware/components/sd_card/sd_card.c +++ b/firmware/components/sd_card/sd_card.c @@ -136,7 +136,7 @@ int mount(int argc, char** argv) { } } /* print card info if mount successfully */ - sdmmc_card_print_info(stdout, card); + // sdmmc_card_print_info(stdout, card); sd_card_fill_info(card); } return ESP_OK; @@ -224,7 +224,7 @@ esp_err_t sd_card_unmount() { return err; } -esp_err_t sd_card_format() { +esp_err_t sd_card_check_format() { ESP_LOGI(TAG, "Formatting SD Card..."); _format_if_mount_failed = true; esp_err_t err = sd_card_mount(); @@ -232,6 +232,77 @@ esp_err_t sd_card_format() { return err; } +esp_err_t sd_card_format() { + sd_card_unmount(); + esp_err_t ret; + /* mount sd card */ + ESP_LOGI(TAG, "Initializing SD card, format: %s", + _format_if_mount_failed ? "true" : "false"); + esp_vfs_fat_sdmmc_mount_config_t mount_config = { + .format_if_mount_failed = true, + .max_files = 4, + .allocation_unit_size = 16 * 1024}; + + // initialize SD card and mount FAT filesystem. + sdmmc_card_t* card; + + ESP_LOGI(TAG, "Using SPI peripheral"); + sdmmc_host_t host = SDSPI_HOST_DEFAULT(); + spi_bus_config_t bus_cfg = { + .mosi_io_num = PIN_NUM_MOSI, + .miso_io_num = PIN_NUM_MISO, + .sclk_io_num = PIN_NUM_CLK, + .quadwp_io_num = -1, + .quadhd_io_num = -1, + .max_transfer_sz = 4000, + }; + ret = spi_bus_initialize(host.slot, &bus_cfg, SPI_DMA_CH_AUTO); + if (ret != ESP_OK) { + ESP_LOGE(TAG, "Failed to initialize bus."); + return ESP_ERR_NO_MEM; + } + + // This initializes the slot without card detect (CD) and write protect (WP) + // signals. Modify slot_config.gpio_cd and slot_config.gpio_wp if your board + // has these signals. + sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT(); + slot_config.gpio_cs = PIN_NUM_CS; + slot_config.host_id = host.slot; + + ret = esp_vfs_fat_sdspi_mount(MOUNT_POINT, &host, &slot_config, &mount_config, + &card); + + if (ret != ESP_OK) { + if (ret == ESP_FAIL) { + ESP_LOGE(TAG, + "Failed to mount filesystem. " + "If you want the card to be formatted, set " + "format_if_mount_failed = true."); + spi_bus_free(host.slot); + return ESP_ERR_NOT_SUPPORTED; + } else { + ESP_LOGE(TAG, + "Failed to initialize the card (%s). " + "Make sure SD card lines have pull-up resistors in place.", + esp_err_to_name(ret)); + // Free the bus after mounting failed + spi_bus_free(host.slot); + return ESP_ERR_NOT_MOUNTED; + } + } + /* print card info if mount successfully */ + // sdmmc_card_print_info(stdout, card); + sd_card_fill_info(card); + ret = esp_vfs_fat_sdcard_format(MOUNT_POINT, card); + if (ret != ESP_OK) { + ESP_LOGE(TAG, "Failed to format SD card"); + return ESP_FAIL; + } + + return ESP_OK; + // return err; +} + bool sd_card_is_mounted() { return _sd_card_mounted; } diff --git a/firmware/main/modules/gps/wardriving/wardriving_module.c b/firmware/main/modules/gps/wardriving/wardriving_module.c index a7807e2..e460552 100644 --- a/firmware/main/modules/gps/wardriving/wardriving_module.c +++ b/firmware/main/modules/gps/wardriving/wardriving_module.c @@ -395,7 +395,7 @@ void wardriving_module_keyboard_cb(uint8_t button_name, uint8_t button_event) { } else if (wardriving_module_state == WARDRIVING_MODULE_STATE_INVALID_SD_CARD) { wardriving_screens_module_formating_sd_card(); - esp_err_t err = sd_card_format(); + esp_err_t err = sd_card_check_format(); if (err == ESP_OK) { ESP_LOGI(TAG, "Format done"); wardriving_module_start_scan(); diff --git a/firmware/main/modules/menus_module/menus_include/menus.h b/firmware/main/modules/menus_module/menus_include/menus.h index 95d551f..85c8ca3 100644 --- a/firmware/main/modules/menus_module/menus_include/menus.h +++ b/firmware/main/modules/menus_module/menus_include/menus.h @@ -90,6 +90,7 @@ typedef enum { MENU_SETTINGS_WIFI, MENU_SETTINGS_SD_CARD, MENU_SETTINGS_SD_CARD_INFO, + MENU_SETTINGS_SD_CARD_CHECK_FORMAT, MENU_SETTINGS_SD_CARD_FORMAT, MENU_STEALTH_MODE, /* Menu count */ @@ -467,6 +468,13 @@ menu_t menus[] = { ////////////////////////////////// .on_exit_cb = NULL, .is_visible = true}, {.display_name = "Check Format", + .menu_idx = MENU_SETTINGS_SD_CARD_CHECK_FORMAT, + .parent_idx = MENU_SETTINGS_SD_CARD, + .last_selected_submenu = 0, + .on_enter_cb = sd_card_settings_verify_sd_card, + .on_exit_cb = NULL, + .is_visible = true}, + {.display_name = "Format", .menu_idx = MENU_SETTINGS_SD_CARD_FORMAT, .parent_idx = MENU_SETTINGS_SD_CARD, .last_selected_submenu = 0, diff --git a/firmware/main/modules/screen_saver/screen_saver.c b/firmware/main/modules/settings/display/screen_saver/screen_saver.c similarity index 100% rename from firmware/main/modules/screen_saver/screen_saver.c rename to firmware/main/modules/settings/display/screen_saver/screen_saver.c diff --git a/firmware/main/modules/screen_saver/screen_saver.h b/firmware/main/modules/settings/display/screen_saver/screen_saver.h similarity index 100% rename from firmware/main/modules/screen_saver/screen_saver.h rename to firmware/main/modules/settings/display/screen_saver/screen_saver.h diff --git a/firmware/main/modules/settings/sd_card/sd_card_settings_module.c b/firmware/main/modules/settings/sd_card/sd_card_settings_module.c index 56f8216..d4bd9b6 100644 --- a/firmware/main/modules/settings/sd_card/sd_card_settings_module.c +++ b/firmware/main/modules/settings/sd_card/sd_card_settings_module.c @@ -10,7 +10,8 @@ const char* TAG = "sd_card_settings_module"; typedef enum { SD_CARD_SETTINGS_VERIFYING = 0, - SD_CARD_SETTINGS_OK, + SD_CARD_SETTINGS_MOUNT_OK, + SD_CARD_SETTINGS_WRONG_FORMAT, SD_CARD_SETTINGS_FORMAT_QUESTION, SD_CARD_SETTINGS_FORMATTING, SD_CARD_SETTINGS_FORMAT_DONE, @@ -19,9 +20,8 @@ typedef enum { } sd_card_settings_state_t; const char* sd_card_state_to_name[] = { - "Verifying", "OK", "Format question", - "Formatting", "Format done", "Failed format", - "No SD card", + "Verifying", "Mount OK", "Wrong format", "Format question", + "Formatting", "Format done", "Failed format", "No SD card", }; sd_card_settings_state_t state = SD_CARD_SETTINGS_VERIFYING; @@ -30,17 +30,30 @@ void sd_card_settings_verify_sd_card() { menus_module_set_app_state(true, sd_card_settings_keyboard_cb); ESP_LOGI(TAG, "Verifying SD card..."); state = SD_CARD_SETTINGS_VERIFYING; + bool format = false; + if (menus_module_get_current_menu() == MENU_SETTINGS_SD_CARD_FORMAT) { + format = true; + } esp_err_t err = sd_card_mount(); - if (err == ESP_ERR_NOT_SUPPORTED) { - state = SD_CARD_SETTINGS_FORMAT_QUESTION; - sd_card_settings_screens_module_format_question(); - } else if (err == ESP_OK) { - state = SD_CARD_SETTINGS_OK; - sd_card_settings_screens_module_sd_card_ok(); - } else if (err != ESP_OK) { - state = SD_CARD_SETTINGS_NO_SD_CARD; - sd_card_settings_screens_module_no_sd_card(); + switch (err) { + case ESP_ERR_NOT_SUPPORTED: + state = SD_CARD_SETTINGS_WRONG_FORMAT; + sd_card_settings_screens_module_wrong_format(); + break; + case ESP_OK: + if (format) { + state = SD_CARD_SETTINGS_FORMAT_QUESTION; + sd_card_settings_screens_module_format_question(); + } else { + state = SD_CARD_SETTINGS_MOUNT_OK; + sd_card_settings_screens_module_sd_card_ok(); + } + break; + default: + state = SD_CARD_SETTINGS_NO_SD_CARD; + sd_card_settings_screens_module_no_sd_card(); + break; } sd_card_unmount(); } @@ -56,10 +69,11 @@ void sd_card_settings_keyboard_cb(uint8_t button_name, uint8_t button_event) { break; case BUTTON_RIGHT: ESP_LOGI(TAG, "State: %s", sd_card_state_to_name[state]); + esp_err_t err; switch (state) { - case SD_CARD_SETTINGS_FORMAT_QUESTION: + case SD_CARD_SETTINGS_WRONG_FORMAT: sd_card_settings_screens_module_formating_sd_card(); - esp_err_t err = sd_card_format(); + err = sd_card_check_format(); if (err == ESP_OK) { ESP_LOGI(TAG, "Format done"); state = SD_CARD_SETTINGS_FORMAT_DONE; @@ -69,9 +83,30 @@ void sd_card_settings_keyboard_cb(uint8_t button_name, uint8_t button_event) { sd_card_settings_screens_module_failed_format_sd_card(); } break; - case SD_CARD_SETTINGS_OK: - menus_module_exit_app(); + case SD_CARD_SETTINGS_FORMAT_QUESTION: + sd_card_settings_screens_module_formating_sd_card(); + err = sd_card_check_format(); + if (err == ESP_OK) { + ESP_LOGI(TAG, "Mount ok, formatting..."); + state = SD_CARD_SETTINGS_FORMATTING; + esp_err_t err_format = sd_card_format(); + if (err_format == ESP_OK) { + state = SD_CARD_SETTINGS_FORMAT_DONE; + sd_card_settings_screens_module_format_done(); + } else { + state = SD_CARD_SETTINGS_FAILED_FORMAT; + sd_card_settings_screens_module_failed_format_sd_card(); + } + } else { + state = SD_CARD_SETTINGS_FAILED_FORMAT; + sd_card_settings_screens_module_failed_format_sd_card(); + } + break; + case SD_CARD_SETTINGS_FORMATTING: + // TODO: implement on LEFT button + ESP_LOGI(TAG, "Formatting..."); break; + case SD_CARD_SETTINGS_MOUNT_OK: default: menus_module_exit_app(); break; diff --git a/firmware/main/modules/settings/sd_card/sd_card_settings_screens_module.c b/firmware/main/modules/settings/sd_card/sd_card_settings_screens_module.c index ac45482..a6f9941 100644 --- a/firmware/main/modules/settings/sd_card/sd_card_settings_screens_module.c +++ b/firmware/main/modules/settings/sd_card/sd_card_settings_screens_module.c @@ -24,7 +24,7 @@ void sd_card_settings_screens_module_sd_card_ok() { oled_screen_display_text_center("Ok", screen_64 ? 5 : 3, OLED_DISPLAY_INVERT); } -void sd_card_settings_screens_module_format_question() { +void sd_card_settings_screens_module_wrong_format() { oled_screen_clear(); oled_screen_display_text_center("SD Card is not", screen_64 ? 1 : 0, OLED_DISPLAY_NORMAL); @@ -35,6 +35,17 @@ void sd_card_settings_screens_module_format_question() { oled_screen_display_text_center("Ok", screen_64 ? 5 : 3, OLED_DISPLAY_INVERT); } +void sd_card_settings_screens_module_format_question() { + oled_screen_clear(); + oled_screen_display_text_center("SD Card data", screen_64 ? 1 : 0, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("will be lost!", screen_64 ? 2 : 1, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("Format?", screen_64 ? 3 : 2, + OLED_DISPLAY_NORMAL); + oled_screen_display_text_center("Ok", screen_64 ? 5 : 3, OLED_DISPLAY_INVERT); +} + void sd_card_settings_screens_module_formating_sd_card() { oled_screen_clear(); oled_screen_display_text_center("Formating SD", screen_64 ? 2 : 0, @@ -58,5 +69,5 @@ void sd_card_settings_screens_module_format_done() { oled_screen_clear(); oled_screen_display_text_center("Format done!", screen_64 ? 3 : 1, OLED_DISPLAY_NORMAL); - oled_screen_display_text_center("Ok", screen_64 ? 3 : 0, OLED_DISPLAY_INVERT); + oled_screen_display_text_center("Ok", screen_64 ? 5 : 3, OLED_DISPLAY_INVERT); } diff --git a/firmware/main/modules/settings/sd_card/sd_card_settings_screens_module.h b/firmware/main/modules/settings/sd_card/sd_card_settings_screens_module.h index a945cae..56a36fb 100644 --- a/firmware/main/modules/settings/sd_card/sd_card_settings_screens_module.h +++ b/firmware/main/modules/settings/sd_card/sd_card_settings_screens_module.h @@ -4,6 +4,8 @@ void sd_card_settings_screens_module_no_sd_card(); void sd_card_settings_screens_module_sd_card_ok(); +void sd_card_settings_screens_module_wrong_format(); + void sd_card_settings_screens_module_format_question(); void sd_card_settings_screens_module_formating_sd_card(); From a942c01f6e689e7d273da586c313ae6dc80d29eb Mon Sep 17 00:00:00 2001 From: deimos Date: Fri, 27 Sep 2024 08:53:06 -0600 Subject: [PATCH 27/31] refactor: mount sd card system --- firmware/components/sd_card/include/sd_card.h | 20 +- firmware/components/sd_card/sd_card.c | 270 ++++++------------ 2 files changed, 101 insertions(+), 189 deletions(-) diff --git a/firmware/components/sd_card/include/sd_card.h b/firmware/components/sd_card/include/sd_card.h index a28a993..970ce54 100644 --- a/firmware/components/sd_card/include/sd_card.h +++ b/firmware/components/sd_card/include/sd_card.h @@ -4,8 +4,6 @@ #include #include "esp_err.h" -#define ESP_ERR_ALREADY_MOUNTED ESP_ERR_NOT_ALLOWED -#define ESP_ERR_NOT_MOUNTED ESP_ERR_NOT_FOUND #define ESP_ERR_FILE_EXISTS ESP_ERR_NOT_ALLOWED #define ESP_ERR_FILE_OPEN_FAILED ESP_FAIL #define ESP_ERR_FILE_WRITE_FAILED ESP_FAIL @@ -29,10 +27,9 @@ void sd_card_begin(); * * @return esp_err_t * - * @note return ESP_ERR_NOT_FOUND if the SD card is not found. * @note return ESP_ERR_NO_MEM if failed to initialize the spi bus. * @note return ESP_ERR_NOT_SUPPORTED if the SD card is not formatted with FAT. - * @note return ESP_ERR_INVALID_ARG if the arguments are invalid. + * @note return ESP_ERR_NOT_FOUND if the SD card is not found. * @note return ESP_FAIL if the operation failed. * @note return ESP_OK if the operation was successful or the card is already * mounted. @@ -44,7 +41,7 @@ esp_err_t sd_card_mount(); * * @return esp_err_t * - * @note return ESP_ERR_NOT_MOUNTED if the SD card is not mounted. + * @note return ESP_ERR_NOT_FOUND if the SD card is not mounted. * @note return ESP_FAIL if the operation failed. * @note return ESP_OK if the operation was successful. */ @@ -54,8 +51,6 @@ esp_err_t sd_card_unmount(); * Mount the SD card. * * @return esp_err_t - * - * @note return ESP_ERR_NOT_FOUND if the SD card is not found. * @note return ESP_ERR_NO_MEM if failed to initialize the spi bus. * @note return ESP_ERR_NOT_SUPPORTED if the SD card is not formatted with FAT. * @note return ESP_ERR_INVALID_ARG if the arguments are invalid. @@ -79,6 +74,13 @@ esp_err_t sd_card_format(); */ bool sd_card_is_mounted(); +/** + * Check if the SD card is not mounted. + * + * return bool + */ +bool sd_card_is_not_mounted(); + /** * @brief Create a directory in the SD card. * @@ -86,7 +88,7 @@ bool sd_card_is_mounted(); * * @return esp_err_t * - * @note return ESP_ERR_NOT_MOUNTED if the SD card is not mounted. + * @note return ESP_ERR_NOT_FOUND if the SD card is not mounted. * @note return ESP_OK if the operation was successful or the directory already * exists. * @note return ESP_FAIL if the operation failed. @@ -100,7 +102,7 @@ esp_err_t sd_card_create_dir(const char* dir_name); * * @return esp_err_t * - * @note return ESP_ERR_NOT_MOUNTED if the SD card is not mounted. + * @note return ESP_ERR_NOT_FOUND if the SD card is not mounted. * @note return ESP_ERR_FILE_EXISTS if the file already exists. * @note return ESP_FAIL if the operation failed. * @note return ESP_OK if the operation was successful. diff --git a/firmware/components/sd_card/sd_card.c b/firmware/components/sd_card/sd_card.c index 1a4ecf8..7d92d72 100644 --- a/firmware/components/sd_card/sd_card.c +++ b/firmware/components/sd_card/sd_card.c @@ -2,7 +2,6 @@ #include #include -#include "argtable3/argtable3.h" #include "driver/sdmmc_host.h" #include "driver/sdspi_host.h" #include "driver/spi_common.h" @@ -40,7 +39,7 @@ const char* f_result_to_name[] = {"FR_OK", "FR_INVALID_PARAMETER"}; static const char* TAG = "sd_card"; -bool _sd_card_mounted = false; +sdmmc_card_t* card; bool _format_if_mount_failed = false; sd_card_info_t _sd_card_info; @@ -52,7 +51,7 @@ static struct { esp_err_t sd_card_fill_info(const sdmmc_card_t* card); void print_files_in_sd() { - if (!_sd_card_mounted) { + if (sd_card_is_not_mounted()) { ESP_LOGE(TAG, "SD card not mounted"); return; } @@ -71,141 +70,109 @@ void print_files_in_sd() { } /** 'mount' command */ -int mount(int argc, char** argv) { +int mount() { esp_err_t ret; + /* mount sd card */ + ESP_LOGI(TAG, "Initializing SD card, format: %s", + _format_if_mount_failed ? "true" : "false"); + esp_vfs_fat_sdmmc_mount_config_t mount_config = { + .format_if_mount_failed = _format_if_mount_failed, + .max_files = 4, + .allocation_unit_size = 16 * 1024}; - int nerrors = arg_parse(argc, argv, (void**) &mount_args); - if (nerrors != 0) { - arg_print_errors(stderr, mount_args.end, argv[0]); - return ESP_ERR_INVALID_ARG; + // initialize SD card and mount FAT filesystem. + ESP_LOGI(TAG, "Using SPI peripheral"); + sdmmc_host_t host = SDSPI_HOST_DEFAULT(); + spi_bus_config_t bus_cfg = { + .mosi_io_num = PIN_NUM_MOSI, + .miso_io_num = PIN_NUM_MISO, + .sclk_io_num = PIN_NUM_CLK, + .quadwp_io_num = -1, + .quadhd_io_num = -1, + .max_transfer_sz = 4000, + }; + ret = spi_bus_initialize(host.slot, &bus_cfg, SPI_DMA_CH_AUTO); + if (ret != ESP_OK) { + ESP_LOGE(TAG, "Failed to initialize bus."); + return ESP_ERR_NO_MEM; } - /* mount sd card */ - if (!strncmp(mount_args.device->sval[0], "sd", 2)) { - ESP_LOGI(TAG, "Initializing SD card, format: %s", - _format_if_mount_failed ? "true" : "false"); - esp_vfs_fat_sdmmc_mount_config_t mount_config = { - .format_if_mount_failed = _format_if_mount_failed, - .max_files = 4, - .allocation_unit_size = 16 * 1024}; - - // initialize SD card and mount FAT filesystem. - sdmmc_card_t* card; - - ESP_LOGI(TAG, "Using SPI peripheral"); - sdmmc_host_t host = SDSPI_HOST_DEFAULT(); - spi_bus_config_t bus_cfg = { - .mosi_io_num = PIN_NUM_MOSI, - .miso_io_num = PIN_NUM_MISO, - .sclk_io_num = PIN_NUM_CLK, - .quadwp_io_num = -1, - .quadhd_io_num = -1, - .max_transfer_sz = 4000, - }; - ret = spi_bus_initialize(host.slot, &bus_cfg, SPI_DMA_CH_AUTO); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to initialize bus."); - return ESP_ERR_NO_MEM; - } - // This initializes the slot without card detect (CD) and write protect (WP) - // signals. Modify slot_config.gpio_cd and slot_config.gpio_wp if your board - // has these signals. - sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT(); - slot_config.gpio_cs = PIN_NUM_CS; - slot_config.host_id = host.slot; - - ret = esp_vfs_fat_sdspi_mount(MOUNT_POINT, &host, &slot_config, - &mount_config, &card); - - if (ret != ESP_OK) { - if (ret == ESP_FAIL) { - ESP_LOGE(TAG, - "Failed to mount filesystem. " - "If you want the card to be formatted, set " - "format_if_mount_failed = true."); - spi_bus_free(host.slot); - return ESP_ERR_NOT_SUPPORTED; - } else { - ESP_LOGE(TAG, - "Failed to initialize the card (%s). " - "Make sure SD card lines have pull-up resistors in place.", - esp_err_to_name(ret)); - // Free the bus after mounting failed - spi_bus_free(host.slot); - return ESP_ERR_NOT_MOUNTED; - } + // This initializes the slot without card detect (CD) and write protect (WP) + // signals. Modify slot_config.gpio_cd and slot_config.gpio_wp if your board + // has these signals. + sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT(); + slot_config.gpio_cs = PIN_NUM_CS; + slot_config.host_id = host.slot; + + ret = esp_vfs_fat_sdspi_mount(MOUNT_POINT, &host, &slot_config, &mount_config, + &card); + + if (ret != ESP_OK) { + if (ret == ESP_FAIL) { + ESP_LOGE(TAG, + "Failed to mount filesystem. " + "If you want the card to be formatted, set " + "format_if_mount_failed = true."); + spi_bus_free(host.slot); + return ESP_ERR_NOT_SUPPORTED; + } else { + ESP_LOGE(TAG, + "Failed to initialize the card (%s). " + "Make sure SD card lines have pull-up resistors in place.", + esp_err_to_name(ret)); + // Free the bus after mounting failed + spi_bus_free(host.slot); + return ESP_ERR_NOT_FOUND; } - /* print card info if mount successfully */ - // sdmmc_card_print_info(stdout, card); - sd_card_fill_info(card); } + /* print card info if mount successfully */ + // sdmmc_card_print_info(stdout, card); + sd_card_fill_info(card); return ESP_OK; } -void register_mount(void) { - mount_args.device = - arg_str1(NULL, NULL, "", "choose a proper device to mount/unmount"); - mount_args.end = arg_end(1); -} - -esp_err_t unmount(int argc, char** argv) { +esp_err_t unmount() { esp_err_t ret; - if (!_sd_card_mounted) { + if (sd_card_is_not_mounted()) { ESP_LOGE(TAG, "SD card not mounted"); return ESP_ERR_NOT_ALLOWED; } sdmmc_host_t host = SDSPI_HOST_DEFAULT(); - int nerrors = arg_parse(argc, argv, (void**) &mount_args); - if (nerrors != 0) { - arg_print_errors(stderr, mount_args.end, argv[0]); - return ESP_ERR_INVALID_ARG; - } + /* unmount sd card */ - if (!strncmp(mount_args.device->sval[0], "sd", 2)) { - if (esp_vfs_fat_sdmmc_unmount() != ESP_OK) { - ESP_LOGE(TAG, "Card unmount failed"); - return ESP_FAIL; - } - ret = spi_bus_free(host.slot); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to deinitialize bus."); - return ESP_FAIL; - } + // TODO: use esp_vfs_fat_sdcard_unmount instead + if (esp_vfs_fat_sdmmc_unmount() != ESP_OK) { + ESP_LOGE(TAG, "Card unmount failed"); + return ESP_FAIL; + } + ret = spi_bus_free(host.slot); + if (ret != ESP_OK) { + ESP_LOGE(TAG, "Failed to deinitialize bus."); + return ESP_FAIL; } ESP_LOGI(TAG, "Card unmounted"); return ESP_OK; } -void register_unmount(void) { - mount_args.device = - arg_str1(NULL, NULL, "", "choose a proper device to mount/unmount"); - mount_args.end = arg_end(1); -} - void sd_card_begin() { #if !defined(CONFIG_SD_CARD_DEBUG) esp_log_level_set(TAG, ESP_LOG_NONE); #endif - register_mount(); - register_unmount(); } esp_err_t sd_card_mount() { + ESP_LOGI(TAG, "Mounting SD Card..."); esp_err_t err = ESP_OK; - if (_sd_card_mounted) { + if (sd_card_is_mounted()) { ESP_LOGW(TAG, "SD card already mounted"); return err; } - const char** mount_argv[] = {"mount", "sd"}; - uint8_t mount_argc = 2; - - err = mount(mount_argc, (char**) mount_argv); + err = mount(); if (err == ESP_OK) { - _sd_card_mounted = true; return err; } else { ESP_LOGE(TAG, "Failed to mount SD card"); @@ -214,18 +181,11 @@ esp_err_t sd_card_mount() { } esp_err_t sd_card_unmount() { - const char** unmount_argv2[] = {"unmount", "sd"}; - uint8_t unmount_argc2 = 2; - - esp_err_t err = unmount(unmount_argc2, (char**) unmount_argv2); - if (err == ESP_OK) { - _sd_card_mounted = false; - } - return err; + return unmount(); } esp_err_t sd_card_check_format() { - ESP_LOGI(TAG, "Formatting SD Card..."); + ESP_LOGI(TAG, "Checking SD Card format..."); _format_if_mount_failed = true; esp_err_t err = sd_card_mount(); _format_if_mount_failed = false; @@ -233,68 +193,19 @@ esp_err_t sd_card_check_format() { } esp_err_t sd_card_format() { - sd_card_unmount(); - esp_err_t ret; - /* mount sd card */ - ESP_LOGI(TAG, "Initializing SD card, format: %s", - _format_if_mount_failed ? "true" : "false"); - esp_vfs_fat_sdmmc_mount_config_t mount_config = { - .format_if_mount_failed = true, - .max_files = 4, - .allocation_unit_size = 16 * 1024}; - - // initialize SD card and mount FAT filesystem. - sdmmc_card_t* card; - - ESP_LOGI(TAG, "Using SPI peripheral"); - sdmmc_host_t host = SDSPI_HOST_DEFAULT(); - spi_bus_config_t bus_cfg = { - .mosi_io_num = PIN_NUM_MOSI, - .miso_io_num = PIN_NUM_MISO, - .sclk_io_num = PIN_NUM_CLK, - .quadwp_io_num = -1, - .quadhd_io_num = -1, - .max_transfer_sz = 4000, - }; - ret = spi_bus_initialize(host.slot, &bus_cfg, SPI_DMA_CH_AUTO); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to initialize bus."); - return ESP_ERR_NO_MEM; + esp_err_t err = ESP_OK; + if (sd_card_is_not_mounted()) { + err = sd_card_mount(); } - // This initializes the slot without card detect (CD) and write protect (WP) - // signals. Modify slot_config.gpio_cd and slot_config.gpio_wp if your board - // has these signals. - sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT(); - slot_config.gpio_cs = PIN_NUM_CS; - slot_config.host_id = host.slot; - - ret = esp_vfs_fat_sdspi_mount(MOUNT_POINT, &host, &slot_config, &mount_config, - &card); - - if (ret != ESP_OK) { - if (ret == ESP_FAIL) { - ESP_LOGE(TAG, - "Failed to mount filesystem. " - "If you want the card to be formatted, set " - "format_if_mount_failed = true."); - spi_bus_free(host.slot); - return ESP_ERR_NOT_SUPPORTED; - } else { - ESP_LOGE(TAG, - "Failed to initialize the card (%s). " - "Make sure SD card lines have pull-up resistors in place.", - esp_err_to_name(ret)); - // Free the bus after mounting failed - spi_bus_free(host.slot); - return ESP_ERR_NOT_MOUNTED; - } + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to mount SD card"); + return ESP_FAIL; } - /* print card info if mount successfully */ - // sdmmc_card_print_info(stdout, card); - sd_card_fill_info(card); - ret = esp_vfs_fat_sdcard_format(MOUNT_POINT, card); - if (ret != ESP_OK) { + + ESP_LOGI(TAG, "Formatting SD Card..."); + err = esp_vfs_fat_sdcard_format(MOUNT_POINT, card); + if (err != ESP_OK) { ESP_LOGE(TAG, "Failed to format SD card"); return ESP_FAIL; } @@ -304,15 +215,14 @@ esp_err_t sd_card_format() { } bool sd_card_is_mounted() { - return _sd_card_mounted; + return sd_card_create_dir(".minino") == ESP_OK; } -esp_err_t sd_card_create_dir(const char* dir_name) { - if (!_sd_card_mounted) { - ESP_LOGE(TAG, "SD card not mounted"); - return ESP_ERR_NOT_MOUNTED; - } +bool sd_card_is_not_mounted() { + return !sd_card_is_mounted(); +} +esp_err_t sd_card_create_dir(const char* dir_name) { FRESULT res = f_mkdir(dir_name); if (res == FR_OK) { ESP_LOGI(TAG, "Directory created"); @@ -328,7 +238,7 @@ esp_err_t sd_card_create_dir(const char* dir_name) { } esp_err_t sd_card_create_file(const char* path) { - if (!_sd_card_mounted) { + if (sd_card_is_not_mounted()) { ESP_LOGE(TAG, "SD card not mounted"); return ESP_FAIL; } @@ -357,7 +267,7 @@ esp_err_t sd_card_create_file(const char* path) { } esp_err_t sd_card_read_file(const char* path) { - if (!_sd_card_mounted) { + if (sd_card_is_not_mounted()) { ESP_LOGE(TAG, "SD card not mounted"); return ESP_FAIL; } @@ -389,7 +299,7 @@ esp_err_t sd_card_read_file(const char* path) { } esp_err_t sd_card_write_file(const char* path, char* data) { - if (!_sd_card_mounted) { + if (sd_card_is_not_mounted()) { ESP_LOGE(TAG, "SD card not mounted"); return ESP_FAIL; } @@ -446,7 +356,7 @@ esp_err_t sd_card_fill_info(const sdmmc_card_t* card) { } sd_card_info_t sd_card_get_info() { - if (!_sd_card_mounted) { + if (sd_card_is_not_mounted()) { ESP_LOGE(TAG, "SD card not mounted"); } From 04d2901fd6ee99046114e5f78a6ae630992f97ed Mon Sep 17 00:00:00 2001 From: deimos Date: Fri, 4 Oct 2024 12:43:18 -0600 Subject: [PATCH 28/31] refactor: use esp_vfs_fat_sdcard_unmount instead of esp_vfs_fat_sdmmc_unmount --- firmware/components/sd_card/sd_card.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/components/sd_card/sd_card.c b/firmware/components/sd_card/sd_card.c index 7d92d72..2c78696 100644 --- a/firmware/components/sd_card/sd_card.c +++ b/firmware/components/sd_card/sd_card.c @@ -143,7 +143,7 @@ esp_err_t unmount() { /* unmount sd card */ // TODO: use esp_vfs_fat_sdcard_unmount instead - if (esp_vfs_fat_sdmmc_unmount() != ESP_OK) { + if (esp_vfs_fat_sdcard_unmount(MOUNT_POINT, card) != ESP_OK) { ESP_LOGE(TAG, "Card unmount failed"); return ESP_FAIL; } From fdded88e1423662caa7e187c8e37cf14987031bc Mon Sep 17 00:00:00 2001 From: deimos Date: Fri, 4 Oct 2024 13:02:28 -0600 Subject: [PATCH 29/31] feat: move file manager to apps --- .../menus_module/menus_include/menus.h | 70 ++++++++++--------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/firmware/main/modules/menus_module/menus_include/menus.h b/firmware/main/modules/menus_module/menus_include/menus.h index 85c8ca3..6b51311 100644 --- a/firmware/main/modules/menus_module/menus_include/menus.h +++ b/firmware/main/modules/menus_module/menus_include/menus.h @@ -415,13 +415,33 @@ menu_t menus[] = { ////////////////////////////////// .on_enter_cb = gps_screens_show_help, .on_exit_cb = NULL, .is_visible = true}, - {.display_name = "Time zone", - .menu_idx = MENU_SETTINGS_TIME_ZONE, - .parent_idx = MENU_SETTINGS_SYSTEM, +#endif +#ifdef CONFIG_FILE_MANAGER_ENABLE + {.display_name = "File Manager", + .menu_idx = MENU_FILE_MANAGER, + .parent_idx = MENU_APPLICATIONS, .last_selected_submenu = 0, - .on_enter_cb = settings_module_time_zone, + .on_enter_cb = NULL, + .on_exit_cb = NULL, + .is_visible = true}, + #ifdef CONFIG_FILE_MANAGER_LOCAL + {.display_name = "Local", + .menu_idx = MENU_FILE_MANAGER_LOCAL, + .parent_idx = MENU_FILE_MANAGER, + .last_selected_submenu = 0, + .on_enter_cb = file_manager_module_init, .on_exit_cb = NULL, .is_visible = true}, + #endif + #ifdef CONFIG_FILE_MANAGER_WEB + {.display_name = "Web", + .menu_idx = MENU_FILE_MANAGER_WEB, + .parent_idx = MENU_FILE_MANAGER, + .last_selected_submenu = 0, + .on_enter_cb = web_file_browser_module_begin, + .on_exit_cb = NULL, + .is_visible = true}, + #endif #endif #ifdef CONFIG_OTA_ENABLE {.display_name = "Update", @@ -446,13 +466,15 @@ menu_t menus[] = { ////////////////////////////////// .on_enter_cb = NULL, .on_exit_cb = NULL, .is_visible = true}, - {.display_name = "WiFi", - .menu_idx = MENU_SETTINGS_WIFI, +#ifdef CONFIG_GPS_APPS_ENABLE + {.display_name = "Time zone", + .menu_idx = MENU_SETTINGS_TIME_ZONE, .parent_idx = MENU_SETTINGS_SYSTEM, .last_selected_submenu = 0, - .on_enter_cb = wifi_settings_begin, + .on_enter_cb = settings_module_time_zone, .on_exit_cb = NULL, .is_visible = true}, +#endif {.display_name = "SD card", .menu_idx = MENU_SETTINGS_SD_CARD, .parent_idx = MENU_SETTINGS_SYSTEM, @@ -460,6 +482,13 @@ menu_t menus[] = { ////////////////////////////////// .on_enter_cb = NULL, .on_exit_cb = NULL, .is_visible = true}, + {.display_name = "WiFi", + .menu_idx = MENU_SETTINGS_WIFI, + .parent_idx = MENU_SETTINGS_SYSTEM, + .last_selected_submenu = 0, + .on_enter_cb = wifi_settings_begin, + .on_exit_cb = NULL, + .is_visible = true}, {.display_name = "Info", .menu_idx = MENU_SETTINGS_SD_CARD_INFO, .parent_idx = MENU_SETTINGS_SD_CARD, @@ -481,33 +510,6 @@ menu_t menus[] = { ////////////////////////////////// .on_enter_cb = sd_card_settings_verify_sd_card, .on_exit_cb = NULL, .is_visible = true}, -#ifdef CONFIG_FILE_MANAGER_ENABLE - {.display_name = "File Manager", - .menu_idx = MENU_FILE_MANAGER, - .parent_idx = MENU_SETTINGS, - .last_selected_submenu = 0, - .on_enter_cb = NULL, - .on_exit_cb = NULL, - .is_visible = true}, - #ifdef CONFIG_FILE_MANAGER_LOCAL - {.display_name = "Local", - .menu_idx = MENU_FILE_MANAGER_LOCAL, - .parent_idx = MENU_FILE_MANAGER, - .last_selected_submenu = 0, - .on_enter_cb = file_manager_module_init, - .on_exit_cb = NULL, - .is_visible = true}, - #endif - #ifdef CONFIG_FILE_MANAGER_WEB - {.display_name = "Web", - .menu_idx = MENU_FILE_MANAGER_WEB, - .parent_idx = MENU_FILE_MANAGER, - .last_selected_submenu = 0, - .on_enter_cb = web_file_browser_module_begin, - .on_exit_cb = NULL, - .is_visible = true}, - #endif -#endif {.display_name = "Stealth Mode", .menu_idx = MENU_STEALTH_MODE, .parent_idx = MENU_SETTINGS, From cce6abd5f473d41951e95fe8f1a0a14cdd8b4a6f Mon Sep 17 00:00:00 2001 From: deimos Date: Fri, 4 Oct 2024 13:19:43 -0600 Subject: [PATCH 30/31] fix: sd card info panics when there's no sd card --- firmware/components/sd_card/sd_card.c | 4 -- .../main/modules/settings/settings_module.c | 41 ++++++++++++------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/firmware/components/sd_card/sd_card.c b/firmware/components/sd_card/sd_card.c index 2c78696..c2b9433 100644 --- a/firmware/components/sd_card/sd_card.c +++ b/firmware/components/sd_card/sd_card.c @@ -356,9 +356,5 @@ esp_err_t sd_card_fill_info(const sdmmc_card_t* card) { } sd_card_info_t sd_card_get_info() { - if (sd_card_is_not_mounted()) { - ESP_LOGE(TAG, "SD card not mounted"); - } - return _sd_card_info; } diff --git a/firmware/main/modules/settings/settings_module.c b/firmware/main/modules/settings/settings_module.c index d230fe8..fbf68fe 100644 --- a/firmware/main/modules/settings/settings_module.c +++ b/firmware/main/modules/settings/settings_module.c @@ -38,23 +38,34 @@ void update_sd_card_info() { oled_screen_clear(); modals_module_show_banner("Loading..."); vTaskDelay(1000 / portTICK_PERIOD_MS); // Wait for the SD card to be mounted - sd_card_info_t sd_info = sd_card_get_info(); - char* name_str = malloc(strlen(sd_info.name) + 1); - sprintf(name_str, "Name: %s", sd_info.name); - char* capacity_str = malloc(20); - sprintf(capacity_str, "Space: %.2fGB", ((float) sd_info.total_space) / 1024); - char* speed_str = malloc(25); - sprintf(speed_str, "Speed: %.2fMHz", sd_info.speed); - char* type_str = malloc(strlen(sd_info.type) + 1 + 6); - sprintf(type_str, "Type: %s", sd_info.type); + if (sd_card_is_not_mounted()) { + sd_card_info_2[0] = ""; + sd_card_info_2[1] = "No SD Card"; + sd_card_info_2[2] = ""; + sd_card_info_2[3] = ""; + sd_card_info_2[4] = ""; + sd_card_info_2[5] = ""; + } else { + sd_card_info_t sd_info = sd_card_get_info(); + char* name_str = malloc(strlen(sd_info.name) + 1); + sprintf(name_str, "Name: %s", sd_info.name); + char* capacity_str = malloc(20); + sprintf(capacity_str, "Space: %.2fGB", + ((float) sd_info.total_space) / 1024); + char* speed_str = malloc(25); + sprintf(speed_str, "Speed: %.2fMHz", sd_info.speed); + char* type_str = malloc(strlen(sd_info.type) + 1 + 6); + sprintf(type_str, "Type: %s", sd_info.type); + + sd_card_info_2[0] = ""; + sd_card_info_2[1] = "SD Card Info"; + sd_card_info_2[2] = name_str; + sd_card_info_2[3] = capacity_str; + sd_card_info_2[4] = speed_str; + sd_card_info_2[5] = type_str; + } - sd_card_info_2[0] = ""; - sd_card_info_2[1] = "SD Card Info"; - sd_card_info_2[2] = name_str; - sd_card_info_2[3] = capacity_str; - sd_card_info_2[4] = speed_str; - sd_card_info_2[5] = type_str; sd_card_unmount(); general_register_scrolling_menu(&SD_inf); general_screen_display_scrolling_text_handler(menus_module_exit_app); From 6796513d31b5863390fc86aa7d7df826ecb3ca5a Mon Sep 17 00:00:00 2001 From: deimos Date: Fri, 4 Oct 2024 13:25:08 -0600 Subject: [PATCH 31/31] fix: free memory on sd card info menu --- .../main/modules/settings/settings_module.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/firmware/main/modules/settings/settings_module.c b/firmware/main/modules/settings/settings_module.c index fbf68fe..cd8509c 100644 --- a/firmware/main/modules/settings/settings_module.c +++ b/firmware/main/modules/settings/settings_module.c @@ -58,12 +58,17 @@ void update_sd_card_info() { char* type_str = malloc(strlen(sd_info.type) + 1 + 6); sprintf(type_str, "Type: %s", sd_info.type); - sd_card_info_2[0] = ""; - sd_card_info_2[1] = "SD Card Info"; - sd_card_info_2[2] = name_str; - sd_card_info_2[3] = capacity_str; - sd_card_info_2[4] = speed_str; - sd_card_info_2[5] = type_str; + sd_card_info_2[0] = strdup(""); + sd_card_info_2[1] = strdup("SD Card Info"); + sd_card_info_2[2] = strdup(name_str); + sd_card_info_2[3] = strdup(capacity_str); + sd_card_info_2[4] = strdup(speed_str); + sd_card_info_2[5] = strdup(type_str); + + free(name_str); + free(capacity_str); + free(speed_str); + free(type_str); } sd_card_unmount();