Skip to content

Commit

Permalink
feat: Add more screens
Browse files Browse the repository at this point in the history
  • Loading branch information
JahazielLem committed Oct 11, 2024
1 parent 6796513 commit ad8a6a9
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 2 deletions.
46 changes: 46 additions & 0 deletions firmware/main/drivers/oled_driver/oled_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion firmware/main/drivers/oled_driver/oled_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions firmware/main/general/general_screens.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions firmware/main/general/general_screens.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions firmware/main/modules/oled_screen/oled_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion firmware/main/modules/oled_screen/oled_screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,6 @@ void oled_screen_display_show();
*
* @return Number of pages of the OLED display
*/
uint8_t oled_screen_get_pages();
uint8_t oled_screen_get_pages();

void oled_screen_display_card_border_full_h();

0 comments on commit ad8a6a9

Please sign in to comment.