From b5efc4f3a2c140bd876efd208f036dea237161b5 Mon Sep 17 00:00:00 2001 From: Th3maz1ng Date: Sat, 4 Nov 2023 12:11:40 +0100 Subject: [PATCH] Cleaned up some code, calling vibrate functions where needed. --- src/W800_SDK_v1.00.10/app/gfx/gfx_task.c | 34 +++++++++++++----------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/W800_SDK_v1.00.10/app/gfx/gfx_task.c b/src/W800_SDK_v1.00.10/app/gfx/gfx_task.c index 39d90db..7b32c03 100644 --- a/src/W800_SDK_v1.00.10/app/gfx/gfx_task.c +++ b/src/W800_SDK_v1.00.10/app/gfx/gfx_task.c @@ -162,6 +162,7 @@ static void setDisplayVibrationDurationCb(uint8_t *duration, SettingMode_e mode) else { watch_settings_display_set_vibrate_on_touch_duration(*duration); + watch_peripherals_vibrate_on_item_click(); } } @@ -174,6 +175,7 @@ static void setDisplayVibrationStrengthCb(uint8_t *strength, SettingMode_e mode) else { watch_settings_display_set_vibrate_on_touch_strength(*strength); + watch_peripherals_vibrate_on_item_click(); } } @@ -198,6 +200,7 @@ static void setNotificationVibrationDurationCb(uint8_t *duration, SettingMode_e else { watch_settings_notification_set_notification_vibration_duration(*duration); + watch_peripherals_vibrate_on_message_notifications(); } } @@ -210,6 +213,7 @@ static void setNotificationVibrationStrengthCb(uint8_t *strength, SettingMode_e else { watch_settings_notification_set_notification_vibration_strength(*strength); + watch_peripherals_vibrate_on_message_notifications(); } } @@ -507,13 +511,15 @@ static void parser_event_cb(gadget_bridge_event_data_t *gadget_bridge_event_data static void ble_service_nus_data_rx_cb(const uint8_t *data, uint16_t length) { - /*for (uint16_t i = 0; i < length; i++) + #if HARDWARE_PLATFORM != SMART_WATCH_PCB_RELEASE + for (uint16_t i = 0; i < length; i++) { - if (data[i] < 32) - printf("[%u]", data[i]); + if (data[i] < 32 || data[i] > 126) + printf("[%u]", data[i]); else - printf("%c", data[i]); - }*/ + printf("%c", data[i]); + } + #endif gadget_bridge_parser_feed((const char *)data, length); while(gadget_bridge_parser_run() == GADGET_BRIDGE_PARSER_CODE_PARSING); @@ -644,20 +650,14 @@ static void notification_on_state_change_cb(NotificationState_e notificationStat switch (notificationState) { case NOTIFICATION_STATE_DISPLAYED: + // Let's change the MCU clocks to its max speed, this is done to get the best responsiveness when having large texts + watch_power_management_overwrite_default_cpu_clocks(CPU_CLK_240M, CPU_CLK_240M); // Let's give a user feedback by vibrating the watch if it is configured to do so - if(persistency_get_settings()->notification.notification_vibration_duration) - { - uint16_t vibration_strength = (persistency_get_settings()->notification.notification_vibration_strength + 1)*32; - uint32_t vibration_duration_ms = 0; - - if(persistency_get_settings()->notification.notification_vibration_duration) - vibration_duration_ms = persistency_get_settings()->notification.notification_vibration_duration*50 + 50; - - uint16_t vibration_pattern[VIBRATION_PATTERN_SLOTS] = {vibration_duration_ms, vibration_duration_ms, vibration_duration_ms}; - watch_peripherals_vibrate_with_pattern(vibration_strength > 255 ? 255 : vibration_strength, vibration_pattern); - } + watch_peripherals_vibrate_on_message_notifications(); break; case NOTIFICATION_STATE_CLEARED: + // Let's restore MCU clocks to it's default + watch_power_management_restore_default_cpu_clocks(true, true); default: break; } @@ -724,6 +724,8 @@ void gfx_task(void *param) /* Initialize lvgl screens */ watch_face_init(&watchFace); menu_screen_init(&menuScreen); + menu_screen_register_on_menu_item_click_cb(&menuScreen, &(watch_peripherals_vibrate_on_item_click)); + compass_screen_init(&compassScreen); compass_screen_register_on_state_change_cb(&compassScreen, &(compass_screen_on_state_change_cb)); compass_screen_register_azimuth_and_temperature_cb(&compassScreen, &(compass_screen_azimuth_and_temperature_cb));