if(uapi_dev_runtime_get_train_status() && !wear_status)\r
avg_hrs = 0;\r
\r
- if(living_status != 2)\r
+ wear_status_pre = wear_status;\r
+\r
+ if(uapi_dev_runtime_get_sleep_monitoring_status())\r
{\r
- wear_status_pre = wear_status;\r
-#ifdef SUPPORT_CYWEE_SERVICE\r
- cywee_wear_status_update(&wear_status);\r
-#endif\r
+ if(!wear_status)\r
+ {\r
+ #ifdef SUPPORT_CYWEE_SERVICE\r
+ cywee_wear_status_update(&wear_status);\r
+ #endif\r
+ }\r
+ else if(living_status == 1 && wear_status)\r
+ {\r
+ #ifdef SUPPORT_CYWEE_SERVICE\r
+ cywee_wear_status_update(&wear_status);\r
+ #endif\r
+ }\r
+ }\r
+ else\r
+ {\r
+ if(living_status != 2)\r
+ {\r
+\r
+ #ifdef SUPPORT_CYWEE_SERVICE\r
+ cywee_wear_status_update(&wear_status);\r
+ #endif\r
+ }\r
}\r
+\r
+\r
// printf("wear_status:%d\n",wear_status);\r
\r
if(!uapi_dev_runtime_get_factory_test_status_flag())\r
get_avg_hrs(hrs_result.hr_result);\r
\r
living_status = 1;\r
+ #ifdef SUPPORT_CYWEE_SERVICE\r
+ cywee_wear_status_update(&living_status);\r
+ #endif\r
}\r
else if(hrs_result.living_status == MSG_LIVING_FAIL)\r
{\r
living_status = 2;\r
wear_status = 0;\r
wear_status_pre = 0;\r
- hx3695_unwearstatus_update();\r
+ // hx3695_unwearstatus_update();\r
+\r
+ #ifdef SUPPORT_CYWEE_SERVICE\r
+ cywee_wear_status_update(&living_status);\r
+ #endif\r
living_wear_cnt = 0;\r
}\r
}\r
#pragma pack(1)
typedef struct
{
- // float avg_vol = 0;
+ float avg_vol = 0;
float sum_vol = 0;
uint8_t vol_num = 0;
float history_data[AVG_VOLTAGE_COUNT] = {0};
int left = 0;
int right = -1;
uint32_t time = 0;
- // uint8_t percent = 0;
+ uint8_t percent = 0;
} BAT_VOL_T;
#pragma pack()
uapi_get_timestampe_ss(&time);
for(int i = 0; i < bat_vol.vol_num;i++)
{
- // printf("history_data[%d]:%.3f\n",i,bat_vol.history_data[i]);
+ printf("history_data[%d]:%.3f\n",i,bat_vol.history_data[i]);
if(bat_vol.history_data[i] < 3.3 || bat_vol.history_data[i] > 4.45)
bat_vol.history_data[i] = 0;
}
bat_vol.time = time;
- // bat_vol.percent = cur_percent;
+ bat_vol.percent = cur_percent;
uapi_save_file_data("/user/userdata/battery.bin",(uint8_t *)&bat_vol,sizeof(BAT_VOL_T),"wb");
// uapi_save_file_data("/user/userdata/battery_time.bin",(uint8_t *)&time,sizeof(uint32_t),"wb");
}
void battery_restore_vol(void)
{
- // float cur_vol = 0;
+ float cur_vol = 0;
uint32_t time = 0;
uint16_t len = sizeof(BAT_VOL_T);
return;
}
- // batteryservice_get_voltage_by_channel(&cur_vol,ADC_CHANNEL_BAT_VOLTAGE);
+ batteryservice_get_voltage_by_channel(&cur_vol,ADC_CHANNEL_BAT_VOLTAGE);
- // if(bat_vol.percent > 0 && bat_vol.percent<=100 && (fabsf(cur_vol - bat_vol.avg_vol) < 0.15))
- // history_percent = bat_vol.percent;
+ if(bat_vol.percent > 0 && bat_vol.percent<=100 && (fabsf(cur_vol - bat_vol.avg_vol) < 0.15))
+ history_percent = bat_vol.percent;
// for(int i = 0; i < AVG_VOLTAGE_COUNT;i++)
// {
// printf("history_data[%d]:%.3f\n",i,bat_vol.history_data[i]);
// }
// }
- // printf("bat_vol.percent:%d,cur_vol:%.3f,bat_vol.avg_vol:%.3f\n",bat_vol.vol_num,cur_vol,bat_vol.avg_vol);
+ printf("bat_vol.percent:%d,cur_vol:%.3f,bat_vol.avg_vol:%.3f\n",bat_vol.vol_num,cur_vol,bat_vol.avg_vol);
- // printf("vol_num:%d\n",bat_vol.vol_num);
+ printf("vol_num:%d\n",bat_vol.vol_num);
}
void battery_percent_init(uint8_t percent)
{
percernt_installized = 1;
- history_percent = percent;
+ // history_percent = percent;
}
battery_info_t *get_current_battery_info(void)
for (int i = 0;i < bat_vol.vol_num; i++)
{
- // PRINT("333history_data[%d] : %.3f\n",i,bat_vol.history_data[i]);
+ PRINT("333history_data[%d] : %.3f\n",i,bat_vol.history_data[i]);
if (bat_vol.history_data[i] < min_vol)
min_vol = bat_vol.history_data[i];
if (bat_vol.history_data[i] > max_vol)
}
- // bat_vol.avg_vol = (bat_vol.sum_vol - max_vol - min_vol) / (bat_vol.vol_num - 2);
- // printf("avg_vol : %.3f\n",bat_vol.avg_vol);
- *vol = (bat_vol.sum_vol - max_vol - min_vol) / (bat_vol.vol_num - 2);
+ bat_vol.avg_vol = (bat_vol.sum_vol - max_vol - min_vol) / (bat_vol.vol_num - 2);
+ printf("avg_vol : %.3f\n",bat_vol.avg_vol);
+ // *vol = (bat_vol.sum_vol - max_vol - min_vol) / (bat_vol.vol_num - 2);
// printf("avg_vol : %.3f\n",*vol);
}
- else
- *vol = bat_vol.sum_vol / bat_vol.vol_num;
- // bat_vol.avg_vol = bat_vol.sum_vol / bat_vol.vol_num;
+ else
+ bat_vol.avg_vol = bat_vol.sum_vol / bat_vol.vol_num;
+ // *vol = bat_vol.sum_vol / bat_vol.vol_num;
}
}
int DecimalPart_1 = (int)(DecimalPart / 100);
int DecimalPart_2 = (int)((DecimalPart % 100) / 10);
int DecimalPart_3 = (int)(DecimalPart % 10);
- // PRINT("222*voltage : %.3f \n",*voltage);
+ PRINT("222*voltage : %.3f \n",*voltage);
// PRINT("DecimalPart_1 : %d , DecimalPart_2 : %d DecimalPart_3 : %d \n",DecimalPart_1,DecimalPart_2,DecimalPart_3);
uint16_t value = DecimalPart_1 << 8 | DecimalPart_2 << 4 | DecimalPart_3 << 0;
}
else
{
- // cur_percent = battery_get_percent_by_voltage(bat_vol.avg_vol);
- cur_percent = battery_get_percent_by_voltage(*voltage);
+ cur_percent = battery_get_percent_by_voltage(bat_vol.avg_vol);
+ // cur_percent = battery_get_percent_by_voltage(*voltage);
}
}