Minor updates to the lvgl files used in the emulation
This commit is contained in:
parent
88badff358
commit
a8e1d0412e
@ -56,8 +56,13 @@ static void timer_anim_cb(lv_timer_t *timer)
|
|||||||
{
|
{
|
||||||
CompassScreen_t *compassScreen = timer->user_data;
|
CompassScreen_t *compassScreen = timer->user_data;
|
||||||
static uint16_t azimuth = 0;
|
static uint16_t azimuth = 0;
|
||||||
|
static float temp = -20;
|
||||||
compass_screen_set_azimuth(compassScreen, azimuth++);
|
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)
|
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));
|
memset(compassScreen, 0, sizeof(CompassScreen_t));
|
||||||
strcpy(compassScreen->compassAzimuth.text, "0° N");
|
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)
|
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);
|
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)
|
void compass_screen_create(CompassScreen_t * const compassScreen)
|
||||||
{
|
{
|
||||||
if(!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_set_style_text_font(compassScreen->compassAzimuth.label, &lv_font_montserrat_28, LV_PART_MAIN);
|
||||||
lv_obj_center(compassScreen->compassAzimuth.label);
|
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 :
|
//Add some graduation :
|
||||||
if(compassScreen->compassGraduation.meter)
|
/*if(compassScreen->compassGraduation.meter)
|
||||||
{
|
{
|
||||||
LV_LOG_ERROR("meter should be NULL here !");
|
LV_LOG_ERROR("meter should be NULL here !");
|
||||||
lv_obj_del(compassScreen->compassGraduation.meter);
|
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);
|
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_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_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)
|
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);
|
lv_obj_add_event_cb(compassScreen->display, &(cleanup_event_cb), LV_EVENT_DELETE, compassScreen);
|
||||||
|
|
||||||
//To delete
|
//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)
|
void compass_screen_destroy(CompassScreen_t * const compassScreen)
|
||||||
@ -285,6 +320,7 @@ void compass_screen_destroy(CompassScreen_t * const compassScreen)
|
|||||||
|
|
||||||
compassScreen->display = NULL;
|
compassScreen->display = NULL;
|
||||||
compassScreen->compassAzimuth.label = NULL;
|
compassScreen->compassAzimuth.label = NULL;
|
||||||
|
compassScreen->compassTemperature.label = NULL;
|
||||||
compassScreen->northCardinal.label = NULL;
|
compassScreen->northCardinal.label = NULL;
|
||||||
compassScreen->eastCardinal.label = NULL;
|
compassScreen->eastCardinal.label = NULL;
|
||||||
compassScreen->southCardinal.label = NULL;
|
compassScreen->southCardinal.label = NULL;
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
|
|
||||||
typedef struct CompassAzimuthLabel
|
typedef struct CompassLabel
|
||||||
{
|
{
|
||||||
lv_obj_t *label;
|
lv_obj_t *label;
|
||||||
char text[9];
|
char text[9];
|
||||||
} CompassAzimuth_t;
|
} CompassLabel_t;
|
||||||
|
|
||||||
typedef struct CompassCardinal
|
typedef struct CompassCardinal
|
||||||
{
|
{
|
||||||
@ -35,7 +35,8 @@ typedef struct CompassScreen
|
|||||||
lv_obj_t *northMarker;
|
lv_obj_t *northMarker;
|
||||||
lv_obj_t *display;
|
lv_obj_t *display;
|
||||||
|
|
||||||
CompassAzimuth_t compassAzimuth;
|
CompassLabel_t compassAzimuth;
|
||||||
|
CompassLabel_t compassTemperature;
|
||||||
} CompassScreen_t;
|
} CompassScreen_t;
|
||||||
|
|
||||||
/* Initializes the compass screen context object */
|
/* 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 */
|
/* Set the compassAzimuth in degrees to show */
|
||||||
void compass_screen_set_azimuth(CompassScreen_t * const compassScreen, uint16_t azimuth);
|
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 */
|
/* Builds the compass screen graphically */
|
||||||
void compass_screen_create(CompassScreen_t * const compassScreen);
|
void compass_screen_create(CompassScreen_t * const compassScreen);
|
||||||
|
|
||||||
|
@ -242,3 +242,13 @@ void watch_face_destroy(WatchFace_t * const watchFace)
|
|||||||
watchFace->mediumHand24h.handImg = NULL;
|
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);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user