From: penglei <1624952103@qq.com> Date: Mon, 23 Sep 2024 13:25:18 +0000 (+0800) Subject: 优化省电模式操作逻辑,优化睡眠模式文件存储 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=b94d1b06ede659a954faf1c019562b40ed002313;p=mirrors%2FFD230.git 优化省电模式操作逻辑,优化睡眠模式文件存储 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp index c680a35b3..a96f7215f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: SLEPPNOTIFY24-06-26 19:36:48 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-09-18 16:54:42 + * @LastEditTime: 2024-09-23 18:21:49 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp * @Description: * @@ -150,10 +150,9 @@ namespace OHOS static char status_file_path[64] = {0}; static uint32_t fall_asleep_timestamp = 0; - static uint32_t history_wake_up_timestamp = 0; + // static uint32_t history_wake_up_timestamp = 0; static char day[12] = {0}; static char dir_path[64] = {0}; - void clean_sleep_data(void) { total_time = 0; @@ -233,7 +232,6 @@ namespace OHOS bool save_sleep_data(SLEEP_T *data) { - bool ephemeral_data = false; //临时数据标志 if(access(time_file_path, F_OK) == -1) { @@ -314,7 +312,6 @@ namespace OHOS total_deep_sleep_time -= data->total_deep_sleep_time; total_mild_sleep_time -= data->total_mild_sleep_time; total_rem_sleep_time -= data->total_rem_sleep_time; - ephemeral_data = true; } if(access(status_file_path, F_OK) == -1) @@ -327,7 +324,10 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "save_sleep_data fopen fail"); return false; } - history_wake_up_timestamp = data->wake_up_timestamp; + // if(data->wake_up_timestamp != 0) + // { + // history_wake_up_timestamp = data->wake_up_timestamp; //更新历史出睡时间戳 + // } fwrite(data->sleep_status, sizeof(SLEEP_STATE_T), data->status_num, fp); } else @@ -338,25 +338,33 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "save_sleep_data fopen fail"); return false; } - - if(!ephemeral_data && history_wake_up_timestamp != data->wake_up_timestamp && ((data->fall_asleep_timestamp - history_wake_up_timestamp) < 2 * 60 * 60)) - { - fseek(fp, -sizeof(SLEEP_STATE_T), SEEK_END); - SLEEP_STATE_T sleep_status = {0,0}; - sleep_status.stat = 3; //清醒状态 - sleep_status.timestamp = history_wake_up_timestamp; //清醒状态时间为上一次的出睡时间 - history_wake_up_timestamp = data->wake_up_timestamp; //更新历史出睡时间戳 - fwrite(&sleep_status, sizeof(SLEEP_STATE_T), 1, fp); //替换历史出睡数据 改为清醒状态 - fwrite(&data->sleep_status[1], sizeof(SLEEP_STATE_T), data->status_num - 1, fp); //跳过入睡状态写入文件 - } - else - { - if(data->wake_up_timestamp != 0) - { - history_wake_up_timestamp = data->wake_up_timestamp; //更新历史出睡时间戳 - } - fwrite(data->sleep_status, sizeof(SLEEP_STATE_T), data->status_num, fp); - } + fwrite(data->sleep_status, sizeof(SLEEP_STATE_T), data->status_num, fp); + // if(history_wake_up_timestamp != data->wake_up_timestamp && ((data->fall_asleep_timestamp - history_wake_up_timestamp) < 2 * 60 * 60)) + // { + // fseek(fp, -sizeof(SLEEP_STATE_T), SEEK_END); + // SLEEP_STATE_T sleep_status = {0,0}; + // fread(&sleep_status, sizeof(SLEEP_STATE_T), 1, fp); + // if(sleep_status.stat == 4) //如果存在出睡睡觉 替换为清醒 + // { + // sleep_status.stat = 3; //清醒状态 + // sleep_status.timestamp = history_wake_up_timestamp; //清醒状态时间为上一次的出睡时间 + // fwrite(&sleep_status, sizeof(SLEEP_STATE_T), 1, fp); //替换历史出睡数据 改为清醒状态 + // fwrite(&data->sleep_status[1], sizeof(SLEEP_STATE_T), data->status_num - 1, fp); //跳过入睡状态写入文件 + // } + // else + // { + //fwrite(data->sleep_status, sizeof(SLEEP_STATE_T), data->status_num, fp); + //} + // } + // else + // { + // fwrite(data->sleep_status, sizeof(SLEEP_STATE_T), data->status_num, fp); + // } + + // if(data->wake_up_timestamp != 0) + // { + // history_wake_up_timestamp = data->wake_up_timestamp; //更新历史出睡时间戳 + // } } fclose(fp); diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h index e9d40b8de..003da1c7d 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h @@ -1,8 +1,8 @@ /* * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-17 09:32:03 - * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-08-26 19:20:26 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-09-23 17:37:53 * @FilePath: /FD230/code/sdk/drivers/peripheral/config/include/ConfigModelC.h */ #ifndef _CONFIG_MODEL_C_H_ @@ -41,6 +41,11 @@ void cm_initScreenBrightness(void); */ void cm_initializeScreenDuration(void); +/* + * @brief 获取屏幕亮度 + */ +int cm_getScreenBrightness(void); + /* * @brief 初始化抬腕亮屏 */ diff --git a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp index 34dd6ab03..386b99d4b 100644 --- a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp +++ b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp @@ -1336,6 +1336,11 @@ void cm_initScreenBrightness(void) uapi_setScreenBrightness(brightness); } +int cm_getScreenBrightness(void) +{ + return OHOS::ConfigModel::GetInstance()->GetBrightness(); +} + void cm_initializeScreenDuration(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cm_initializeScreenDuration"); diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index a4ce7f8b5..21fd25e74 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -772,6 +772,11 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_TEST); else send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_WEAR_MODE_TEST); +#else + memset(&csd, 0, sizeof(CUSTOM_OFFBODY_DETECT)); + csd.sensorType = CUSTOM_OFFBODY_DETECT; + csd.fData[0] = 1; + CWM_CustomSensorInput(&csd); #endif } if((int)sensorEVT->fData[1] == CUSTOM_ON_CHARGING) @@ -1257,7 +1262,8 @@ int cywee_main_dml(void) memset(&scl, 0, sizeof(scl)); scl.iData[0] = 1; #ifdef AP_ENABLE_DML_SDO_LISTEN - scl.iData[2] = 4+16; //分离式DML + scl.iData[2] = 2+16; //分离式DML + CWM_CustomSensorInput_Fifo_Init(GSENSON_MSG_COUNT); #else scl.iData[1] = 18; //00000000000000000000000000010010 高位在前 #endif @@ -1298,6 +1304,7 @@ int cywee_main_dml(void) scl.iData[0] = 1; scl.iData[1] = 1; #ifdef AP_ENABLE_DML_SDO_LISTEN + scl.iData[1] = 2; scl.iData[3] = 3; #endif CWM_SettingControl(SCL_DML_DRV_INIT, &scl); @@ -1376,7 +1383,7 @@ int cywee_main_dml(void) #endif //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__); // CWM_Sensor_Enable(IDX_GYRO); - CWM_Sensor_Enable(IDX_ALGO_NO_MOTION); + //CWM_Sensor_Enable(IDX_ALGO_NO_MOTION); //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__); // CWM_Sensor_Enable(IDX_ALGO_ANY_MOTION); CWM_Sensor_Enable(IDX_ALGO_ABSOLUTE_STATIC); diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index f4edea0cf..c2498e05d 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -1206,7 +1206,7 @@ void uapi_set4GCapability(bool isopen) if(isopen) { power_on_cat1(); - if(!uapi_dev_runtime_get_saveele_status()) + // if(!uapi_dev_runtime_get_saveele_status()) { uapi_dev_runtime_set_cat1_powerstat(1); } @@ -1225,7 +1225,7 @@ void uapi_set4GCapability(bool isopen) else { power_off_cat1(); - if(!uapi_dev_runtime_get_saveele_status()) + // if(!uapi_dev_runtime_get_saveele_status()) { uapi_dev_runtime_set_cat1_powerstat(0); } @@ -2323,12 +2323,21 @@ void uapi_enter_power_saving_mode(void) //配置runtime uapi_dev_runtime_set_saveele_status(1); + //关闭抬腕亮屏 + uapi_take_to_wake(0); + + //亮度最低 + uapi_setScreenBrightness(51); //关闭蓝牙 - if(uapi_dev_runtime_get_bt_powerstat()) - { - stop_custom_ble_service(); - } - + // if(uapi_dev_runtime_get_bt_powerstat()) + // { + // stop_custom_ble_service(); + // } + //断联蓝牙 + uapi_disconnect_remote_device(); + //关br 保持ble连接 + uapi_close_br_scan(); + //关闭cat1 if(uapi_dev_runtime_get_cat1_powerstat()) { @@ -2353,11 +2362,21 @@ void uapi_exit_power_saving_mode(void) { PRINT("Exit Power Saving Mode !!! \r\n"); + //打开抬腕亮屏 + if(mmi_flip_wrist_switch_get()) + { + uapi_take_to_wake(1); + } - //打开蓝牙 - if(cm_custom_ble_service_on_flag()) - start_custom_ble_service(); + //恢复亮度 + uapi_setScreenBrightness(cm_getScreenBrightness()); + // //打开蓝牙 + // if(cm_custom_ble_service_on_flag()) + // start_custom_ble_service(); + //开广播 + if(cm_custom_ble_service_on_flag()) + uapi_open_br_scan(); //打开cat1 if(cm_poweron_cat1_on_bootup_flag()) uapi_set4GCapability(true); @@ -2907,7 +2926,7 @@ void uapi_analysis_sleep_data(char * timepath , char *statuspath) int status = -1; uint8_t index = 0; char timestampe_str[10] = {0}; - char status_str[10] = {0}; + char status_str[20] = {0}; uapi_get_file_data(timepath,sleep_data,&datelen); @@ -2981,6 +3000,9 @@ void uapi_analysis_sleep_data(char * timepath , char *statuspath) case 7: strcpy(status_str,"出睡最后一笔输出"); break; + case 9: + strcpy(status_str,"未出睡最后一笔输出"); + break; case 12: strcpy(status_str,"快速动眼"); break;