diff --git a/src/W800_SDK_v1.00.10/app/gfx/settings_screen.c b/src/W800_SDK_v1.00.10/app/gfx/settings_screen.c index 617fa03..18d80d2 100644 --- a/src/W800_SDK_v1.00.10/app/gfx/settings_screen.c +++ b/src/W800_SDK_v1.00.10/app/gfx/settings_screen.c @@ -1,3 +1,4 @@ +#include #include "lvgl.h" #include "common_screen_components.h" #include "settings_screen.h" @@ -12,9 +13,9 @@ static const char *hour_options = "00\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n1 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 *timeout_options = "Never\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 *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\n50 ms\n100 ms\n150 ms\n200 ms\n250 ms\n300 ms\n350 ms"; +static const char* vibration_duration = "None\n100 ms\n150 ms\n200 ms\n250 ms\n300 ms\n350 ms\n400 ms"; static const char* vibration_force = "1\n2\n3\n4\n5\n6\n7\n8"; static const char* language_options = "Francais\nDeutsch\nEnglish"; @@ -62,6 +63,11 @@ static void gesture_event_cb(lv_event_t *e) static void cleanup_event_cb(lv_event_t *e) { SettingsScreen_t *settingsScreen = e->user_data; + + // Here we call the save callback + if(settingsScreen->settingsScreenAPIInterface.saveSettingsCb) + settingsScreen->settingsScreenAPIInterface.saveSettingsCb(); + settings_screen_destroy(settingsScreen); LV_LOG_USER("cleanup"); } @@ -194,6 +200,10 @@ static void activation_switch_cb(lv_event_t *e) { if(settingsScreen->settingsScreenAPIInterface.setWiFiEnabledSettingsCb)settingsScreen->settingsScreenAPIInterface.setWiFiEnabledSettingsCb(&toggled, SETTING_MODE_SET); } + else if(e->target == settingsScreen->wrist_tilt_switch) + { + if(settingsScreen->settingsScreenAPIInterface.setWristTiltSettingsCb)settingsScreen->settingsScreenAPIInterface.setWristTiltSettingsCb(&toggled, SETTING_MODE_SET); + } } static void language_dropdown_cb(lv_event_t *e) @@ -211,6 +221,13 @@ static void language_dropdown_cb(lv_event_t *e) _settings_screen_update_labels_language(settingsScreen); } +static void factory_reset_cb(lv_event_t *e) +{ + SettingsScreen_t *settingsScreen = e->user_data; + + if(settingsScreen->settingsScreenAPIInterface.factoryResetCb) settingsScreen->settingsScreenAPIInterface.factoryResetCb(); +} + static void about_refresh_timer_cb(lv_timer_t *timer) { SettingsScreen_t *settingsScreen = timer->user_data; @@ -373,16 +390,20 @@ static void load_display_side_screen(SettingsScreen_t *settingsScreen) lv_label_set_text_static(label, "Wakeup :"); lv_obj_align_to(label, orientation_dropdown, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); - 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); + settingsScreen->wrist_tilt_switch = lv_switch_create(settingsScreen->side_screen); + bool toggled = false; + if(settingsScreen->settingsScreenAPIInterface.setWristTiltSettingsCb)settingsScreen->settingsScreenAPIInterface.setWristTiltSettingsCb(&toggled, SETTING_MODE_GET); + if(toggled)lv_obj_add_state(settingsScreen->wrist_tilt_switch, LV_STATE_CHECKED); + lv_obj_align_to(settingsScreen->wrist_tilt_switch, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_add_event_cb(settingsScreen->wrist_tilt_switch, &(activation_switch_cb), LV_EVENT_VALUE_CHANGED, settingsScreen); label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Wrist Tilt"); - lv_obj_align_to(label, wrist_tilt_toggle, LV_ALIGN_OUT_RIGHT_MID, 10, 0); + lv_obj_align_to(label, settingsScreen->wrist_tilt_switch, LV_ALIGN_OUT_RIGHT_MID, 10, 0); 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, settingsScreen->wrist_tilt_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); 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); @@ -401,6 +422,9 @@ static void load_display_side_screen(SettingsScreen_t *settingsScreen) lv_obj_align_to(on_touch_vibration_strength_roller, on_touch_vibration_duration_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); lv_roller_set_options(on_touch_vibration_strength_roller, vibration_force, LV_ROLLER_MODE_NORMAL); lv_roller_set_visible_row_count(on_touch_vibration_strength_roller, 2); + uint8_t strength = 0; + if(settingsScreen->settingsScreenAPIInterface.setDisplayVibrationStrengthSettingsCb)settingsScreen->settingsScreenAPIInterface.setDisplayVibrationStrengthSettingsCb(&strength, SETTING_MODE_GET); + lv_roller_set_selected(on_touch_vibration_strength_roller, strength, LV_ANIM_OFF); lv_obj_set_width(on_touch_vibration_strength_roller, lv_obj_get_width(on_touch_vibration_duration_roller)); lv_obj_add_event_cb(on_touch_vibration_strength_roller, &(vibration_strength_roller_cb), LV_EVENT_RELEASED, settingsScreen); @@ -517,6 +541,18 @@ static void load_about_side_screen(SettingsScreen_t *settingsScreen) lv_obj_align_to(settingsScreen->currentTime.current_time_label, rtc_time, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); _set_rtc_time_to_label(settingsScreen); + label = lv_label_create(settingsScreen->side_screen); + lv_label_set_text_static(label, "Factory Reset :"); + lv_obj_align_to(label, settingsScreen->currentTime.current_time_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); + + 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_add_event_cb(factory_rst_btn, &(factory_reset_cb), 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) { diff --git a/src/W800_SDK_v1.00.10/app/gfx/settings_screen.h b/src/W800_SDK_v1.00.10/app/gfx/settings_screen.h index 6c8d1c1..b8feb4c 100644 --- a/src/W800_SDK_v1.00.10/app/gfx/settings_screen.h +++ b/src/W800_SDK_v1.00.10/app/gfx/settings_screen.h @@ -14,12 +14,15 @@ typedef struct SettingsScreenAPIInterface void (*setTimeSettingsCb)(uint8_t *hour, uint8_t *minute, uint8_t *second, uint8_t *day, uint8_t *month, uint8_t *year, 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 (*setDisplayVibrationDurationSettingsCb)(uint8_t *duration, SettingMode_e mode); void (*setDisplayVibrationStrengthSettingsCb)(uint8_t *strength, SettingMode_e mode); - void (*setOrientationSettingsCb)(uint8_t *orientation, 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 (*saveSettingsCb)(void); + void (*factoryResetCb)(void); } SettingsScreenAPIInterface_t; typedef struct SettingsScreen @@ -43,8 +46,10 @@ typedef struct SettingsScreen lv_obj_t *day_roller; lv_obj_t *month_roller; lv_obj_t *year_roller; + lv_obj_t *wrist_tilt_switch; lv_obj_t *ble_switch; lv_obj_t *wifi_switch; + struct { lv_obj_t *current_time_label;