Started to clean up the POC(Proof Of Concept) code
This commit is contained in:
parent
fc3850b6f3
commit
bfede27653
@ -210,7 +210,7 @@
|
||||
*LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
|
||||
*LV_LOG_LEVEL_USER Only logs added by the user
|
||||
*LV_LOG_LEVEL_NONE Do not log anything*/
|
||||
#define LV_LOG_LEVEL LV_LOG_LEVEL_USER
|
||||
#define LV_LOG_LEVEL LV_LOG_LEVEL_ERROR
|
||||
|
||||
/*1: Print the log with 'printf';
|
||||
*0: User need to register a callback with `lv_log_register_print_cb()`*/
|
||||
|
@ -63,9 +63,14 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLi
|
||||
lv_obj_t *screen_mask = lv_img_create(top_layer);
|
||||
lv_img_set_src(screen_mask, &watch_mask);
|
||||
|
||||
config_screen();
|
||||
menu_screen();
|
||||
watch_face();
|
||||
WatchFace_t watchFace;
|
||||
watch_face_init(&watchFace);
|
||||
lv_obj_t *watchFaceObj = watch_face_create(&watchFace);
|
||||
lv_scr_load(watchFaceObj);
|
||||
|
||||
//config_screen();
|
||||
//menu_screen();
|
||||
//watch_face();
|
||||
|
||||
while(!lv_win32_quit_signal) {
|
||||
/* Periodically call the lv_task handler.
|
||||
|
@ -119,7 +119,7 @@ void watch_face(void)
|
||||
LV_IMG_DECLARE(watch_casio_medium_hand_asset)
|
||||
LV_IMG_DECLARE(watch_casio_small_hand_asset)
|
||||
|
||||
watch_screen = lv_obj_create(NULL);
|
||||
watch_screen = lv_scr_act(); //lv_obj_create(NULL);
|
||||
lv_scr_load(watch_screen);
|
||||
|
||||
lv_obj_t *watch_face_img = lv_img_create(watch_screen);
|
||||
@ -181,4 +181,126 @@ void watch_face(void)
|
||||
LV_LOG_USER("Starting watch timer");
|
||||
hand_timer = lv_timer_create(&(lv_timer_cb),199,NULL);
|
||||
//hand_timer = lv_timer_create(&(lv_timer_cb2),1000,NULL);
|
||||
|
||||
//lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
void watch_face_init(WatchFace_t * const watchFace)
|
||||
{
|
||||
if(!watchFace)
|
||||
{
|
||||
LV_LOG_ERROR("NULL pointer given !");
|
||||
return;
|
||||
}
|
||||
memset(watchFace, 0, sizeof(WatchFace_t));
|
||||
}
|
||||
|
||||
void watch_face_register_cb(WatchFace_t * const watchFace, DateTimeCb_t DateTimeCb)
|
||||
{
|
||||
if(!watchFace)
|
||||
{
|
||||
LV_LOG_ERROR("NULL pointer given !");
|
||||
return;
|
||||
}
|
||||
|
||||
watchFace->DateTimeCb = DateTimeCb;
|
||||
}
|
||||
|
||||
lv_obj_t *watch_face_create(WatchFace_t * const watchFace)
|
||||
{
|
||||
if(!watchFace)
|
||||
{
|
||||
LV_LOG_ERROR("NULL pointer given !");
|
||||
return;
|
||||
}
|
||||
|
||||
//We declare the needed assets for the watch face:
|
||||
LV_IMG_DECLARE(watch_casio_face_asset)
|
||||
LV_IMG_DECLARE(watch_casio_hour_hand_asset)
|
||||
LV_IMG_DECLARE(watch_casio_minute_hand_asset)
|
||||
LV_IMG_DECLARE(watch_casio_second_hand_asset)
|
||||
LV_IMG_DECLARE(watch_casio_medium_hand_asset)
|
||||
LV_IMG_DECLARE(watch_casio_small_hand_asset)
|
||||
|
||||
//We create our parent screen :
|
||||
lv_obj_t *watchFaceScreen = lv_obj_create(NULL);
|
||||
|
||||
//We load our assets :
|
||||
lv_obj_t *watchFaceImg = lv_img_create(watchFaceScreen);
|
||||
lv_img_set_src(watchFaceImg, &watch_casio_face_asset);
|
||||
|
||||
lv_obj_t *smallHandImg = lv_img_create(watchFaceScreen);
|
||||
lv_img_set_src(smallHandImg, &watch_casio_small_hand_asset);
|
||||
lv_obj_set_pos(smallHandImg, 69, 98);
|
||||
lv_img_set_pivot(smallHandImg, 4, 20);
|
||||
|
||||
if(watchFace->mediumHand24hImg)
|
||||
{
|
||||
LV_LOG_ERROR("mediumHand24hImg should be NULL here !");
|
||||
lv_obj_del(watchFace->mediumHand24hImg);
|
||||
watchFace->mediumHand24hImg = NULL;
|
||||
}
|
||||
|
||||
watchFace->mediumHand24hImg = lv_img_create(watchFaceScreen);
|
||||
lv_img_set_src(watchFace->mediumHand24hImg, &watch_casio_medium_hand_asset);
|
||||
lv_obj_set_pos(watchFace->mediumHand24hImg, 115, 48);
|
||||
lv_img_set_pivot(watchFace->mediumHand24hImg, 4, 25);
|
||||
|
||||
lv_obj_t *mediumHandChronoImg = lv_img_create(watchFaceScreen);
|
||||
lv_img_set_src(mediumHandChronoImg, &watch_casio_medium_hand_asset);
|
||||
lv_obj_set_pos(mediumHandChronoImg, 115, 140);
|
||||
lv_img_set_pivot(mediumHandChronoImg, 4, 25);
|
||||
|
||||
//Date window is created here
|
||||
if(watchFace->dateWindow)
|
||||
{
|
||||
LV_LOG_ERROR("dateWindow should be NULL here !");
|
||||
lv_obj_del(watchFace->dateWindow);
|
||||
watchFace->dateWindow = NULL;
|
||||
}
|
||||
watchFace->dateWindow = lv_label_create(watchFaceScreen);
|
||||
lv_label_set_text_static(watchFace->dateWindow, watchFace->dateWindowText);
|
||||
lv_obj_set_pos(watchFace->dateWindow, 182,112);
|
||||
|
||||
if(watchFace->hourHandImg)
|
||||
{
|
||||
LV_LOG_ERROR("hourHandImg should be NULL here !");
|
||||
lv_obj_del(watchFace->hourHandImg);
|
||||
watchFace->hourHandImg = NULL;
|
||||
}
|
||||
|
||||
watchFace->hourHandImg = lv_img_create(watchFaceScreen);
|
||||
lv_img_set_src(watchFace->hourHandImg, &watch_casio_hour_hand_asset);
|
||||
lv_obj_set_pos(watchFace->hourHandImg, 112, 60);
|
||||
lv_img_set_pivot(watchFace->hourHandImg, 8, 60);
|
||||
|
||||
if(watchFace->minuteHandImg)
|
||||
{
|
||||
LV_LOG_ERROR("minuteHandImg should be NULL here !");
|
||||
lv_obj_del(watchFace->minuteHandImg);
|
||||
watchFace->minuteHandImg = NULL;
|
||||
}
|
||||
|
||||
watchFace->minuteHandImg = lv_img_create(watchFaceScreen);
|
||||
lv_img_set_src(watchFace->minuteHandImg, &watch_casio_minute_hand_asset);
|
||||
lv_obj_set_pos(watchFace->minuteHandImg, 112, 28);
|
||||
lv_img_set_pivot(watchFace->minuteHandImg, 7, 92);
|
||||
|
||||
if(watchFace->secondHandImg)
|
||||
{
|
||||
LV_LOG_ERROR("secondHandImg should be NULL here !");
|
||||
lv_obj_del(watchFace->secondHandImg);
|
||||
watchFace->secondHandImg = NULL;
|
||||
}
|
||||
|
||||
watchFace->secondHandImg = lv_img_create(watchFaceScreen);
|
||||
lv_img_set_src(watchFace->secondHandImg, &watch_casio_second_hand_asset);
|
||||
lv_obj_set_pos(watchFace->secondHandImg, 115, 28);
|
||||
lv_img_set_pivot(watchFace->secondHandImg, 5, 92);
|
||||
|
||||
//We create the timer to run the watch animations
|
||||
|
||||
|
||||
return watchFaceScreen;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,33 @@
|
||||
#ifndef WATCH_FACE_H
|
||||
#define WATCH_FACE_H
|
||||
|
||||
#include "lvgl.h"
|
||||
#include <time.h>
|
||||
|
||||
typedef void (*DateTimeCb_t)(struct tm * const DateTime);
|
||||
|
||||
/* Watch face context object */
|
||||
typedef struct WatchFace
|
||||
{
|
||||
DateTimeCb_t DateTimeCb; //Call back function used to retrieve the date and time needed by the watch face
|
||||
lv_obj_t *hourHandImg;
|
||||
lv_obj_t *minuteHandImg;
|
||||
lv_obj_t *secondHandImg;
|
||||
lv_obj_t *mediumHand24hImg;
|
||||
lv_obj_t *dateWindow;
|
||||
lv_timer_t *handAnimationTimer;
|
||||
char dateWindowText[3];
|
||||
} WatchFace_t;
|
||||
|
||||
/* Initializes the watch face context object */
|
||||
void watch_face_init(WatchFace_t * const watchFace);
|
||||
|
||||
/* Registers a call back function to retrieve the time and date */
|
||||
void watch_face_register_cb(WatchFace_t * const watchFace, DateTimeCb_t DateTimeCb);
|
||||
|
||||
/* Builds the watch face graphically and returns it as a lv_obj_t* */
|
||||
lv_obj_t *watch_face_create(WatchFace_t * const watchFace);
|
||||
|
||||
void watch_face(void);
|
||||
|
||||
#endif // WATCH_FACE_H
|
||||
|
Loading…
Reference in New Issue
Block a user