diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/compass_screen.c b/src/lvgl_win_sim/lv_port_win_codeblocks/compass_screen.c index 1de32ad..7c11bf7 100644 --- a/src/lvgl_win_sim/lv_port_win_codeblocks/compass_screen.c +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/compass_screen.c @@ -56,8 +56,13 @@ static void timer_anim_cb(lv_timer_t *timer) { CompassScreen_t *compassScreen = timer->user_data; static uint16_t azimuth = 0; + static float temp = -20; compass_screen_set_azimuth(compassScreen, azimuth++); - lv_meter_set_scale_range(compassScreen->compassGraduation.meter, compassScreen->compassGraduation.scale, 0, 330, 330, -azimuth-90); + compass_screen_set_temperature(compassScreen, temp+=0.09); + + if(temp > 120) temp = -20; + + //lv_meter_set_scale_range(compassScreen->compassGraduation.meter, compassScreen->compassGraduation.scale, 0, 330, 330, -azimuth-90); } static void create_cardinal(CompassCardinal_t *cardidanl, const char *cardinalText, lv_color_t textColor, lv_coord_t x, lv_coord_t y, lv_obj_t *parent) @@ -96,6 +101,7 @@ void compass_screen_init(CompassScreen_t * const compassScreen) memset(compassScreen, 0, sizeof(CompassScreen_t)); strcpy(compassScreen->compassAzimuth.text, "0° N"); + strcpy(compassScreen->compassTemperature.text, "0.00°C"); } void compass_screen_set_azimuth(CompassScreen_t * const compassScreen, uint16_t azimuth) @@ -143,6 +149,23 @@ void compass_screen_set_azimuth(CompassScreen_t * const compassScreen, uint16_t rotate_cardinal(&compassScreen->westCardinal, azimuth); } +void compass_screen_set_temperature(CompassScreen_t * const compassScreen, float temperature) +{ + if(!compassScreen) + { + LV_LOG_ERROR("NULL pointer given !"); + return; + } + + //Mandatory, if the screen is not displayed anymore, we should still be able to call this function ! + if(!compassScreen->display) return; + + //Update the temperature label + sprintf(compassScreen->compassTemperature.text, "%.2f°C", temperature); + lv_label_set_text_static(compassScreen->compassTemperature.label, compassScreen->compassTemperature.text); + +} + void compass_screen_create(CompassScreen_t * const compassScreen) { if(!compassScreen) @@ -204,8 +227,20 @@ void compass_screen_create(CompassScreen_t * const compassScreen) lv_obj_set_style_text_font(compassScreen->compassAzimuth.label, &lv_font_montserrat_28, LV_PART_MAIN); lv_obj_center(compassScreen->compassAzimuth.label); + //Temperature label is created here + if(compassScreen->compassTemperature.label) + { + LV_LOG_ERROR("label should be NULL here !"); + lv_obj_del(compassScreen->compassTemperature.label); + compassScreen->compassTemperature.label = NULL; + } + compassScreen->compassTemperature.label = lv_label_create(compassScreen->display); + lv_label_set_text_static(compassScreen->compassTemperature.label, compassScreen->compassTemperature.text); + lv_obj_set_style_text_font(compassScreen->compassTemperature.label, &lv_font_montserrat_24, LV_PART_MAIN); + lv_obj_align(compassScreen->compassTemperature.label, LV_ALIGN_CENTER, 0, -22); + //Add some graduation : - if(compassScreen->compassGraduation.meter) + /*if(compassScreen->compassGraduation.meter) { LV_LOG_ERROR("meter should be NULL here !"); lv_obj_del(compassScreen->compassGraduation.meter); @@ -220,7 +255,7 @@ void compass_screen_create(CompassScreen_t * const compassScreen) compassScreen->compassGraduation.scale = lv_meter_add_scale(compassScreen->compassGraduation.meter); lv_meter_set_scale_ticks(compassScreen->compassGraduation.meter, compassScreen->compassGraduation.scale, 12, 1, 0, lv_color_black()); lv_meter_set_scale_major_ticks(compassScreen->compassGraduation.meter, compassScreen->compassGraduation.scale, 1, 1, 0, lv_color_black(), 11); - lv_meter_set_scale_range(compassScreen->compassGraduation.meter, compassScreen->compassGraduation.scale, 0, 330, 330, -90); + lv_meter_set_scale_range(compassScreen->compassGraduation.meter, compassScreen->compassGraduation.scale, 0, 330, 330, -90);*/ if(compassScreen->northMarker) { @@ -272,7 +307,7 @@ void compass_screen_create(CompassScreen_t * const compassScreen) lv_obj_add_event_cb(compassScreen->display, &(cleanup_event_cb), LV_EVENT_DELETE, compassScreen); //To delete - //lv_timer_create(&(timer_anim_cb), 2, compassScreen); + lv_timer_create(&(timer_anim_cb), 2, compassScreen); } void compass_screen_destroy(CompassScreen_t * const compassScreen) @@ -285,6 +320,7 @@ void compass_screen_destroy(CompassScreen_t * const compassScreen) compassScreen->display = NULL; compassScreen->compassAzimuth.label = NULL; + compassScreen->compassTemperature.label = NULL; compassScreen->northCardinal.label = NULL; compassScreen->eastCardinal.label = NULL; compassScreen->southCardinal.label = NULL; diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/compass_screen.h b/src/lvgl_win_sim/lv_port_win_codeblocks/compass_screen.h index 6597d26..244100e 100644 --- a/src/lvgl_win_sim/lv_port_win_codeblocks/compass_screen.h +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/compass_screen.h @@ -3,11 +3,11 @@ #include "lvgl.h" -typedef struct CompassAzimuthLabel +typedef struct CompassLabel { lv_obj_t *label; char text[9]; -} CompassAzimuth_t; +} CompassLabel_t; typedef struct CompassCardinal { @@ -35,7 +35,8 @@ typedef struct CompassScreen lv_obj_t *northMarker; lv_obj_t *display; - CompassAzimuth_t compassAzimuth; + CompassLabel_t compassAzimuth; + CompassLabel_t compassTemperature; } CompassScreen_t; /* Initializes the compass screen context object */ @@ -44,6 +45,9 @@ void compass_screen_init(CompassScreen_t * const compassScreen); /* Set the compassAzimuth in degrees to show */ void compass_screen_set_azimuth(CompassScreen_t * const compassScreen, uint16_t azimuth); +/* Set the compassTemperature in degrees celsius to show */ +void compass_screen_set_temperature(CompassScreen_t * const compassScreen, float temperature); + /* Builds the compass screen graphically */ void compass_screen_create(CompassScreen_t * const compassScreen); diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/watch_face.c b/src/lvgl_win_sim/lv_port_win_codeblocks/watch_face.c index 82352aa..8747c28 100644 --- a/src/lvgl_win_sim/lv_port_win_codeblocks/watch_face.c +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/watch_face.c @@ -242,3 +242,13 @@ void watch_face_destroy(WatchFace_t * const watchFace) watchFace->mediumHand24h.handImg = NULL; } +void watch_face_force_sync(WatchFace_t *const watchFace) +{ + if(!watchFace) + { + LV_LOG_ERROR("NULL pointer given !"); + return; + } + + update_watch_hands_angles(watchFace, 0); +}