From ad8a6a9bc6754b8341ac245681ecedb9abca4ddb Mon Sep 17 00:00:00 2001 From: Kevin Jahaziel Leon Morales Date: Fri, 11 Oct 2024 05:49:46 -0600 Subject: [PATCH] feat: Add more screens --- .../main/drivers/oled_driver/oled_driver.c | 46 +++++++++++++++++++ .../main/drivers/oled_driver/oled_driver.h | 2 +- firmware/main/general/general_screens.c | 33 +++++++++++++ firmware/main/general/general_screens.h | 1 + .../main/modules/oled_screen/oled_screen.c | 7 +++ .../main/modules/oled_screen/oled_screen.h | 4 +- 6 files changed, 91 insertions(+), 2 deletions(-) diff --git a/firmware/main/drivers/oled_driver/oled_driver.c b/firmware/main/drivers/oled_driver/oled_driver.c index 993dd8c..5c26c9c 100644 --- a/firmware/main/drivers/oled_driver/oled_driver.c +++ b/firmware/main/drivers/oled_driver/oled_driver.c @@ -806,6 +806,52 @@ void oled_driver_draw_modal_box(oled_driver_t* dev, // oled_driver_show_buffer(dev); } +void oled_driver_draw_modal_box_full_h(oled_driver_t* dev) { +#ifdef CONFIG_RESOLUTION_128X64 + int initial_page = 2; + int height_offset = 35; + int y_offset = 3; +#else + int initial_page = 1; + int height_offset = 29; + int y_offset = 0; +#endif + int page = initial_page; + int x = 0; + int y = page * 4 - y_offset; // 13 + int width = x + dev->_width - 4; + int height = y + height_offset; //- 6; // 15 + + oled_driver_draw_rect(dev, x, y, width, height, 0); + oled_driver_draw_rect(dev, x, y, width - 1, height - 1, 0); + + // Top left border + oled_driver_draw_pixel(dev, x, y, 1); + oled_driver_draw_pixel(dev, x + 1, y, 1); + oled_driver_draw_pixel(dev, x, y + 1, 1); + oled_driver_draw_pixel(dev, x + 1, y + 1, 0); + + // Top right border + oled_driver_draw_pixel(dev, width - 1, y, 1); + oled_driver_draw_pixel(dev, width - 2, y, 1); + oled_driver_draw_pixel(dev, width - 1, y + 1, 1); + oled_driver_draw_pixel(dev, width - 2, y + 1, 0); + + // Bottom left border + oled_driver_draw_pixel(dev, x, y + height - 1, 1); + oled_driver_draw_pixel(dev, x + 1, y + height - 1, 1); + oled_driver_draw_pixel(dev, x, y + height - 2, 1); + oled_driver_draw_pixel(dev, x + 1, y + height - 2, 0); + + // Bottom right border + oled_driver_draw_pixel(dev, width - 1, y + height - 1, 1); + oled_driver_draw_pixel(dev, width - 2, y + height - 1, 1); + oled_driver_draw_pixel(dev, width - 1, y + height - 2, 1); + oled_driver_draw_pixel(dev, width - 2, y + height - 2, 0); + + // oled_driver_show_buffer(dev); +} + void oled_driver_set_encrypt_value(bool value) { encrypt = value; } diff --git a/firmware/main/drivers/oled_driver/oled_driver.h b/firmware/main/drivers/oled_driver/oled_driver.h index 8bb34e4..258701f 100644 --- a/firmware/main/drivers/oled_driver/oled_driver.h +++ b/firmware/main/drivers/oled_driver/oled_driver.h @@ -246,7 +246,7 @@ 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_draw_modal_box_full_h(oled_driver_t* dev); void oled_driver_set_encrypt_value(bool value); void oled_driver_set_typography_value(bool value); #ifdef __cplusplus diff --git a/firmware/main/general/general_screens.c b/firmware/main/general/general_screens.c index 7e19248..4394400 100644 --- a/firmware/main/general/general_screens.c +++ b/firmware/main/general/general_screens.c @@ -183,6 +183,39 @@ void general_screen_display_card_information_handler(char* title, genera_screen_display_card_information(title, body); } +void genera_screen_display_card_information_scroll_nbc(char* title, + char* body) { + general_register_menu(&card_info_menu_ctx); + general_clear_screen(); + oled_screen_display_card_border_full_h(); + int page = ITEM_PAGE_OFFSET; + oled_screen_display_text_center(title, page, OLED_DISPLAY_NORMAL); + page++; + if (strlen(body) > MAX_LINE_CHAR) { + oled_screen_display_text_splited(body, &page, OLED_DISPLAY_NORMAL); + oled_screen_display_show(); + return; + } + oled_screen_display_text_center(body, page, OLED_DISPLAY_NORMAL); + oled_screen_display_show(); +} + +void genera_screen_display_card_information_nbc(char* title, char* body) { + general_register_menu(&card_info_menu_ctx); + general_clear_screen(); + oled_screen_display_card_border_full_h(); + int page = ITEM_PAGE_OFFSET; + oled_screen_display_text_center(title, page, OLED_DISPLAY_NORMAL); + page++; + if (strlen(body) > MAX_LINE_CHAR) { + oled_screen_display_text_splited(body, &page, OLED_DISPLAY_NORMAL); + oled_screen_display_show(); + return; + } + oled_screen_display_text_center(body, page, OLED_DISPLAY_NORMAL); + oled_screen_display_show(); +} + void genera_screen_display_card_information(char* title, char* body) { general_register_menu(&card_info_menu_ctx); general_clear_screen(); diff --git a/firmware/main/general/general_screens.h b/firmware/main/general/general_screens.h index 1f39edb..1322f99 100644 --- a/firmware/main/general/general_screens.h +++ b/firmware/main/general/general_screens.h @@ -31,6 +31,7 @@ void general_register_scrolling_menu(const general_menu_t* ctx); void general_clear_screen(); void general_screen_display_menu(uint16_t current_option); void genera_screen_display_card_information(char* title, char* body); +void genera_screen_display_card_information_nbc(char* title, char* body); void genera_screen_display_notify_information(char* title, char* body); void general_screen_display_card_information_handler(char* title, char* body, diff --git a/firmware/main/modules/oled_screen/oled_screen.c b/firmware/main/modules/oled_screen/oled_screen.c index 8eecb95..4f103b6 100644 --- a/firmware/main/modules/oled_screen/oled_screen.c +++ b/firmware/main/modules/oled_screen/oled_screen.c @@ -145,6 +145,13 @@ void oled_screen_display_card_border() { xSemaphoreGive(oled_mutex); } +void oled_screen_display_card_border_full_h() { + xSemaphoreTake(oled_mutex, portMAX_DELAY); + oled_driver_draw_modal_box_full_h(&dev); + oled_driver_show_buffer(&dev); + xSemaphoreGive(oled_mutex); +} + void oled_screen_display_text_splited(char* p_text, int* p_started_page, int invert) { diff --git a/firmware/main/modules/oled_screen/oled_screen.h b/firmware/main/modules/oled_screen/oled_screen.h index 5a1a007..96af2c7 100644 --- a/firmware/main/modules/oled_screen/oled_screen.h +++ b/firmware/main/modules/oled_screen/oled_screen.h @@ -141,4 +141,6 @@ void oled_screen_display_show(); * * @return Number of pages of the OLED display */ -uint8_t oled_screen_get_pages(); \ No newline at end of file +uint8_t oled_screen_get_pages(); + +void oled_screen_display_card_border_full_h(); \ No newline at end of file