From 95e1a50ea2e1cc2a13cefd4afe7c354e0f4d114c Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 19 Jul 2024 16:08:46 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E5=96=9D=E6=B0=B4=E6=8F=90?= =?utf8?q?=E9=86=92=E7=9A=84=E6=97=B6=E9=97=B4=E6=AE=B5=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/AlarmClockTimerConfig.cpp | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp index c21d3ad04..e5c61002e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp @@ -72,11 +72,6 @@ extern "C" #define SEDENTARY_TIME_RANGE (((curTime.tm_hour > sedentary_start_hour) || (curTime.tm_hour == sedentary_start_hour && curTime.tm_min >= sedentary_start_min)) && \ ((curTime.tm_hour < sedentary_stop_hour) || (curTime.tm_hour == sedentary_stop_hour && curTime.tm_min < sedentary_stop_min))) -#define DRINKREMIND_TIME_RANGE ((((curTime.tm_hour > drinkreminder_start_hour && curTime.tm_hour < 24) || (curTime.tm_hour == drinkreminder_start_hour && curTime.tm_min >= drinkreminder_start_min)) && \ - ((curTime.tm_hour < drinkreminder_end_hour && curTime.tm_hour >= 0) || (curTime.tm_hour == drinkreminder_end_hour && curTime.tm_min < drinkreminder_end_min))) || \ - ((curTime.tm_hour >= 0 && curTime.tm_hour < drinkreminder_end_hour) || (curTime.tm_hour == drinkreminder_end_hour && curTime.tm_min < drinkreminder_end_min)) && \ - ((curTime.tm_hour > drinkreminder_start_hour - 24 || (curTime.tm_hour == drinkreminder_start_hour - 24 && curTime.tm_min >= drinkreminder_start_min)))) - #define WAKE_TIME_RANGE (((wake_time_hour < sleep_time_hour) && \ ((curTime.tm_hour > wake_time_hour) || \ (curTime.tm_hour == wake_time_hour && curTime.tm_min >= wake_time_min)) && \ @@ -140,6 +135,31 @@ extern "C" } } + static bool is_drinkremind_time_range(struct tm &curTime) + { + int drinkreminder_start_time_min = drinkreminder_start_hour * 60 + drinkreminder_start_min; /* 开始时间的分钟数 */ + int drinkreminder_end_time_min = drinkreminder_end_hour * 60 + drinkreminder_end_min; /* 结束时间的分钟数 */ + int cur_time_min = curTime.tm_hour * 60 + curTime.tm_min; /* 当前时间的分钟数 */ + + // 处理非跨天的情况 + if (drinkreminder_end_time_min > drinkreminder_start_time_min) + { + if (cur_time_min >= drinkreminder_start_time_min && cur_time_min <= drinkreminder_end_time_min) + { + return true; + } + } + else // 处理跨天的情况 + { + if (cur_time_min >= drinkreminder_start_time_min || cur_time_min <= drinkreminder_end_time_min) + { + return true; + } + } + + return false; + } + void clean_sleep_flag(void) { uapi_dev_runtime_set_sleep_status(0); @@ -428,7 +448,7 @@ extern "C" else if (drinkreminder_switch == 2) { // 判断当前时间是否在提醒时间段内 - if (DRINKREMIND_TIME_RANGE) + if (is_drinkremind_time_range(curTime)) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, " curTime.tm_sec = %d", curTime.tm_sec); double interval_time = (drinkreminder_freq == 0) ? 0.5 : drinkreminder_freq; // 频率设置 @@ -462,7 +482,7 @@ extern "C" } } } - else if (!DRINKREMIND_TIME_RANGE && uapi_dev_runtime_get_drinkremind_status() == 1) + else if (!is_drinkremind_time_range(curTime) && uapi_dev_runtime_get_drinkremind_status() == 1) { uapi_dev_runtime_set_drinkremind_status(0); } -- 2.17.1