Skip to content

Commit bbef79a

Browse files
authored
feature: update intro message with WebScreen image. (#24)
1 parent f253c52 commit bbef79a

File tree

3 files changed

+301
-13
lines changed

3 files changed

+301
-13
lines changed

webscreen/fallback.cpp

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
#include "rm67162.h"
55
#include <lvgl.h>
66
#include "notification.h"
7+
#include "webscreen.h"
78
#include "globals.h"
89
#include "tick.h"
910
static lv_obj_t *fb_label = nullptr;
1011
static lv_obj_t *fb_gif = nullptr;
12+
static lv_obj_t *fb_container = nullptr;
13+
static lv_obj_t *fb_image = nullptr;
1114
static lv_disp_draw_buf_t fbDrawBuf;
1215
static lv_color_t *fbBuf = nullptr;
1316

@@ -27,8 +30,9 @@ static void create_scroll_animation(lv_obj_t *obj, int32_t start, int32_t end, u
2730
lv_anim_set_values(&a, start, end);
2831
lv_anim_set_time(&a, duration);
2932
lv_anim_set_exec_cb(&a, scroll_anim_cb);
30-
lv_anim_set_path_cb(&a, lv_anim_path_ease_in_out);
33+
lv_anim_set_path_cb(&a, lv_anim_path_linear);
3134
lv_anim_set_repeat_count(&a, 2);
35+
lv_anim_set_repeat_delay(&a, 500);
3236
lv_anim_set_ready_cb(&a, [](lv_anim_t *anim) {
3337
lv_obj_t *obj = (lv_obj_t *)anim->var;
3438
lv_obj_add_flag(obj, LV_OBJ_FLAG_HIDDEN);
@@ -60,30 +64,49 @@ void fallback_setup() {
6064
disp_drv.flush_cb = fallback_disp_flush;
6165
disp_drv.draw_buf = &fbDrawBuf;
6266
lv_disp_drv_register(&disp_drv);
67+
68+
// Create a container for the image and label
69+
fb_container = lv_obj_create(lv_scr_act());
70+
lv_obj_set_size(fb_container, 536, LV_SIZE_CONTENT);
71+
lv_obj_set_style_bg_opa(fb_container, LV_OPA_TRANSP, 0);
72+
lv_obj_set_style_border_opa(fb_container, LV_OPA_TRANSP, 0);
73+
lv_obj_set_style_pad_all(fb_container, 0, 0);
74+
lv_obj_set_flex_flow(fb_container, LV_FLEX_FLOW_COLUMN);
75+
lv_obj_set_flex_align(fb_container, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
76+
77+
// Create the webscreen image with better quality settings
78+
fb_image = lv_img_create(fb_container);
79+
lv_img_set_src(fb_image, &webscreen);
80+
lv_img_set_antialias(fb_image, true);
81+
lv_obj_set_style_pad_bottom(fb_image, 15, 0);
82+
lv_obj_set_style_img_recolor(fb_image, lv_color_white(), 0);
83+
lv_obj_set_style_img_recolor_opa(fb_image, 0, 0);
84+
85+
// Create the label with improved styling
6386
static lv_style_t style;
6487
lv_style_init(&style);
6588
lv_style_set_text_font(&style, &lv_font_montserrat_40);
6689
lv_style_set_text_color(&style, lv_color_white());
6790
lv_style_set_bg_color(&style, lv_color_black());
68-
lv_style_set_pad_all(&style, 5);
91+
lv_style_set_pad_all(&style, 10);
6992
lv_style_set_text_align(&style, LV_TEXT_ALIGN_CENTER);
70-
fb_label = lv_label_create(lv_scr_act());
93+
lv_style_set_text_line_space(&style, 8);
94+
95+
fb_label = lv_label_create(fb_container);
7196
lv_obj_add_style(fb_label, &style, 0);
7297
lv_label_set_text(fb_label,
73-
"/\\_/\\\n"
74-
"= ( • . • ) =\n"
75-
" / \\ \n"
76-
"Welcome to Webscreen! This is the Notification App, you can also run apps from the SD card.\n"
98+
"Welcome! This is the Notification App, you can also run apps from the SD card.\n"
7799
" \n"
78100
" \n");
79101
lv_label_set_long_mode(fb_label, LV_LABEL_LONG_WRAP);
80102
lv_obj_set_width(fb_label, 525);
81-
lv_obj_align(fb_label, LV_ALIGN_CENTER, 0, 0);
82-
create_scroll_animation(fb_label, 240, -lv_obj_get_height(fb_label), 10000);
103+
104+
lv_obj_align(fb_container, LV_ALIGN_TOP_MID, 0, 240);
105+
create_scroll_animation(fb_container, 240, -lv_obj_get_height(fb_container) - 100, 8000);
83106
fb_gif = lv_gif_create(lv_scr_act());
84107
lv_gif_set_src(fb_gif, &notification);
85108
lv_obj_align(fb_gif, LV_ALIGN_CENTER, 0, 0);
86-
lv_obj_clear_flag(fb_label, LV_OBJ_FLAG_HIDDEN);
109+
lv_obj_clear_flag(fb_container, LV_OBJ_FLAG_HIDDEN);
87110
lv_obj_add_flag(fb_gif, LV_OBJ_FLAG_HIDDEN);
88111
}
89112

@@ -92,9 +115,9 @@ void fallback_loop() {
92115
if (Serial.available()) {
93116
String line = Serial.readStringUntil('\n');
94117
lv_label_set_text(fb_label, line.c_str());
95-
lv_obj_align(fb_label, LV_ALIGN_CENTER, 0, 0);
96-
lv_obj_clear_flag(fb_label, LV_OBJ_FLAG_HIDDEN);
118+
lv_obj_align(fb_container, LV_ALIGN_CENTER, 0, 0);
119+
lv_obj_clear_flag(fb_container, LV_OBJ_FLAG_HIDDEN);
97120
lv_obj_add_flag(fb_gif, LV_OBJ_FLAG_HIDDEN);
98-
create_scroll_animation(fb_label, 240, -lv_obj_get_height(fb_label), 10000);
121+
create_scroll_animation(fb_container, 240, -lv_obj_get_height(fb_container) - 100, 8000);
99122
}
100123
}

0 commit comments

Comments
 (0)