diff --git a/firmware/components/buzzer/Kconfig.projbuild b/firmware/components/buzzer/Kconfig.projbuild new file mode 100644 index 00000000..572b663d --- /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 522e68fc..aaf7c669 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/cmd_wifi/cmd_wifi.c b/firmware/components/cmd_wifi/cmd_wifi.c index ab81c78b..6fa556ff 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/components/leds/Kconfig.projbuild b/firmware/components/leds/Kconfig.projbuild new file mode 100644 index 00000000..1d93aa47 --- /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 3123b280..d73b8ab4 100644 --- a/firmware/components/leds/leds.c +++ b/firmware/components/leds/leds.c @@ -14,6 +14,10 @@ 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 +27,10 @@ void leds_begin() { } void leds_deinit() { +#ifndef CONFIG_LEDS_COMPONENT_ENABLED + return; +#endif + if (!left_led || !right_led) { return; } @@ -35,32 +43,60 @@ 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 +106,26 @@ 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); } diff --git a/firmware/components/minino_config/Kconfig.projbuild b/firmware/components/minino_config/Kconfig.projbuild index 71524182..46ab71d6 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 diff --git a/firmware/components/sd_card/include/sd_card.h b/firmware/components/sd_card/include/sd_card.h index f8e5e057..970ce548 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,20 +41,29 @@ 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. */ 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_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(); @@ -68,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. * @@ -75,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. @@ -89,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 0a67b01f..c2b9433c 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; - - 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; - } /* 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; - } + 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. + 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_sdcard_unmount(MOUNT_POINT, card) != 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,34 +181,48 @@ 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_format() { - ESP_LOGI(TAG, "Formatting SD Card..."); +esp_err_t sd_card_check_format() { + ESP_LOGI(TAG, "Checking SD Card format..."); _format_if_mount_failed = true; esp_err_t err = sd_card_mount(); _format_if_mount_failed = false; return err; } +esp_err_t sd_card_format() { + esp_err_t err = ESP_OK; + if (sd_card_is_not_mounted()) { + err = sd_card_mount(); + } + + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to mount SD card"); + return ESP_FAIL; + } + + 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; + } + + return ESP_OK; + // return err; +} + 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"); @@ -257,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; } @@ -286,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; } @@ -318,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; } @@ -375,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_mounted) { - ESP_LOGE(TAG, "SD card not mounted"); - } - return _sd_card_info; } diff --git a/firmware/main/apps/ble/hid_device/hid_screens.c b/firmware/main/apps/ble/hid_device/hid_screens.c index 413f3aa8..a755307e 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/apps/thread_sniffer/thread_sniffer.c b/firmware/main/apps/thread_sniffer/thread_sniffer.c index 7033fa25..2ac77d60 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 f714c5cb..0e766c90 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: diff --git a/firmware/main/drivers/oled_driver/oled_driver.c b/firmware/main/drivers/oled_driver/oled_driver.c index e0a32313..993dd8c3 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 a7954afa..8bb34e41 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 diff --git a/firmware/main/general/bitmaps_general.h b/firmware/main/general/bitmaps_general.h index d4edf66e..562822d4 100644 --- a/firmware/main/general/bitmaps_general.h +++ b/firmware/main/general/bitmaps_general.h @@ -52,44 +52,48 @@ 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}; - -// '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}; +// '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[] = { + 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}; + +// '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[] = { @@ -153,11 +157,17 @@ 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 = { .bitmap = epd_bitmap_electroniccats, + .width = 48, + .height = 30, +}; + +const epd_bitmap_t minino_baby_dragon_bitmap = { + .bitmap = epd_bitmap_baby_dragon_ss, .width = 32, .height = 32, }; @@ -168,13 +178,14 @@ typedef enum { 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}; +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}; +char* epd_bitmaps_list[] = {"Letters", "Face", "PwnLabs", "EC", + "Mini face", "Baby Dragon", NULL}; #endif // BITMAPS_GENERAL_H \ No newline at end of file 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 a0eb165d..a4b353dd 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/general/general_screens.c b/firmware/main/general/general_screens.c index 92e14fe0..7e192482 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 @@ -61,6 +62,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 +202,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/file_manager/file_manager_module.c b/firmware/main/modules/file_manager/file_manager_module.c index 7344a09f..bf19fbd0 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/file_manager/file_manager_screens.c b/firmware/main/modules/file_manager/file_manager_screens.c index 458313a8..44cf0219 100644 --- a/firmware/main/modules/file_manager/file_manager_screens.c +++ b/firmware/main/modules/file_manager/file_manager_screens.c @@ -1,20 +1,29 @@ #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); 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)); 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 ? ">" : ""); diff --git a/firmware/main/modules/gps/wardriving/wardriving_module.c b/firmware/main/modules/gps/wardriving/wardriving_module.c index a7807e21..e4605522 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 95d551f2..6b513112 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 */ @@ -414,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", @@ -445,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, @@ -459,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, @@ -467,39 +497,19 @@ menu_t menus[] = { ////////////////////////////////// .on_exit_cb = NULL, .is_visible = true}, {.display_name = "Check Format", - .menu_idx = MENU_SETTINGS_SD_CARD_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}, -#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, + {.display_name = "Format", + .menu_idx = MENU_SETTINGS_SD_CARD_FORMAT, + .parent_idx = MENU_SETTINGS_SD_CARD, .last_selected_submenu = 0, - .on_enter_cb = web_file_browser_module_begin, + .on_enter_cb = sd_card_settings_verify_sd_card, .on_exit_cb = NULL, .is_visible = true}, - #endif -#endif {.display_name = "Stealth Mode", .menu_idx = MENU_STEALTH_MODE, .parent_idx = MENU_SETTINGS, diff --git a/firmware/main/modules/modals/keyboard/keyboard_screens.c b/firmware/main/modules/modals/keyboard/keyboard_screens.c index 1ab66957..30535517 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 diff --git a/firmware/main/modules/modals/modals_screens.c b/firmware/main/modules/modals/modals_screens.c index c7dd8833..f9fee4a6 100644 --- a/firmware/main/modules/modals/modals_screens.c +++ b/firmware/main/modules/modals/modals_screens.c @@ -4,26 +4,37 @@ #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(); } 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(); @@ -63,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); 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 dd752011..cd8411d9 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); } diff --git a/firmware/main/modules/settings/display/display_settings.c b/firmware/main/modules/settings/display/display_settings.c index 83f755d0..f90c9e8e 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,18 @@ #define TIMER_MAX_TIME 360 #define TIMER_MIN_TIME 30 +#ifdef CONFIG_RESOLUTION_128X64 + #define ITEMOFFSET 2 + #define ITEMSPERSCREEN 4 + #define TIME_PAGE 4 + #define Y_N_OFFSET 4 +#else // CONFIG_RESOLUTION_128X32 + #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; static char* display_settings_menu_items[] = {"Screen Logo", "Screen Time", @@ -64,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(); } @@ -88,7 +104,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 +116,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(); } @@ -118,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); @@ -159,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; @@ -166,7 +184,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); @@ -199,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; @@ -241,7 +260,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/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/flash_fs/flash_fs_screens.c b/firmware/main/modules/settings/flash_fs/flash_fs_screens.c index 4ceaa28c..663d34b6 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) { 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 56f82166..d4bd9b6a 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 85381a44..a6f9941e 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,73 @@ #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_wrong_format() { + oled_screen_clear(); + 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_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 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", 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 ? 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 a945cae6..56a36fb1 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(); diff --git a/firmware/main/modules/settings/settings_module.c b/firmware/main/modules/settings/settings_module.c index d230fe89..cd8509cf 100644 --- a/firmware/main/modules/settings/settings_module.c +++ b/firmware/main/modules/settings/settings_module.c @@ -38,23 +38,39 @@ 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] = 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_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); diff --git a/firmware/main/modules/settings/wifi/wifi_settings.c b/firmware/main/modules/settings/wifi/wifi_settings.c index 9645d2c5..2809e86c 100644 --- a/firmware/main/modules/settings/wifi/wifi_settings.c +++ b/firmware/main/modules/settings/wifi/wifi_settings.c @@ -2,13 +2,27 @@ #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" #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 4 + #define ITEMOFFSET 2 + #define ITEMSPERSCREEN 4 +#else // CONFIG_RESOLUTION_128X32 + #define START_PAGE 0 + #define Y_N_OFFSET 2 + #define ITEMOFFSET 1 + #define ITEMSPERSCREEN 3 +#endif + static int selected_item = 0; static int total_items = 0; static int max_items = 6; @@ -55,17 +69,23 @@ 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() { 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 +99,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 +114,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(); @@ -116,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); @@ -133,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; } } @@ -156,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++; } @@ -175,23 +203,22 @@ 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", 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); } } 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); } } @@ -244,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: @@ -326,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; @@ -360,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); @@ -374,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); diff --git a/firmware/main/modules/wifi/wifi_bitmaps.h b/firmware/main/modules/wifi/wifi_bitmaps.h index bba20895..fa792250 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 156cf43b..e6ae5c67 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,21 +25,35 @@ 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"); } } 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; } void wifi_screens_sniffer_animation_start() { + oled_screen_clear(); animations_task_run(&wifi_screens_display_sniffer_animation_task, 100, NULL); } diff --git a/firmware/main/modules/zigbee/zigbee_bitmaps.h b/firmware/main/modules/zigbee/zigbee_bitmaps.h index 9ce69399..b5371671 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,191 +176,161 @@ 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 -// 'zigbee_loading-1', 128x32px -const unsigned char zigbee_bitmap_loading_1[] = { +#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, 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 -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, 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_loading-3', 128x32px -const unsigned char zigbee_bitmap_loading_3[] = { + +// '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, 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 -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, 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', 32x32px +const unsigned char zigbee_bitmap_loading_1[] = { + 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, 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, 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, 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 5f73b5d1..a186b769 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() { @@ -80,28 +96,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); } diff --git a/firmware/resources/PWNlab-logo.png b/firmware/resources/PWNlab-logo.png new file mode 100644 index 00000000..381c0193 Binary files /dev/null and b/firmware/resources/PWNlab-logo.png differ diff --git a/firmware/resources/PWNlab-logo.xcf b/firmware/resources/PWNlab-logo.xcf new file mode 100644 index 00000000..e5638741 Binary files /dev/null and b/firmware/resources/PWNlab-logo.xcf differ diff --git a/firmware/resources/ec-face-logo.png b/firmware/resources/ec-face-logo.png new file mode 100644 index 00000000..a4a237e0 Binary files /dev/null and b/firmware/resources/ec-face-logo.png differ diff --git a/firmware/resources/ec-face-logo.xcf b/firmware/resources/ec-face-logo.xcf new file mode 100644 index 00000000..6d148f7c Binary files /dev/null and b/firmware/resources/ec-face-logo.xcf differ diff --git a/firmware/resources/wifi-loading-1-128x32.png b/firmware/resources/wifi-loading-1-128x32.png new file mode 100644 index 00000000..2d9d2d06 Binary files /dev/null and b/firmware/resources/wifi-loading-1-128x32.png differ 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 00000000..881fea70 Binary files /dev/null and b/firmware/resources/wifi-loading-128x32.xcf differ diff --git a/firmware/resources/wifi-loading-2-128x32.png b/firmware/resources/wifi-loading-2-128x32.png new file mode 100644 index 00000000..bb952fa5 Binary files /dev/null and b/firmware/resources/wifi-loading-2-128x32.png differ diff --git a/firmware/resources/wifi-loading-2.png b/firmware/resources/wifi-loading-2-128x64.png similarity index 100% rename from firmware/resources/wifi-loading-2.png rename to firmware/resources/wifi-loading-2-128x64.png diff --git a/firmware/resources/wifi-loading-3-128x32.png b/firmware/resources/wifi-loading-3-128x32.png new file mode 100644 index 00000000..402cf3aa Binary files /dev/null and b/firmware/resources/wifi-loading-3-128x32.png differ diff --git a/firmware/resources/wifi-loading-3.png b/firmware/resources/wifi-loading-3-128x64.png similarity index 100% rename from firmware/resources/wifi-loading-3.png rename to firmware/resources/wifi-loading-3-128x64.png diff --git a/firmware/resources/wifi-loading-4-128x32.png b/firmware/resources/wifi-loading-4-128x32.png new file mode 100644 index 00000000..8f452e23 Binary files /dev/null and b/firmware/resources/wifi-loading-4-128x32.png differ 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 diff --git a/firmware/resources/zigbee_switch_128x32.png b/firmware/resources/zigbee_switch_128x32.png new file mode 100644 index 00000000..1d4bccf1 Binary files /dev/null and b/firmware/resources/zigbee_switch_128x32.png differ diff --git a/firmware/resources/zigbee_switch_128x32.xcf b/firmware/resources/zigbee_switch_128x32.xcf new file mode 100644 index 00000000..592c3bc5 Binary files /dev/null and b/firmware/resources/zigbee_switch_128x32.xcf differ diff --git a/firmware/resources/zigbee_switch_128x32_dark.png b/firmware/resources/zigbee_switch_128x32_dark.png new file mode 100644 index 00000000..c53b349c Binary files /dev/null and b/firmware/resources/zigbee_switch_128x32_dark.png differ diff --git a/firmware/sdkconfig.defaults b/firmware/sdkconfig.defaults index 3f7e2bd5..8dae4dfd 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