#include "ui.h" #include "ui_helpers.h" #include "bsp.h" #include "dbversion.h" #ifdef ENABLE_FACE_75_2_DIAL #include "./faces/75_2_dial/75_2_dial.h" #endif #ifdef ENABLE_FACE_SMART_RESIZED #include "./faces/smart_resized/smart_resized.h" #endif #include "watchMenu.h" #include "main_alipay.h" #define EPAT_LOG(subId, debugLevel, format, ...) \ ECPLAT_PRINTF(UNILOG_LVGL, subId, debugLevel, format, ##__VA_ARGS__) char *ui_settings_EN[8] = { "Settings", "Screen Brightness", "Circular Scroll", "Screen Timeout", "Show Alerts", "Language" }; char *ui_settings_CN[8] = { "设置", "屏幕亮度", "环形滚动", "息屏时间", "显示告警", "语言" }; ui_label_t call_label = { .numstr = " ", .name = "呼叫中", .icon = "D:/ui_img_answer.png", .button = "结束" }; ui_label_t ring_label = { .numstr = "10086", .name = "测试", .icon = "D:/ui_img_ring.png", .button = "接听" }; ui_language_label_t watch_lable; lv_font_t *pFontNumber = NULL; lv_font_t *pFontExtern_28 = NULL; lv_font_t *pFontExtern_48 = NULL; ///////////////////// VARIABLES //////////////////// void pulseCall_Animation(lv_obj_t *TargetObject, int delay); void analogSecond_Animation(lv_obj_t * TargetObject, int delay); lv_anim_t secondsAnimation_0; void ui_event_clockScreen(lv_event_t *e); lv_obj_t *ui_clockScreen; lv_obj_t *ui_hourLabel; lv_obj_t *ui_minuteLabel; lv_obj_t *ui_dateLabel; lv_obj_t *ui_weatherIcon; lv_obj_t *ui_weatherTemp; lv_obj_t *ui_dayLabel; lv_obj_t *ui_amPmLabel; void ui_event_alertPanel(lv_event_t *e); lv_obj_t *ui_alertPanel; lv_obj_t *ui_alertIcon; lv_obj_t *ui_alertText; void ui_event_weatherScreen(lv_event_t *e); lv_obj_t *ui_weatherScreen; lv_obj_t *ui_weatherPanel; lv_obj_t *ui_weatherCity; lv_obj_t *ui_weatherCurrentIcon; lv_obj_t *ui_weatherCurrentTemp; lv_obj_t *ui_weatherUpdateTime; lv_obj_t *ui_forecastPanel; lv_obj_t *ui_forecastTitle; lv_obj_t *ui_forecastList; void ui_event_appListScreen(lv_event_t *e); lv_obj_t *ui_appListScreen; lv_obj_t *ui_appList; void ui_event_gameListScreen(lv_event_t *e); lv_obj_t *ui_gameListScreen; lv_obj_t *ui_gameList; void ui_event_notificationScreen(lv_event_t *e); lv_obj_t *ui_notificationScreen; lv_obj_t *ui_messagePanel; lv_obj_t *ui_messageIcon; lv_obj_t *ui_messageTime; lv_obj_t *ui_messageContent; lv_obj_t *ui_messageList; void ui_event_settingsScreen(lv_event_t *e); lv_obj_t *ui_settingsScreen; lv_obj_t *ui_settingsList; lv_obj_t *ui_settingsTitle; lv_obj_t *ui_brightnessPanel; void ui_event_brightnessSlider(lv_event_t *e); lv_obj_t *ui_brightnessSlider; lv_obj_t *ui_brightnessIcon; lv_obj_t *ui_brightnessLabel; lv_obj_t *ui_scrollingPanel; lv_obj_t *ui_icon_scrolling; void ui_event_scrollMode(lv_event_t *e); lv_obj_t *ui_Switch2; lv_obj_t *ui_scrollLabel; lv_obj_t *ui_timeoutPanel; void ui_event_alertStateSwitch(lv_event_t *e); lv_obj_t *ui_alertStateLabel; lv_obj_t *ui_alertStateSwitch; lv_obj_t *ui_alertStateIcon; lv_obj_t *ui_alertStatePanel; void ui_event_timeoutSelect(lv_event_t *e); lv_obj_t *ui_timeoutSelect; lv_obj_t *ui_timeoutIcon; lv_obj_t *ui_timeoutLabel; lv_obj_t *ui_languagePanel; void ui_event_languageSelect(lv_event_t *e); lv_obj_t *ui_languageSelect; lv_obj_t *ui_languageIcon; lv_obj_t *ui_languageLabel; lv_obj_t *ui_batteryPanel; void ui_event_batterySlider(lv_event_t *e); lv_obj_t *ui_batterySlider; lv_obj_t *ui_batteryIcon; lv_obj_t *ui_batteryLabel; lv_obj_t *ui_aboutPanel; lv_obj_t *ui_aboutIcon; lv_obj_t *ui_aboutText; void ui_event_kenyaPanel(lv_event_t *e); lv_obj_t *ui_kenyaPanel; lv_obj_t *ui_kenyaIcon; lv_obj_t *ui_kenyaText; void ui_event_screen_control(lv_event_t *e); lv_obj_t *ui_controlScreen; lv_obj_t *ui_controlTitle; void ui_event_musicPlayButton(lv_event_t *e); lv_obj_t *ui_musicPlayButton; void ui_event_musicPrevButton(lv_event_t *e); lv_obj_t *ui_musicPrevButton; void ui_event_musicNextButton(lv_event_t *e); lv_obj_t *ui_musicNextButton; lv_obj_t *ui_btStateButton; lv_obj_t *ui_searchPanel; void ui_event_button_reserve(lv_event_t *e); lv_obj_t *ui_reserveButton; lv_obj_t *ui_volumeUpButton; lv_obj_t *ui_volumeDownButton; void ui_event_button_dial(lv_event_t *e); lv_obj_t *ui_icon_btn_dial; void ui_event_appInfoScreen(lv_event_t *e); lv_obj_t *ui_appInfoScreen; lv_obj_t *ui_appInfoPanel; lv_obj_t *ui_appInfoTitle; lv_obj_t *ui_appDetailsPanel; lv_obj_t *ui_appDetailsIcon; lv_obj_t *ui_appDetailsText; lv_obj_t *ui_appConnectionPanel; lv_obj_t *ui_appConnectionIcon; lv_obj_t *ui_appConnectionText; lv_obj_t *ui_appBatteryPanel; lv_obj_t *ui_appBatteryIcon; lv_obj_t *ui_appBatteryText; lv_obj_t *ui_appBatteryLevel; void ui_event_screen_dialpad(lv_event_t *e); lv_obj_t *ui_dialpadScreen; lv_obj_t *ui_dialpadLabel; lv_obj_t *ui_dialMatrix; void ui_event_screen_call(lv_event_t *e); lv_obj_t *ui_callScreen; lv_obj_t *ui_callNumber; lv_obj_t *ui_callLabel; lv_obj_t *ui_callButton; lv_obj_t *ui_callButtonText; lv_obj_t *ui_callIcon; lv_obj_t *ui_callPanel; void ui_event_screen_ringing(lv_event_t *e); lv_obj_t *ui_ringScreen; lv_obj_t *ui_ringIcon; lv_obj_t *ui_ringButton; lv_obj_t *ui_ringButtonText; lv_obj_t *ui_ringNumber; lv_obj_t *ui_ringName; lv_obj_t *ui_cameraScreen; lv_obj_t *ui_cameraPanel; lv_obj_t *ui_cameraTitle; lv_obj_t *ui_cameraIcon; lv_obj_t *ui_cameraLabel; lv_obj_t *ui_cameraButton; lv_obj_t *ui_cameraButtonLabel; void ui_filesScreen_screen_init(void); lv_obj_t *ui_filesScreen; lv_obj_t *ui_fileManagerPanel; lv_obj_t *ui_driveInfoPanel; lv_obj_t *ui_driveInfoIcon; lv_obj_t *ui_driveInfoLabel; lv_obj_t *ui_driveInfoBar; lv_obj_t *ui_fileInfoPanel; lv_obj_t *ui_fileInfoIcon; lv_obj_t *ui_fileInfoName; lv_obj_t *ui_fileInfoSize; lv_obj_t *ui_folderInfoPanel; lv_obj_t *ui_folderInfoIcon; lv_obj_t *ui_folderInfoName; lv_obj_t *ui_driveBackPanel; lv_obj_t *ui_driveBackIcon; lv_obj_t *ui_driveBackLabel; lv_obj_t *ui_errorWindow; lv_obj_t *ui_errorPanel; lv_obj_t *ui_errorTitle; lv_obj_t *ui_errorMessage; void ui_event_errorClose(lv_event_t *e); lv_obj_t *ui_errorClose; lv_obj_t *ui_errorCloseText; lv_obj_t *ui_home; lv_obj_t *ui_game; lv_obj_t *ui_faceSelect; lv_obj_t *face_custom_root; bool isRinging; bool toAppList; // flag open from app list bool circular; int numFaces; int numGames; int currentIndex; void ui_event____initial_actions0(lv_event_t *e); lv_obj_t *ui____initial_actions0; Face faces[MAX_FACES]; Face games[MAX_GAMES]; Drag logoEv; void registerWatchface_cb(const char *name, const lv_img_dsc_t *preview, lv_obj_t **watchface); void addNotificationList(int appId, const char *message, int index); void addForecast(int day, int temp, int icon); void setWeatherIcon(lv_obj_t *obj, int id, bool day); void setNotificationIcon(lv_obj_t *obj, int appId); void ui_update_watchfaces(int second, int minute, int hour, bool mode, bool am, int day, int month, int year, int weekday, int temp, int icon, int battery, bool connection, int steps, int distance, int kcal, int bpm, int oxygen); void addListDrive(const char *name, int total, int used, lv_event_cb_t event_cb); void addListDir(const char *name); void addListFile(const char *name, int size); void addListBack(lv_event_cb_t event_cb); void addSelectItem(lv_obj_t *parent); const lv_img_dsc_t *notificationIcons[] = { "D:/ui_img_sms.png", // SMS "D:/ui_img_mail.png", // Mail "D:/ui_img_weibo.png", // Weibo "D:/ui_img_wechat.png" // Wechat }; const char *days[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}; ///////////////////// TEST LVGL SETTINGS //////////////////// #if LV_COLOR_DEPTH != 16 #error "LV_COLOR_DEPTH should be 16bit to match SquareLine Studio's settings" #endif ///////////////////// ANIMATIONS //////////////////// void pulseCall_Animation(lv_obj_t *TargetObject, int delay) { ui_anim_user_data_t *PropertyAnimation_0_user_data = lv_mem_alloc(sizeof(ui_anim_user_data_t)); PropertyAnimation_0_user_data->target = TargetObject; PropertyAnimation_0_user_data->val = -1; lv_anim_t PropertyAnimation_0; lv_anim_init(&PropertyAnimation_0); lv_anim_set_time(&PropertyAnimation_0, 1000); lv_anim_set_user_data(&PropertyAnimation_0, PropertyAnimation_0_user_data); lv_anim_set_custom_exec_cb(&PropertyAnimation_0, _ui_anim_callback_set_image_zoom); lv_anim_set_values(&PropertyAnimation_0, 0, 100); lv_anim_set_path_cb(&PropertyAnimation_0, lv_anim_path_ease_out); lv_anim_set_delay(&PropertyAnimation_0, delay + 0); lv_anim_set_deleted_cb(&PropertyAnimation_0, _ui_anim_callback_free_user_data); lv_anim_set_playback_time(&PropertyAnimation_0, 1000); lv_anim_set_playback_delay(&PropertyAnimation_0, 0); lv_anim_set_repeat_count(&PropertyAnimation_0, LV_ANIM_REPEAT_INFINITE); lv_anim_set_repeat_delay(&PropertyAnimation_0, 0); lv_anim_set_early_apply(&PropertyAnimation_0, false); lv_anim_set_get_value_cb(&PropertyAnimation_0, &_ui_anim_callback_get_image_zoom); lv_anim_start(&PropertyAnimation_0); ui_anim_user_data_t *PropertyAnimation_1_user_data = lv_mem_alloc(sizeof(ui_anim_user_data_t)); PropertyAnimation_1_user_data->target = TargetObject; PropertyAnimation_1_user_data->val = -1; lv_anim_t PropertyAnimation_1; lv_anim_init(&PropertyAnimation_1); lv_anim_set_time(&PropertyAnimation_1, 2000); lv_anim_set_user_data(&PropertyAnimation_1, PropertyAnimation_1_user_data); lv_anim_set_custom_exec_cb(&PropertyAnimation_1, _ui_anim_callback_set_y); lv_anim_set_values(&PropertyAnimation_1, 0, 20); lv_anim_set_path_cb(&PropertyAnimation_1, lv_anim_path_ease_out); lv_anim_set_delay(&PropertyAnimation_1, delay + 0); lv_anim_set_deleted_cb(&PropertyAnimation_1, _ui_anim_callback_free_user_data); lv_anim_set_playback_time(&PropertyAnimation_1, 2000); lv_anim_set_playback_delay(&PropertyAnimation_1, 0); lv_anim_set_repeat_count(&PropertyAnimation_1, LV_ANIM_REPEAT_INFINITE); lv_anim_set_repeat_delay(&PropertyAnimation_1, 0); lv_anim_set_early_apply(&PropertyAnimation_1, false); lv_anim_set_get_value_cb(&PropertyAnimation_1, &_ui_anim_callback_get_y); lv_anim_start(&PropertyAnimation_1); } /** \fn \brief \return */ void findPhone_Animation(lv_obj_t *TargetObject, int delay) { ui_anim_user_data_t *PropertyAnimation_0_user_data = lv_mem_alloc(sizeof(ui_anim_user_data_t)); PropertyAnimation_0_user_data->target = TargetObject; PropertyAnimation_0_user_data->val = -1; lv_anim_t PropertyAnimation_0; lv_anim_init(&PropertyAnimation_0); lv_anim_set_time(&PropertyAnimation_0, 500); lv_anim_set_user_data(&PropertyAnimation_0, PropertyAnimation_0_user_data); lv_anim_set_custom_exec_cb(&PropertyAnimation_0, _ui_anim_callback_set_width); lv_anim_set_values(&PropertyAnimation_0, 64, 110); lv_anim_set_path_cb(&PropertyAnimation_0, lv_anim_path_linear); lv_anim_set_delay(&PropertyAnimation_0, delay + 0); lv_anim_set_deleted_cb(&PropertyAnimation_0, _ui_anim_callback_free_user_data); lv_anim_set_playback_time(&PropertyAnimation_0, 500); lv_anim_set_playback_delay(&PropertyAnimation_0, 0); lv_anim_set_repeat_count(&PropertyAnimation_0, LV_ANIM_REPEAT_INFINITE); lv_anim_set_repeat_delay(&PropertyAnimation_0, 0); lv_anim_set_early_apply(&PropertyAnimation_0, false); lv_anim_start(&PropertyAnimation_0); ui_anim_user_data_t *PropertyAnimation_1_user_data = lv_mem_alloc(sizeof(ui_anim_user_data_t)); PropertyAnimation_1_user_data->target = TargetObject; PropertyAnimation_1_user_data->val = -1; lv_anim_t PropertyAnimation_1; lv_anim_init(&PropertyAnimation_1); lv_anim_set_time(&PropertyAnimation_1, 500); lv_anim_set_user_data(&PropertyAnimation_1, PropertyAnimation_1_user_data); lv_anim_set_custom_exec_cb(&PropertyAnimation_1, _ui_anim_callback_set_height); lv_anim_set_values(&PropertyAnimation_1, 64, 110); lv_anim_set_path_cb(&PropertyAnimation_1, lv_anim_path_linear); lv_anim_set_delay(&PropertyAnimation_1, delay + 0); lv_anim_set_deleted_cb(&PropertyAnimation_1, _ui_anim_callback_free_user_data); lv_anim_set_playback_time(&PropertyAnimation_1, 500); lv_anim_set_playback_delay(&PropertyAnimation_1, 0); lv_anim_set_repeat_count(&PropertyAnimation_1, LV_ANIM_REPEAT_INFINITE); lv_anim_set_repeat_delay(&PropertyAnimation_1, 0); lv_anim_set_early_apply(&PropertyAnimation_1, false); lv_anim_start(&PropertyAnimation_1); } /** \fn \brief \return */ void analogSecond_Animation(lv_obj_t * TargetObject, int delay) { ui_anim_user_data_t * secondsAnimation_0_user_data = lv_mem_alloc(sizeof(ui_anim_user_data_t)); secondsAnimation_0_user_data->target = TargetObject; secondsAnimation_0_user_data->val = -1; lv_anim_init(&secondsAnimation_0); lv_anim_set_time(&secondsAnimation_0, 60000); lv_anim_set_user_data(&secondsAnimation_0, secondsAnimation_0_user_data); lv_anim_set_custom_exec_cb(&secondsAnimation_0, _ui_anim_callback_set_image_angle); lv_anim_set_values(&secondsAnimation_0, 0, 3600); lv_anim_set_path_cb(&secondsAnimation_0, lv_anim_path_linear); lv_anim_set_delay(&secondsAnimation_0, delay + 0); lv_anim_set_deleted_cb(&secondsAnimation_0, _ui_anim_callback_free_user_data); lv_anim_set_playback_time(&secondsAnimation_0, 0); lv_anim_set_playback_delay(&secondsAnimation_0, 0); lv_anim_set_repeat_count(&secondsAnimation_0, LV_ANIM_REPEAT_INFINITE); lv_anim_set_repeat_delay(&secondsAnimation_0, 0); lv_anim_set_early_apply(&secondsAnimation_0, false); lv_anim_set_get_value_cb(&secondsAnimation_0, &_ui_anim_callback_get_image_angle); lv_anim_start(&secondsAnimation_0); } ///////////////////// FUNCTIONS //////////////////// void ui_event____initial_actions0(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_SCREEN_LOAD_START) { pulseCall_Animation(ui_ringIcon, 0); findPhone_Animation(ui_callPanel, 0); } } /** \fn \brief \return */ void ui_event_clockScreen(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_RIGHT) { toAppList = false; // flag was not open from app list _ui_screen_change(ui_notificationScreen, LV_SCR_LOAD_ANIM_OVER_RIGHT, 500, 0); } if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_LEFT) { _ui_screen_change(ui_appListScreen, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0); } if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_BOTTOM) { _ui_screen_change(ui_controlScreen, LV_SCR_LOAD_ANIM_MOVE_BOTTOM, 500, 0); } if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_TOP) { toAppList = false; // flag was not open from app list _ui_screen_change(ui_weatherScreen, LV_SCR_LOAD_ANIM_MOVE_TOP, 500, 0); } if (event_code == LV_EVENT_SCREEN_LOAD_START) { onLoadHome(e); } if (event_code == LV_EVENT_LONG_PRESSED) { // ui_home = ui_pcbScreen; // _ui_screen_change(ui_home, LV_SCR_LOAD_ANIM_FADE_ON, 500, 0); onWatchfaceChange(e); } } /** \fn \brief \return */ void ui_event_appListScreen(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_RIGHT) { _ui_screen_change(ui_home, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0); } } /** \fn \brief \return */ void ui_event_gameListScreen(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_RIGHT) { _ui_screen_change(ui_appListScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0); } } /** \fn \brief \return */ #if 0 void ui_event_alertPanel(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_CLICKED) { onClickAlert(e); _ui_flag_modify(ui_alertPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD); } if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_LEFT) { _ui_flag_modify(ui_alertPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD); } } #endif /** \fn \brief \return */ void ui_event_weatherScreen(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_BOTTOM) { if (toAppList) { // do nothing } else { _ui_screen_change(ui_home, LV_SCR_LOAD_ANIM_MOVE_BOTTOM, 500, 0); // load home } } if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_LEFT) { _ui_flag_modify(ui_weatherPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD); _ui_flag_modify(ui_forecastPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE); onForecastOpen(e); } if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_RIGHT) { if (!lv_obj_has_flag(ui_weatherPanel, LV_OBJ_FLAG_HIDDEN)) { if (toAppList) { _ui_screen_change(ui_appListScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0); return; } } _ui_flag_modify(ui_weatherPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE); _ui_flag_modify(ui_forecastPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD); } if (event_code == LV_EVENT_SCREEN_LOAD_START) { onWeatherLoad(e); } } void ui_event_notificationScreen(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_LEFT) { if (lv_obj_has_flag(ui_messageList, LV_OBJ_FLAG_HIDDEN)) { _ui_flag_modify(ui_messageList, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE); _ui_flag_modify(ui_messagePanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD); } else { _ui_flag_modify(ui_messageList, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE); _ui_flag_modify(ui_messagePanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD); if (toAppList) { } else { _ui_screen_change(ui_home, LV_SCR_LOAD_ANIM_FADE_ON, 500, 0); } } } if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_RIGHT) { if (toAppList) { if (!lv_obj_has_flag(ui_messageList, LV_OBJ_FLAG_HIDDEN)) { _ui_screen_change(ui_appListScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0); return; } } _ui_flag_modify(ui_messagePanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD); _ui_flag_modify(ui_messageList, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE); } if (event_code == LV_EVENT_SCREEN_LOAD_START) { onNotificationsOpen(e); } } void ui_event_settingsScreen(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_RIGHT) { _ui_screen_change(ui_appListScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0); } } void ui_event_appInfoScreen(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_RIGHT) { _ui_screen_change(ui_appListScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0); } } /** \fn \brief \return */ void ui_event_screen_ringing(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_RIGHT) { _ui_screen_change(ui_home, LV_SCR_LOAD_ANIM_FADE_OUT, 500, 0); onHangUp(); // LV_LOG_WARN("%d",event_code); } if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_TOP) { onHangUp(); if (toAppList) { _ui_screen_change(ui_appListScreen, LV_SCR_LOAD_ANIM_MOVE_TOP, 500, 0); } else { _ui_screen_change(ui_controlScreen, LV_SCR_LOAD_ANIM_MOVE_TOP, 500, 0); } // LV_LOG_USER("%d",event_code); } } /** \fn \brief \return */ void ui_event_screen_camera(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); // lv_obj_t *target = lv_event_get_target(e); // LV_LOG_WARN("--%d,%d",event_code,lv_indev_get_gesture_dir(lv_indev_get_act())); if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_TOP) { if (toAppList) { _ui_screen_change(ui_appListScreen, LV_SCR_LOAD_ANIM_MOVE_TOP, 500, 0); } else { _ui_screen_change(ui_controlScreen, LV_SCR_LOAD_ANIM_MOVE_TOP, 500, 0); } } } /** \fn \brief \return */ void ui_event_screen_dialpad(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_TOP) { if (toAppList) // flag was open from app list { _ui_screen_change(ui_appListScreen, LV_SCR_LOAD_ANIM_MOVE_TOP, 500, 0); } else { _ui_screen_change(ui_controlScreen, LV_SCR_LOAD_ANIM_MOVE_TOP, 500, 0); } LV_LOG_WARN("%d",event_code); } if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_RIGHT) { // _ui_screen_change(ui_home, LV_SCR_LOAD_ANIM_FADE_OUT, 500, 0); _ui_screen_change(ui_appListScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0); phone_text_index=0; memset(call_label.numstr,0,sizeof(call_label.numstr)); // LV_LOG_WARN("--%d",event_code); } } /** \fn \brief \return */ void ui_event_brightnessSlider(lv_event_t *e) { lv_disp_t *display = lv_disp_get_default(); lv_obj_t *actScr = lv_disp_get_scr_act(display); if (actScr != ui_settingsScreen) { return; } lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_VALUE_CHANGED) { onBrightnessChange(e); } } void ui_event_scrollMode(lv_event_t *e) { lv_disp_t *display = lv_disp_get_default(); lv_obj_t *actScr = lv_disp_get_scr_act(display); if (actScr != ui_settingsScreen) { return; } lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_VALUE_CHANGED) { circular = lv_obj_has_state(target, LV_STATE_CHECKED); lv_obj_scroll_by(ui_settingsList, 0, circular ? 1 : -1, LV_ANIM_ON); lv_obj_scroll_by(ui_appList, 0, circular ? 1 : -1, LV_ANIM_OFF); lv_obj_scroll_by(ui_messageList, 0, circular ? 1 : -1, LV_ANIM_OFF); lv_obj_scroll_by(ui_appInfoPanel, 0, circular ? 1 : -1, LV_ANIM_OFF); lv_obj_scroll_by(ui_gameList, 0, circular ? 1 : -1, LV_ANIM_OFF); lv_obj_scroll_by(ui_fileManagerPanel, 0, circular ? 1 : -1, LV_ANIM_OFF); onScrollMode(e); } } void ui_event_alertStateSwitch(lv_event_t *e) { lv_disp_t *display = lv_disp_get_default(); lv_obj_t *actScr = lv_disp_get_scr_act(display); if (actScr != ui_settingsScreen) { return; } lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_VALUE_CHANGED) { onAlertState(e); } } /** \fn \brief \return */ void ui_event_timeoutSelect(lv_event_t *e) { lv_disp_t *display = lv_disp_get_default(); lv_obj_t *actScr = lv_disp_get_scr_act(display); if (actScr != ui_settingsScreen) { return; } lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_VALUE_CHANGED) { onTimeoutChange(e); } } /** \fn \brief \return */ void ui_event_languageSelect(lv_event_t *e) { lv_disp_t *display = lv_disp_get_default(); lv_obj_t *actScr = lv_disp_get_scr_act(display); if (actScr != ui_settingsScreen) { return; } lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_VALUE_CHANGED) { onLanguageChange(e); } } /** \fn \brief \return */ void ui_event_batterySlider(lv_event_t *e) { lv_disp_t *display = lv_disp_get_default(); lv_obj_t *actScr = lv_disp_get_scr_act(display); if (actScr != ui_settingsScreen) { return; } lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_VALUE_CHANGED) { _ui_slider_set_text_value(ui_batteryLabel, target, "电量 ", "%"); } if (event_code == LV_EVENT_RELEASED) { onBatteryChange(e); } } /** \fn \brief \return */ void ui_event_kenyaPanel(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_CLICKED) { _ui_screen_change(ui_appListScreen, LV_SCR_LOAD_ANIM_MOVE_TOP, 500, 0); } } /** \fn \brief \return */ void ui_event_screen_control(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_TOP) { _ui_screen_change(ui_home, LV_SCR_LOAD_ANIM_MOVE_TOP, 500, 0); // _ui_state_modify(ui_reserveButton, LV_STATE_CHECKED, _UI_MODIFY_STATE_ADD); // onRinging(); } if (event_code == LV_EVENT_SCREEN_UNLOAD_START) { // _ui_state_modify(ui_callButtonText, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE); // _ui_flag_modify(ui_searchPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD); } if(event_code < LV_EVENT_COVER_CHECK && event_code > LV_EVENT_DRAW_PART_END){ LV_LOG_USER("%d",event_code); } } /** \fn \brief \return */ void ui_event_musicPlayButton(lv_event_t *e) { lv_disp_t *display = lv_disp_get_default(); lv_obj_t *actScr = lv_disp_get_scr_act(display); if (actScr != ui_controlScreen) { return; } lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_CLICKED) { onMusicPlay(e); } } /** \fn \brief \return */ void ui_event_musicPrevButton(lv_event_t *e) { lv_disp_t *display = lv_disp_get_default(); lv_obj_t *actScr = lv_disp_get_scr_act(display); if (actScr != ui_controlScreen) { return; } lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_CLICKED) { onMusicPrevious(e); } } /** \fn \brief \return */ void ui_event_musicNextButton(lv_event_t *e) { lv_disp_t *display = lv_disp_get_default(); lv_obj_t *actScr = lv_disp_get_scr_act(display); if (actScr != ui_controlScreen) { return; } lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_CLICKED) { onMusicNext(e); } } /** \fn \brief \return */ void ui_event_screen_call(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_RIGHT) { toAppList = true; // flag was open from app list phone_text_index=0; memset(call_label.numstr,0,sizeof(call_label.numstr)); _ui_screen_change(ui_appListScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0); lv_label_set_text(ui_dialpadLabel, call_label.numstr); onHangUp(); } if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_BOTTOM) { toAppList = false; // flag was not open from app list phone_text_index=0; memset(call_label.numstr,0,sizeof(call_label.numstr)); _ui_screen_change(ui_appListScreen, LV_SCR_LOAD_ANIM_MOVE_BOTTOM, 500, 0); lv_label_set_text(ui_dialpadLabel, call_label.numstr); onHangUp(); // LV_LOG_USER("%d",event_code); } if (event_code == LV_EVENT_SCREEN_UNLOAD_START) { LV_LOG_USER("%d",event_code); phone_text_index=0; memset(call_label.numstr,0,sizeof(call_label.numstr)); // lv_label_set_text(ui_dialpadLabel, call_label.numstr); _ui_label_set_property(ui_dialpadLabel, _UI_LABEL_PROPERTY_TEXT, " "); // _ui_label_set_property(ui_callLabel, _UI_LABEL_PROPERTY_TEXT,watch_lable.dialing[3]); // _ui_label_set_property(ui_callButtonText, _UI_LABEL_PROPERTY_TEXT, watch_lable.dialing[0]); // _ui_state_modify(ui_callButton, LV_STATE_CHECKED, _UI_MODIFY_STATE_REMOVE); _ui_flag_modify(ui_callPanel, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_REMOVE); } } /** \fn \brief \return */ void ui_event_faceSelected(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); int index = (int)lv_event_get_user_data(e); if (target == ui_home) { return; } if (event_code == LV_EVENT_CLICKED) { if (index >= numFaces) { showError("Watchface Error", "Watchface out of bounds"); return; } if (currentIndex != index) { currentIndex = index; if (faces[index].custom) { onCustomFaceSelected(faces[index].customIndex); onFaceSelected(e); return; } else { ui_home = *faces[index].watchface; onCustomFaceSelected(-1); } } lv_scr_load_anim(ui_home, LV_SCR_LOAD_ANIM_FADE_ON, 500, 0, false); onFaceSelected(e); } } /** \fn \brief \return */ void ui_event_button_capture(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); // LV_LOG_WARN("--%d",event_code); if (event_code == LV_EVENT_CLICKED) { onCaptureClick(); } } /** \fn \brief \return */ void onAppListClicked(lv_event_t *e) { lv_disp_t *display = lv_disp_get_default(); lv_obj_t *actScr = lv_disp_get_scr_act(display); if (actScr != ui_appListScreen) { return; } int index = (int)lv_event_get_user_data(e); switch (index) { case 0: toAppList = true; // flag was open from app list _ui_screen_change(ui_notificationScreen, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0); break; case 1: toAppList = true; // flag was open from app list _ui_screen_change(ui_weatherScreen, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0); break; case 2: _ui_screen_change(ui_settingsScreen, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0); break; case 3: _ui_screen_change(ui_appInfoScreen, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0); break; case 4: toAppList = true; // flag was open from app list // extern aliAppInfo_t alipayInfo; // if(alipayInfo.status >= E_ALI_STA_BINDIND_SUCCESS) // _ui_screen_change(ui_alipayScreen,LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0); // else // _ui_screen_change(ui_bindCodeScreen,LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0); break; case 5: lv_obj_clean(ui_fileManagerPanel); addSelectItem(ui_fileManagerPanel); for (int i = 0; i < numFaces; i++) { addFaceList(ui_fileManagerPanel, faces[i]); } _ui_screen_change(ui_filesScreen, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0); break; case 6: toAppList = true; // flag was open from app list phone_text_index=0; memset(call_label.numstr,0,sizeof(call_label.numstr)); _ui_screen_change(ui_dialpadScreen, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0); break; case 7: toAppList = true; // flag was open from app list _ui_screen_change(ui_gameListScreen, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0); break; case 8: _ui_screen_change(ui_filesScreen, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0); break; } } /** \fn \brief \return */ static void onScroll(lv_event_t *e) { lv_obj_t *list = lv_event_get_target(e); lv_area_t list_a; lv_obj_get_coords(list, &list_a); lv_coord_t list_y_center = list_a.y1 + lv_area_get_height(&list_a) / 2; lv_coord_t r = lv_obj_get_height(list) * 7 / 10; uint32_t i; uint32_t child_cnt = lv_obj_get_child_cnt(list); for (i = 0; i < child_cnt; i++) { lv_obj_t *child = lv_obj_get_child(list, i); lv_area_t child_a; lv_obj_get_coords(child, &child_a); lv_coord_t child_y_center = child_a.y1 + lv_area_get_height(&child_a) / 2; lv_coord_t diff_y = child_y_center - list_y_center; diff_y = LV_ABS(diff_y); /*Get the x of diff_y on a circle.*/ lv_coord_t x; /*If diff_y is out of the circle use the last point of the circle (the radius)*/ if (diff_y >= r) { x = r; } else { /*Use Pythagoras theorem to get x from radius and y*/ uint32_t x_sqr = r * r - diff_y * diff_y; lv_sqrt_res_t res; lv_sqrt(x_sqr, &res, 0x8000); /*Use lvgl's built in sqrt root function*/ x = r - res.i; } /*Translate the item by the calculated X coordinate*/ lv_obj_set_style_translate_x(child, circular ? x : 0, 0); /*Use some opacity with larger translations*/ // lv_opa_t opa = lv_map(x, 0, r, LV_OPA_TRANSP, LV_OPA_COVER); // lv_obj_set_style_opa(child, LV_OPA_COVER - opa, 0); } } /** \fn \brief \return */ void watchfaceEvents(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_RIGHT) { toAppList = false; // flag was not open from app list lv_scr_load_anim(ui_notificationScreen, LV_SCR_LOAD_ANIM_OVER_RIGHT, 500, 0, false); } if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_LEFT) { lv_scr_load_anim(ui_appListScreen, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0, false); } if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_BOTTOM) { lv_scr_load_anim(ui_controlScreen, LV_SCR_LOAD_ANIM_MOVE_BOTTOM, 500, 0, false); } if (event_code == LV_EVENT_GESTURE && lv_indev_get_gesture_dir(lv_indev_get_act()) == LV_DIR_TOP) { toAppList = false; // flag was not open from app list lv_scr_load_anim(ui_weatherScreen, LV_SCR_LOAD_ANIM_MOVE_TOP, 500, 0, false); } if (event_code == LV_EVENT_LONG_PRESSED_REPEAT) { lv_disp_t *display = lv_disp_get_default(); lv_obj_t *actScr = lv_disp_get_scr_act(display); if (actScr != ui_home) { return; } // ui_home = ui_clockScreen; lv_scr_load_anim(ui_faceSelect, LV_SCR_LOAD_ANIM_FADE_ON, 500, 0, false); } } /** \fn \brief \return */ void onFaceEvent(lv_event_t *e) { watchfaceEvents(e); } /** \fn \brief \return */ void ui_event_gameSelected(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); int index = (int)lv_event_get_user_data(e); lv_disp_t *display = lv_disp_get_default(); lv_obj_t *actScr = lv_disp_get_scr_act(display); if (actScr != ui_gameListScreen) { return; } if (event_code == LV_EVENT_CLICKED) { if (index >= numGames) { showError("Game Error", "Could not lauch the game, index out of bounds"); return; } // ui_game = *games[index].watchface; if (!*games[index].watchface) { showError("Game Error", "Game root object not initialized"); return; } lv_scr_load_anim(*games[index].watchface, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0, false); // lv_scr_load_anim(ui_raceScreen, LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0, false); } } /** \fn \brief \return */ void ui_gameExit() { lv_scr_load_anim(ui_gameListScreen, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 500, 0, false); } /** \fn \brief \return */ void ui_event_errorClose(lv_event_t *e) { lv_event_code_t event_code = lv_event_get_code(e); lv_obj_t *target = lv_event_get_target(e); if (event_code == LV_EVENT_CLICKED) { _ui_flag_modify(ui_errorWindow, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD); } } /** \fn \brief \return */ void ui_event_face_select(lv_event_t *e) { lv_disp_t *display = lv_disp_get_default(); lv_obj_t *actScr = lv_disp_get_scr_act(display); if (actScr != ui_filesScreen) { return; } lv_scr_load_anim(ui_faceSelect, LV_SCR_LOAD_ANIM_FADE_ON, 500, 0, false); } uint8_t getWeatherIconIndex(uint8_t id) { if (id > 7) { return 0; } return id; } int getNotificationIconIndex(int id) { switch (id) { case 0x03: return 0; case 0x04: return 1; case 0x07: return 2; case 0x08: return 3; case 0x0A: return 4; case 0x0B: return 5; case 0x0E: return 6; case 0x0F: return 7; case 0x10: return 8; case 0x11: return 9; case 0x12: return 10; case 0x13: return 11; case 0x14: return 12; case 0x16: return 13; case 0x17: return 14; case 0x18: return 15; case 0xC0: return 16; case 0x09: return 17; default: return 0; } } void setWeatherIcon(lv_obj_t *obj, int id, bool day) { // lv_img_set_src(obj, day ? weatherIcons[getWeatherIconIndex(id)] : weatherNtIcons[getWeatherIconIndex(id)]); } void setNotificationIcon(lv_obj_t *obj, int appId) { lv_img_set_src(obj, notificationIcons[getNotificationIconIndex(appId)]); } /** \fn \brief \return */ void add_appList(const char *appName, int index, const void *img) { lv_obj_t *ui_appListPanel = lv_obj_create(ui_appList); lv_obj_set_width(ui_appListPanel, 200); lv_obj_set_height(ui_appListPanel, 64); lv_obj_set_align(ui_appListPanel, LV_ALIGN_CENTER); lv_obj_clear_flag(ui_appListPanel, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_radius(ui_appListPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(ui_appListPanel, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_appListPanel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_color(ui_appListPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_opa(ui_appListPanel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(ui_appListPanel, 1, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_side(ui_appListPanel, LV_BORDER_SIDE_BOTTOM, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_left(ui_appListPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_right(ui_appListPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_top(ui_appListPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_bottom(ui_appListPanel, 5, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_t *ui_appListIcon = lv_img_create(ui_appListPanel); lv_img_set_src(ui_appListIcon, img); lv_obj_set_width(ui_appListIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_appListIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_appListIcon, -74); lv_obj_set_y(ui_appListIcon, 2); lv_obj_set_align(ui_appListIcon, LV_ALIGN_CENTER); lv_obj_add_flag(ui_appListIcon, LV_OBJ_FLAG_ADV_HITTEST); /// Flags lv_obj_clear_flag(ui_appListIcon, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_img_set_zoom(ui_appListIcon, 150); lv_obj_t *ui_appListLabel = lv_label_create(ui_appListPanel); lv_obj_set_width(ui_appListLabel, 160); lv_obj_set_height(ui_appListLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_appListLabel, 54); lv_obj_set_y(ui_appListLabel, 3); lv_obj_set_align(ui_appListLabel, LV_ALIGN_LEFT_MID); lv_label_set_text(ui_appListLabel, appName); lv_label_set_long_mode(ui_appListLabel, LV_LABEL_LONG_CLIP); lv_obj_add_event_cb(ui_appListPanel, onAppListClicked, LV_EVENT_CLICKED, (void *)index); } /** \fn \brief \return */ void add_gameList(const char *appName, int index, const void *img) { lv_obj_t *ui_gameListPanel = lv_obj_create(ui_gameList); lv_obj_set_width(ui_gameListPanel, 200); lv_obj_set_height(ui_gameListPanel, 64); lv_obj_set_align(ui_gameListPanel, LV_ALIGN_CENTER); lv_obj_clear_flag(ui_gameListPanel, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_radius(ui_gameListPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(ui_gameListPanel, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_gameListPanel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_color(ui_gameListPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_opa(ui_gameListPanel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(ui_gameListPanel, 1, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_side(ui_gameListPanel, LV_BORDER_SIDE_BOTTOM, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_left(ui_gameListPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_right(ui_gameListPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_top(ui_gameListPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_bottom(ui_gameListPanel, 5, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_t *ui_gameListIcon = lv_img_create(ui_gameListPanel); lv_img_set_src(ui_gameListIcon, img); lv_obj_set_width(ui_gameListIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_gameListIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_gameListIcon, -74); lv_obj_set_y(ui_gameListIcon, 2); lv_obj_set_align(ui_gameListIcon, LV_ALIGN_CENTER); lv_obj_add_flag(ui_gameListIcon, LV_OBJ_FLAG_ADV_HITTEST); /// Flags lv_obj_clear_flag(ui_gameListIcon, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_img_set_zoom(ui_gameListIcon, 150); lv_obj_t *ui_gameListLabel = lv_label_create(ui_gameListPanel); lv_obj_set_width(ui_gameListLabel, 160); lv_obj_set_height(ui_gameListLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_gameListLabel, 54); lv_obj_set_y(ui_gameListLabel, 3); lv_obj_set_align(ui_gameListLabel, LV_ALIGN_LEFT_MID); lv_label_set_text(ui_gameListLabel, appName); lv_label_set_long_mode(ui_gameListLabel, LV_LABEL_LONG_CLIP); // lv_obj_set_style_text_font(ui_gameListLabel, &lv_font_montserrat_20, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_add_event_cb(ui_gameListPanel, ui_event_gameSelected, LV_EVENT_CLICKED, (void *)index); } /** \fn \brief \return */ void addWatchface(const char *name, const lv_img_dsc_t *src, int index) { lv_obj_t *ui_faceItem = lv_obj_create(ui_faceSelect); lv_obj_set_width(ui_faceItem, 160); lv_obj_set_height(ui_faceItem, 180); lv_obj_set_align(ui_faceItem, LV_ALIGN_CENTER); lv_obj_clear_flag(ui_faceItem, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_add_flag(ui_faceItem, LV_OBJ_FLAG_SNAPPABLE); lv_obj_clear_flag(ui_faceItem, LV_OBJ_FLAG_SCROLL_ONE); lv_obj_set_style_radius(ui_faceItem, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(ui_faceItem, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_faceItem, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(ui_faceItem, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_outline_color(ui_faceItem, lv_color_hex(0x142ABC), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_outline_opa(ui_faceItem, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_outline_width(ui_faceItem, 2, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_outline_pad(ui_faceItem, 1, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_left(ui_faceItem, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_right(ui_faceItem, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_top(ui_faceItem, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_bottom(ui_faceItem, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_t *ui_facePreview = lv_img_create(ui_faceItem); lv_img_set_src(ui_facePreview, src); lv_obj_set_width(ui_facePreview, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_facePreview, LV_SIZE_CONTENT); /// 1 lv_obj_set_align(ui_facePreview, LV_ALIGN_TOP_MID); lv_obj_add_flag(ui_facePreview, LV_OBJ_FLAG_ADV_HITTEST); /// Flags lv_obj_clear_flag(ui_facePreview, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_t *ui_faceLabel = lv_label_create(ui_faceItem); lv_obj_set_width(ui_faceLabel, 160); lv_obj_set_height(ui_faceLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_align(ui_faceLabel, LV_ALIGN_BOTTOM_MID); lv_label_set_long_mode(ui_faceLabel, LV_LABEL_LONG_DOT); lv_label_set_text(ui_faceLabel, name); lv_obj_set_style_text_align(ui_faceLabel, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_add_event_cb(ui_faceItem, ui_event_faceSelected, LV_EVENT_ALL, (void *)index); } /** \fn \brief \return */ void addSelectItem(lv_obj_t *parent) { lv_obj_t *ui_faceSelectItem = lv_obj_create(parent); lv_obj_set_width(ui_faceSelectItem, 240); lv_obj_set_height(ui_faceSelectItem, 50); lv_obj_set_align(ui_faceSelectItem, LV_ALIGN_CENTER); lv_obj_clear_flag(ui_faceSelectItem, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_radius(ui_faceSelectItem, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(ui_faceSelectItem, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_faceSelectItem, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_color(ui_faceSelectItem, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_opa(ui_faceSelectItem, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(ui_faceSelectItem, 1, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_side(ui_faceSelectItem, LV_BORDER_SIDE_BOTTOM, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_t *ui_faceItemIcon = lv_img_create(ui_faceSelectItem); lv_img_set_src(ui_faceItemIcon, "D:/ui_img_clock.png"); lv_obj_set_width(ui_faceItemIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_faceItemIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_faceItemIcon, 10); lv_obj_set_y(ui_faceItemIcon, 0); lv_obj_set_align(ui_faceItemIcon, LV_ALIGN_LEFT_MID); lv_obj_add_flag(ui_faceItemIcon, LV_OBJ_FLAG_ADV_HITTEST); /// Flags lv_obj_clear_flag(ui_faceItemIcon, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_img_recolor(ui_faceItemIcon, lv_color_hex(0x2062E3), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_img_recolor_opa(ui_faceItemIcon, 200, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_t *ui_faceItemName = lv_label_create(ui_faceSelectItem); lv_obj_set_width(ui_faceItemName, 117); lv_obj_set_height(ui_faceItemName, LV_SIZE_CONTENT); lv_obj_set_x(ui_faceItemName, 50); lv_obj_set_y(ui_faceItemName, 0); lv_obj_set_align(ui_faceItemName, LV_ALIGN_LEFT_MID); lv_label_set_long_mode(ui_faceItemName, LV_LABEL_LONG_CLIP); watch_lable.system[1] = "选择表盘"; //"Change Current" lv_label_set_text(ui_faceItemName, watch_lable.system[1]); lv_obj_add_event_cb(ui_faceSelectItem, ui_event_face_select, LV_EVENT_CLICKED, NULL); } /** \fn \brief \return */ void addForecast(int day, int temp, int icon) { lv_obj_t *forecastItem = lv_obj_create(ui_forecastList); lv_obj_set_width(forecastItem, 200); lv_obj_set_height(forecastItem, 40); lv_obj_set_align(forecastItem, LV_ALIGN_CENTER); lv_obj_clear_flag(forecastItem, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_radius(forecastItem, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(forecastItem, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(forecastItem, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_color(forecastItem, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_opa(forecastItem, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(forecastItem, 1, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_side(forecastItem, LV_BORDER_SIDE_BOTTOM, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_left(forecastItem, 5, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_right(forecastItem, 5, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_top(forecastItem, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_bottom(forecastItem, 10, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_t *forecastIcon = lv_img_create(forecastItem); lv_obj_set_width(forecastIcon, LV_SIZE_CONTENT); /// 40 lv_obj_set_height(forecastIcon, LV_SIZE_CONTENT); /// 32 lv_obj_set_align(forecastIcon, LV_ALIGN_CENTER); lv_obj_add_flag(forecastIcon, LV_OBJ_FLAG_ADV_HITTEST); /// Flags lv_obj_clear_flag(forecastIcon, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_img_set_zoom(forecastIcon, 150); setWeatherIcon(forecastIcon, icon, true); lv_obj_t *forecastTemp = lv_label_create(forecastItem); lv_obj_set_width(forecastTemp, 58); lv_obj_set_height(forecastTemp, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(forecastTemp, 68); lv_obj_set_y(forecastTemp, 3); lv_obj_set_align(forecastTemp, LV_ALIGN_CENTER); lv_label_set_long_mode(forecastTemp, LV_LABEL_LONG_CLIP); lv_label_set_text_fmt(forecastTemp, "%d°C", temp); // lv_obj_set_style_text_font(forecastTemp, &lv_font_montserrat_20, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_t *forecastDay = lv_label_create(forecastItem); lv_obj_set_width(forecastDay, 68); lv_obj_set_height(forecastDay, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(forecastDay, -56); lv_obj_set_y(forecastDay, 3); lv_obj_set_align(forecastDay, LV_ALIGN_CENTER); lv_label_set_long_mode(forecastDay, LV_LABEL_LONG_CLIP); lv_label_set_text(forecastDay, days[day % 7]); // lv_obj_set_style_text_font(forecastDay, &lv_font_montserrat_20, LV_PART_MAIN | LV_STATE_DEFAULT); } void addNotificationList(int appId, const char *message, int index) { lv_obj_t *notificationItem = lv_obj_create(ui_messageList); lv_obj_set_width(notificationItem, 200); lv_obj_set_height(notificationItem, LV_SIZE_CONTENT); /// 50 lv_obj_set_align(notificationItem, LV_ALIGN_CENTER); lv_obj_set_flex_flow(notificationItem, LV_FLEX_FLOW_ROW); lv_obj_set_flex_align(notificationItem, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START); lv_obj_clear_flag(notificationItem, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_radius(notificationItem, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(notificationItem, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(notificationItem, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_color(notificationItem, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_opa(notificationItem, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(notificationItem, 1, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_side(notificationItem, LV_BORDER_SIDE_BOTTOM, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_left(notificationItem, 5, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_right(notificationItem, 5, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_top(notificationItem, 5, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_bottom(notificationItem, 5, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_t *notificationIcon = lv_img_create(notificationItem); lv_obj_set_width(notificationIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(notificationIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_align(notificationIcon, LV_ALIGN_CENTER); lv_obj_add_flag(notificationIcon, LV_OBJ_FLAG_ADV_HITTEST); /// Flags lv_obj_clear_flag(notificationIcon, LV_OBJ_FLAG_SCROLLABLE); /// Flags setNotificationIcon(notificationIcon, appId); lv_obj_t *notificationText = lv_label_create(notificationItem); lv_obj_set_width(notificationText, 140); lv_obj_set_height(notificationText, LV_SIZE_CONTENT); /// 1 lv_obj_set_align(notificationText, LV_ALIGN_CENTER); lv_label_set_long_mode(notificationText, LV_LABEL_LONG_DOT); lv_label_set_text(notificationText, message); lv_obj_add_event_cb(notificationItem, ui_event_messageClick, LV_EVENT_CLICKED, (void *)index); } /** \fn \brief \return */ void addAppInfo(const void *src, const char *txt) { lv_obj_t *ui_appDetailsPanel = lv_obj_create(ui_appInfoPanel); lv_obj_set_width(ui_appDetailsPanel, 190); lv_obj_set_height(ui_appDetailsPanel, 50); lv_obj_set_align(ui_appDetailsPanel, LV_ALIGN_CENTER); lv_obj_clear_flag(ui_appDetailsPanel, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_radius(ui_appDetailsPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(ui_appDetailsPanel, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_appDetailsPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_color(ui_appDetailsPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_opa(ui_appDetailsPanel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(ui_appDetailsPanel, 1, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_side(ui_appDetailsPanel, LV_BORDER_SIDE_BOTTOM, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_left(ui_appDetailsPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_right(ui_appDetailsPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_top(ui_appDetailsPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_bottom(ui_appDetailsPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_t *ui_appDetailsIcon = lv_img_create(ui_appDetailsPanel); lv_img_set_src(ui_appDetailsIcon, src); lv_obj_set_width(ui_appDetailsIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_appDetailsIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_align(ui_appDetailsIcon, LV_ALIGN_LEFT_MID); lv_obj_add_flag(ui_appDetailsIcon, LV_OBJ_FLAG_ADV_HITTEST); /// Flags lv_obj_clear_flag(ui_appDetailsIcon, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_t *ui_appDetailsText = lv_label_create(ui_appDetailsPanel); lv_obj_set_width(ui_appDetailsText, 139); lv_obj_set_height(ui_appDetailsText, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_appDetailsText, 43); lv_obj_set_y(ui_appDetailsText, 8); lv_label_set_text(ui_appDetailsText, txt); lv_label_set_recolor(ui_appDetailsText, true); } /** \fn \brief \return */ void addListDrive(const char *name, int total, int used, lv_event_cb_t event_cb) { ui_driveInfoPanel = lv_obj_create(ui_fileManagerPanel); lv_obj_set_width(ui_driveInfoPanel, 240); lv_obj_set_height(ui_driveInfoPanel, 60); lv_obj_set_align(ui_driveInfoPanel, LV_ALIGN_CENTER); lv_obj_clear_flag(ui_driveInfoPanel, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_radius(ui_driveInfoPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(ui_driveInfoPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_driveInfoPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_color(ui_driveInfoPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_opa(ui_driveInfoPanel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(ui_driveInfoPanel, 1, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_side(ui_driveInfoPanel, LV_BORDER_SIDE_BOTTOM, LV_PART_MAIN | LV_STATE_DEFAULT); // lv_obj_set_style_bg_color(ui_driveInfoPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_PRESSED); // lv_obj_set_style_bg_opa(ui_driveInfoPanel, 100, LV_PART_MAIN | LV_STATE_PRESSED); ui_driveInfoIcon = lv_img_create(ui_driveInfoPanel); lv_img_set_src(ui_driveInfoIcon, "D:/ui_img_drive.png"); lv_obj_set_width(ui_driveInfoIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_driveInfoIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_driveInfoIcon, 10); lv_obj_set_y(ui_driveInfoIcon, 0); lv_obj_set_align(ui_driveInfoIcon, LV_ALIGN_LEFT_MID); lv_obj_add_flag(ui_driveInfoIcon, LV_OBJ_FLAG_ADV_HITTEST); /// Flags lv_obj_clear_flag(ui_driveInfoIcon, LV_OBJ_FLAG_SCROLLABLE); /// Flags ui_driveInfoLabel = lv_label_create(ui_driveInfoPanel); lv_obj_set_width(ui_driveInfoLabel, 150); lv_obj_set_height(ui_driveInfoLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_driveInfoLabel, 50); lv_obj_set_y(ui_driveInfoLabel, -7); lv_obj_set_align(ui_driveInfoLabel, LV_ALIGN_LEFT_MID); if (total >= 1048576) { lv_label_set_text_fmt(ui_driveInfoLabel, "%s - %dMB", name, (total / 1048576)); } else if (total >= 1024) { lv_label_set_text_fmt(ui_driveInfoLabel, "%s - %dkB", name, (total / 1024)); } else if (total == 0) { lv_label_set_text_fmt(ui_driveInfoLabel, "%s - (n/a)", name); } else { lv_label_set_text_fmt(ui_driveInfoLabel, "%s - %dB", name, total); } // lv_obj_set_style_text_font(ui_driveInfoLabel, &lv_font_montserrat_16, LV_PART_MAIN | LV_STATE_DEFAULT); ui_driveInfoBar = lv_bar_create(ui_driveInfoPanel); if (total == 0) { lv_bar_set_value(ui_driveInfoBar, 0, LV_ANIM_OFF); } else { lv_bar_set_value(ui_driveInfoBar, ((used * 100) / total), LV_ANIM_OFF); } lv_bar_set_start_value(ui_driveInfoBar, 0, LV_ANIM_OFF); lv_obj_set_width(ui_driveInfoBar, 150); lv_obj_set_height(ui_driveInfoBar, 10); lv_obj_set_x(ui_driveInfoBar, 50); lv_obj_set_y(ui_driveInfoBar, 11); lv_obj_set_align(ui_driveInfoBar, LV_ALIGN_LEFT_MID); lv_obj_add_event_cb(ui_driveInfoPanel, event_cb, LV_EVENT_CLICKED, NULL); } /** \fn \brief \return */ void addListDir(const char *name) { ui_folderInfoPanel = lv_obj_create(ui_fileManagerPanel); lv_obj_set_width(ui_folderInfoPanel, 240); lv_obj_set_height(ui_folderInfoPanel, 50); lv_obj_set_align(ui_folderInfoPanel, LV_ALIGN_CENTER); lv_obj_clear_flag(ui_folderInfoPanel, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_radius(ui_folderInfoPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(ui_folderInfoPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_folderInfoPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_color(ui_folderInfoPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_opa(ui_folderInfoPanel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(ui_folderInfoPanel, 1, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_side(ui_folderInfoPanel, LV_BORDER_SIDE_BOTTOM, LV_PART_MAIN | LV_STATE_DEFAULT); // lv_obj_set_style_bg_color(ui_folderInfoPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_PRESSED); // lv_obj_set_style_bg_opa(ui_folderInfoPanel, 100, LV_PART_MAIN | LV_STATE_PRESSED); ui_folderInfoIcon = lv_img_create(ui_folderInfoPanel); lv_img_set_src(ui_folderInfoIcon, "D:/ui_img_directory.png"); lv_obj_set_width(ui_folderInfoIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_folderInfoIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_folderInfoIcon, 10); lv_obj_set_y(ui_folderInfoIcon, 0); lv_obj_set_align(ui_folderInfoIcon, LV_ALIGN_LEFT_MID); lv_obj_add_flag(ui_folderInfoIcon, LV_OBJ_FLAG_ADV_HITTEST); /// Flags lv_obj_clear_flag(ui_folderInfoIcon, LV_OBJ_FLAG_SCROLLABLE); /// Flags ui_folderInfoName = lv_label_create(ui_folderInfoPanel); lv_obj_set_width(ui_folderInfoName, 150); lv_obj_set_height(ui_folderInfoName, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_folderInfoName, 50); lv_obj_set_y(ui_folderInfoName, 0); lv_obj_set_align(ui_folderInfoName, LV_ALIGN_LEFT_MID); lv_label_set_text(ui_folderInfoName, name); // lv_obj_set_style_text_font(ui_folderInfoName, &lv_font_montserrat_16, LV_PART_MAIN | LV_STATE_DEFAULT); } /** \fn \brief \return */ void addListFile(const char *name, int size) { ui_fileInfoPanel = lv_obj_create(ui_fileManagerPanel); lv_obj_set_width(ui_fileInfoPanel, 240); lv_obj_set_height(ui_fileInfoPanel, 50); lv_obj_set_align(ui_fileInfoPanel, LV_ALIGN_CENTER); lv_obj_clear_flag(ui_fileInfoPanel, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_radius(ui_fileInfoPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(ui_fileInfoPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_fileInfoPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_color(ui_fileInfoPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_opa(ui_fileInfoPanel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(ui_fileInfoPanel, 1, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_side(ui_fileInfoPanel, LV_BORDER_SIDE_BOTTOM, LV_PART_MAIN | LV_STATE_DEFAULT); // lv_obj_set_style_bg_color(ui_fileInfoPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_PRESSED); // lv_obj_set_style_bg_opa(ui_fileInfoPanel, 100, LV_PART_MAIN | LV_STATE_PRESSED); ui_fileInfoIcon = lv_img_create(ui_fileInfoPanel); // lv_img_set_src(ui_fileInfoIcon, &ui_img_file_png); lv_img_set_src(ui_fileInfoIcon, "D:/ui_img_file.png"); lv_obj_set_width(ui_fileInfoIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_fileInfoIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_fileInfoIcon, 10); lv_obj_set_y(ui_fileInfoIcon, 0); lv_obj_set_align(ui_fileInfoIcon, LV_ALIGN_LEFT_MID); lv_obj_add_flag(ui_fileInfoIcon, LV_OBJ_FLAG_ADV_HITTEST); /// Flags lv_obj_clear_flag(ui_fileInfoIcon, LV_OBJ_FLAG_SCROLLABLE); /// Flags ui_fileInfoName = lv_label_create(ui_fileInfoPanel); lv_obj_set_width(ui_fileInfoName, 150); lv_obj_set_height(ui_fileInfoName, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_fileInfoName, 50); lv_obj_set_y(ui_fileInfoName, -7); lv_obj_set_align(ui_fileInfoName, LV_ALIGN_LEFT_MID); lv_label_set_text(ui_fileInfoName, name); // lv_obj_set_style_text_font(ui_fileInfoName, &lv_font_montserrat_16, LV_PART_MAIN | LV_STATE_DEFAULT); ui_fileInfoSize = lv_label_create(ui_fileInfoPanel); lv_obj_set_width(ui_fileInfoSize, 150); lv_obj_set_height(ui_fileInfoSize, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_fileInfoSize, 50); lv_obj_set_y(ui_fileInfoSize, 11); lv_obj_set_align(ui_fileInfoSize, LV_ALIGN_LEFT_MID); if (size >= 1048576) { lv_label_set_text_fmt(ui_fileInfoSize, "%dmb", (size / 1048576)); } else if (size >= 1024) { lv_label_set_text_fmt(ui_fileInfoSize, "%dkb", (size / 1024)); } else { lv_label_set_text_fmt(ui_fileInfoSize, "%db", size); } lv_obj_set_style_text_align(ui_fileInfoSize, LV_TEXT_ALIGN_RIGHT, LV_PART_MAIN | LV_STATE_DEFAULT); // lv_obj_set_style_text_font(ui_fileInfoSize, &lv_font_montserrat_14, LV_PART_MAIN | LV_STATE_DEFAULT); } /** \fn \brief \return */ void addListBack(lv_event_cb_t event_cb) { ui_driveBackPanel = lv_obj_create(ui_fileManagerPanel); lv_obj_set_width(ui_driveBackPanel, 240); lv_obj_set_height(ui_driveBackPanel, 50); lv_obj_set_align(ui_driveBackPanel, LV_ALIGN_CENTER); lv_obj_clear_flag(ui_driveBackPanel, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_radius(ui_driveBackPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(ui_driveBackPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_driveBackPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_color(ui_driveBackPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_opa(ui_driveBackPanel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(ui_driveBackPanel, 1, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_side(ui_driveBackPanel, LV_BORDER_SIDE_BOTTOM, LV_PART_MAIN | LV_STATE_DEFAULT); // lv_obj_set_style_bg_color(ui_driveBackPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_PRESSED); // lv_obj_set_style_bg_opa(ui_driveBackPanel, 100, LV_PART_MAIN | LV_STATE_PRESSED); ui_driveBackIcon = lv_img_create(ui_driveBackPanel); lv_img_set_src(ui_driveBackIcon, "D:/ui_img_back.png"); lv_obj_set_width(ui_driveBackIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_driveBackIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_driveBackIcon, 10); lv_obj_set_y(ui_driveBackIcon, 0); lv_obj_set_align(ui_driveBackIcon, LV_ALIGN_LEFT_MID); lv_obj_add_flag(ui_driveBackIcon, LV_OBJ_FLAG_ADV_HITTEST); /// Flags lv_obj_clear_flag(ui_driveBackIcon, LV_OBJ_FLAG_SCROLLABLE); /// Flags ui_driveBackLabel = lv_label_create(ui_driveBackPanel); lv_obj_set_width(ui_driveBackLabel, 150); lv_obj_set_height(ui_driveBackLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_driveBackLabel, 50); lv_obj_set_y(ui_driveBackLabel, 0); lv_obj_set_align(ui_driveBackLabel, LV_ALIGN_LEFT_MID); lv_label_set_text(ui_driveBackLabel, "返回");//"Back" lv_obj_add_event_cb(ui_driveBackPanel, event_cb, LV_EVENT_CLICKED, NULL); } /** \fn \brief \return */ void registerWatchface_cb(const char *name, const lv_img_dsc_t *preview, lv_obj_t **watchface) { if (numFaces >= MAX_FACES) { return; } faces[numFaces].name = name; faces[numFaces].preview = preview; faces[numFaces].watchface = watchface; addWatchface(faces[numFaces].name, faces[numFaces].preview, numFaces); numFaces++; } /** \fn \brief \return */ void registerGame_cb(const char *name, const lv_img_dsc_t *icon, lv_obj_t **game) { if (numGames >= MAX_GAMES) { return; } games[numGames].name = name; games[numGames].preview = icon; games[numGames].watchface = game; // addGame add_gameList(games[numGames].name, numGames, games[numGames].preview); numGames++; } /** \fn \brief \return */ void init_face_select() { ui_faceSelect = lv_obj_create(NULL); lv_obj_set_width(ui_faceSelect, 240); lv_obj_set_height(ui_faceSelect, 240); lv_obj_set_align(ui_faceSelect, LV_ALIGN_CENTER); lv_obj_set_flex_flow(ui_faceSelect, LV_FLEX_FLOW_ROW); lv_obj_set_flex_align(ui_faceSelect, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); lv_obj_clear_flag(ui_faceSelect, LV_OBJ_FLAG_SNAPPABLE); /// Flags lv_obj_set_scrollbar_mode(ui_faceSelect, LV_SCROLLBAR_MODE_OFF); lv_obj_set_scroll_snap_x(ui_faceSelect, LV_SCROLL_SNAP_CENTER); lv_obj_set_style_radius(ui_faceSelect, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(ui_faceSelect, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_faceSelect, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(ui_faceSelect, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_left(ui_faceSelect, 30, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_right(ui_faceSelect, 30, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_top(ui_faceSelect, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_bottom(ui_faceSelect, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_row(ui_faceSelect, 10, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_column(ui_faceSelect, 15, LV_PART_MAIN | LV_STATE_DEFAULT); } /** \fn \brief \return */ void showError(const char *title, const char *message) { lv_disp_t *display = lv_disp_get_default(); lv_obj_t *actScr = lv_disp_get_scr_act(display); // attach the error windows to current screen lv_obj_set_parent(ui_errorWindow, actScr); lv_label_set_text(ui_errorTitle, title); lv_label_set_text(ui_errorMessage, message); lv_obj_clear_flag(ui_errorWindow, LV_OBJ_FLAG_HIDDEN); // show the error lv_obj_scroll_to_y(ui_errorWindow, 0, LV_ANIM_ON); } ///////////////////// SCREENS //////////////////// void ui_clockScreen_screen_init(void) { ui_clockScreen = lv_obj_create(NULL); lv_obj_clear_flag(ui_clockScreen, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_bg_color(ui_clockScreen, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_clockScreen, 255, LV_PART_MAIN | LV_STATE_DEFAULT); // lv_obj_set_style_radius(ui_clockScreen, 120, LV_PART_MAIN | LV_STATE_DEFAULT); // lv_obj_set_style_bg_img_src(ui_clockScreen, "D:/night-sky.png", LV_PART_MAIN | LV_STATE_DEFAULT); // lv_obj_set_style_outline_color(ui_clockScreen, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); // lv_obj_set_style_outline_opa(ui_clockScreen, 255, LV_PART_MAIN | LV_STATE_DEFAULT); // lv_obj_set_style_outline_width(ui_clockScreen, 55, LV_PART_MAIN | LV_STATE_DEFAULT); // lv_obj_set_style_outline_pad(ui_clockScreen, 0, LV_PART_MAIN | LV_STATE_DEFAULT); ui_hourLabel = lv_label_create(ui_clockScreen); lv_obj_set_width(ui_hourLabel, LV_SIZE_CONTENT); lv_obj_set_height(ui_hourLabel, LV_SIZE_CONTENT); // lv_obj_set_x(ui_hourLabel, -50); // lv_obj_set_y(ui_hourLabel, -32); // lv_obj_set_align(ui_hourLabel, LV_ALIGN_CENTER); lv_obj_align(ui_hourLabel,LV_ALIGN_CENTER,-48,-40); lv_label_set_text(ui_hourLabel, "12"); lv_obj_set_style_text_align(ui_hourLabel, LV_TEXT_ALIGN_RIGHT, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_text_font(ui_hourLabel, pFontNumber, LV_PART_MAIN | LV_STATE_DEFAULT); ui_minuteLabel = lv_label_create(ui_clockScreen); lv_obj_set_width(ui_minuteLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_minuteLabel, LV_SIZE_CONTENT); /// 1 // lv_obj_set_x(ui_minuteLabel, 32); // lv_obj_set_y(ui_minuteLabel, 60); // lv_obj_set_align(ui_minuteLabel, LV_ALIGN_CENTER); lv_obj_align(ui_minuteLabel,LV_ALIGN_CENTER,32,48); lv_label_set_text(ui_minuteLabel, "28"); lv_obj_set_style_text_font(ui_minuteLabel, pFontNumber, LV_PART_MAIN | LV_STATE_DEFAULT); ui_dateLabel = lv_label_create(ui_clockScreen); lv_obj_set_width(ui_dateLabel, 113); lv_obj_set_height(ui_dateLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_dateLabel, 89); lv_obj_set_y(ui_dateLabel, -24); lv_obj_set_align(ui_dateLabel, LV_ALIGN_CENTER); lv_label_set_long_mode(ui_dateLabel, LV_LABEL_LONG_CLIP); lv_label_set_text(ui_dateLabel, "08\nJuly"); // lv_obj_set_style_text_font(ui_dateLabel, &lv_font_montserrat_20, LV_PART_MAIN | LV_STATE_DEFAULT); ui_weatherIcon = lv_img_create(ui_clockScreen); lv_img_set_src(ui_weatherIcon, "D:/ui_img_weather_1.png"); lv_obj_set_width(ui_weatherIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_weatherIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_weatherIcon, -63); lv_obj_set_y(ui_weatherIcon, 29); lv_obj_set_align(ui_weatherIcon, LV_ALIGN_CENTER); lv_obj_add_flag(ui_weatherIcon, LV_OBJ_FLAG_ADV_HITTEST); /// Flags lv_obj_clear_flag(ui_weatherIcon, LV_OBJ_FLAG_SCROLLABLE); /// Flags ui_weatherTemp = lv_label_create(ui_clockScreen); lv_obj_set_width(ui_weatherTemp, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_weatherTemp, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_weatherTemp, -61); lv_obj_set_y(ui_weatherTemp, 72); lv_obj_set_align(ui_weatherTemp, LV_ALIGN_CENTER); lv_label_set_text(ui_weatherTemp, "15 °C"); lv_obj_set_style_text_font(ui_weatherTemp, pFontExtern_28, LV_PART_MAIN | LV_STATE_DEFAULT); ui_dayLabel = lv_label_create(ui_clockScreen); lv_obj_set_width(ui_dayLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_dayLabel, LV_SIZE_CONTENT); /// 1 // lv_obj_set_x(ui_dayLabel, 0); // lv_obj_set_y(ui_dayLabel, -100); // lv_obj_set_align(ui_dayLabel, LV_ALIGN_CENTER); lv_obj_align(ui_dayLabel,LV_ALIGN_TOP_MID,0,8); lv_label_set_text(ui_dayLabel, "星期天"); ui_amPmLabel = lv_label_create(ui_clockScreen); lv_obj_set_width(ui_amPmLabel, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_amPmLabel, LV_SIZE_CONTENT); /// 1 // lv_obj_set_x(ui_amPmLabel, 12); // lv_obj_set_y(ui_amPmLabel, 105); // lv_obj_set_align(ui_amPmLabel, LV_ALIGN_CENTER); lv_obj_align(ui_amPmLabel,LV_ALIGN_BOTTOM_MID,0,-8); lv_label_set_text(ui_amPmLabel, "PM"); #if 0 ui_alertPanel = lv_obj_create(ui_clockScreen); lv_obj_set_width(ui_alertPanel, 200); lv_obj_set_height(ui_alertPanel, 55); lv_obj_set_align(ui_alertPanel, LV_ALIGN_CENTER); lv_obj_clear_flag(ui_alertPanel, LV_OBJ_FLAG_HIDDEN); lv_obj_clear_flag(ui_alertPanel, LV_OBJ_FLAG_GESTURE_BUBBLE | LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_bg_color(ui_alertPanel, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_alertPanel, 240, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_color(ui_alertPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_opa(ui_alertPanel, 240, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(ui_alertPanel, 1, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_left(ui_alertPanel, 5, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_right(ui_alertPanel, 5, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_top(ui_alertPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_bottom(ui_alertPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); ui_alertIcon = lv_img_create(ui_alertPanel); lv_img_set_src(ui_alertIcon, "D:/ui_img_wechat.png"); lv_obj_set_width(ui_alertIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_alertIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_align(ui_alertIcon, LV_ALIGN_LEFT_MID); lv_obj_add_flag(ui_alertIcon, LV_OBJ_FLAG_ADV_HITTEST); /// Flags lv_obj_clear_flag(ui_alertIcon, LV_OBJ_FLAG_SCROLLABLE); /// Flags ui_alertText = lv_label_create(ui_alertPanel); lv_obj_set_width(ui_alertText, 142); lv_obj_set_height(ui_alertText, 40); lv_obj_set_x(ui_alertText, 39); lv_obj_set_y(ui_alertText, 0); lv_obj_set_align(ui_alertText, LV_ALIGN_LEFT_MID); lv_label_set_long_mode(ui_alertText, LV_LABEL_LONG_DOT); lv_label_set_text(ui_alertText,"收到一条消息"); lv_obj_add_event_cb(ui_alertPanel, ui_event_alertPanel, LV_EVENT_ALL, NULL); #endif lv_obj_add_event_cb(ui_clockScreen, watchfaceEvents, LV_EVENT_ALL, NULL); } /** \fn \brief \return */ void ui_weatherScreen_screen_init(void) { ui_weatherScreen = lv_obj_create(NULL); lv_obj_clear_flag(ui_weatherScreen, LV_OBJ_FLAG_SCROLLABLE); /// Flags // lv_obj_set_style_radius(ui_weatherScreen, 120, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(ui_weatherScreen, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_weatherScreen, 255, LV_PART_MAIN | LV_STATE_DEFAULT); // lv_obj_set_style_bg_img_src(ui_weatherScreen, &ui_img_857483832, LV_PART_MAIN | LV_STATE_DEFAULT); // lv_obj_set_style_bg_img_opa(ui_weatherScreen, 150, LV_PART_MAIN | LV_STATE_DEFAULT); // lv_obj_set_style_outline_color(ui_weatherScreen, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); // lv_obj_set_style_outline_opa(ui_weatherScreen, 255, LV_PART_MAIN | LV_STATE_DEFAULT); // lv_obj_set_style_outline_width(ui_weatherScreen, 55, LV_PART_MAIN | LV_STATE_DEFAULT); // lv_obj_set_style_outline_pad(ui_weatherScreen, 0, LV_PART_MAIN | LV_STATE_DEFAULT); ui_weatherPanel = lv_obj_create(ui_weatherScreen); lv_obj_set_width(ui_weatherPanel, lv_pct(100)); lv_obj_set_height(ui_weatherPanel, lv_pct(100)); lv_obj_set_align(ui_weatherPanel, LV_ALIGN_CENTER); lv_obj_add_flag(ui_weatherPanel, LV_OBJ_FLAG_HIDDEN); /// Flags lv_obj_clear_flag(ui_weatherPanel, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_radius(ui_weatherPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(ui_weatherPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_weatherPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(ui_weatherPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); ui_weatherCity = lv_label_create(ui_weatherPanel); lv_obj_set_width(ui_weatherCity, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_weatherCity, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_weatherCity, -3); lv_obj_set_y(ui_weatherCity, -85); lv_obj_set_align(ui_weatherCity, LV_ALIGN_CENTER); lv_label_set_text(ui_weatherCity, ""); ui_weatherCurrentIcon = lv_img_create(ui_weatherPanel); lv_img_set_src(ui_weatherCurrentIcon, "D:/ui_img_weather_8.png"); lv_obj_set_width(ui_weatherCurrentIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_weatherCurrentIcon, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_weatherCurrentIcon, 0); lv_obj_set_y(ui_weatherCurrentIcon, -29); lv_obj_set_align(ui_weatherCurrentIcon, LV_ALIGN_CENTER); lv_obj_add_flag(ui_weatherCurrentIcon, LV_OBJ_FLAG_ADV_HITTEST); /// Flags lv_obj_clear_flag(ui_weatherCurrentIcon, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_img_set_zoom(ui_weatherCurrentIcon, 400); ui_weatherCurrentTemp = lv_label_create(ui_weatherPanel); lv_obj_set_width(ui_weatherCurrentTemp, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_weatherCurrentTemp, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_weatherCurrentTemp, 0); lv_obj_set_y(ui_weatherCurrentTemp, 44); lv_obj_set_align(ui_weatherCurrentTemp, LV_ALIGN_CENTER); lv_label_set_text(ui_weatherCurrentTemp, "--°C"); lv_obj_set_style_text_font(ui_weatherCurrentTemp, pFontExtern_48, LV_PART_MAIN | LV_STATE_DEFAULT); ui_weatherUpdateTime = lv_label_create(ui_weatherPanel); lv_obj_set_width(ui_weatherUpdateTime, LV_SIZE_CONTENT); /// 1 lv_obj_set_height(ui_weatherUpdateTime, LV_SIZE_CONTENT); /// 1 lv_obj_set_x(ui_weatherUpdateTime, 0); lv_obj_set_y(ui_weatherUpdateTime, 97); lv_obj_set_align(ui_weatherUpdateTime, LV_ALIGN_CENTER); watch_lable.weather[0] = "更新于\n--:--"; //"updated at\n--:--" lv_label_set_text(ui_weatherUpdateTime, watch_lable.weather[0]); lv_obj_set_style_text_align(ui_weatherUpdateTime, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); ui_forecastPanel = lv_obj_create(ui_weatherScreen); lv_obj_set_width(ui_forecastPanel, lv_pct(100)); lv_obj_set_height(ui_forecastPanel, lv_pct(100)); // lv_obj_set_style_radius(ui_forecastPanel, 120, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_align(ui_forecastPanel, LV_ALIGN_CENTER); lv_obj_set_scrollbar_mode(ui_forecastPanel, LV_SCROLLBAR_MODE_OFF); lv_obj_set_scroll_dir(ui_forecastPanel, LV_DIR_VER); lv_obj_set_style_radius(ui_forecastPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(ui_forecastPanel, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_forecastPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(ui_forecastPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); ui_forecastTitle = lv_label_create(ui_forecastPanel); lv_obj_set_width(ui_forecastTitle, 150); lv_obj_set_height(ui_forecastTitle, LV_SIZE_CONTENT); lv_obj_set_align(ui_forecastTitle, LV_ALIGN_TOP_MID); watch_lable.weather[1] = "天气预报"; //"Forecast" lv_label_set_text(ui_forecastTitle, watch_lable.weather[1]); lv_obj_set_style_text_align(ui_forecastTitle, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_color(ui_forecastTitle, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_opa(ui_forecastTitle, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(ui_forecastTitle, 1, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_side(ui_forecastTitle, LV_BORDER_SIDE_BOTTOM, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_left(ui_forecastTitle, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_right(ui_forecastTitle, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_top(ui_forecastTitle, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_bottom(ui_forecastTitle, 5, LV_PART_MAIN | LV_STATE_DEFAULT); ui_forecastList = lv_obj_create(ui_forecastPanel); lv_obj_set_width(ui_forecastList, 240); lv_obj_set_height(ui_forecastList, LV_SIZE_CONTENT); /// 50 lv_obj_set_x(ui_forecastList, 0); lv_obj_set_y(ui_forecastList, 31); lv_obj_set_align(ui_forecastList, LV_ALIGN_TOP_MID); lv_obj_set_flex_flow(ui_forecastList, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_align(ui_forecastList, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); lv_obj_clear_flag(ui_forecastList, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_radius(ui_forecastList, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(ui_forecastList, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_forecastList, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(ui_forecastList, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_left(ui_forecastList, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_right(ui_forecastList, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_top(ui_forecastList, 10, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_bottom(ui_forecastList, 50, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_t *info = lv_label_create(ui_forecastList); lv_obj_set_width(info, 180); lv_obj_set_height(info, LV_SIZE_CONTENT); /// 1 lv_obj_set_align(info, LV_ALIGN_CENTER); // lv_label_set_text(info, "Weather information has not yet been synced. Make sure to enable it in the app settings."); lv_label_set_text(info, "天气信息未同步. 请确保已经打开了相关配置."); lv_obj_add_event_cb(ui_weatherScreen, ui_event_weatherScreen, LV_EVENT_ALL, NULL); } /** \fn \brief \return */ void ui_appList_screen_init(void) { ui_appListScreen = lv_obj_create(NULL); lv_obj_clear_flag(ui_appListScreen, LV_OBJ_FLAG_SCROLLABLE); /// Flags lv_obj_set_style_bg_color(ui_appListScreen, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_appListScreen, 255, LV_PART_MAIN | LV_STATE_DEFAULT); ui_appList = lv_obj_create(ui_appListScreen); lv_obj_set_width(ui_appList, lv_pct(100)); lv_obj_set_height(ui_appList, lv_pct(100)); lv_obj_set_align(ui_appList, LV_ALIGN_TOP_MID); lv_obj_set_flex_flow(ui_appList, LV_FLEX_FLOW_COLUMN); lv_obj_set_flex_align(ui_appList, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); lv_obj_set_scrollbar_mode(ui_appList, LV_SCROLLBAR_MODE_OFF); lv_obj_set_scroll_dir(ui_appList, LV_DIR_VER); lv_obj_set_style_radius(ui_appList, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(ui_appList, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_opa(ui_appList, 255, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(ui_appList, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_left(ui_appList, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_right(ui_appList, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_top(ui_appList, 50, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_bottom(ui_appList, 70, LV_PART_MAIN | LV_STATE_DEFAULT); for (uint32_t i=0; i