From 4107a5461fe9d4ad88a8b910964e1c2392d8ecfc Mon Sep 17 00:00:00 2001 From: Th3maz1ng Date: Sun, 22 Oct 2023 08:59:28 +0200 Subject: [PATCH] Added new settings to the notification section of the settings (Vibrations duration and strength for the message notifications and for the call notifications), added switches to enable or disable notifications --- .../app/gfx/settings_screen.c | 281 +++++++++++++----- .../app/gfx/settings_screen.h | 8 +- .../app/persistency/watch_settings.c | 36 ++- .../app/persistency/watch_settings.h | 40 ++- .../lv_port_win_codeblocks/settings_screen.c | 86 ++++-- 5 files changed, 340 insertions(+), 111 deletions(-) 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 6fddd32..0719c10 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 @@ -16,10 +16,30 @@ static const char *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_force = "1\n2\n3\n4\n5\n6\n7\n8"; +static const char* vibration_strength = "1\n2\n3\n4\n5\n6\n7\n8"; static const char* language_options = "Francais\nDeutsch\nEnglish"; +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 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); @@ -28,7 +48,6 @@ 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_data_to_label(SettingsScreen_t * const settingsScreen); static void _set_bmp280_data_to_label(SettingsScreen_t * const settingsScreen); -static void _reset_switch_pointers(SettingsScreen_t * const settingsScreen); 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); @@ -161,30 +180,48 @@ static void brightness_slider_cb(lv_event_t *e) settingsScreen->settingsScreenAPIInterface.setBrightnessSettingsCb(&brightness, SETTING_MODE_SET); } -static void vibration_duration_roller_cb(lv_event_t *e) +static void vibration_typed_roller_cb(lv_event_t *e) { SettingsScreen_t *settingsScreen = e->user_data; - if(!settingsScreen->settingsScreenAPIInterface.setDisplayVibrationDurationSettingsCb) return; - lv_obj_t *roller = lv_event_get_target(e); uint8_t index = lv_roller_get_selected(roller); + roller_id_e roller_id = (roller_id_e) lv_obj_get_user_data(roller); - settingsScreen->settingsScreenAPIInterface.setDisplayVibrationDurationSettingsCb(&index, SETTING_MODE_SET); - - common_screen_onclick_vibration(); -} - -static void vibration_strength_roller_cb(lv_event_t *e) -{ - SettingsScreen_t *settingsScreen = e->user_data; - if(!settingsScreen->settingsScreenAPIInterface.setDisplayVibrationStrengthSettingsCb) return; - - lv_obj_t *roller = lv_event_get_target(e); - uint8_t index = lv_roller_get_selected(roller); - - settingsScreen->settingsScreenAPIInterface.setDisplayVibrationStrengthSettingsCb(&index, SETTING_MODE_SET); - - common_screen_onclick_vibration(); + switch(roller_id) + { + case ROLLER_ID_TOUCH_VIBRATION_DURATION: + if (!settingsScreen->settingsScreenAPIInterface.setDisplayVibrationDurationSettingsCb) + return; + settingsScreen->settingsScreenAPIInterface.setDisplayVibrationDurationSettingsCb(&index, SETTING_MODE_SET); + common_screen_onclick_vibration(); + break; + case ROLLER_ID_TOUCH_VIBRATION_STRENGTH: + if(!settingsScreen->settingsScreenAPIInterface.setDisplayVibrationStrengthSettingsCb) + return; + settingsScreen->settingsScreenAPIInterface.setDisplayVibrationStrengthSettingsCb(&index, SETTING_MODE_SET); + common_screen_onclick_vibration(); + break; + case ROLLER_ID_NOTIFICATION_VIBRATION_DURATION: + if (!settingsScreen->settingsScreenAPIInterface.setNotificationVibrationDurationSettingsCb) + return; + settingsScreen->settingsScreenAPIInterface.setNotificationVibrationDurationSettingsCb(&index, SETTING_MODE_SET); + break; + case ROLLER_ID_NOTIFICATION_VIBRATION_STRENGTH: + if (!settingsScreen->settingsScreenAPIInterface.setNotificationVibrationStrengthSettingsCb) + return; + settingsScreen->settingsScreenAPIInterface.setNotificationVibrationStrengthSettingsCb(&index, SETTING_MODE_SET); + break; + case ROLLER_ID_CALL_VIBRATION_DURATION: + if (!settingsScreen->settingsScreenAPIInterface.setCallVibrationDurationSettingsCb) + return; + settingsScreen->settingsScreenAPIInterface.setCallVibrationDurationSettingsCb(&index, SETTING_MODE_SET); + break; + case ROLLER_ID_CALL_VIBRATION_STRENGTH: + if (!settingsScreen->settingsScreenAPIInterface.setCallVibrationStrengthSettingsCb) + return; + settingsScreen->settingsScreenAPIInterface.setCallVibrationStrengthSettingsCb(&index, SETTING_MODE_SET); + break; + } } static void timeout_roller_cb(lv_event_t * e) @@ -212,27 +249,38 @@ static void orientation_dropdown_cb(lv_event_t *e) static void activation_switch_cb(lv_event_t *e) { - SettingsScreen_t *settingsScreen = e->user_data; + SettingsScreen_t *settingsScreen = lv_event_get_user_data(e); + lv_obj_t *switch_obj = lv_event_get_target(e); + bool toggled = lv_obj_has_state(switch_obj, LV_STATE_CHECKED); + switch_id_e switch_id = (switch_id_e) lv_obj_get_user_data(switch_obj); - bool toggled = lv_obj_has_state(e->target, LV_STATE_CHECKED); - - if(e->target == settingsScreen->ble_switch) + switch(switch_id) { - if(settingsScreen->settingsScreenAPIInterface.setBLEEnabledSettingsCb)settingsScreen->settingsScreenAPIInterface.setBLEEnabledSettingsCb(&toggled, SETTING_MODE_SET); - _show_ble_pairing_key(settingsScreen, toggled); - } - else if(e->target == settingsScreen->wifi_switch) - { - 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); - } - else if(e->target == settingsScreen->auto_set_time_switch) - { - if(settingsScreen->settingsScreenAPIInterface.setAutomaticTimeSettingsCb)settingsScreen->settingsScreenAPIInterface.setAutomaticTimeSettingsCb(&toggled, SETTING_MODE_SET); - _enable_time_and_date_rollers(!toggled, settingsScreen); + case SWITCH_ID_BLE_ENABLE: + if(settingsScreen->settingsScreenAPIInterface.setBLEEnabledSettingsCb) + settingsScreen->settingsScreenAPIInterface.setBLEEnabledSettingsCb(&toggled, SETTING_MODE_SET); + _show_ble_pairing_key(settingsScreen, toggled); + break; + case SWITCH_ID_WIFI_ENABLE: + if(settingsScreen->settingsScreenAPIInterface.setWiFiEnabledSettingsCb) + settingsScreen->settingsScreenAPIInterface.setWiFiEnabledSettingsCb(&toggled, SETTING_MODE_SET); + break; + case SWITCH_ID_WRIST_TILT_ENABLE: + if(settingsScreen->settingsScreenAPIInterface.setWristTiltSettingsCb) + settingsScreen->settingsScreenAPIInterface.setWristTiltSettingsCb(&toggled, SETTING_MODE_SET); + break; + case SWITCH_ID_AUTOMATIC_TIME_ENABLE: + if(settingsScreen->settingsScreenAPIInterface.setAutomaticTimeSettingsCb)settingsScreen->settingsScreenAPIInterface.setAutomaticTimeSettingsCb(&toggled, SETTING_MODE_SET); + _enable_time_and_date_rollers(!toggled, settingsScreen); + break; + case SWITCH_ID_NOTIFICATION_ENABLE: + if(settingsScreen->settingsScreenAPIInterface.setNotificationEnabledSettingsCb) + settingsScreen->settingsScreenAPIInterface.setNotificationEnabledSettingsCb(&toggled, SETTING_MODE_SET); + break; + case SWITCH_ID_CALL_ENABLED: + if(settingsScreen->settingsScreenAPIInterface.setCallEnabledSettingsCb) + settingsScreen->settingsScreenAPIInterface.setCallEnabledSettingsCb(&toggled, SETTING_MODE_SET); + break; } } @@ -284,23 +332,24 @@ static void load_time_and_date_side_screen(SettingsScreen_t *settingsScreen) lv_obj_t *label = lv_label_create(settingsScreen->side_screen); 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_t *switch_obj = lv_switch_create(settingsScreen->side_screen); + lv_obj_set_user_data(switch_obj, (void *)SWITCH_ID_AUTOMATIC_TIME_ENABLE); + lv_obj_align_to(switch_obj, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); bool auto_set_enable = false; if(settingsScreen->settingsScreenAPIInterface.setAutomaticTimeSettingsCb)settingsScreen->settingsScreenAPIInterface.setAutomaticTimeSettingsCb(&auto_set_enable, SETTING_MODE_GET); if(auto_set_enable) { - lv_obj_add_state(settingsScreen->auto_set_time_switch, LV_STATE_CHECKED); + lv_obj_add_state(switch_obj, LV_STATE_CHECKED); } - lv_obj_add_event_cb(settingsScreen->auto_set_time_switch, &(activation_switch_cb), LV_EVENT_VALUE_CHANGED, settingsScreen); + lv_obj_add_event_cb(switch_obj, &(activation_switch_cb), LV_EVENT_VALUE_CHANGED, settingsScreen); label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Automatic"); - lv_obj_align_to(label, settingsScreen->auto_set_time_switch, LV_ALIGN_OUT_RIGHT_MID, 10, 0); + lv_obj_align_to(label, switch_obj, LV_ALIGN_OUT_RIGHT_MID, 10, 0); 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, switch_obj, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); settingsScreen->hour_roller = lv_roller_create(settingsScreen->side_screen); settingsScreen->minute_roller = lv_roller_create(settingsScreen->side_screen); @@ -434,73 +483,150 @@ 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); - settingsScreen->wrist_tilt_switch = lv_switch_create(settingsScreen->side_screen); + lv_obj_t *switch_obj = lv_switch_create(settingsScreen->side_screen); + lv_obj_set_user_data(switch_obj, (void *)SWITCH_ID_WRIST_TILT_ENABLE); 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); + if(toggled)lv_obj_add_state(switch_obj, LV_STATE_CHECKED); + lv_obj_align_to(switch_obj, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_add_event_cb(switch_obj, &(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, settingsScreen->wrist_tilt_switch, LV_ALIGN_OUT_RIGHT_MID, 10, 0); + lv_obj_align_to(label, switch_obj, 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, settingsScreen->wrist_tilt_switch, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_align_to(label, switch_obj, 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); lv_roller_set_options(on_touch_vibration_duration_roller, vibration_duration, LV_ROLLER_MODE_NORMAL); + lv_obj_set_user_data(on_touch_vibration_duration_roller, (void *)ROLLER_ID_TOUCH_VIBRATION_DURATION); lv_roller_set_visible_row_count(on_touch_vibration_duration_roller, 2); uint8_t duration = 0; if(settingsScreen->settingsScreenAPIInterface.setDisplayVibrationDurationSettingsCb)settingsScreen->settingsScreenAPIInterface.setDisplayVibrationDurationSettingsCb(&duration, SETTING_MODE_GET); lv_roller_set_selected(on_touch_vibration_duration_roller, duration, LV_ANIM_OFF); - lv_obj_add_event_cb(on_touch_vibration_duration_roller, &(vibration_duration_roller_cb), LV_EVENT_RELEASED, settingsScreen); + lv_obj_add_event_cb(on_touch_vibration_duration_roller, &(vibration_typed_roller_cb), LV_EVENT_RELEASED, settingsScreen); label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Duration"); - lv_obj_align_to(label, on_touch_vibration_duration_roller, LV_ALIGN_OUT_RIGHT_MID, 10, 0); + 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_roller_set_options(on_touch_vibration_strength_roller, vibration_force, LV_ROLLER_MODE_NORMAL); + lv_roller_set_options(on_touch_vibration_strength_roller, vibration_strength, LV_ROLLER_MODE_NORMAL); + lv_obj_set_user_data(on_touch_vibration_strength_roller, (void *)ROLLER_ID_TOUCH_VIBRATION_STRENGTH); 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); + lv_obj_add_event_cb(on_touch_vibration_strength_roller, &(vibration_typed_roller_cb), LV_EVENT_RELEASED, settingsScreen); label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Strength"); - lv_obj_align_to(label, on_touch_vibration_strength_roller, LV_ALIGN_OUT_RIGHT_MID, 10, 0); + lv_obj_align_to(label, on_touch_vibration_strength_roller, LV_ALIGN_OUT_RIGHT_MID, 5, 0); } static void load_notifications_side_screen(SettingsScreen_t *settingsScreen) { - lv_obj_t *label = lv_label_create(settingsScreen->side_screen); - lv_label_set_text_static(label, "Vibrate on\nnotifications :"); + // Notification enable switch + lv_obj_t *notification_enable_switch = lv_switch_create(settingsScreen->side_screen); + lv_obj_set_user_data(notification_enable_switch, (void *)SWITCH_ID_NOTIFICATION_ENABLE); + bool toggled = false; + if(settingsScreen->settingsScreenAPIInterface.setNotificationEnabledSettingsCb) + settingsScreen->settingsScreenAPIInterface.setNotificationEnabledSettingsCb(&toggled, SETTING_MODE_GET); + if(toggled)lv_obj_add_state(notification_enable_switch, LV_STATE_CHECKED); + lv_obj_add_event_cb(notification_enable_switch, &(activation_switch_cb), LV_EVENT_VALUE_CHANGED, settingsScreen); - 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_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); + lv_obj_t * label = lv_label_create(settingsScreen->side_screen); + lv_label_set_text_static(label, "Notifications"); + 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_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); + lv_roller_set_options(on_notification_vibration_duration_roller, vibration_duration, LV_ROLLER_MODE_NORMAL); + lv_obj_set_user_data(on_notification_vibration_duration_roller, (void *)ROLLER_ID_NOTIFICATION_VIBRATION_DURATION); + lv_roller_set_visible_row_count(on_notification_vibration_duration_roller, 2); + uint8_t duration = 0; + if(settingsScreen->settingsScreenAPIInterface.setNotificationVibrationDurationSettingsCb) + settingsScreen->settingsScreenAPIInterface.setNotificationVibrationDurationSettingsCb(&duration, SETTING_MODE_GET); + lv_roller_set_selected(on_notification_vibration_duration_roller, duration, LV_ANIM_OFF); + lv_obj_add_event_cb(on_notification_vibration_duration_roller, &(vibration_typed_roller_cb), LV_EVENT_RELEASED, settingsScreen); label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Duration"); - lv_obj_align_to(label, on_touch_vibration_duration_roller, LV_ALIGN_OUT_RIGHT_MID, 10, 0); + lv_obj_align_to(label, on_notification_vibration_duration_roller, LV_ALIGN_OUT_RIGHT_MID, 5, 0); - lv_obj_t *on_touch_vibration_force_roller = lv_roller_create(settingsScreen->side_screen); - lv_obj_align_to(on_touch_vibration_force_roller, on_touch_vibration_duration_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); - lv_roller_set_options(on_touch_vibration_force_roller, vibration_force, LV_ROLLER_MODE_NORMAL); - lv_roller_set_visible_row_count(on_touch_vibration_force_roller, 2); - lv_obj_set_width(on_touch_vibration_force_roller, lv_obj_get_width(on_touch_vibration_duration_roller)); + 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_roller_set_options(on_notification_vibration_strength_roller, vibration_strength, LV_ROLLER_MODE_NORMAL); + lv_obj_set_user_data(on_notification_vibration_strength_roller, (void *)ROLLER_ID_NOTIFICATION_VIBRATION_STRENGTH); + lv_roller_set_visible_row_count(on_notification_vibration_strength_roller, 2); + uint8_t strength = 0; + if(settingsScreen->settingsScreenAPIInterface.setNotificationVibrationStrengthSettingsCb) + settingsScreen->settingsScreenAPIInterface.setNotificationVibrationStrengthSettingsCb(&strength, SETTING_MODE_GET); + lv_roller_set_selected(on_notification_vibration_strength_roller, strength, LV_ANIM_OFF); + lv_obj_set_width(on_notification_vibration_strength_roller, lv_obj_get_width(on_notification_vibration_duration_roller)); + lv_obj_add_event_cb(on_notification_vibration_strength_roller, &(vibration_typed_roller_cb), LV_EVENT_RELEASED, settingsScreen); label = lv_label_create(settingsScreen->side_screen); - lv_label_set_text_static(label, "Force"); - lv_obj_align_to(label, on_touch_vibration_force_roller, LV_ALIGN_OUT_RIGHT_MID, 10, 0); + lv_label_set_text_static(label, "Strength"); + lv_obj_align_to(label, on_notification_vibration_strength_roller, LV_ALIGN_OUT_RIGHT_MID, 5, 0); + + // Call enable switch + lv_obj_t *call_enable_switch = lv_switch_create(settingsScreen->side_screen); + lv_obj_set_user_data(call_enable_switch, (void *)SWITCH_ID_CALL_ENABLED); + toggled = false; + if(settingsScreen->settingsScreenAPIInterface.setCallEnabledSettingsCb) + settingsScreen->settingsScreenAPIInterface.setCallEnabledSettingsCb(&toggled, SETTING_MODE_GET); + if(toggled)lv_obj_add_state(call_enable_switch, LV_STATE_CHECKED); + lv_obj_align_to(call_enable_switch, on_notification_vibration_strength_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + lv_obj_add_event_cb(call_enable_switch, &(activation_switch_cb), LV_EVENT_VALUE_CHANGED, settingsScreen); + + label = lv_label_create(settingsScreen->side_screen); + lv_label_set_text_static(label, "Calls"); + 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_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_roller_set_options(on_call_vibration_duration_roller, vibration_duration, LV_ROLLER_MODE_NORMAL); + lv_obj_set_user_data(on_call_vibration_duration_roller, (void *)ROLLER_ID_CALL_VIBRATION_DURATION); + lv_roller_set_visible_row_count(on_call_vibration_duration_roller, 2); + duration = 0; + if(settingsScreen->settingsScreenAPIInterface.setCallVibrationDurationSettingsCb) + settingsScreen->settingsScreenAPIInterface.setCallVibrationDurationSettingsCb(&duration, SETTING_MODE_GET); + lv_roller_set_selected(on_call_vibration_duration_roller, duration, LV_ANIM_OFF); + lv_obj_add_event_cb(on_call_vibration_duration_roller, &(vibration_typed_roller_cb), LV_EVENT_RELEASED, settingsScreen); + + label = lv_label_create(settingsScreen->side_screen); + lv_label_set_text_static(label, "Duration"); + 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_roller_set_options(on_call_vibration_strength_roller, vibration_strength, LV_ROLLER_MODE_NORMAL); + lv_obj_set_user_data(on_call_vibration_strength_roller, (void *)ROLLER_ID_CALL_VIBRATION_STRENGTH); + lv_roller_set_visible_row_count(on_call_vibration_strength_roller, 2); + strength = 0; + if(settingsScreen->settingsScreenAPIInterface.setCallVibrationStrengthSettingsCb) + settingsScreen->settingsScreenAPIInterface.setCallVibrationStrengthSettingsCb(&strength, SETTING_MODE_GET); + lv_roller_set_selected(on_call_vibration_strength_roller, strength, LV_ANIM_OFF); + lv_obj_set_width(on_call_vibration_strength_roller, lv_obj_get_width(on_call_vibration_duration_roller)); + lv_obj_add_event_cb(on_call_vibration_strength_roller, &(vibration_typed_roller_cb), LV_EVENT_RELEASED, settingsScreen); + + label = lv_label_create(settingsScreen->side_screen); + lv_label_set_text_static(label, "Strength"); + lv_obj_align_to(label, on_call_vibration_strength_roller, LV_ALIGN_OUT_RIGHT_MID, 5, 0); } static void load_connectivity_side_screen(SettingsScreen_t *settingsScreen) @@ -509,6 +635,7 @@ static void load_connectivity_side_screen(SettingsScreen_t *settingsScreen) lv_label_set_text_static(label, "Connectivity :"); settingsScreen->ble_switch = lv_switch_create(settingsScreen->side_screen); + lv_obj_set_user_data(settingsScreen->ble_switch, (void *)SWITCH_ID_BLE_ENABLE); lv_obj_align_to(settingsScreen->ble_switch, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); bool ble_toggled = false; if(settingsScreen->settingsScreenAPIInterface.setBLEEnabledSettingsCb)settingsScreen->settingsScreenAPIInterface.setBLEEnabledSettingsCb(&ble_toggled, SETTING_MODE_GET); @@ -561,6 +688,7 @@ static void load_connectivity_side_screen(SettingsScreen_t *settingsScreen) lv_obj_align_to(settingsScreen->ble_mac_addr.label, settingsScreen->ble_dev_mac_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 5); settingsScreen->wifi_switch = lv_switch_create(settingsScreen->side_screen); + lv_obj_set_user_data(settingsScreen->wifi_switch, (void *)SWITCH_ID_WIFI_ENABLE); lv_obj_align_to(settingsScreen->wifi_switch, settingsScreen->ble_mac_addr.label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); bool wifi_toggled = false; if(settingsScreen->settingsScreenAPIInterface.setWiFiEnabledSettingsCb)settingsScreen->settingsScreenAPIInterface.setWiFiEnabledSettingsCb(&wifi_toggled, SETTING_MODE_GET); @@ -842,7 +970,6 @@ static void _simulate_side_screen_item_click(SettingsScreen_t * const settingsSc settingsScreen->last_selected_item = item; lv_obj_clean(settingsScreen->side_screen); - _reset_switch_pointers(settingsScreen); if(item == settingsScreen->time_and_date_item) { @@ -924,14 +1051,6 @@ static void _set_bmp280_data_to_label(SettingsScreen_t * const settingsScreen) lv_label_set_text_static(settingsScreen->bmp280_temperature.label, settingsScreen->bmp280_temperature.text); } -static void _reset_switch_pointers(SettingsScreen_t * const settingsScreen) -{ - settingsScreen->auto_set_time_switch = NULL; - settingsScreen->wrist_tilt_switch = NULL; - settingsScreen->ble_switch = NULL; - settingsScreen->wifi_switch = NULL; -} - static void _enable_time_and_date_rollers(bool enabled, SettingsScreen_t * const settingsScreen) { if(enabled) 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 a1fc13f..3b45568 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 @@ -18,8 +18,14 @@ typedef struct SettingsScreenAPIInterface 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); @@ -67,7 +73,6 @@ typedef struct SettingsScreen lv_obj_t *side_screen; /* Menu widgets */ - lv_obj_t *auto_set_time_switch; lv_obj_t *hour_roller; lv_obj_t *minute_roller; lv_obj_t *second_roller; @@ -76,7 +81,6 @@ 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 *wifi_switch; lv_obj_t *wifi_label; lv_obj_t *ble_switch; diff --git a/src/W800_SDK_v1.00.10/app/persistency/watch_settings.c b/src/W800_SDK_v1.00.10/app/persistency/watch_settings.c index b59059c..38a3327 100644 --- a/src/W800_SDK_v1.00.10/app/persistency/watch_settings.c +++ b/src/W800_SDK_v1.00.10/app/persistency/watch_settings.c @@ -29,10 +29,12 @@ static const WatchSettings_t defaultWatchSettings = .activity_step_counter_en = true, }, .notification = { - .notification_vibration_duration = 3, + .notification_enabled = true, + .notification_vibration_duration = 0, .notification_vibration_strength = 6, - .notification_vibrate_on_notification_receive = true, - .notification_vibrate_on_call_receive = true, + .call_enabled = true, + .call_vibration_duration = 0, + .call_vibration_strength = 6, }, .connectivity = { .connectivity_ble_enabled = false, @@ -111,18 +113,42 @@ void watch_settings_display_set_vibrate_on_touch_duration(uint8_t duration) _params_changed = true; } -void watch_settings_notification_set_vibration_strength(uint8_t level) +void watch_settings_notification_set_notification_enabled(bool enabled) +{ + watchSettings.notification.notification_enabled = enabled; + _params_changed = true; +} + +void watch_settings_notification_set_notification_vibration_strength(uint8_t level) { watchSettings.notification.notification_vibration_strength = level; _params_changed = true; } -void watch_settings_notification_set_vibration_duration(uint8_t duration) +void watch_settings_notification_set_notification_vibration_duration(uint8_t duration) { watchSettings.notification.notification_vibration_duration = duration; _params_changed = true; } +void watch_settings_notification_set_call_enabled(bool enabled) +{ + watchSettings.notification.call_enabled = enabled; + _params_changed = true; +} + +void watch_settings_notification_set_call_vibration_strength(uint8_t level) +{ + watchSettings.notification.call_vibration_strength = level; + _params_changed = true; +} + +void watch_settings_notification_set_call_vibration_duration(uint8_t duration) +{ + watchSettings.notification.call_vibration_duration = duration; + _params_changed = true; +} + void watch_settings_connectivity_set_ble_enabled(bool enabled) { watchSettings.connectivity.connectivity_ble_enabled = enabled; diff --git a/src/W800_SDK_v1.00.10/app/persistency/watch_settings.h b/src/W800_SDK_v1.00.10/app/persistency/watch_settings.h index f0d696a..3cd5aa4 100644 --- a/src/W800_SDK_v1.00.10/app/persistency/watch_settings.h +++ b/src/W800_SDK_v1.00.10/app/persistency/watch_settings.h @@ -51,10 +51,12 @@ typedef struct Activity */ typedef struct Notification { - uint32_t notification_vibrate_on_notification_receive:1, - notification_vibrate_on_call_receive:1, + uint32_t notification_enabled:1, // Enable or disable messages notifications notification_vibration_strength:3, - notification_vibration_duration:3; + notification_vibration_duration:3, + call_enabled:1, // Enable or disable calls notifications + call_vibration_strength:3, + call_vibration_duration:3; } Notification_t; /** @@ -174,19 +176,47 @@ void watch_settings_display_set_vibrate_on_touch_strength(uint8_t level); */ void watch_settings_display_set_vibrate_on_touch_duration(uint8_t duration); +/** + * @brief + * + * @param enabled + */ +void watch_settings_notification_set_notification_enabled(bool enabled); + /** * @brief * * @param level */ -void watch_settings_notification_set_vibration_strength(uint8_t level); +void watch_settings_notification_set_notification_vibration_strength(uint8_t level); /** * @brief * * @param duration */ -void watch_settings_notification_set_vibration_duration(uint8_t duration); +void watch_settings_notification_set_notification_vibration_duration(uint8_t duration); + +/** + * @brief + * + * @param enabled + */ +void watch_settings_notification_set_call_enabled(bool enabled); + +/** + * @brief + * + * @param level + */ +void watch_settings_notification_set_call_vibration_strength(uint8_t level); + +/** + * @brief + * + * @param duration + */ +void watch_settings_notification_set_call_vibration_duration(uint8_t duration); /** * @brief 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 8b8c223..58487fb 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 @@ -14,7 +14,7 @@ static const char *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_force = "1\n2\n3\n4\n5\n6\n7\n8"; +static const char* vibration_strength = "1\n2\n3\n4\n5\n6\n7\n8"; static const char* language_options = "Francais\nDeutsch\nEnglish"; @@ -302,43 +302,93 @@ static void load_display_side_screen(SettingsScreen_t *settingsScreen) label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Duration"); - lv_obj_align_to(label, on_touch_vibration_duration_roller, LV_ALIGN_OUT_RIGHT_MID, 10, 0); + 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_roller_set_options(on_touch_vibration_strength_roller, vibration_force, LV_ROLLER_MODE_NORMAL); + 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)); label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Strength"); - lv_obj_align_to(label, on_touch_vibration_strength_roller, LV_ALIGN_OUT_RIGHT_MID, 10, 0); + lv_obj_align_to(label, on_touch_vibration_strength_roller, LV_ALIGN_OUT_RIGHT_MID, 5, 0); } static void load_notifications_side_screen(SettingsScreen_t *settingsScreen) { - lv_obj_t *label = lv_label_create(settingsScreen->side_screen); - lv_label_set_text_static(label, "Vibrate on\nnotifications :"); + // Notification enable switch + lv_obj_t *notification_enable_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(notification_enable_switch, LV_STATE_CHECKED); + //lv_obj_add_event_cb(notification_enable_switch, &(activation_switch_cb), LV_EVENT_VALUE_CHANGED, settingsScreen); - 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_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_t * label = lv_label_create(settingsScreen->side_screen); + lv_label_set_text_static(label, "Notifications"); + lv_obj_align_to(label, notification_enable_switch, LV_ALIGN_OUT_RIGHT_MID, 5, 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_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); + lv_roller_set_options(on_notification_vibration_duration_roller, vibration_duration, LV_ROLLER_MODE_NORMAL); + lv_roller_set_visible_row_count(on_notification_vibration_duration_roller, 2); //lv_obj_add_event_cb(vibration_duration_roller, &(vibration_duration_roller_cb), LV_EVENT_RELEASED, settingsScreen); label = lv_label_create(settingsScreen->side_screen); lv_label_set_text_static(label, "Duration"); - lv_obj_align_to(label, on_touch_vibration_duration_roller, LV_ALIGN_OUT_RIGHT_MID, 10, 0); + lv_obj_align_to(label, on_notification_vibration_duration_roller, LV_ALIGN_OUT_RIGHT_MID, 5, 0); - lv_obj_t *on_touch_vibration_force_roller = lv_roller_create(settingsScreen->side_screen); - lv_obj_align_to(on_touch_vibration_force_roller, on_touch_vibration_duration_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); - lv_roller_set_options(on_touch_vibration_force_roller, vibration_force, LV_ROLLER_MODE_NORMAL); - lv_roller_set_visible_row_count(on_touch_vibration_force_roller, 2); - lv_obj_set_width(on_touch_vibration_force_roller, lv_obj_get_width(on_touch_vibration_duration_roller)); + 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_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)); label = lv_label_create(settingsScreen->side_screen); - lv_label_set_text_static(label, "Force"); - lv_obj_align_to(label, on_touch_vibration_force_roller, LV_ALIGN_OUT_RIGHT_MID, 10, 0); + lv_label_set_text_static(label, "Strength"); + lv_obj_align_to(label, on_notification_vibration_strength_roller, LV_ALIGN_OUT_RIGHT_MID, 5, 0); + + // 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, on_notification_vibration_strength_roller, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); + //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, "Calls"); + lv_obj_align_to(label, call_enable_switch, LV_ALIGN_OUT_RIGHT_MID, 5, 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_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_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); + + label = lv_label_create(settingsScreen->side_screen); + lv_label_set_text_static(label, "Duration"); + 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_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)); + + label = lv_label_create(settingsScreen->side_screen); + lv_label_set_text_static(label, "Strength"); + lv_obj_align_to(label, on_call_vibration_strength_roller, LV_ALIGN_OUT_RIGHT_MID, 5, 0); } static void load_connectivity_side_screen(SettingsScreen_t *settingsScreen)