How to create a clock?

fast clock crate
/*

LV_IMG_DECLARE(watch_bg);
LV_IMG_DECLARE(hour);
LV_IMG_DECLARE(minute);
LV_IMG_DECLARE(second);

lv_obj_t * lvMinute;
lv_obj_t * lvHour;
lv_obj_t * lvSecond ;

uint8_t Minute =24;
uint8_t Hour =8;
uint8_t Second=2 ;

static void update_time(void *arg)
{
time_t now_t;
char strftime_buf[64];

if(Second++>60)
{
   Second=0;
    if(Minute++>60)
    {
        Minute=0;
       if(Hour++>12) Hour=0;
    }

}


if(main_clock_label !=NULL)
{
 sprintf(strftime_buf,"%d:%d:%d",Hour,Minute,Second);
 lv_label_set_text(main_clock_label, strftime_buf);
 }

if(lvHour !=NULL)
{

   // Hour,Minute,Second;


    lv_img_set_angle(  lvHour, Hour*30*10);
    lv_img_set_angle(  lvMinute, Minute*6*10);
    lv_img_set_angle(  lvSecond, Second*6*10);

}

}

void analog( lv_obj_t *win)
{

lv_obj_t *central = lv_page_create(win, NULL);
lv_obj_set_size(central, vres-2 , hres/2-2);
lv_obj_set_pos(central,  0, 0);
lv_page_set_scrlbar_mode(central, LV_SCRLBAR_MODE_OFF);


lv_obj_t * img = lv_img_create(central,NULL);
lv_img_set_src(img, &watch_bg);
lv_obj_set_size(img, 200, 200);
lv_obj_set_pos(img,pos_x,pos_y);



lvHour = lv_img_create(central,NULL);
lv_img_set_src( lvHour, &hour);
lv_obj_align(  lvHour, img,LV_ALIGN_CENTER, 0, 0);
lv_img_set_angle(  lvHour, 750);

lvMinute = lv_img_create(central,NULL);
lv_img_set_src( lvMinute, &minute);
lv_obj_align(  lvMinute, img,LV_ALIGN_CENTER, 0, 0);
lv_img_set_angle(  lvHour, 1950);

lvSecond = lv_img_create(central,NULL);
lv_img_set_src( lvSecond, &second);
lv_obj_align(  lvSecond, img,LV_ALIGN_CENTER, 0, 0);
lv_img_set_angle(  lvSecond, 600);

lv_task_create(update_time, 100, LV_TASK_PRIO_LOW, NULL);

}

*/
clock_app.zip (175.1 KB)WhatsApp Video 2020-08-02 at 18.09.01.zip (2.4 MB)

1 Like