From 636d581bbf0a4a439d824537f29a0dc99c5f053b Mon Sep 17 00:00:00 2001 From: anschrammh Date: Fri, 2 May 2025 11:23:19 +0200 Subject: [PATCH] Updated LVGL simulator files : aligned the watch_face and settings_screen sources --- .../lv_port_win_codeblocks/LittlevGL.layout | 889 +++++++++--------- .../lv_port_win_codeblocks/firmware_version.h | 2 +- .../lv_port_win_codeblocks/main.c | 119 ++- .../lv_port_win_codeblocks/settings_screen.c | 532 ++++++++--- .../lv_port_win_codeblocks/settings_screen.h | 116 ++- .../lv_port_win_codeblocks/watch_face.c | 153 ++- .../lv_port_win_codeblocks/watch_face.h | 51 +- 7 files changed, 1230 insertions(+), 632 deletions(-) diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/LittlevGL.layout b/src/lvgl_win_sim/lv_port_win_codeblocks/LittlevGL.layout index 66b0612..35e7d8c 100644 --- a/src/lvgl_win_sim/lv_port_win_codeblocks/LittlevGL.layout +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/LittlevGL.layout @@ -2,403 +2,19 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -406,24 +22,49 @@ - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -451,9 +92,39 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -461,44 +132,39 @@ - - - - - - - - - - - - - - - - + - + - + - + - + - + - + - + + + + + + + + + + + @@ -506,34 +172,253 @@ - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -541,9 +426,149 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/firmware_version.h b/src/lvgl_win_sim/lv_port_win_codeblocks/firmware_version.h index 63a9047..50c7f00 100644 --- a/src/lvgl_win_sim/lv_port_win_codeblocks/firmware_version.h +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/firmware_version.h @@ -2,6 +2,6 @@ #define FIRMWARE_VERSION_H #define FIRMWARE_VERSION "0.0.1" //Firmware creation -#define FIRMWARE_TIME_DATE (__TIME__" "__DATE__) +#define FIRMWARE_COMPILATION_TIME_DATE (__TIME__" "__DATE__) #endif //FIRMWARE_VERSION_H diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/main.c b/src/lvgl_win_sim/lv_port_win_codeblocks/main.c index 5699098..250f8c0 100644 --- a/src/lvgl_win_sim/lv_port_win_codeblocks/main.c +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/main.c @@ -148,10 +148,122 @@ static uint32_t musicPlayerTimeRefmsCb(void) return ms_time; } +static void setTimeCb(uint8_t *hour, uint8_t *minute, uint8_t *second, uint8_t *day, uint8_t *month, uint8_t *year, SettingMode_e mode) +{ + struct tm timeToSet; + + //First we get the current time from the RTC + time_t time_type = time(NULL); + memcpy(&timeToSet, localtime(&time_type), sizeof timeToSet); + + if(SETTING_MODE_GET == mode) + { + *hour = timeToSet.tm_hour; + *minute = timeToSet.tm_min; + *second = timeToSet.tm_sec; + *day = timeToSet.tm_mday; + *month = timeToSet.tm_mon; + *year = timeToSet.tm_year; + } +} + +static void getBatteryVoltageCb(uint16_t *battery_voltage) +{ + static uint16_t bat_vol = 0; + bat_vol += 12; + bat_vol %= 4200; + *battery_voltage = bat_vol; +} + +static void getMagnetometerRawDataCb(int16_t *field_x, int16_t *field_y, int16_t *field_z, float *temperature) +{ + static int16_t x = -235, y = 1522, z = 65; + static float temp = 15.42f; + x += 15; + y -= 12; + z += 19; + + if(field_x && field_y && field_z) + { + *field_x = x; + *field_y = y; + *field_z = z; + } + + temp += 0.04f; if(temp > 35) temp = 15.42f; + if(temperature) + *temperature = temp; +} + +static void getAccelerometerRawDataCb(int16_t *accel_x, int16_t *accel_y, int16_t *accel_z, float *temperature, uint32_t *step_count) +{ + static int16_t x = 665, y = -25, z = 1245; + static uint32_t steps = 666U; + static float temp = 15.42f; + x += 15; + y -= 12; + z -= 19; + if(accel_x && accel_y && accel_z) + { + *accel_x = x; + *accel_y = y; + *accel_z = z; + } + + + temp += 0.04f; if(temp > 35) temp = 15.42f; + if(temperature) + *temperature = temp; + + steps += 1; + if(step_count) + *step_count = steps; +} + +static void getBMP280DataCb(float *temperature, float *pressure) +{ + /* We want hPa's */ + static float temp = 15.42f, press = 981.42f; + temp += 0.26f; if(temp > 35) temp = 15.42f; + press += 1.42f;if(press > 1045) press = 981.42f; + + *temperature = temp; + *pressure = press; +} + +static void getComponentVersionCb(const char **version, ComponentVersion_e component) +{ + if(*version) + { + switch(component) + { + case COMPONENT_FREERTOS: + *version = "10.4.1"; + break; + case COMPONENT_LVGL: + *version = "8.4.1"; + break; + default: + break; + } + } +} + WatchFace_t watchFace; MenuScreen_t menuScreen; CompassScreen_t compassScreen; + SettingsScreen_t settingsScreen; +SettingsScreenAPIInterface_t settingsScreenAPIInterface = +{ + .setTimeSettingsCb = &(setTimeCb), + .getBatteryVoltageCb = &(getBatteryVoltageCb), + .getMagnetometerRawDataCb = &(getMagnetometerRawDataCb), + .getAccelerometerRawDataCb = &(getAccelerometerRawDataCb), + .getBMP280DataCb = &(getBMP280DataCb), + .getComponentVersionCb = &(getComponentVersionCb), +}; + AltimeterScreen_t altimeterScreen; FindMyPhoneScreen_t findMyPhoneScreen; MusicPlayerScreen_t musicPlayerScreen; @@ -183,6 +295,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLi compass_screen_register_on_state_change_cb(&compassScreen, &(compass_screen_on_state_change_cb)); compass_screen_register_azimuth_and_temperature_cb(&compassScreen, &(azimuth_and_temperature_cb)); settings_screen_init(&settingsScreen); + settings_screen_register_API_interface(&settingsScreen, &settingsScreenAPIInterface); altimeter_screen_init(&altimeterScreen); altimeter_screen_register_on_state_change_cb(&altimeterScreen, &(alti_on_state_change_cb)); altimeter_screen_register_measurement_cb(&altimeterScreen, &(alti_meas_cb)); @@ -207,15 +320,15 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLi watch_face_register_date_time_cb(&watchFace, &(date_time_cb)); watch_face_create(&watchFace); - lv_scr_load(watchFace.display); - + lv_scr_load_anim(watchFace.display, LV_SCR_LOAD_ANIM_NONE, 0, 0, true); watch_face_set_step_count_indicator(&watchFace, 10258); //settings_screen(); //watch_face(); - while(!lv_win32_quit_signal) { + while(!lv_win32_quit_signal) + { /* Periodically call the lv_task handler. * It could be done in a timer interrupt or an OS task too.*/ lv_task_handler(); diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/settings_screen.c b/src/lvgl_win_sim/lv_port_win_codeblocks/settings_screen.c index 2d6cca2..5c846ed 100644 --- a/src/lvgl_win_sim/lv_port_win_codeblocks/settings_screen.c +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/settings_screen.c @@ -1,24 +1,47 @@ +#include +#include #include "lvgl.h" #include "common_screen_components.h" #include "settings_screen.h" #include "menu_screen.h" #include "firmware_version.h" -static const char *day_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31"; -static const char *month_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12"; -static const char *year_options = "22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40"; -static const char *hour_options = "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23"; -static const char *second_minute_options = "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59"; -static const char *date_format = "dd/mm/yyyy\ndd/mm/yy\nyyyy/mm/dd\nyy/mm/dd"; +static const char * const day_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31"; +static const char * const month_options = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12"; +static const char * const year_options = "22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40"; +static const char * const hour_options = "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23"; +static const char * const second_minute_options = "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59"; +static const char * const date_format = "dd/mm/yyyy\ndd/mm/yy\nyyyy/mm/dd\nyy/mm/dd"; -static const char *timeout_options = "Off\n5 seconds\n10 seconds\n15 seconds\n20 seconds\n25 seconds\n30 seconds\n35 seconds\n40 seconds\n45 seconds\n50 seconds\n55 seconds\n60 seconds"; -static const char *orientation_format = "Default\n90�\n180�\n270�"; -static const char* vibration_duration = "None\n100 ms\n150 ms\n200 ms\n250 ms\n300 ms\n350 ms\n400 ms"; -static const char* vibration_strength = "1\n2\n3\n4\n5\n6\n7\n8"; +static const char * const timeout_options = "Off\n5 seconds\n10 seconds\n15 seconds\n20 seconds\n25 seconds\n30 seconds\n35 seconds\n40 seconds\n45 seconds\n50 seconds\n55 seconds\n60 seconds"; +static const char * const orientation_format = "Default\n90�\n180�\n270�"; +static const char * const vibration_duration = "None\n100 ms\n150 ms\n200 ms\n250 ms\n300 ms\n350 ms\n400 ms"; +static const char * const vibration_strength = "1\n2\n3\n4\n5\n6\n7\n8"; -static const char* language_options = "Francais\nDeutsch\nEnglish"; +static const char * const language_options = "Francais\nDeutsch\nEnglish"; + +static const char * const default_version = "NaN"; + +typedef enum roller_id +{ + ROLLER_ID_TOUCH_VIBRATION_DURATION = 0, + ROLLER_ID_TOUCH_VIBRATION_STRENGTH, + ROLLER_ID_NOTIFICATION_VIBRATION_DURATION, + ROLLER_ID_NOTIFICATION_VIBRATION_STRENGTH, + ROLLER_ID_CALL_VIBRATION_DURATION, + ROLLER_ID_CALL_VIBRATION_STRENGTH, +} roller_id_e; + +typedef enum switch_id +{ + SWITCH_ID_BLE_ENABLE = 0, + SWITCH_ID_WIFI_ENABLE, + SWITCH_ID_WRIST_TILT_ENABLE, + SWITCH_ID_AUTOMATIC_TIME_ENABLE, + SWITCH_ID_NOTIFICATION_ENABLE, + SWITCH_ID_CALL_ENABLED, +} switch_id_e; -static void _simulate_side_screen_item_click(SettingsScreen_t * const settingsScreen, lv_obj_t *item); static void _enable_time_and_date_rollers(bool enabled, SettingsScreen_t * const settingsScreen); static void _show_ble_pairing_key(SettingsScreen_t * const settingsScreen, bool show); static void _reset_switch_pointers(SettingsScreen_t * const settingsScreen) @@ -28,6 +51,16 @@ static void _reset_switch_pointers(SettingsScreen_t * const settingsScreen) } static lv_obj_t *add_menu_list_item(lv_obj_t *list, const char *text, lv_event_cb_t event_cb, void *user_data, SettingsScreenCategory_e category); static void update_menu_list_item_text(lv_obj_t *menu_list_item, const char *text); +static void _simulate_side_screen_item_click(SettingsScreen_t * const settingsScreen, lv_obj_t *item); + +/* Helper functions used to update sensor label data */ +static void _set_rtc_time_to_label(SettingsScreen_t * const settingsScreen); +static void _set_battery_voltage_to_label(SettingsScreen_t * const settingsScreen); +static void _set_magnetometer_axes_to_label(SettingsScreen_t * const settingsScreen); +static void _set_magnetometer_temperature_to_label(SettingsScreen_t * const settingsScreen); +static void _set_accelerometer_axes_to_label(SettingsScreen_t * const settingsScreen); +static void _set_accelerometer_steps_and_temperature_to_label(SettingsScreen_t * const settingsScreen); +static void _set_pressure_sensor_to_label(SettingsScreen_t * const settingsScreen); static void gesture_event_cb(lv_event_t *e) { @@ -42,7 +75,7 @@ static void gesture_event_cb(lv_event_t *e) case LV_DIR_RIGHT: LV_LOG_USER("GESTURE : RIGHT"); // We delete the timer if it was created - if(settingsScreen->about_refresh_timer)lv_timer_del(settingsScreen->about_refresh_timer); + if(settingsScreen->sensors_refresh_timer)lv_timer_del(settingsScreen->sensors_refresh_timer); // We create the menu screen and switch to it extern MenuScreen_t menuScreen; menu_screen_create(&menuScreen); @@ -155,11 +188,26 @@ static void factory_reset_cb(lv_event_t *e) } -static void about_refresh_timer_cb(lv_timer_t *timer) +static void sensors_refresh_timer_cb(lv_timer_t *timer) { SettingsScreen_t *settingsScreen = timer->user_data; - lv_label_set_text_static(settingsScreen->currentTime.current_time_label, settingsScreen->currentTime.current_time_text); + /* Timer callback is called every 150 ms, + some data don't need that update rate */ + static uint8_t timer_divider = 6; + + if(timer_divider++ == 6) + { + _set_rtc_time_to_label(settingsScreen); + _set_battery_voltage_to_label(settingsScreen); + _set_pressure_sensor_to_label(settingsScreen); + _set_magnetometer_temperature_to_label(settingsScreen); + _set_accelerometer_steps_and_temperature_to_label(settingsScreen); + timer_divider = 0; + } + + _set_magnetometer_axes_to_label(settingsScreen); + _set_accelerometer_axes_to_label(settingsScreen); } static void load_time_and_date_side_screen(SettingsScreen_t *settingsScreen) @@ -168,7 +216,7 @@ static void load_time_and_date_side_screen(SettingsScreen_t *settingsScreen) lv_label_set_text_static(label, "Set Time & Date :"); settingsScreen->auto_set_time_switch = lv_switch_create(settingsScreen->side_screen); - lv_obj_align_to(settingsScreen->auto_set_time_switch, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(settingsScreen->auto_set_time_switch, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_add_event_cb(settingsScreen->auto_set_time_switch, &(activation_switch_cb), LV_EVENT_VALUE_CHANGED, settingsScreen); label = lv_label_create(settingsScreen->side_screen); @@ -177,7 +225,7 @@ static void load_time_and_date_side_screen(SettingsScreen_t *settingsScreen) label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Time :"); - lv_obj_align_to(label, settingsScreen->auto_set_time_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(label, settingsScreen->auto_set_time_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); settingsScreen->hour_roller = lv_roller_create(settingsScreen->side_screen); settingsScreen->minute_roller = lv_roller_create(settingsScreen->side_screen); @@ -200,12 +248,12 @@ static void load_time_and_date_side_screen(SettingsScreen_t *settingsScreen) label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Time Format :"); - lv_obj_align_to(label, settingsScreen->hour_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(label, settingsScreen->hour_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); settingsScreen->checkbox_time_12H = lv_checkbox_create(settingsScreen->side_screen); lv_checkbox_set_text(settingsScreen->checkbox_time_12H, "12H"); lv_obj_set_style_radius(settingsScreen->checkbox_time_12H, LV_RADIUS_CIRCLE, LV_PART_INDICATOR); - lv_obj_align_to(settingsScreen->checkbox_time_12H, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(settingsScreen->checkbox_time_12H, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_add_event_cb(settingsScreen->checkbox_time_12H, &(time_format_cb), LV_EVENT_CLICKED, settingsScreen); settingsScreen->checkbox_time_24H = lv_checkbox_create(settingsScreen->side_screen); @@ -219,14 +267,14 @@ static void load_time_and_date_side_screen(SettingsScreen_t *settingsScreen) label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Date :"); - lv_obj_align_to(label, settingsScreen->checkbox_time_12H, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(label, settingsScreen->checkbox_time_12H, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); settingsScreen->day_roller = lv_roller_create(settingsScreen->side_screen); settingsScreen->month_roller = lv_roller_create(settingsScreen->side_screen); settingsScreen->year_roller = lv_roller_create(settingsScreen->side_screen); lv_roller_set_options(settingsScreen->day_roller, day_options, LV_ROLLER_MODE_NORMAL); - lv_obj_align_to(settingsScreen->day_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(settingsScreen->day_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_roller_set_visible_row_count(settingsScreen->day_roller, 2); lv_obj_add_event_cb(settingsScreen->day_roller, &(time_roller_cb), LV_EVENT_RELEASED, settingsScreen); @@ -242,11 +290,11 @@ static void load_time_and_date_side_screen(SettingsScreen_t *settingsScreen) label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Date Format :"); - lv_obj_align_to(label, settingsScreen->day_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(label, settingsScreen->day_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_t *date_dropdown = lv_dropdown_create(settingsScreen->side_screen); lv_dropdown_set_options_static(date_dropdown, date_format); - lv_obj_align_to(date_dropdown, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(date_dropdown, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); } static void load_display_side_screen(SettingsScreen_t *settingsScreen) @@ -255,36 +303,36 @@ static void load_display_side_screen(SettingsScreen_t *settingsScreen) lv_label_set_text_static(label, "Brightness :"); lv_obj_t *slider = lv_slider_create(settingsScreen->side_screen); - lv_obj_align_to(slider, label, LV_ALIGN_OUT_BOTTOM_LEFT, 10, 10); + lv_obj_align_to(slider, label, LV_ALIGN_OUT_BOTTOM_LEFT, 10, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_clear_flag(slider, LV_OBJ_FLAG_GESTURE_BUBBLE); lv_obj_set_width(slider, lv_pct(90)); lv_obj_add_event_cb(slider, &(brightness_slider_cb), LV_EVENT_VALUE_CHANGED, settingsScreen); label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Display Off After :"); - lv_obj_align_to(label, slider, LV_ALIGN_OUT_BOTTOM_LEFT, -10, 10); + lv_obj_align_to(label, slider, LV_ALIGN_OUT_BOTTOM_LEFT, -10, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_t *timeout_roller = lv_roller_create(settingsScreen->side_screen); - lv_obj_align_to(timeout_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 10, 10); + lv_obj_align_to(timeout_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 10, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_roller_set_options(timeout_roller, timeout_options, LV_ROLLER_MODE_NORMAL); lv_roller_set_visible_row_count(timeout_roller, 2); lv_obj_add_event_cb(timeout_roller, &(timeout_roller_cb), LV_EVENT_RELEASED, settingsScreen); label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Screen Orientation :"); - lv_obj_align_to(label, timeout_roller, LV_ALIGN_OUT_BOTTOM_LEFT, -10, 10); + lv_obj_align_to(label, timeout_roller, LV_ALIGN_OUT_BOTTOM_LEFT, -10, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_t *orientation_dropdown = lv_dropdown_create(settingsScreen->side_screen); - lv_obj_align_to(orientation_dropdown, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(orientation_dropdown, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_dropdown_set_options_static(orientation_dropdown, orientation_format); lv_obj_add_event_cb(orientation_dropdown, &(orientation_dropdown_cb), LV_EVENT_VALUE_CHANGED, settingsScreen); label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Wakeup :"); - lv_obj_align_to(label, orientation_dropdown, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(label, orientation_dropdown, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_t *wrist_tilt_toggle = lv_switch_create(settingsScreen->side_screen); - lv_obj_align_to(wrist_tilt_toggle, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(wrist_tilt_toggle, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Wrist Tilt"); @@ -292,10 +340,10 @@ static void load_display_side_screen(SettingsScreen_t *settingsScreen) label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Vibrate On Touch :"); - lv_obj_align_to(label, wrist_tilt_toggle, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(label, wrist_tilt_toggle, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_t *on_touch_vibration_duration_roller = lv_roller_create(settingsScreen->side_screen); - lv_obj_align_to(on_touch_vibration_duration_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(on_touch_vibration_duration_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_roller_set_options(on_touch_vibration_duration_roller, vibration_duration, LV_ROLLER_MODE_NORMAL); lv_roller_set_visible_row_count(on_touch_vibration_duration_roller, 2); //lv_obj_add_event_cb(vibration_duration_roller, &(vibration_duration_roller_cb), LV_EVENT_RELEASED, settingsScreen); @@ -305,7 +353,7 @@ static void load_display_side_screen(SettingsScreen_t *settingsScreen) lv_obj_align_to(label, on_touch_vibration_duration_roller, LV_ALIGN_OUT_RIGHT_MID, 5, 0); lv_obj_t *on_touch_vibration_strength_roller = lv_roller_create(settingsScreen->side_screen); - lv_obj_align_to(on_touch_vibration_strength_roller, on_touch_vibration_duration_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(on_touch_vibration_strength_roller, on_touch_vibration_duration_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_roller_set_options(on_touch_vibration_strength_roller, vibration_strength, LV_ROLLER_MODE_NORMAL); lv_roller_set_visible_row_count(on_touch_vibration_strength_roller, 2); lv_obj_set_width(on_touch_vibration_strength_roller, lv_obj_get_width(on_touch_vibration_duration_roller)); @@ -327,16 +375,16 @@ static void load_notifications_side_screen(SettingsScreen_t *settingsScreen) //if(settingsScreen->settingsScreenAPIInterface.setWristTiltSettingsCb) //settingsScreen->settingsScreenAPIInterface.setWristTiltSettingsCb(&toggled, SETTING_MODE_GET); if(toggled)lv_obj_add_state(notification_enable_switch, LV_STATE_CHECKED); - lv_obj_align_to(notification_enable_switch, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(notification_enable_switch, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); //lv_obj_add_event_cb(notification_enable_switch, &(activation_switch_cb), LV_EVENT_VALUE_CHANGED, settingsScreen); label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Enabled"); - lv_obj_align_to(label, notification_enable_switch, LV_ALIGN_OUT_RIGHT_MID, 5, 0); + lv_obj_align_to(label, notification_enable_switch, LV_ALIGN_OUT_RIGHT_MID, 10, 0); label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Vibrate On\nNotifications :"); - lv_obj_align_to(label, notification_enable_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(label, notification_enable_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_t *on_notification_vibration_duration_roller = lv_roller_create(settingsScreen->side_screen); lv_obj_align_to(on_notification_vibration_duration_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); @@ -349,7 +397,7 @@ static void load_notifications_side_screen(SettingsScreen_t *settingsScreen) lv_obj_align_to(label, on_notification_vibration_duration_roller, LV_ALIGN_OUT_RIGHT_MID, 5, 0); lv_obj_t *on_notification_vibration_strength_roller = lv_roller_create(settingsScreen->side_screen); - lv_obj_align_to(on_notification_vibration_strength_roller, on_notification_vibration_duration_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(on_notification_vibration_strength_roller, on_notification_vibration_duration_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_roller_set_options(on_notification_vibration_strength_roller, vibration_strength, LV_ROLLER_MODE_NORMAL); lv_roller_set_visible_row_count(on_notification_vibration_strength_roller, 2); lv_obj_set_width(on_notification_vibration_strength_roller, lv_obj_get_width(on_notification_vibration_duration_roller)); @@ -360,26 +408,26 @@ static void load_notifications_side_screen(SettingsScreen_t *settingsScreen) label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Calls\nNotifications :"); - lv_obj_align_to(label, on_notification_vibration_strength_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(label, on_notification_vibration_strength_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); // Call enable switch lv_obj_t *call_enable_switch = lv_switch_create(settingsScreen->side_screen); toggled = false; //if(settingsScreen->settingsScreenAPIInterface.setWristTiltSettingsCb) //settingsScreen->settingsScreenAPIInterface.setWristTiltSettingsCb(&toggled, SETTING_MODE_GET); if(toggled)lv_obj_add_state(call_enable_switch, LV_STATE_CHECKED); - lv_obj_align_to(call_enable_switch, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(call_enable_switch, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); //lv_obj_add_event_cb(notification_enable_switch, &(activation_switch_cb), LV_EVENT_VALUE_CHANGED, settingsScreen); label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Enabled"); - lv_obj_align_to(label, call_enable_switch, LV_ALIGN_OUT_RIGHT_MID, 5, 0); + lv_obj_align_to(label, call_enable_switch, LV_ALIGN_OUT_RIGHT_MID, 10, 0); label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Vibrate On Calls :"); - lv_obj_align_to(label, call_enable_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(label, call_enable_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_t *on_call_vibration_duration_roller = lv_roller_create(settingsScreen->side_screen); - lv_obj_align_to(on_call_vibration_duration_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(on_call_vibration_duration_roller, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_roller_set_options(on_call_vibration_duration_roller, vibration_duration, LV_ROLLER_MODE_NORMAL); lv_roller_set_visible_row_count(on_call_vibration_duration_roller, 2); //lv_obj_add_event_cb(vibration_duration_roller, &(vibration_duration_roller_cb), LV_EVENT_RELEASED, settingsScreen); @@ -389,7 +437,7 @@ static void load_notifications_side_screen(SettingsScreen_t *settingsScreen) lv_obj_align_to(label, on_call_vibration_duration_roller, LV_ALIGN_OUT_RIGHT_MID, 5, 0); lv_obj_t *on_call_vibration_strength_roller = lv_roller_create(settingsScreen->side_screen); - lv_obj_align_to(on_call_vibration_strength_roller, on_call_vibration_duration_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(on_call_vibration_strength_roller, on_call_vibration_duration_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_roller_set_options(on_call_vibration_strength_roller, vibration_strength, LV_ROLLER_MODE_NORMAL); lv_roller_set_visible_row_count(on_call_vibration_strength_roller, 2); lv_obj_set_width(on_call_vibration_strength_roller, lv_obj_get_width(on_call_vibration_duration_roller)); @@ -401,49 +449,44 @@ static void load_notifications_side_screen(SettingsScreen_t *settingsScreen) static void load_connectivity_side_screen(SettingsScreen_t *settingsScreen) { - lv_obj_t *label = lv_label_create(settingsScreen->side_screen); - lv_label_set_text_static(label, "Connectivity :"); - settingsScreen->ble_switch = lv_switch_create(settingsScreen->side_screen); - lv_obj_align_to(settingsScreen->ble_switch, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); lv_obj_add_event_cb(settingsScreen->ble_switch, &(activation_switch_cb), LV_EVENT_VALUE_CHANGED, settingsScreen); - label = lv_label_create(settingsScreen->side_screen); + lv_obj_t *label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Bluetooth"); lv_obj_align_to(label, settingsScreen->ble_switch, LV_ALIGN_OUT_RIGHT_MID, 10, 0); settingsScreen->ble_pairing_label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(settingsScreen->ble_pairing_label, "Pairing Code :"); - lv_obj_align_to(settingsScreen->ble_pairing_label, settingsScreen->ble_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); + lv_obj_align_to(settingsScreen->ble_pairing_label, settingsScreen->ble_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_add_flag(settingsScreen->ble_pairing_label, LV_OBJ_FLAG_HIDDEN); settingsScreen->ble_pairing_key.label = lv_label_create(settingsScreen->side_screen); lv_obj_set_style_text_color(settingsScreen->ble_pairing_key.label, lv_color_make(130, 130, 130), LV_PART_MAIN); - lv_obj_align_to(settingsScreen->ble_pairing_key.label, settingsScreen->ble_pairing_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); + lv_obj_align_to(settingsScreen->ble_pairing_key.label, settingsScreen->ble_pairing_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); lv_obj_add_flag(settingsScreen->ble_pairing_key.label, LV_OBJ_FLAG_HIDDEN); settingsScreen->ble_dev_name_label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(settingsScreen->ble_dev_name_label, "Device Name :"); - lv_obj_align_to(settingsScreen->ble_dev_name_label, settingsScreen->ble_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); + lv_obj_align_to(settingsScreen->ble_dev_name_label, settingsScreen->ble_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); settingsScreen->ble_dev_name_value = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(settingsScreen->ble_dev_name_value, "MDBT42Q_W800SW"); lv_obj_set_style_text_color(settingsScreen->ble_dev_name_value, lv_color_make(130, 130, 130), LV_PART_MAIN); - lv_obj_align_to(settingsScreen->ble_dev_name_value, settingsScreen->ble_dev_name_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); + lv_obj_align_to(settingsScreen->ble_dev_name_value, settingsScreen->ble_dev_name_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); settingsScreen->ble_dev_mac_label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(settingsScreen->ble_dev_mac_label, "Device MAC :"); - lv_obj_align_to(settingsScreen->ble_dev_mac_label, settingsScreen->ble_dev_name_value, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); + lv_obj_align_to(settingsScreen->ble_dev_mac_label, settingsScreen->ble_dev_name_value, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); settingsScreen->ble_mac_addr.label = lv_label_create(settingsScreen->side_screen); strcpy(settingsScreen->ble_mac_addr.text, "XX:XX:XX:XX:XX:XX"); lv_label_set_text_static(settingsScreen->ble_mac_addr.label, settingsScreen->ble_mac_addr.text); lv_obj_set_style_text_color(settingsScreen->ble_mac_addr.label, lv_color_make(130, 130, 130), LV_PART_MAIN); - lv_obj_align_to(settingsScreen->ble_mac_addr.label, settingsScreen->ble_dev_mac_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); - + lv_obj_align_to(settingsScreen->ble_mac_addr.label, settingsScreen->ble_dev_mac_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); settingsScreen->wifi_switch = lv_switch_create(settingsScreen->side_screen); - lv_obj_align_to(settingsScreen->wifi_switch, settingsScreen->ble_mac_addr.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(settingsScreen->wifi_switch, settingsScreen->ble_mac_addr.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_add_state(settingsScreen->wifi_switch, LV_STATE_DISABLED); settingsScreen->wifi_label = lv_label_create(settingsScreen->side_screen); @@ -451,13 +494,119 @@ static void load_connectivity_side_screen(SettingsScreen_t *settingsScreen) lv_obj_align_to(settingsScreen->wifi_label, settingsScreen->wifi_switch, LV_ALIGN_OUT_RIGHT_MID, 10, 0); } +static void load_sensors_side_screen(SettingsScreen_t *settingsScreen) +{ + /* First, display the RTC time */ + lv_obj_t *rtc_time = lv_label_create(settingsScreen->side_screen); + lv_label_set_text_static(rtc_time, "System Clock :"); + + settingsScreen->sensors_labels.clock.label = lv_label_create(settingsScreen->side_screen); + lv_obj_set_style_text_color(settingsScreen->sensors_labels.clock.label, lv_color_make(130, 130, 130), LV_PART_MAIN); + lv_obj_align_to(settingsScreen->sensors_labels.clock.label, rtc_time, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); + _set_rtc_time_to_label(settingsScreen); + + /* Let's display the magnetometer data */ + lv_obj_t *magnetometer_data = lv_label_create(settingsScreen->side_screen); + lv_label_set_text_static(magnetometer_data, "Magnetometer :"); + lv_obj_align_to(magnetometer_data, settingsScreen->sensors_labels.clock.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); + + settingsScreen->sensors_labels.magnetometer.x.label = lv_label_create(settingsScreen->side_screen); + lv_obj_set_style_text_color(settingsScreen->sensors_labels.magnetometer.x.label, lv_color_make(130, 130, 130), LV_PART_MAIN); + lv_obj_align_to(settingsScreen->sensors_labels.magnetometer.x.label, magnetometer_data, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 3); + + settingsScreen->sensors_labels.magnetometer.y.label = lv_label_create(settingsScreen->side_screen); + lv_obj_set_style_text_color(settingsScreen->sensors_labels.magnetometer.y.label, lv_color_make(130, 130, 130), LV_PART_MAIN); + lv_obj_align_to(settingsScreen->sensors_labels.magnetometer.y.label, settingsScreen->sensors_labels.magnetometer.x.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); + + settingsScreen->sensors_labels.magnetometer.z.label = lv_label_create(settingsScreen->side_screen); + lv_obj_set_style_text_color(settingsScreen->sensors_labels.magnetometer.z.label, lv_color_make(130, 130, 130), LV_PART_MAIN); + lv_obj_align_to(settingsScreen->sensors_labels.magnetometer.z.label, settingsScreen->sensors_labels.magnetometer.y.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); + + settingsScreen->sensors_labels.magnetometer.temperature.label = lv_label_create(settingsScreen->side_screen); + lv_obj_set_style_text_color(settingsScreen->sensors_labels.magnetometer.temperature.label, lv_color_make(130, 130, 130), LV_PART_MAIN); + lv_obj_align_to(settingsScreen->sensors_labels.magnetometer.temperature.label, settingsScreen->sensors_labels.magnetometer.z.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); + _set_magnetometer_axes_to_label(settingsScreen); + _set_magnetometer_temperature_to_label(settingsScreen); + + lv_obj_update_layout(settingsScreen->sensors_labels.magnetometer.temperature.label); + + lv_obj_t *magnetometer_cal_btn = lv_btn_create(settingsScreen->side_screen); + lv_obj_align(magnetometer_cal_btn, LV_ALIGN_TOP_MID, 0, lv_obj_get_y(settingsScreen->sensors_labels.magnetometer.temperature.label) + lv_obj_get_height(settingsScreen->sensors_labels.magnetometer.temperature.label) + SETTINGS_SCREEN_CATEGORY_SPACING_INNER); + + lv_obj_t *magnetometer_cal_btn_label = lv_label_create(magnetometer_cal_btn); + lv_label_set_text_static(magnetometer_cal_btn_label, "Calibrate"); + lv_obj_center(magnetometer_cal_btn_label); + + lv_obj_update_layout(magnetometer_cal_btn); + + /* Let's display the accelerometer data */ + lv_obj_t *accelerometer_data = lv_label_create(settingsScreen->side_screen); + lv_label_set_text_static(accelerometer_data, "Accelerometer :"); + lv_obj_align(accelerometer_data, LV_ALIGN_TOP_LEFT, 0, lv_obj_get_y(magnetometer_cal_btn) + lv_obj_get_height(magnetometer_cal_btn) + SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); + + settingsScreen->sensors_labels.accelerometer.x.label = lv_label_create(settingsScreen->side_screen); + lv_obj_set_style_text_color(settingsScreen->sensors_labels.accelerometer.x.label, lv_color_make(130, 130, 130), LV_PART_MAIN); + lv_obj_align_to(settingsScreen->sensors_labels.accelerometer.x.label, accelerometer_data, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); + + settingsScreen->sensors_labels.accelerometer.y.label = lv_label_create(settingsScreen->side_screen); + lv_obj_set_style_text_color(settingsScreen->sensors_labels.accelerometer.y.label, lv_color_make(130, 130, 130), LV_PART_MAIN); + lv_obj_align_to(settingsScreen->sensors_labels.accelerometer.y.label, settingsScreen->sensors_labels.accelerometer.x.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); + + settingsScreen->sensors_labels.accelerometer.z.label = lv_label_create(settingsScreen->side_screen); + lv_obj_set_style_text_color(settingsScreen->sensors_labels.accelerometer.z.label, lv_color_make(130, 130, 130), LV_PART_MAIN); + lv_obj_align_to(settingsScreen->sensors_labels.accelerometer.z.label, settingsScreen->sensors_labels.accelerometer.y.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); + + settingsScreen->sensors_labels.accelerometer.temperature.label = lv_label_create(settingsScreen->side_screen); + lv_obj_set_style_text_color(settingsScreen->sensors_labels.accelerometer.temperature.label, lv_color_make(130, 130, 130), LV_PART_MAIN); + lv_obj_align_to(settingsScreen->sensors_labels.accelerometer.temperature.label, settingsScreen->sensors_labels.accelerometer.z.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); + + settingsScreen->sensors_labels.accelerometer.steps.label = lv_label_create(settingsScreen->side_screen); + lv_obj_set_style_text_color(settingsScreen->sensors_labels.accelerometer.steps.label, lv_color_make(130, 130, 130), LV_PART_MAIN); + lv_obj_align_to(settingsScreen->sensors_labels.accelerometer.steps.label, settingsScreen->sensors_labels.accelerometer.temperature.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); + _set_accelerometer_axes_to_label(settingsScreen); + _set_accelerometer_steps_and_temperature_to_label(settingsScreen); + + /* Let's display the pressure sensor data */ + lv_obj_t *bmp280_data = lv_label_create(settingsScreen->side_screen); + lv_label_set_text_static(bmp280_data, "Pressure &\nTemperature :"); + lv_obj_align_to(bmp280_data, settingsScreen->sensors_labels.accelerometer.steps.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); + + settingsScreen->sensors_labels.pressure.pressure.label = lv_label_create(settingsScreen->side_screen); + lv_obj_set_style_text_color(settingsScreen->sensors_labels.pressure.pressure.label, lv_color_make(130, 130, 130), LV_PART_MAIN); + lv_obj_align_to(settingsScreen->sensors_labels.pressure.pressure.label, bmp280_data, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); + + settingsScreen->sensors_labels.pressure.temperature.label = lv_label_create(settingsScreen->side_screen); + lv_obj_set_style_text_color(settingsScreen->sensors_labels.pressure.temperature.label, lv_color_make(130, 130, 130), LV_PART_MAIN); + lv_obj_align_to(settingsScreen->sensors_labels.pressure.temperature.label, settingsScreen->sensors_labels.pressure.pressure.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); + _set_pressure_sensor_to_label(settingsScreen); + + /* Let's display the battery voltage */ + lv_obj_t *battery_label = lv_label_create(settingsScreen->side_screen); + lv_label_set_text_static(battery_label, "Battery Voltage :"); + lv_obj_align_to(battery_label, settingsScreen->sensors_labels.pressure.temperature.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); + + settingsScreen->sensors_labels.battery_voltage.label = lv_label_create(settingsScreen->side_screen); + lv_obj_set_style_text_color(settingsScreen->sensors_labels.battery_voltage.label, lv_color_make(130, 130, 130), LV_PART_MAIN); + lv_obj_align_to(settingsScreen->sensors_labels.battery_voltage.label, battery_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); + _set_battery_voltage_to_label(settingsScreen); + + /* Create and start the refresh timer */ + if(settingsScreen->sensors_refresh_timer) + { + LV_LOG_ERROR("sensors_refresh_timer should be NULL here !"); + lv_timer_del(settingsScreen->sensors_refresh_timer); + settingsScreen->sensors_refresh_timer = NULL; + } + settingsScreen->sensors_refresh_timer = lv_timer_create(&(sensors_refresh_timer_cb), 150, settingsScreen); +} + static void load_language_side_screen(SettingsScreen_t *settingsScreen) { lv_obj_t *label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Language :"); lv_obj_t *language_dropdown = lv_dropdown_create(settingsScreen->side_screen); - lv_obj_align_to(language_dropdown, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(language_dropdown, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_dropdown_set_options_static(language_dropdown, language_options); lv_obj_add_event_cb(language_dropdown, &(language_dropdown_cb), LV_EVENT_VALUE_CHANGED, settingsScreen); } @@ -469,7 +618,7 @@ static void load_about_side_screen(SettingsScreen_t *settingsScreen) lv_obj_t *firmware_label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(firmware_label, "Firmware :"); - lv_obj_align_to(firmware_label, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(firmware_label, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_t *version_label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(version_label, FIRMWARE_VERSION); @@ -477,91 +626,56 @@ static void load_about_side_screen(SettingsScreen_t *settingsScreen) lv_obj_align_to(version_label, firmware_label, LV_ALIGN_OUT_RIGHT_MID, 7, 0); lv_obj_t *compile_label = lv_label_create(settingsScreen->side_screen); - lv_label_set_text_static(compile_label, "Compile date :"); - lv_obj_align_to(compile_label, firmware_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); + lv_label_set_text_static(compile_label, "Compile Date :"); + lv_obj_align_to(compile_label, firmware_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_t *compile_date_label = lv_label_create(settingsScreen->side_screen); - lv_label_set_text_static(compile_date_label, FIRMWARE_TIME_DATE); + lv_label_set_text_static(compile_date_label, FIRMWARE_COMPILATION_TIME_DATE); lv_obj_set_style_text_color(compile_date_label, lv_color_make(130, 130, 130), LV_PART_MAIN); - lv_obj_align_to(compile_date_label, compile_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); + lv_obj_align_to(compile_date_label, compile_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); - lv_obj_t *rtc_time = lv_label_create(settingsScreen->side_screen); - lv_label_set_text_static(rtc_time, "RTC :"); - lv_obj_align_to(rtc_time, compile_date_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); + /* Display other firmware component's versions */ + lv_obj_t *freertos_label = lv_label_create(settingsScreen->side_screen); + lv_label_set_text_static(freertos_label, "FreeRTOS Version :"); + lv_obj_align_to(freertos_label, compile_date_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); - /* Display current time and date with refresh */ - settingsScreen->currentTime.current_time_label = lv_label_create(settingsScreen->side_screen); - lv_label_set_text_static(settingsScreen->currentTime.current_time_label, "XX:XX:XX XX/XX/XXXX"); - lv_obj_set_style_text_color(settingsScreen->currentTime.current_time_label, lv_color_make(130, 130, 130), LV_PART_MAIN); - lv_obj_align_to(settingsScreen->currentTime.current_time_label, rtc_time, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); + lv_obj_t *freertos_version_label = lv_label_create(settingsScreen->side_screen); - lv_obj_t *magnetometer_data = lv_label_create(settingsScreen->side_screen); - lv_label_set_text_static(magnetometer_data, "Magnetometer :"); - lv_obj_align_to(magnetometer_data, settingsScreen->currentTime.current_time_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); + const char *freertos_version = default_version; + if(settingsScreen->settingsScreenAPIInterface.getComponentVersionCb) + settingsScreen->settingsScreenAPIInterface.getComponentVersionCb(&freertos_version, COMPONENT_FREERTOS); - lv_obj_t *magnetometer_data_x = lv_label_create(settingsScreen->side_screen); - lv_obj_set_style_text_color(magnetometer_data_x, lv_color_make(130, 130, 130), LV_PART_MAIN); - lv_label_set_text_static(magnetometer_data_x, "x: 1456"); - lv_obj_align_to(magnetometer_data_x, magnetometer_data, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 3); + lv_label_set_text_static(freertos_version_label, freertos_version); + + lv_obj_set_style_text_color(freertos_version_label, lv_color_make(130, 130, 130), LV_PART_MAIN); + lv_obj_align_to(freertos_version_label, freertos_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); - lv_obj_t *magnetometer_data_y = lv_label_create(settingsScreen->side_screen); - lv_obj_set_style_text_color(magnetometer_data_y, lv_color_make(130, 130, 130), LV_PART_MAIN); - lv_label_set_text_static(magnetometer_data_y, "y: -456"); - lv_obj_align_to(magnetometer_data_y, magnetometer_data_x, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 3); + lv_obj_t *lvgl_label = lv_label_create(settingsScreen->side_screen); + lv_label_set_text_static(lvgl_label, "LVGL Version :"); + lv_obj_align_to(lvgl_label, freertos_version_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); - lv_obj_t *magnetometer_data_z = lv_label_create(settingsScreen->side_screen); - lv_obj_set_style_text_color(magnetometer_data_z, lv_color_make(130, 130, 130), LV_PART_MAIN); - lv_label_set_text_static(magnetometer_data_z, "z: -20"); - lv_obj_align_to(magnetometer_data_z, magnetometer_data_y, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 3); + lv_obj_t *lvgl_version_label = lv_label_create(settingsScreen->side_screen); - lv_obj_t *magnetometer_data_temp = lv_label_create(settingsScreen->side_screen); - lv_obj_set_style_text_color(magnetometer_data_temp, lv_color_make(130, 130, 130), LV_PART_MAIN); - lv_label_set_text_static(magnetometer_data_temp, "21.52 °C"); - lv_obj_align_to(magnetometer_data_temp, magnetometer_data_z, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 3); - - lv_obj_t *bmp280 = lv_label_create(settingsScreen->side_screen); - lv_label_set_text_static(bmp280, "Pressure & temp :"); - lv_obj_align_to(bmp280, magnetometer_data_temp, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); - - lv_obj_t *bmp280_temperature = lv_label_create(settingsScreen->side_screen); - lv_obj_set_style_text_color(bmp280_temperature, lv_color_make(130, 130, 130), LV_PART_MAIN); - lv_label_set_text_static(bmp280_temperature, "20.42 °C"); - lv_obj_align_to(bmp280_temperature, bmp280, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 3); - - lv_obj_t *bmp280_pressure = lv_label_create(settingsScreen->side_screen); - lv_obj_set_style_text_color(bmp280_pressure, lv_color_make(130, 130, 130), LV_PART_MAIN); - lv_label_set_text_static(bmp280_pressure, "9525 hPa"); - lv_obj_align_to(bmp280_pressure, bmp280_temperature, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 3); - - lv_obj_t *battery_label = lv_label_create(settingsScreen->side_screen); - lv_label_set_text_static(battery_label, "Battery Voltage :"); - lv_obj_align_to(battery_label, bmp280_pressure, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); - - lv_obj_t *battery_voltage = lv_label_create(settingsScreen->side_screen); - lv_label_set_text_static(battery_voltage, "4277 mV"); - lv_obj_set_style_text_color(battery_voltage, lv_color_make(130, 130, 130), LV_PART_MAIN); - lv_obj_align_to(battery_voltage, battery_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 3); + const char *lvgl_version = default_version; + if(settingsScreen->settingsScreenAPIInterface.getComponentVersionCb) + settingsScreen->settingsScreenAPIInterface.getComponentVersionCb(&lvgl_version, COMPONENT_LVGL); + + lv_label_set_text_static(lvgl_version_label, lvgl_version); + + lv_obj_set_style_text_color(lvgl_version_label, lv_color_make(130, 130, 130), LV_PART_MAIN); + lv_obj_align_to(lvgl_version_label, lvgl_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Factory Reset :"); - lv_obj_align_to(label, battery_voltage, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); + lv_obj_align_to(label, lvgl_version_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_t *factory_rst_btn = lv_btn_create(settingsScreen->side_screen); - lv_obj_align_to(factory_rst_btn, label, LV_ALIGN_OUT_BOTTOM_MID, 0, 5); + lv_obj_align_to(factory_rst_btn, label, LV_ALIGN_OUT_BOTTOM_MID, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_add_event_cb(factory_rst_btn, NULL, LV_EVENT_CLICKED, settingsScreen); label = lv_label_create(factory_rst_btn); lv_label_set_text_static(label, "Reset"); lv_obj_center(label); - - /* Create and start the refresh timer */ - if(settingsScreen->about_refresh_timer) - { - LV_LOG_ERROR("about_refresh_timer should be NULL here !"); - lv_timer_del(settingsScreen->about_refresh_timer); - settingsScreen->about_refresh_timer = NULL; - } - settingsScreen->about_refresh_timer = lv_timer_create(&(about_refresh_timer_cb), 150, settingsScreen); } static void menu_list_item_event_handler(lv_event_t * e) @@ -643,6 +757,7 @@ void settings_screen_create(SettingsScreen_t * const settingsScreen) lv_obj_set_style_radius(settingsScreen->side_screen, 0, LV_PART_MAIN); lv_obj_set_style_border_width(settingsScreen->side_screen, 0, LV_PART_MAIN); lv_obj_set_style_pad_left(settingsScreen->side_screen, 5, LV_PART_MAIN); + // Add some padding to make the settings page scroll longer lv_obj_set_style_pad_bottom(settingsScreen->side_screen, 70, LV_PART_MAIN); lv_obj_set_scroll_dir(settingsScreen->side_screen, LV_DIR_VER); @@ -678,29 +793,30 @@ void settings_screen_destroy(SettingsScreen_t * const settingsScreen) settingsScreen->settingsScreenOnStateChangeCb(SETTINGS_SCREEN_STATE_CLOSED, (SettingsScreenCategory_e)lv_obj_get_user_data(settingsScreen->last_selected_item)); } - settingsScreen->hour_roller = NULL; - settingsScreen->minute_roller = NULL; - settingsScreen->second_roller = NULL; - settingsScreen->day_roller = NULL; - settingsScreen->month_roller = NULL; - settingsScreen->year_roller = NULL; - settingsScreen->display = NULL; - settingsScreen->about_refresh_timer = NULL; - settingsScreen->last_selected_item = NULL; + settingsScreen->hour_roller = NULL; + settingsScreen->minute_roller = NULL; + settingsScreen->second_roller = NULL; + settingsScreen->day_roller = NULL; + settingsScreen->month_roller = NULL; + settingsScreen->year_roller = NULL; + settingsScreen->display = NULL; + settingsScreen->sensors_refresh_timer = NULL; + settingsScreen->last_selected_item = NULL; } static void _simulate_side_screen_item_click(SettingsScreen_t * const settingsScreen, lv_obj_t *item) { if(settingsScreen->last_selected_item == item) return; - if(settingsScreen->last_selected_item == settingsScreen->about_item) + if(settingsScreen->last_selected_item == settingsScreen->sensors_item) { - lv_timer_del(settingsScreen->about_refresh_timer); - settingsScreen->about_refresh_timer = NULL; + lv_timer_del(settingsScreen->sensors_refresh_timer); + settingsScreen->sensors_refresh_timer = NULL; } // Updating the background of the selected category lv_obj_set_style_bg_color(item, lv_color_make(178, 223, 219), LV_PART_MAIN); + if(settingsScreen->last_selected_item) lv_obj_set_style_bg_color(settingsScreen->last_selected_item, lv_color_white(), LV_PART_MAIN); @@ -735,6 +851,10 @@ static void _simulate_side_screen_item_click(SettingsScreen_t * const settingsSc { load_connectivity_side_screen(settingsScreen); } + else if(item == settingsScreen->sensors_item) + { + load_sensors_side_screen(settingsScreen); + } else if(item == settingsScreen->language_item) { load_language_side_screen(settingsScreen); @@ -745,6 +865,134 @@ static void _simulate_side_screen_item_click(SettingsScreen_t * const settingsSc } } +static void _set_rtc_time_to_label(SettingsScreen_t * const settingsScreen) +{ + uint8_t hour = 0U, minute = 0U, second = 0U, day = 0U, month = 0U, year = 0U; + if(settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb) + settingsScreen->settingsScreenAPIInterface.setTimeSettingsCb(&hour, &minute, &second, &day, &month, &year, SETTING_MODE_GET); + snprintf(settingsScreen->sensors_labels.clock.text, + sizeof(settingsScreen->sensors_labels.clock.text)-1, "%s%u:%s%u:%s%u %s%u/%s%u/%u", + hour < 10 ? "0":"", hour, + minute < 10 ? "0":"", minute, + second < 10 ? "0":"", second, + day < 10 ? "0":"", day, + month + 1 < 10 ? "0":"", month + 1, + year+1900); + + lv_label_set_text_static(settingsScreen->sensors_labels.clock.label, settingsScreen->sensors_labels.clock.text); +} + +static void _set_battery_voltage_to_label(SettingsScreen_t * const settingsScreen) +{ + uint16_t voltage = 0U; + if(settingsScreen->settingsScreenAPIInterface.getBatteryVoltageCb) settingsScreen->settingsScreenAPIInterface.getBatteryVoltageCb(&voltage); + + snprintf(settingsScreen->sensors_labels.battery_voltage.text, + sizeof(settingsScreen->sensors_labels.battery_voltage.text)-1, "%u mV", voltage); + + lv_label_set_text_static(settingsScreen->sensors_labels.battery_voltage.label, settingsScreen->sensors_labels.battery_voltage.text); +} + +static void _set_magnetometer_axes_to_label(SettingsScreen_t * const settingsScreen) +{ + int16_t field_x = 0, field_y = 0, field_z = 0; + + if(settingsScreen->settingsScreenAPIInterface.getMagnetometerRawDataCb) + settingsScreen->settingsScreenAPIInterface.getMagnetometerRawDataCb(&field_x, + &field_y, + &field_z, + NULL); + snprintf(settingsScreen->sensors_labels.magnetometer.x.text, + sizeof(settingsScreen->sensors_labels.magnetometer.x.text)-1, + "x: %d", field_x); + snprintf(settingsScreen->sensors_labels.magnetometer.y.text, + sizeof(settingsScreen->sensors_labels.magnetometer.y.text)-1, + "y: %d", field_y); + snprintf(settingsScreen->sensors_labels.magnetometer.z.text, + sizeof(settingsScreen->sensors_labels.magnetometer.z.text)-1, + "z: %d", field_z); + + lv_label_set_text_static(settingsScreen->sensors_labels.magnetometer.x.label, settingsScreen->sensors_labels.magnetometer.x.text); + lv_label_set_text_static(settingsScreen->sensors_labels.magnetometer.y.label, settingsScreen->sensors_labels.magnetometer.y.text); + lv_label_set_text_static(settingsScreen->sensors_labels.magnetometer.z.label, settingsScreen->sensors_labels.magnetometer.z.text); +} + +static void _set_magnetometer_temperature_to_label(SettingsScreen_t * const settingsScreen) +{ + float temperature = 0.0f; + + if(settingsScreen->settingsScreenAPIInterface.getMagnetometerRawDataCb) + settingsScreen->settingsScreenAPIInterface.getMagnetometerRawDataCb(NULL, + NULL, + NULL, + &temperature); + + snprintf(settingsScreen->sensors_labels.magnetometer.temperature.text, + sizeof(settingsScreen->sensors_labels.magnetometer.temperature.text)-1, + "%.2f °C", temperature); + + lv_label_set_text_static(settingsScreen->sensors_labels.magnetometer.temperature.label, settingsScreen->sensors_labels.magnetometer.temperature.text); +} + +static void _set_accelerometer_axes_to_label(SettingsScreen_t * const settingsScreen) +{ + int16_t accel_x = 0, accel_y = 0, accel_z = 0; + + if(settingsScreen->settingsScreenAPIInterface.getAccelerometerRawDataCb) + settingsScreen->settingsScreenAPIInterface.getAccelerometerRawDataCb(&accel_x, + &accel_y, + &accel_z, + NULL, + NULL); + snprintf(settingsScreen->sensors_labels.accelerometer.x.text, + sizeof(settingsScreen->sensors_labels.accelerometer.x.text)-1, + "x: %d", accel_x); + snprintf(settingsScreen->sensors_labels.accelerometer.y.text, + sizeof(settingsScreen->sensors_labels.accelerometer.y.text)-1, + "y: %d", accel_y); + snprintf(settingsScreen->sensors_labels.accelerometer.z.text, + sizeof(settingsScreen->sensors_labels.accelerometer.z.text)-1, + "z: %d", accel_z); + + lv_label_set_text_static(settingsScreen->sensors_labels.accelerometer.x.label, settingsScreen->sensors_labels.accelerometer.x.text); + lv_label_set_text_static(settingsScreen->sensors_labels.accelerometer.y.label, settingsScreen->sensors_labels.accelerometer.y.text); + lv_label_set_text_static(settingsScreen->sensors_labels.accelerometer.z.label, settingsScreen->sensors_labels.accelerometer.z.text); +} + +static void _set_accelerometer_steps_and_temperature_to_label(SettingsScreen_t * const settingsScreen) +{ + float temperature = 0.0F; + uint32_t steps = 0U; + + if(settingsScreen->settingsScreenAPIInterface.getAccelerometerRawDataCb) + settingsScreen->settingsScreenAPIInterface.getAccelerometerRawDataCb(NULL, + NULL, + NULL, + &temperature, + &steps); + snprintf(settingsScreen->sensors_labels.accelerometer.temperature.text, + sizeof(settingsScreen->sensors_labels.accelerometer.temperature.text)-1, + "%.2f °C", temperature); + snprintf(settingsScreen->sensors_labels.accelerometer.steps.text, + sizeof(settingsScreen->sensors_labels.accelerometer.steps.text)-1, + "%s: %u", "steps", steps); + + lv_label_set_text_static(settingsScreen->sensors_labels.accelerometer.temperature.label, settingsScreen->sensors_labels.accelerometer.temperature.text); + lv_label_set_text_static(settingsScreen->sensors_labels.accelerometer.steps.label, settingsScreen->sensors_labels.accelerometer.steps.text); +} + +static void _set_pressure_sensor_to_label(SettingsScreen_t * const settingsScreen) +{ + float pressure = 0.0F, temperature = 0.0F; + if(settingsScreen->settingsScreenAPIInterface.getBMP280DataCb) settingsScreen->settingsScreenAPIInterface.getBMP280DataCb(&temperature, &pressure); + + snprintf(settingsScreen->sensors_labels.pressure.pressure.text, sizeof(settingsScreen->sensors_labels.pressure.pressure.text)-1, "%.2f hPa", pressure); + snprintf(settingsScreen->sensors_labels.pressure.temperature.text, sizeof(settingsScreen->sensors_labels.pressure.temperature.text)-1, "%.2f °C", temperature); + + lv_label_set_text_static(settingsScreen->sensors_labels.pressure.pressure.label, settingsScreen->sensors_labels.pressure.pressure.text); + lv_label_set_text_static(settingsScreen->sensors_labels.pressure.temperature.label, settingsScreen->sensors_labels.pressure.temperature.text); +} + static void _enable_time_and_date_rollers(bool enabled, SettingsScreen_t * const settingsScreen) { if(enabled) @@ -808,11 +1056,11 @@ static void update_menu_list_item_text(lv_obj_t *menu_list_item, const char *tex static void _show_ble_pairing_key(SettingsScreen_t * const settingsScreen, bool show) { - lv_obj_align_to(settingsScreen->ble_pairing_label, settingsScreen->ble_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); + lv_obj_align_to(settingsScreen->ble_pairing_label, settingsScreen->ble_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); if(show) { lv_label_set_text_static(settingsScreen->ble_pairing_key.label, settingsScreen->ble_pairing_key.text); - lv_obj_align_to(settingsScreen->ble_dev_name_label, settingsScreen->ble_pairing_key.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); + lv_obj_align_to(settingsScreen->ble_dev_name_label, settingsScreen->ble_pairing_key.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_clear_flag(settingsScreen->ble_pairing_label, LV_OBJ_FLAG_HIDDEN); lv_obj_clear_flag(settingsScreen->ble_pairing_key.label, LV_OBJ_FLAG_HIDDEN); } @@ -820,12 +1068,12 @@ static void _show_ble_pairing_key(SettingsScreen_t * const settingsScreen, bool { lv_obj_add_flag(settingsScreen->ble_pairing_key.label, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(settingsScreen->ble_pairing_label, LV_OBJ_FLAG_HIDDEN); - lv_obj_align_to(settingsScreen->ble_dev_name_label, settingsScreen->ble_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); + lv_obj_align_to(settingsScreen->ble_dev_name_label, settingsScreen->ble_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); } - lv_obj_align_to(settingsScreen->ble_dev_name_value, settingsScreen->ble_dev_name_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); - lv_obj_align_to(settingsScreen->ble_dev_mac_label, settingsScreen->ble_dev_name_value, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); - lv_obj_align_to(settingsScreen->ble_mac_addr.label, settingsScreen->ble_dev_mac_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); - lv_obj_align_to(settingsScreen->wifi_switch, settingsScreen->ble_mac_addr.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(settingsScreen->ble_dev_name_value, settingsScreen->ble_dev_name_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); + lv_obj_align_to(settingsScreen->ble_dev_mac_label, settingsScreen->ble_dev_name_value, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); + lv_obj_align_to(settingsScreen->ble_mac_addr.label, settingsScreen->ble_dev_mac_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_INNER); + lv_obj_align_to(settingsScreen->wifi_switch, settingsScreen->ble_mac_addr.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, SETTINGS_SCREEN_CATEGORY_SPACING_OUTER); lv_obj_align_to(settingsScreen->wifi_label, settingsScreen->wifi_switch, LV_ALIGN_OUT_RIGHT_MID, 10, 0); } diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/settings_screen.h b/src/lvgl_win_sim/lv_port_win_codeblocks/settings_screen.h index 08c421b..58e4ad7 100644 --- a/src/lvgl_win_sim/lv_port_win_codeblocks/settings_screen.h +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/settings_screen.h @@ -3,9 +3,51 @@ #include "lvgl.h" +#define SETTINGS_SCREEN_CATEGORY_SPACING_INNER (3) +#define SETTINGS_SCREEN_CATEGORY_SPACING_OUTER (10) + +typedef enum SettingMode +{ + SETTING_MODE_GET = 0, + SETTING_MODE_SET +} SettingMode_e; + +typedef enum ComponentVersion +{ + COMPONENT_FREERTOS = 0, + COMPONENT_LVGL +} ComponentVersion_e; + typedef struct SettingsScreenAPIInterface { - + void (*setAutomaticTimeSettingsCb)(bool *enabled, SettingMode_e mode); + void (*setTimeSettingsCb)(uint8_t *hour, uint8_t *minute, uint8_t *second, uint8_t *day, uint8_t *month, uint8_t *year, SettingMode_e mode); + void (*setTimeFormatSettingsCb)(bool *hour_24H_format, SettingMode_e mode); + void (*setBrightnessSettingsCb)(uint8_t *brightness, SettingMode_e mode); + void (*setTimeoutSettingsCb)(uint8_t *timeout, SettingMode_e mode); + void (*setOrientationSettingsCb)(uint8_t *orientation, SettingMode_e mode); + void (*setWristTiltSettingsCb)(bool *enabled, SettingMode_e mode); + void (*setNotificationEnabledSettingsCb)(bool *enabled, SettingMode_e mode); + void (*setDisplayVibrationDurationSettingsCb)(uint8_t *duration, SettingMode_e mode); + void (*setDisplayVibrationStrengthSettingsCb)(uint8_t *strength, SettingMode_e mode); + void (*setCallEnabledSettingsCb)(bool *enabled, SettingMode_e mode); + void (*setNotificationVibrationDurationSettingsCb)(uint8_t *duration, SettingMode_e mode); + void (*setNotificationVibrationStrengthSettingsCb)(uint8_t *strength, SettingMode_e mode); + void (*setCallVibrationDurationSettingsCb)(uint8_t *duration, SettingMode_e mode); + void (*setCallVibrationStrengthSettingsCb)(uint8_t *strength, SettingMode_e mode); + void (*setBLEEnabledSettingsCb)(bool *enabled, SettingMode_e mode); + void (*setWiFiEnabledSettingsCb)(bool *enabled, SettingMode_e mode); + void (*setLanguageSettingsCb)(uint8_t *language, SettingMode_e mode); + void (*getBLEDeviceNameCb)(const char **dev_name); + void (*getBLEDeviceMACCb)(const uint8_t **dev_mac); + void (*getBLEDevicePairingKeyCb)(uint32_t *pairing_key); + void (*getBatteryVoltageCb)(uint16_t *battery_voltage); + void (*getMagnetometerRawDataCb)(int16_t *field_x, int16_t *field_y, int16_t *field_z, float *temperature); + void (*getAccelerometerRawDataCb)(int16_t *accel_x, int16_t *accel_y, int16_t *accel_z, float *temperature, uint32_t *step_count); + void (*getBMP280DataCb)(float *temperature, float *pressure); + void (*getComponentVersionCb)(const char **version, ComponentVersion_e component); + void (*saveSettingsCb)(void); + void (*factoryResetCb)(void); } SettingsScreenAPIInterface_t; typedef enum SettingsScreenState @@ -26,6 +68,7 @@ typedef enum SettingsScreenCategory } SettingsScreenCategory_e; typedef void (*SettingsScreenOnStateChangeCb_t)(SettingsScreenState_e settingsScreenState, SettingsScreenCategory_e settingsScreenCategory); +typedef void (*SettingsScreenUserFeedbackCb_t)(void); typedef struct SettingsScreen { @@ -61,6 +104,60 @@ typedef struct SettingsScreen lv_obj_t *ble_dev_name_value; lv_obj_t *ble_dev_mac_label; + struct + { + struct + { + lv_obj_t *label; + char text[20]; + } clock; + + struct + { + struct + { + lv_obj_t *label; + char text[11]; + } x, y, z, temperature; + } magnetometer; + + struct + { + struct + { + lv_obj_t *label; + char text[11]; + } x, y, z, temperature; + + struct + { + lv_obj_t *label; + char text[18]; + } steps; + } accelerometer; + + struct + { + struct + { + lv_obj_t *label; + char text[13]; + } pressure; + + struct + { + lv_obj_t *label; + char text[11]; + } temperature; + } pressure; + + struct + { + lv_obj_t *label; + char text[8]; + } battery_voltage; + } sensors_labels; + struct { lv_obj_t *current_time_label; @@ -83,8 +180,9 @@ typedef struct SettingsScreen lv_obj_t *display; /* Other */ - lv_timer_t *about_refresh_timer; + lv_timer_t *sensors_refresh_timer; SettingsScreenOnStateChangeCb_t settingsScreenOnStateChangeCb; + SettingsScreenUserFeedbackCb_t settingsScreenUserFeedbackCb; } SettingsScreen_t; void settings_screen_init(SettingsScreen_t * const settingsScreen); @@ -92,13 +190,23 @@ void settings_screen_init(SettingsScreen_t * const settingsScreen); /** * @brief Registers a callback function which will be called every time the state of the application changes ie : is opened or closed. * This callback should be used to initialize and deinitialize needed devices drivers like the magnetometer or the temperature sensor. - * @note The state of the application is passed as a parameter or the callback function. + * @note The state of the application is passed as a parameter of the callback function. * - * @param settingsScreen a pointer to the settings screen object structure. + * @param settingsScreen a pointer to the previously initialized settings screen object structure. * @param SettingsScreenOnStateChangeCb the callback of type @ref SettingsScreenOnStateChangeCb_t to register. */ void settings_screen_register_on_state_change_cb(SettingsScreen_t * const settingsScreen, SettingsScreenOnStateChangeCb_t SettingsScreenOnStateChangeCb); +/** + * @brief Registers a callback functions which will be called every time a user feedback should + * be made. In this case, every time a UI element is clicked, the callback will be called. + * This enables the app to react to user interaction. + * + * @param settingsScreen a pointer to the previously initialized settings screen object structure. + * @param settingsScreenUserFeedbackCb the callback of type @ref SettingsScreenUserFeedbackCb_t to register. + */ +void settings_screen_register_user_feedback_cb(SettingsScreen_t * const settingsScreen, SettingsScreenUserFeedbackCb_t settingsScreenUserFeedbackCb); + void settings_screen_register_API_interface(SettingsScreen_t * const settingsScreen, SettingsScreenAPIInterface_t * const settingsScreenAPIInterface); void settings_screen_create(SettingsScreen_t * const settingsScreen); 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 bebdafd..9416c78 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 @@ -89,9 +89,9 @@ static void _set_bluetooth_indicator(WatchFace_t * const watchFace) } } -static void gesture_event_cb(lv_event_t * e) +static void gesture_event_cb(lv_event_t *e) { - WatchFace_t *watchFace = e->user_data; + WatchFace_t *watchFace = lv_event_get_user_data(e); lv_dir_t gesture; switch(gesture = lv_indev_get_gesture_dir(lv_indev_get_act())) @@ -104,6 +104,9 @@ static void gesture_event_cb(lv_event_t * e) // We delete the timer lv_timer_del(watchFace->batteryIndicator.lowBatteryAnimationTimer); lv_timer_del(watchFace->handAnimationTimer); + // Checking if timer is not NULL here because it could have been deleted already + if(watchFace->handHideTimer)lv_timer_del(watchFace->handHideTimer); + lv_timer_del(watchFace->stepCounterRefreshTimer); // We create the menu screen and switch to it extern MenuScreen_t menuScreen; menu_screen_create(&menuScreen); @@ -120,9 +123,9 @@ static void gesture_event_cb(lv_event_t * e) } } -static void cleanup_event_cb(lv_event_t * e) +static void cleanup_event_cb(lv_event_t *e) { - WatchFace_t *watchFace = e->user_data; + WatchFace_t *watchFace = lv_event_get_user_data(e); watch_face_destroy(watchFace); LV_LOG_USER("cleanup"); } @@ -163,7 +166,7 @@ static void update_watch_hands_angles(WatchFace_t * const watchFace, uint8_t inc watchFace->minuteHand.handAngle = 60 * watchFace->dateTime.tm_min + watchFace->secondHand.handAngle / 60; watchFace->hourHand.handAngle = 300 * watchFace->dateTime.tm_hour + watchFace->minuteHand.handAngle / 12; watchFace->mediumHand24h.handAngle = watchFace->hourHand.handAngle / 2; - LV_LOG_USER("angle : %f", watchFace->secondHand.handAngle); + //LV_LOG_USER("angle : %f", watchFace->secondHand.handAngle); //We update the angle lv_img_set_angle(watchFace->secondHand.handImg, (uint16_t) watchFace->secondHand.handAngle % 3600); @@ -220,6 +223,18 @@ static void battery_timer_anim_cb(lv_timer_t *timer) } } +static void step_counter_refresh_cb(lv_timer_t *timer) +{ + WatchFace_t *watchFace = timer->user_data; + + if(watchFace->stepCounterIndicatorCb) + { + uint32_t steps = 0; + watchFace->stepCounterIndicatorCb(&steps); + watch_face_set_step_count_indicator(watchFace, steps); + } +} + static void set_battery_state_icon(WatchFace_t * const watchFace) { switch(watchFace->batteryIndicator.batteryState) @@ -241,39 +256,13 @@ static void set_battery_state_icon(WatchFace_t * const watchFace) } } -static void hide_hour_and_minutes_hand_cb(lv_event_t *e) +/* Just for testing purposes, creates a new notification */ +static void create_notification_cb(lv_event_t *e) { - WatchFace_t *watchFace = lv_event_get_user_data(e); - - // Consumes too much ram on embedded target :-( - /*if(255 == lv_obj_get_style_opa(watchFace->hourHand.handImg, LV_PART_MAIN)) - { - lv_obj_set_style_opa(watchFace->hourHand.handImg, 120, LV_PART_MAIN); - lv_obj_set_style_opa(watchFace->minuteHand.handImg, 120, LV_PART_MAIN); - } - else - { - lv_obj_set_style_opa(watchFace->hourHand.handImg, 255, LV_PART_MAIN); - lv_obj_set_style_opa(watchFace->minuteHand.handImg, 255, LV_PART_MAIN); - }*/ - - if(lv_obj_has_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN)) - { - lv_obj_clear_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN); - lv_obj_clear_flag(watchFace->minuteHand.handImg, LV_OBJ_FLAG_HIDDEN); - } - else - { - lv_obj_add_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN); - lv_obj_add_flag(watchFace->minuteHand.handImg, LV_OBJ_FLAG_HIDDEN); - } - - //Just for testing purposes, create a new notification char *title = malloc(strlen("JoeJohny John")+1); strcpy(title, "JoeJohny John"); char *body = malloc(300+1); - char test[] = "aéb"; strcpy(body, "Héy what's up dude ? What are you doing tonight ?\ Wanna go to the fair with me ?\ This is a quite long message I agree, but it is important\ @@ -284,6 +273,45 @@ to let you know what I do for me and you bro !"); LV_LOG_USER("unread(%u)/ total(%u)", notification_screen_unread_notification_count(¬ificationScreen), notification_screen_notification_count(¬ificationScreen)); } +static void hide_hour_and_minutes_hand_timer_cb(lv_timer_t *timer) +{ + WatchFace_t *watchFace = timer->user_data; + watchFace->handHideTimer = NULL; + + watch_face_show_hour_and_minute_hands(watchFace, true); +} + +static void hide_hour_and_minutes_hand_cb(lv_event_t *e) +{ + WatchFace_t *watchFace = lv_event_get_user_data(e); + + if(lv_obj_has_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN)) + { + if(watchFace->handHideTimer) + { + /* Make the timer execute now to re-display hands + and cleanly free the timer */ + lv_timer_ready(watchFace->handHideTimer); + } + } + else + { + // Let's hide the hands + watch_face_show_hour_and_minute_hands(watchFace, false); + + // Let's start the hand hide timer + if(watchFace->handHideTimer) + { + LV_LOG_ERROR("handHideTimer should be NULL here !"); + lv_timer_del(watchFace->handHideTimer); + watchFace->handHideTimer = NULL; + } + watchFace->handHideTimer = lv_timer_create(&(hide_hour_and_minutes_hand_timer_cb), 3000, watchFace); + // After the timer expires once, delete it by setting the repeat count to 1 + lv_timer_set_repeat_count(watchFace->handHideTimer, 1); + } +} + void watch_face_init(WatchFace_t * const watchFace) { if(!watchFace) @@ -306,6 +334,28 @@ void watch_face_register_date_time_cb(WatchFace_t * const watchFace, DateTimeCb_ watchFace->dateTimeCb = dateTimeCb; } +void watch_face_register_battery_indicator_cb(WatchFace_t *const watchFace, BatteryIndicatorCb_t batteryIndicatorCb) +{ + if(!watchFace) + { + LV_LOG_ERROR("NULL pointer given !"); + return; + } + + watchFace->batteryIndicatorCb = batteryIndicatorCb; +} + +void watch_face_register_step_counter_indicator_cb(WatchFace_t * const watchFace, StepCounterIndicatorCb_t stepCounterIndicatorCb) +{ + if(!watchFace) + { + LV_LOG_ERROR("NULL pointer given !"); + return; + } + + watchFace->stepCounterIndicatorCb = stepCounterIndicatorCb; +} + void watch_face_create(WatchFace_t * const watchFace) { if(!watchFace) @@ -329,6 +379,7 @@ void watch_face_create(WatchFace_t * const watchFace) lv_img_set_src(watchFace->display, watch_face_img); lv_obj_set_style_bg_color(watchFace->display, lv_color_white(), LV_PART_MAIN); lv_obj_add_event_cb(watchFace->display, &(hide_hour_and_minutes_hand_cb), LV_EVENT_LONG_PRESSED, watchFace); + //lv_obj_add_event_cb(watchFace->display, &(create_notification_cb), LV_EVENT_LONG_PRESSED, NULL); //Battery arc is created here if(watchFace->batteryIndicator.batteryArc) @@ -498,8 +549,17 @@ void watch_face_create(WatchFace_t * const watchFace) lv_timer_del(watchFace->handAnimationTimer); watchFace->handAnimationTimer = NULL; } - watchFace->handAnimationTimer = lv_timer_create(&(hand_timer_anim_cb), 200/*1*/, watchFace); + + //We create the timer which refreshes the step counter indicator + if(watchFace->stepCounterRefreshTimer) + { + LV_LOG_ERROR("stepCounterRefreshTimer should be NULL here !"); + lv_timer_del(watchFace->stepCounterRefreshTimer); + watchFace->stepCounterRefreshTimer = NULL; + } + + watchFace->stepCounterRefreshTimer = lv_timer_create(&(step_counter_refresh_cb), 300, watchFace); } void watch_face_set_battery_indicator(WatchFace_t * const watchFace, uint8_t levelInPercent, BatteryState_e batteryState) @@ -593,6 +653,8 @@ void watch_face_destroy(WatchFace_t * const watchFace) watchFace->display = NULL; watchFace->handAnimationTimer = NULL; + watchFace->handHideTimer = NULL; + watchFace->stepCounterRefreshTimer = NULL; watchFace->dateWindow.dateWindowWidget = NULL; watchFace->hourHand.handImg = NULL; watchFace->minuteHand.handImg = NULL; @@ -619,6 +681,29 @@ void watch_face_force_sync(WatchFace_t *const watchFace) update_watch_hands_angles(watchFace, 0); } +void watch_face_show_hour_and_minute_hands(WatchFace_t * const watchFace, bool show) +{ + if(!watchFace) + { + LV_LOG_ERROR("NULL pointer given !"); + return; + } + + if(watch_face_is_in_use(watchFace)) + { + if(show && lv_obj_has_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN)) + { + lv_obj_clear_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN); + lv_obj_clear_flag(watchFace->minuteHand.handImg, LV_OBJ_FLAG_HIDDEN); + } + else if(!show && !lv_obj_has_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN)) + { + lv_obj_add_flag(watchFace->hourHand.handImg, LV_OBJ_FLAG_HIDDEN); + lv_obj_add_flag(watchFace->minuteHand.handImg, LV_OBJ_FLAG_HIDDEN); + } + } +} + bool watch_face_is_in_use(WatchFace_t * const watchFace) { if(!watchFace) diff --git a/src/lvgl_win_sim/lv_port_win_codeblocks/watch_face.h b/src/lvgl_win_sim/lv_port_win_codeblocks/watch_face.h index 63cdb07..51dfca1 100644 --- a/src/lvgl_win_sim/lv_port_win_codeblocks/watch_face.h +++ b/src/lvgl_win_sim/lv_port_win_codeblocks/watch_face.h @@ -63,11 +63,15 @@ typedef struct WatchFace { DateTimeCb_t dateTimeCb; //Call back function used to retrieve the date and time needed by the watch face BatteryIndicatorCb_t batteryIndicatorCb; //Call back function used to update the battery level every minute + StepCounterIndicatorCb_t stepCounterIndicatorCb; + WatchHand_t hourHand; WatchHand_t minuteHand; WatchHand_t secondHand; WatchHand_t mediumHand24h; lv_timer_t *handAnimationTimer; + lv_timer_t *stepCounterRefreshTimer; + lv_timer_t *handHideTimer; lv_obj_t *display; DateWindow_t dateWindow; BatteryIndicator_t batteryIndicator; @@ -76,7 +80,12 @@ typedef struct WatchFace struct tm dateTime; } WatchFace_t; -/* Initializes the watch face context object */ +/** + * @brief Initializes the watch face context object + * @note This function has to be called first before any others + * + * @param watchFace a pointer to the watch face context structure to initialize. + */ void watch_face_init(WatchFace_t * const watchFace); /** @@ -97,19 +106,21 @@ void watch_face_register_date_time_cb(WatchFace_t * const watchFace, DateTimeCb_ void watch_face_register_battery_indicator_cb(WatchFace_t * const watchFace, BatteryIndicatorCb_t batteryIndicatorCb); /** - * @brief Graphically builds the watch face - * + * @brief Registers a call back function used to refresh the step counter indicator located on the watch face. + * The refreshing will be done twice a second. + * + * @param watchFace a pointer to the watch face context structure. + * @param StepCounterIndicatorCb a pointer to a function having the right definition. + */ +void watch_face_register_step_counter_indicator_cb(WatchFace_t * const watchFace, StepCounterIndicatorCb_t stepCounterIndicatorCb); + +/** + * @brief Graphically builds the watch face. + * * @param watchFace a pointer to the watch face context structure. */ void watch_face_create(WatchFace_t * const watchFace); -/** - * @brief Sets the battery indicator to the given value in percent. - * - * @param watchFace a pointer to the watch face context structure. - * @param percentage the value to set the indicator to in percent. - */ - /** * @brief Sets the battery level in percent as well as it's current state to draw on the watch face. * @@ -129,31 +140,39 @@ void watch_face_set_bluetooth_indicator(WatchFace_t * const watchFace, Bluetooth /** * @brief Shows the current step count passed as parameter on the watch face. - * + * * @param watchFace a pointer to the watch face context structure. * @param step_count the step count to show on the watch face. */ void watch_face_set_step_count_indicator(WatchFace_t * const watchFace, uint32_t stepCount); /** - * @brief Forces the watch face to sync up with the RTC by calling the provided date_time_cb + * @brief Forces the watch face to sync up with the RTC by calling the provided date_time_cb. * * @param watchFace a pointer to the watch face context structure. */ void watch_face_force_sync(WatchFace_t * const watchFace); /** - * @brief Returns true if the watch face screen is currently being used and displayed. + * @brief Show or hide the hour and minute hand on the watch face. * * @param watchFace a pointer to the watch face context structure. - * @return true if the watch face screen is being used - * @return false if the watch face screen is not being used/currently displayed + * @param show a boolean value indicating if hands should be shown or not. + */ +void watch_face_show_hour_and_minute_hands(WatchFace_t * const watchFace, bool show); + +/** + * @brief Returns true if the watch face screen is currently being used and displayed. + * + * @param watchFace a pointer to the watch face context structure. + * @return true if the watch face screen is being used. + * @return false if the watch face screen is not being used/currently displayed. */ bool watch_face_is_in_use(WatchFace_t * const watchFace); /** * @brief Frees all resources used by the WatchFace object. - * + * * @param watchFace a pointer to the watch face context structure. */ void watch_face_destroy(WatchFace_t * const watchFace);