1 /** 2 * @file lv_demo_smartwatch.h 3 * 4 */ 5 6 #ifndef LV_DEMO_SMARTWATCH_H 7 #define LV_DEMO_SMARTWATCH_H 8 9 #ifdef __cplusplus 10 extern "C" 11 { 12 #endif 13 14 /********************* 15 * INCLUDES 16 *********************/ 17 #include "../../lvgl.h" 18 19 20 #if LV_USE_DEMO_SMARTWATCH 21 22 /*Testing of dependencies*/ 23 #if LV_FONT_MONTSERRAT_16 == 0 24 #error "LV_FONT_MONTSERRAT_16 text support is required. Enable it in lv_conf.h (LV_FONT_MONTSERRAT_16 1)" 25 #endif 26 #if LV_FONT_MONTSERRAT_20 == 0 27 #error "LV_FONT_MONTSERRAT_20 text support is required. Enable it in lv_conf.h (LV_FONT_MONTSERRAT_20 1)" 28 #endif 29 #if LV_FONT_MONTSERRAT_46 == 0 30 #error "LV_FONT_MONTSERRAT_46 text support is required. Enable it in lv_conf.h (LV_FONT_MONTSERRAT_46 1)" 31 #endif 32 #if LV_FONT_MONTSERRAT_48 == 0 33 #error "LV_FONT_MONTSERRAT_48 text support is required. Enable it in lv_conf.h (LV_FONT_MONTSERRAT_48 1)" 34 #endif 35 #if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN && LV_MEM_SIZE < 150 * 1024 36 #error "It's recommended to have at least 150kB RAM for the smartwatch demo, increase LV_MEM_SIZE" 37 #endif 38 39 /********************* 40 * DEFINES 41 *********************/ 42 43 44 /********************** 45 * TYPEDEFS 46 **********************/ 47 48 typedef void (*lv_smartwatch_music_control_cb_t)(uint16_t); 49 50 typedef void (*lv_smartwatch_notification_click_cb_t)(uint16_t); 51 52 typedef void (*lv_smartwatch_settings_change_cb_t)(uint16_t, uint64_t); 53 54 /********************** 55 * GLOBAL PROTOTYPES 56 **********************/ 57 58 /** 59 * Create a smartwatch demo. 60 */ 61 void lv_demo_smartwatch(void); 62 63 /** 64 * Function to show dialogs 65 * @param title dialog title 66 * @param message dialog message 67 */ 68 void lv_demo_smartwatch_show_dialog(const char * title, const char * message); 69 70 /** 71 * Load the home screen 72 * @param anim_type screen load animation to use 73 * @param time animation time 74 * @param delay delay time before loading the screen 75 */ 76 void lv_demo_smartwatch_home_load(lv_screen_load_anim_t anim_type, uint32_t time, uint32_t delay); 77 78 /** 79 * Get the tileview object 80 * @return pointer to the tileview object 81 */ 82 lv_obj_t * lv_demo_smartwatch_get_tileview(void); 83 84 /** 85 * Get the home tile object that holds the watchfaces 86 * @return pointer to the home tile object 87 */ 88 lv_obj_t * lv_demo_smartwatch_get_tile_home(void); 89 90 /** 91 * Update the position of animated analog seconds 92 * @param second the current seconds position 93 */ 94 void lv_demo_smartwatch_face_update_seconds(int second); 95 96 /** 97 * External apps call this function to return to the app list 98 */ 99 void lv_demo_smartwatch_app_close(void); 100 101 /** 102 * Function to load watchface 103 * @param index position of the watchface 104 * @return whether success or not (unsuccessful means watchface at index was not found) 105 */ 106 bool lv_demo_smartwatch_face_load(uint16_t index); 107 108 /** 109 * Load the home screen watchface view 110 */ 111 void lv_demo_smartwatch_load_home_watchface(void); 112 113 /** 114 * Update time on the default watchface 115 * @param minute minute 116 * @param hour hour 117 * @param am_pm am/pm label 118 * @param date day of month 119 * @param month month label 120 * @param weekday day of the week 121 */ 122 void lv_demo_smartwatch_home_set_time(int minute, int hour, const char * am_pm, int date, const char * month, 123 const char * weekday); 124 125 /** 126 * Function to send watchface events 127 * @param e event 128 */ 129 void lv_demo_smartwatch_face_events_cb(lv_event_t * e); 130 131 /** 132 * Register external watchfaces 133 * @param name name of the app 134 * @param preview preview image of the watchface (180x180) 135 * @param watchface pointer to main object of the watchface 136 * @param seconds pointer to analog seconds object. Used for smooth analog seconds animation 137 */ 138 void lv_demo_smartwatch_register_watchface_cb(const char * name, const lv_image_dsc_t * preview, lv_obj_t ** watchface, 139 lv_obj_t ** seconds); 140 141 /** 142 * Get pointer to the current watchface root object 143 * @return pointer to root object 144 */ 145 lv_obj_t * lv_demo_smartwatch_face_get_current(void); 146 147 /** 148 * Register external apps 149 * @param name name of the app 150 * @param icon launcher icon of the app (64x64) 151 * @param entry pointer to main object of the app 152 */ 153 void lv_demo_smartwatch_register_app_cb(const char * name, const lv_image_dsc_t * icon, lv_obj_t ** entry); 154 155 /** 156 * Clear the notification list 157 */ 158 void lv_demo_smartwatch_clear_notifications(void); 159 160 /** 161 * Add a notification to the list 162 * @param app_id id of the app sending the notification (sets icon from the inbuilt icon list) 163 * @param message the notification message preview 164 * @param index position of the message that will be returned when clicked 165 */ 166 void lv_demo_smartwatch_add_notification(int app_id, const char * message, int index); 167 168 /** 169 * Show a specific notification when in the notification screen 170 * @param app_id id of the app sending the notification (sets icon from the inbuilt icon list) 171 * @param message the notification message content 172 * @param time the notification time 173 */ 174 void lv_demo_smartwatch_show_notification(int app_id, const char * message, const char * time); 175 176 /** 177 * Set the callback function when a notification is clicked 178 * @param cb callback function 179 */ 180 void lv_demo_smartwatch_set_notification_click_cb(lv_smartwatch_notification_click_cb_t cb); 181 182 /** 183 * Set the callback function for settings actions 184 * @param cb callback function 185 */ 186 void lv_demo_smartwatch_set_settings_actions_cb(lv_smartwatch_settings_change_cb_t cb); 187 188 /** 189 * Set the callback function for music control 190 * @param cb callback function 191 */ 192 void lv_demo_smartwatch_set_music_control_cb(lv_smartwatch_music_control_cb_t cb); 193 194 /** 195 * Set the current weather 196 * @param temp current temp in °C 197 * @param icon weather icon to use (0-7) 198 * @param day whether day or night (changes the icon) 199 * @param hour last update hour of the weather 200 * @param minute last update minute of the weather 201 * @param city the current city of the weather 202 */ 203 void lv_demo_smartwatch_set_weather(int temp, uint8_t icon, bool day, int hour, int minute, const char * city); 204 205 /** 206 * Clear daily forecast list 207 */ 208 void lv_demo_smartwatch_weather_daily_clear(void); 209 210 /** 211 * Clear hourly forecast list 212 */ 213 void lv_demo_smartwatch_weather_hourly_clear(void); 214 215 /** 216 * Add daily forecast weather to the list 217 * @param day day of the week (0-7) 218 * @param temp temp in °C 219 * @param id weather icon to use (0-7) 220 */ 221 void lv_demo_smartwatch_weather_add_daily(int day, int temp, int id); 222 223 /** 224 * Add hourly forecast weather to the list 225 * @param hour hour oof the day (0-23) 226 * @param id weather icon to use (0-7) 227 * @param temp temp in °C 228 * @param humidity relative humidity % 229 * @param wind wind speed in km/hr 230 * @param uv uv index 231 * @param info item type (use true when adding forecast details, false adds it as a title row) 232 */ 233 void lv_demo_smartwatch_weather_add_hourly(int hour, int id, int temp, int humidity, int wind, int uv, bool info); 234 235 /** 236 * Clear the qr codes in the list 237 */ 238 void lv_demo_smartwatch_qr_list_clear(void); 239 240 /** 241 * Add qr codes to the list 242 * @param id determines the icon and name of the qr from inbuilt list. Value (0-9) 243 * @param link link to be added as a qr code 244 */ 245 void lv_demo_smartwatch_qr_list_add(uint8_t id, const char * link); 246 247 /** 248 * Add a slider to the main settings list 249 * @param id unique id to track changes (recommended > 0x000F) 250 * @param name title for the setting 251 * @param img icon for the setting 252 * @param value default value for the slider 253 * @param min min value for the slider 254 * @param max max value for the slider 255 * @return pointer to slider object 256 */ 257 lv_obj_t * lv_demo_smartwatch_settings_add_slider(uint16_t id, const char * name, const lv_img_dsc_t * img, 258 int32_t value, 259 int32_t min, int32_t max); 260 261 /** 262 * Add a toggle switch to the main settings list 263 * @param id unique id to track changes (recommended > 0x000F) 264 * @param name title for the setting 265 * @param img icon for the setting 266 * @param state default state for the switch 267 * @return pointer to switch object 268 */ 269 lv_obj_t * lv_demo_smartwatch_settings_add_toggle(uint16_t id, const char * name, const lv_img_dsc_t * img, bool state); 270 271 /** 272 * Add a dropdowwn to the main settings list 273 * @param id unique id to track changes (recommended > 0x000F) 274 * @param name title for the setting 275 * @param img icon for the setting 276 * @param options the dropdown options 277 * @return pointer to dropdown object 278 */ 279 lv_obj_t * lv_demo_smartwatch_settings_add_dropdown(uint16_t id, const char * name, const lv_img_dsc_t * img, 280 const char * options); 281 282 /** 283 * Add a label to the main settings list 284 * @param id unique id to track changes (recommended > 0x000F) 285 * @param name text for the label 286 * @param img icon for the label 287 * @return pointer to label object 288 */ 289 lv_obj_t * lv_demo_smartwatch_settings_add_label(uint16_t id, const char * name, const lv_img_dsc_t * img); 290 291 /** 292 * Set the default scrollbar mode for the smartwatch demo 293 * @param mode scrollbar mode 294 */ 295 void lv_demo_smartwatch_set_default_scrollbar_mode(lv_scrollbar_mode_t mode); 296 297 /** 298 * Set the default brightness for the smartwatch demo settings 299 * @param brightness default brightness value 300 */ 301 void lv_demo_smartwatch_set_default_brightness(uint8_t brightness); 302 303 /** 304 * Set the default timeout for the smartwatch demo settings 305 * @param timeout default timeout value (0-4) 306 */ 307 void lv_demo_smartwatch_set_default_timeout(uint8_t timeout); 308 309 /** 310 * Set the default rotation for the smartwatch demo settings 311 * @param rotation default rotation value (0-3) 312 */ 313 void lv_demo_smartwatch_set_default_rotation(uint8_t rotation); 314 315 /** 316 * Set the default circular scroll for the smartwatch demo settings 317 * @param enabled whether circular scroll is enabled 318 */ 319 void lv_demo_smartwatch_set_default_circular_scroll(bool enabled); 320 321 /** 322 * Set the default alert state for the smartwatch demo settings 323 * @param enabled whether alerts are enabled 324 */ 325 void lv_demo_smartwatch_set_default_alert_state(bool enabled); 326 327 /** 328 * Set the default hints state for the smartwatch demo settings 329 * @param enabled whether hints are enabled 330 */ 331 void lv_demo_smartwatch_set_default_hints_state(bool enabled); 332 333 /** 334 * Get the hint state 335 * @return hint state 336 */ 337 bool lv_demo_smartwatch_get_scroll_hint(void); 338 339 /** 340 * Set the default about info for the smartwatch demo settings 341 * @param info about info text 342 */ 343 void lv_demo_smartwatch_set_default_about_info(const char * info); 344 345 /** 346 * Show the scroll direction hint 347 * @param dir direction of available scroll 348 */ 349 void lv_demo_smartwatch_show_scroll_hint(lv_dir_t dir); 350 351 /** 352 * Show the scroll direction hint 353 * @param state whether to show the hint 354 */ 355 void lv_demo_smartwatch_show_home_hint(bool state); 356 357 /** 358 * Set whether to show scroll hints 359 * @param state whether to show scroll hints 360 */ 361 void lv_demo_smartwatch_set_scroll_hint(bool state); 362 363 /********************** 364 * GLOBAL VARIABLES 365 **********************/ 366 367 /********************** 368 * MACROS 369 **********************/ 370 371 #endif /*LV_USE_DEMO_SMARTWATCH*/ 372 373 #ifdef __cplusplus 374 } /*extern "C"*/ 375 #endif 376 377 #endif /*LV_DEMO_SMARTWATCH_H*/ 378