1 /**
2 * @file lv_demo_smartwatch_home.c
3 * Home screen layout & functions. Basically the watchface for the smartwatch.
4 */
5
6 /*********************
7 * INCLUDES
8 *********************/
9 #include "lv_demo_smartwatch.h"
10 #if LV_USE_DEMO_SMARTWATCH
11
12 #include "lv_demo_smartwatch_private.h"
13 #include "lv_demo_smartwatch_home.h"
14
15 /*********************
16 * DEFINES
17 *********************/
18
19 #define MAX_FACES 15
20
21 /**********************
22 * TYPEDEFS
23 **********************/
24 /**
25 * watchface object
26 */
27 typedef struct {
28 const char * name; /**< name of the watchface, shown in the watchface selector */
29 const lv_image_dsc_t * preview; /**< preview of the watchface, shown in the watchface selector */
30 lv_obj_t ** watchface; /**< pointer to watchface root object */
31 lv_obj_t ** seconds; /**< pointer to analog seconds object in the watchface, used for smooth animation */
32 } watchface_t;
33
34 /**********************
35 * STATIC PROTOTYPES
36 **********************/
37 static void create_screen_home(void);
38
39 static void create_home_hints(void);
40
41 static void lv_demo_smartwatch_add_watchface(const char * name, const lv_image_dsc_t * src, int index);
42 static void clock_screen_event_cb(lv_event_t * e);
43 static void animate_analog_seconds(lv_obj_t * target);
44
45 /**********************
46 * STATIC VARIABLES
47 **********************/
48 static lv_obj_t * face_park;
49 static lv_obj_t * home_panel;
50 static lv_obj_t * clock_screen;
51 static lv_obj_t * hour_label;
52 static lv_obj_t * minute_label;
53 static lv_obj_t * date_label;
54 static lv_obj_t * weather_icon;
55 static lv_obj_t * weather_temperature;
56 static lv_obj_t * weekday_label;
57 static lv_obj_t * am_pm_label;
58
59 static lv_obj_t * alert_panel;
60 static lv_obj_t * alert_icon;
61 static lv_obj_t * alert_text;
62
63 static lv_obj_t * face_select;
64
65 static watchface_t faces[MAX_FACES];
66 static uint32_t num_faces;
67 static uint32_t current_face_index;
68
69 static lv_obj_t * hint_panel;
70 static lv_obj_t * hint_up;
71 static lv_obj_t * hint_down;
72 static lv_obj_t * hint_left;
73 static lv_obj_t * hint_right;
74
75 static lv_anim_t seconds_animation;
76
77 /**********************
78 * MACROS
79 **********************/
80
81 /**********************
82 * GLOBAL FUNCTIONS
83 **********************/
84
lv_demo_smartwatch_register_watchface_cb(const char * name,const lv_image_dsc_t * preview,lv_obj_t ** watchface,lv_obj_t ** seconds)85 void lv_demo_smartwatch_register_watchface_cb(const char * name, const lv_image_dsc_t * preview, lv_obj_t ** watchface,
86 lv_obj_t ** seconds)
87 {
88 if(num_faces >= MAX_FACES) {
89 LV_LOG_WARN("Maximum watchfaces reached. Cannot add more watchfaces");
90 return;
91 }
92 faces[num_faces].name = name;
93 faces[num_faces].preview = preview;
94 faces[num_faces].watchface = watchface;
95 faces[num_faces].seconds = seconds;
96 lv_demo_smartwatch_add_watchface(name, preview, num_faces);
97 num_faces++;
98 }
99
lv_demo_smartwatch_home_create(lv_obj_t * parent)100 void lv_demo_smartwatch_home_create(lv_obj_t * parent)
101 {
102
103 home_panel = lv_tileview_add_tile(parent, 0, 1, LV_DIR_TOP | LV_DIR_RIGHT);
104 lv_obj_remove_flag(home_panel, LV_OBJ_FLAG_SCROLLABLE);
105 lv_obj_set_style_bg_color(home_panel, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
106 lv_obj_set_style_bg_opa(home_panel, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
107
108 face_park = lv_obj_create(NULL); /* parent of inactive watchfaces */
109
110 create_screen_home();
111
112 create_home_hints();
113
114 lv_demo_smartwatch_register_watchface_cb("Default", &img_digital_preview, &clock_screen, NULL);
115 }
116
lv_demo_smartwatch_face_events_cb(lv_event_t * e)117 void lv_demo_smartwatch_face_events_cb(lv_event_t * e)
118 {
119 lv_event_code_t event_code = lv_event_get_code(e);
120
121 if(event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_active()) == LV_DIR_RIGHT) {
122 lv_demo_smartwatch_set_load_app_list(false); /* flag was not open from app list */
123 lv_demo_smartwatch_notifications_load(LV_SCR_LOAD_ANIM_OVER_RIGHT, 500, 0);
124 }
125
126 if(event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_active()) == LV_DIR_TOP) {
127 lv_demo_smartwatch_set_load_app_list(false); /* flag was not open from app list */
128 lv_demo_smartwatch_weather_load(LV_SCR_LOAD_ANIM_MOVE_TOP, 500, 0);
129 }
130
131 if(event_code == LV_EVENT_LONG_PRESSED_REPEAT) {
132 lv_disp_t * display = lv_display_get_default();
133 lv_obj_t * active_screen = lv_display_get_screen_active(display);
134 if(active_screen != lv_demo_smartwatch_get_tileview()) {
135 /* event was triggered but the current screen is no longer active */
136 return;
137 }
138 lv_screen_load_anim(face_select, LV_SCR_LOAD_ANIM_FADE_ON, 500, 0, false);
139 }
140
141
142 }
143
lv_demo_smartwatch_face_selected_cb(lv_event_t * e)144 void lv_demo_smartwatch_face_selected_cb(lv_event_t * e)
145 {
146 lv_event_code_t event_code = lv_event_get_code(e);
147 lv_obj_t * target = lv_event_get_target(e);
148
149 if(target == lv_demo_smartwatch_get_tileview()) {
150 /* the event might be triggered after watchface has been selected, return immediately */
151 return;
152 }
153
154 if(event_code == LV_EVENT_CLICKED) {
155 uint32_t index = (uint32_t)(intptr_t)lv_event_get_user_data(e);
156
157 if(index >= num_faces) {
158 LV_LOG_WARN("Selected watchface index exceeds available faces.");
159 lv_demo_smartwatch_load_home_watchface();
160 return;
161 }
162 lv_obj_scroll_to_view(lv_obj_get_child(face_select, index), LV_ANIM_OFF);
163
164 lv_demo_smartwatch_face_load(index);
165 }
166 }
167
lv_demo_smartwatch_home_set_weather(int temp,const lv_img_dsc_t * icon)168 void lv_demo_smartwatch_home_set_weather(int temp, const lv_img_dsc_t * icon)
169 {
170 lv_label_set_text_fmt(weather_temperature, "%d°C", temp);
171 lv_image_set_src(weather_icon, icon);
172 }
173
lv_demo_smartwatch_home_set_time(int minute,int hour,const char * am_pm,int date,const char * month,const char * weekday)174 void lv_demo_smartwatch_home_set_time(int minute, int hour, const char * am_pm, int date, const char * month,
175 const char * weekday)
176 {
177 lv_label_set_text_fmt(hour_label, "%02d", hour);
178 lv_label_set_text_fmt(weekday_label, "%s", weekday);
179 lv_label_set_text_fmt(minute_label, "%02d", minute);
180 lv_label_set_text_fmt(date_label, "%02d\n%s", date, month);
181 lv_label_set_text(am_pm_label, am_pm);
182 }
183
lv_demo_smartwatch_get_tile_home(void)184 lv_obj_t * lv_demo_smartwatch_get_tile_home(void)
185 {
186 return home_panel;
187 }
188
lv_demo_smartwatch_face_get_current(void)189 lv_obj_t * lv_demo_smartwatch_face_get_current(void)
190 {
191 return *faces[current_face_index].watchface;
192 }
193
lv_demo_smartwatch_face_update_seconds(int second)194 void lv_demo_smartwatch_face_update_seconds(int second)
195 {
196 lv_anim_custom_delete(&seconds_animation, NULL);
197
198 for(int i = 0; (uint32_t)i < num_faces; i++) {
199 if(faces[i].seconds != NULL) {
200 lv_image_set_rotation(*faces[i].seconds, second * 60);
201 animate_analog_seconds(*faces[i].seconds);
202 }
203 }
204 }
205
lv_demo_smartwatch_face_load(uint16_t index)206 bool lv_demo_smartwatch_face_load(uint16_t index)
207 {
208 LV_LOG_WARN("Loading watchface at index %d", index);
209
210 if(index >= num_faces) {
211 LV_LOG_WARN("Cannot load watchface. Selected watchface index exceeds available faces.");
212 return false;
213 }
214
215 if(*faces[index].watchface == NULL) {
216 LV_LOG_WARN("Cannot load watchface, the object is null");
217 return false;
218 }
219 lv_obj_scroll_to_view(lv_obj_get_child(face_select, index), LV_ANIM_OFF);
220 if(current_face_index != index) {
221 current_face_index = index;
222
223 /* remove all objects in the home panel by assigning them a new parent */
224 for(uint32_t i = 0; i < lv_obj_get_child_count(home_panel); i++) {
225 lv_obj_t * current = lv_obj_get_child(home_panel, i);
226 if(current != NULL) {
227 lv_obj_set_parent(current, face_park);
228 }
229 }
230 /* set the selected watchface parent */
231 lv_obj_set_parent((lv_obj_t *)*faces[index].watchface, home_panel);
232
233 lv_obj_set_parent(hint_panel, face_park);
234 }
235
236 lv_demo_smartwatch_load_home_watchface();
237
238 return true;
239 }
240
lv_demo_smartwatch_show_home_hint(bool state)241 void lv_demo_smartwatch_show_home_hint(bool state)
242 {
243
244 lv_obj_set_parent(hint_panel, home_panel);
245
246 if(state && lv_demo_smartwatch_get_scroll_hint()) {
247 lv_obj_remove_flag(hint_panel, LV_OBJ_FLAG_HIDDEN);
248 }
249 else {
250 lv_obj_add_flag(hint_panel, LV_OBJ_FLAG_HIDDEN);
251 }
252 }
253
254 /**********************
255 * STATIC FUNCTIONS
256 **********************/
257
animate_analog_seconds(lv_obj_t * target)258 static void animate_analog_seconds(lv_obj_t * target)
259 {
260 lv_anim_init(&seconds_animation);
261 lv_anim_set_duration(&seconds_animation, 60000);
262 lv_anim_set_values(&seconds_animation, lv_image_get_rotation(target), lv_image_get_rotation(target) + 3600);
263 lv_anim_set_var(&seconds_animation, target);
264 lv_anim_set_exec_cb(&seconds_animation, (lv_anim_exec_xcb_t)lv_image_set_rotation);
265 lv_anim_set_repeat_count(&seconds_animation, LV_ANIM_REPEAT_INFINITE);
266 lv_anim_start(&seconds_animation);
267 }
268
clock_screen_event_cb(lv_event_t * e)269 static void clock_screen_event_cb(lv_event_t * e)
270 {
271 lv_demo_smartwatch_face_events_cb(e);
272 }
273
lv_demo_smartwatch_add_watchface(const char * name,const lv_image_dsc_t * src,int index)274 static void lv_demo_smartwatch_add_watchface(const char * name, const lv_image_dsc_t * src, int index)
275 {
276 lv_obj_t * face_item = lv_obj_create(face_select);
277 lv_obj_set_width(face_item, 160);
278 lv_obj_set_height(face_item, 180);
279 lv_obj_set_align(face_item, LV_ALIGN_CENTER);
280 lv_obj_remove_flag(face_item, LV_OBJ_FLAG_SCROLLABLE);
281 lv_obj_remove_flag(face_item, LV_OBJ_FLAG_SCROLL_ONE);
282 lv_obj_set_style_radius(face_item, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
283 lv_obj_set_style_bg_color(face_item, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
284 lv_obj_set_style_bg_opa(face_item, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
285 lv_obj_set_style_border_width(face_item, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
286 lv_obj_set_style_outline_color(face_item, lv_color_hex(0x142ABC), LV_PART_MAIN | LV_STATE_DEFAULT);
287 lv_obj_set_style_outline_opa(face_item, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
288 lv_obj_set_style_outline_width(face_item, 2, LV_PART_MAIN | LV_STATE_DEFAULT);
289 lv_obj_set_style_outline_pad(face_item, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
290 lv_obj_set_style_pad_left(face_item, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
291 lv_obj_set_style_pad_right(face_item, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
292 lv_obj_set_style_pad_top(face_item, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
293 lv_obj_set_style_pad_bottom(face_item, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
294
295 lv_obj_t * face_preview = lv_image_create(face_item);
296 lv_image_set_src(face_preview, src);
297 lv_obj_set_width(face_preview, LV_SIZE_CONTENT);
298 lv_obj_set_height(face_preview, LV_SIZE_CONTENT);
299 lv_obj_set_align(face_preview, LV_ALIGN_TOP_MID);
300 lv_obj_add_flag(face_preview, LV_OBJ_FLAG_ADV_HITTEST);
301 lv_obj_remove_flag(face_preview, LV_OBJ_FLAG_SCROLLABLE);
302
303 lv_obj_t * face_label = lv_label_create(face_item);
304 lv_obj_set_width(face_label, 160);
305 lv_obj_set_height(face_label, LV_SIZE_CONTENT);
306 lv_obj_set_align(face_label, LV_ALIGN_BOTTOM_MID);
307 lv_label_set_long_mode(face_label, LV_LABEL_LONG_DOT);
308 lv_label_set_text(face_label, name);
309 lv_obj_set_style_text_align(face_label, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
310 lv_obj_set_style_text_font(face_label, &lv_font_montserrat_16, LV_PART_MAIN | LV_STATE_DEFAULT);
311
312 lv_obj_add_event_cb(face_item, lv_demo_smartwatch_face_selected_cb, LV_EVENT_ALL, (void *)(intptr_t)index);
313 }
314
create_screen_home(void)315 static void create_screen_home(void)
316 {
317 clock_screen = lv_obj_create(home_panel);
318 lv_obj_set_width(clock_screen, lv_pct(100));
319 lv_obj_set_height(clock_screen, lv_pct(100));
320 lv_obj_remove_flag(clock_screen, LV_OBJ_FLAG_SCROLLABLE);
321 lv_obj_set_style_bg_color(clock_screen, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
322 lv_obj_set_style_bg_opa(clock_screen, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
323 lv_obj_set_style_radius(clock_screen, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
324 lv_obj_set_style_border_width(clock_screen, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
325
326 hour_label = lv_label_create(clock_screen);
327 lv_obj_set_width(hour_label, 151);
328 lv_obj_set_height(hour_label, LV_SIZE_CONTENT);
329 lv_obj_set_x(hour_label, -89);
330 lv_obj_set_y(hour_label, -25);
331 lv_obj_set_align(hour_label, LV_ALIGN_CENTER);
332 lv_label_set_text(hour_label, "20");
333 lv_obj_set_style_text_align(hour_label, LV_TEXT_ALIGN_RIGHT, LV_PART_MAIN | LV_STATE_DEFAULT);
334 lv_obj_set_style_text_font(hour_label, &lv_font_montserrat_48, LV_PART_MAIN | LV_STATE_DEFAULT);
335
336 minute_label = lv_label_create(clock_screen);
337 lv_obj_set_width(minute_label, LV_SIZE_CONTENT);
338 lv_obj_set_height(minute_label, LV_SIZE_CONTENT);
339 lv_obj_set_x(minute_label, 25);
340 lv_obj_set_y(minute_label, 40);
341 lv_obj_set_align(minute_label, LV_ALIGN_CENTER);
342 lv_label_set_text(minute_label, "28");
343 lv_obj_set_style_text_font(minute_label, &lv_font_montserrat_48, LV_PART_MAIN | LV_STATE_DEFAULT);
344
345 date_label = lv_label_create(clock_screen);
346 lv_obj_set_width(date_label, 113);
347 lv_obj_set_height(date_label, LV_SIZE_CONTENT);
348 lv_obj_set_x(date_label, 59);
349 lv_obj_set_y(date_label, -22);
350 lv_obj_set_align(date_label, LV_ALIGN_CENTER);
351 lv_label_set_long_mode(date_label, LV_LABEL_LONG_CLIP);
352 lv_label_set_text(date_label, "08\nJuly");
353 lv_obj_set_style_text_font(date_label, &lv_font_montserrat_20, LV_PART_MAIN | LV_STATE_DEFAULT);
354
355 weather_icon = lv_image_create(clock_screen);
356 lv_image_set_src(weather_icon, &img_weather_day_6);
357 lv_obj_set_width(weather_icon, LV_SIZE_CONTENT);
358 lv_obj_set_height(weather_icon, LV_SIZE_CONTENT);
359 lv_obj_set_x(weather_icon, -43);
360 lv_obj_set_y(weather_icon, 20);
361 lv_obj_set_align(weather_icon, LV_ALIGN_CENTER);
362 lv_obj_add_flag(weather_icon, LV_OBJ_FLAG_ADV_HITTEST);
363 lv_obj_remove_flag(weather_icon, LV_OBJ_FLAG_SCROLLABLE);
364 lv_image_set_scale(weather_icon, 150);
365
366 weather_temperature = lv_label_create(clock_screen);
367 lv_obj_set_width(weather_temperature, LV_SIZE_CONTENT);
368 lv_obj_set_height(weather_temperature, LV_SIZE_CONTENT);
369 lv_obj_set_x(weather_temperature, -41);
370 lv_obj_set_y(weather_temperature, 50);
371 lv_obj_set_align(weather_temperature, LV_ALIGN_CENTER);
372 lv_label_set_text(weather_temperature, "--°C");
373 lv_obj_set_style_text_font(weather_temperature, &lv_font_montserrat_20, LV_PART_MAIN | LV_STATE_DEFAULT);
374
375 weekday_label = lv_label_create(clock_screen);
376 lv_obj_set_width(weekday_label, LV_SIZE_CONTENT);
377 lv_obj_set_height(weekday_label, LV_SIZE_CONTENT);
378 lv_obj_set_x(weekday_label, 0);
379 lv_obj_set_y(weekday_label, -70);
380 lv_obj_set_align(weekday_label, LV_ALIGN_CENTER);
381 lv_label_set_text(weekday_label, "Sunday");
382 lv_obj_set_style_text_font(weekday_label, &lv_font_montserrat_16, LV_PART_MAIN | LV_STATE_DEFAULT);
383
384 am_pm_label = lv_label_create(clock_screen);
385 lv_obj_set_width(am_pm_label, LV_SIZE_CONTENT);
386 lv_obj_set_height(am_pm_label, LV_SIZE_CONTENT);
387 lv_obj_set_x(am_pm_label, 12);
388 lv_obj_set_y(am_pm_label, 80);
389 lv_obj_set_align(am_pm_label, LV_ALIGN_CENTER);
390 lv_label_set_text(am_pm_label, "PM");
391 lv_obj_set_style_text_font(am_pm_label, &lv_font_montserrat_20, LV_PART_MAIN | LV_STATE_DEFAULT);
392
393 alert_panel = lv_obj_create(clock_screen);
394 lv_obj_set_width(alert_panel, 200);
395 lv_obj_set_height(alert_panel, 55);
396 lv_obj_set_align(alert_panel, LV_ALIGN_CENTER);
397 lv_obj_add_flag(alert_panel, LV_OBJ_FLAG_HIDDEN);
398 lv_obj_remove_flag(alert_panel, LV_OBJ_FLAG_GESTURE_BUBBLE | LV_OBJ_FLAG_SCROLLABLE);
399 lv_obj_set_style_bg_color(alert_panel, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
400 lv_obj_set_style_bg_opa(alert_panel, 240, LV_PART_MAIN | LV_STATE_DEFAULT);
401 lv_obj_set_style_border_color(alert_panel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
402 lv_obj_set_style_border_opa(alert_panel, 240, LV_PART_MAIN | LV_STATE_DEFAULT);
403 lv_obj_set_style_border_width(alert_panel, 1, LV_PART_MAIN | LV_STATE_DEFAULT);
404 lv_obj_set_style_pad_left(alert_panel, 5, LV_PART_MAIN | LV_STATE_DEFAULT);
405 lv_obj_set_style_pad_right(alert_panel, 5, LV_PART_MAIN | LV_STATE_DEFAULT);
406 lv_obj_set_style_pad_top(alert_panel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
407 lv_obj_set_style_pad_bottom(alert_panel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
408
409 alert_icon = lv_image_create(alert_panel);
410 lv_image_set_src(alert_icon, &img_wechat_icon);
411 lv_obj_set_width(alert_icon, LV_SIZE_CONTENT);
412 lv_obj_set_height(alert_icon, LV_SIZE_CONTENT);
413 lv_obj_set_align(alert_icon, LV_ALIGN_LEFT_MID);
414 lv_obj_add_flag(alert_icon, LV_OBJ_FLAG_ADV_HITTEST);
415 lv_obj_remove_flag(alert_icon, LV_OBJ_FLAG_SCROLLABLE);
416
417 alert_text = lv_label_create(alert_panel);
418 lv_obj_set_width(alert_text, 142);
419 lv_obj_set_height(alert_text, 40);
420 lv_obj_set_x(alert_text, 39);
421 lv_obj_set_y(alert_text, 0);
422 lv_obj_set_align(alert_text, LV_ALIGN_LEFT_MID);
423 lv_label_set_long_mode(alert_text, LV_LABEL_LONG_DOT);
424 lv_label_set_text(alert_text, "this is a notification example");
425 lv_obj_set_style_text_font(alert_text, &lv_font_montserrat_16, LV_PART_MAIN | LV_STATE_DEFAULT);
426
427 lv_obj_add_event_cb(clock_screen, clock_screen_event_cb, LV_EVENT_ALL, NULL);
428
429 face_select = lv_obj_create(NULL);
430 lv_obj_set_width(face_select, 240);
431 lv_obj_set_height(face_select, 240);
432 lv_obj_set_align(face_select, LV_ALIGN_CENTER);
433 lv_obj_set_flex_flow(face_select, LV_FLEX_FLOW_ROW);
434 lv_obj_set_flex_align(face_select, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
435 lv_obj_set_scrollbar_mode(face_select, LV_SCROLLBAR_MODE_OFF);
436 lv_obj_set_style_radius(face_select, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
437 lv_obj_set_style_bg_color(face_select, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
438 lv_obj_set_style_bg_opa(face_select, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
439 lv_obj_set_style_border_width(face_select, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
440 lv_obj_set_style_pad_left(face_select, 30, LV_PART_MAIN | LV_STATE_DEFAULT);
441 lv_obj_set_style_pad_right(face_select, 30, LV_PART_MAIN | LV_STATE_DEFAULT);
442 lv_obj_set_style_pad_top(face_select, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
443 lv_obj_set_style_pad_bottom(face_select, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
444 lv_obj_set_style_pad_row(face_select, 10, LV_PART_MAIN | LV_STATE_DEFAULT);
445 lv_obj_set_style_pad_column(face_select, 15, LV_PART_MAIN | LV_STATE_DEFAULT);
446 }
447
create_home_hints(void)448 static void create_home_hints(void)
449 {
450 hint_panel = lv_obj_create(home_panel);
451
452 lv_obj_set_width(hint_panel, lv_pct(100));
453 lv_obj_set_height(hint_panel, lv_pct(100));
454 lv_obj_set_align(hint_panel, LV_ALIGN_CENTER);
455 lv_obj_remove_flag(hint_panel, LV_OBJ_FLAG_CLICKABLE);
456 lv_obj_set_style_radius(hint_panel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
457 lv_obj_set_style_bg_color(hint_panel, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
458 lv_obj_set_style_bg_opa(hint_panel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
459 lv_obj_set_style_border_width(hint_panel, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
460 lv_obj_set_style_pad_left(hint_panel, 5, LV_PART_MAIN | LV_STATE_DEFAULT);
461 lv_obj_set_style_pad_right(hint_panel, 5, LV_PART_MAIN | LV_STATE_DEFAULT);
462 lv_obj_set_style_pad_top(hint_panel, 5, LV_PART_MAIN | LV_STATE_DEFAULT);
463 lv_obj_set_style_pad_bottom(hint_panel, 5, LV_PART_MAIN | LV_STATE_DEFAULT);
464
465 hint_up = lv_image_create(hint_panel);
466 lv_image_set_src(hint_up, &img_note_icon);
467 lv_image_set_scale(hint_up, 200);
468 lv_obj_set_width(hint_up, LV_SIZE_CONTENT);
469 lv_obj_set_height(hint_up, LV_SIZE_CONTENT);
470 lv_obj_set_align(hint_up, LV_ALIGN_TOP_MID);
471 lv_obj_remove_flag(hint_up, LV_OBJ_FLAG_SCROLLABLE);
472 lv_obj_remove_flag(hint_up, LV_OBJ_FLAG_CLICKABLE);
473 lv_obj_set_style_radius(hint_up, 5, LV_PART_MAIN | LV_STATE_DEFAULT);
474 lv_obj_set_style_bg_color(hint_up, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
475 lv_obj_set_style_bg_opa(hint_up, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
476
477 hint_down = lv_image_create(hint_panel);
478 lv_image_set_src(hint_down, &img_cloud_icon);
479 lv_image_set_scale(hint_down, 200);
480 lv_obj_set_width(hint_down, LV_SIZE_CONTENT);
481 lv_obj_set_height(hint_down, LV_SIZE_CONTENT);
482 lv_obj_set_align(hint_down, LV_ALIGN_BOTTOM_MID);
483 lv_obj_remove_flag(hint_down, LV_OBJ_FLAG_SCROLLABLE);
484 lv_obj_remove_flag(hint_down, LV_OBJ_FLAG_CLICKABLE);
485 lv_obj_set_style_radius(hint_down, 5, LV_PART_MAIN | LV_STATE_DEFAULT);
486 lv_obj_set_style_bg_color(hint_down, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
487 lv_obj_set_style_bg_opa(hint_down, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
488
489 hint_left = lv_image_create(hint_panel);
490 lv_image_set_src(hint_left, &img_chat_icon);
491 lv_image_set_scale(hint_left, 200);
492 lv_obj_set_width(hint_left, LV_SIZE_CONTENT);
493 lv_obj_set_height(hint_left, LV_SIZE_CONTENT);
494 lv_obj_set_align(hint_left, LV_ALIGN_LEFT_MID);
495 lv_obj_remove_flag(hint_left, LV_OBJ_FLAG_SCROLLABLE);
496 lv_obj_remove_flag(hint_left, LV_OBJ_FLAG_CLICKABLE);
497 lv_obj_set_style_radius(hint_left, 5, LV_PART_MAIN | LV_STATE_DEFAULT);
498 lv_obj_set_style_bg_color(hint_left, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
499 lv_obj_set_style_bg_opa(hint_left, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
500
501 hint_right = lv_image_create(hint_panel);
502 lv_image_set_src(hint_right, &img_application_icon);
503 lv_image_set_scale(hint_right, 200);
504 lv_obj_set_width(hint_right, LV_SIZE_CONTENT);
505 lv_obj_set_height(hint_right, LV_SIZE_CONTENT);
506 lv_obj_set_align(hint_right, LV_ALIGN_RIGHT_MID);
507 lv_obj_remove_flag(hint_right, LV_OBJ_FLAG_SCROLLABLE);
508 lv_obj_remove_flag(hint_right, LV_OBJ_FLAG_CLICKABLE);
509 lv_obj_set_style_radius(hint_right, 5, LV_PART_MAIN | LV_STATE_DEFAULT);
510 lv_obj_set_style_bg_color(hint_right, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT);
511 lv_obj_set_style_bg_opa(hint_right, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
512 }
513
514 #endif /*LV_USE_DEMO_SMARTWATCH*/
515