static TASK_HANDLE * s_hengai_k18_sleep_task_id = NULL;
+static void mmi_hengai_sleep_data_set(void);
+
+
void mmi_hengai_k18_sleep_task_msg_send(MMI_WATCH_SLEEP_MSG_ID_E msg_id) //, void * msg_param)
{
if(NULL == s_hengai_k18_sleep_task_id)
#endif
+#if 1
+#define __SLEEP_DATA_FILE "C:/hengai_sleep.txt"
+#endif
+
static bool mmi_hengai_k18_sleep_data_send(void)
{
char * temp_buff = NULL;
HENGAI_HEALTH_UART_LOG("[@CHENG_DEBUG][%s][%d]: buff_size=%d,temp_len=%d\n", __FUNCTION__, __LINE__, buff_size, temp_len);
mmi_protocol_fzd_action_sleep_data(temp_buff, temp_len);
+
+#if 1
+ mmi_debug_info_write_to_file(__SLEEP_DATA_FILE, temp_buff, temp_len);
+#endif
+
+
+
if(NULL != temp_buff)
{
lv_mem_free(temp_buff);
if(1 == result)
{
mmi_hengai_k18_sleep_data_send();
- mmi_hengai_sleep_data_set(&s_hengai_sdata);
+ mmi_hengai_sleep_data_set();
}
else if(-1 == result)
{
}
}
-void mmi_hengai_sleep_data_set(sleep_data_t * data) // (nv_watch_hengai_sleep_data_t * data)
+static void mmi_hengai_sleep_data_set(void)
{
unsigned char i = 0;
-
- if(NULL == data)
- return;
if(false == s_sleep_data_in_same_cycle)
{
s_sleep_data_in_same_cycle = true;
- s_hengai_sleep_data.total_sleep_time = data->total_sleep_time;
+ _lv_memset_00(&s_hengai_sleep_data, sizeof(nv_watch_hengai_sleep_data_t));
- s_hengai_sleep_data.begin_sleep_time.year = data->begin_sleep_time.year;
- s_hengai_sleep_data.begin_sleep_time.month = data->begin_sleep_time.month;
- s_hengai_sleep_data.begin_sleep_time.day = data->begin_sleep_time.day;
- s_hengai_sleep_data.begin_sleep_time.hour = data->begin_sleep_time.hour;
- s_hengai_sleep_data.begin_sleep_time.minute = data->begin_sleep_time.minute;
+ s_hengai_sleep_data.begin_sleep_time.year = s_hengai_sdata.begin_sleep_time.year;
+ s_hengai_sleep_data.begin_sleep_time.month = s_hengai_sdata.begin_sleep_time.month;
+ s_hengai_sleep_data.begin_sleep_time.day = s_hengai_sdata.begin_sleep_time.day;
+ s_hengai_sleep_data.begin_sleep_time.hour = s_hengai_sdata.begin_sleep_time.hour;
+ s_hengai_sleep_data.begin_sleep_time.minute = s_hengai_sdata.begin_sleep_time.minute;
+ }
+ HENGAI_HEALTH_UART_LOG("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
- s_hengai_sleep_data.end_sleep_time.year = data->end_sleep_time.year;
- s_hengai_sleep_data.end_sleep_time.month = data->end_sleep_time.month;
- s_hengai_sleep_data.end_sleep_time.day = data->end_sleep_time.day;
- s_hengai_sleep_data.end_sleep_time.hour = data->end_sleep_time.hour;
- s_hengai_sleep_data.end_sleep_time.minute = data->end_sleep_time.minute;
+ s_hengai_sleep_data.end_sleep_time.year = s_hengai_sdata.end_sleep_time.year;
+ s_hengai_sleep_data.end_sleep_time.month = s_hengai_sdata.end_sleep_time.month;
+ s_hengai_sleep_data.end_sleep_time.day = s_hengai_sdata.end_sleep_time.day;
+ s_hengai_sleep_data.end_sleep_time.hour = s_hengai_sdata.end_sleep_time.hour;
+ s_hengai_sleep_data.end_sleep_time.minute = s_hengai_sdata.end_sleep_time.minute;
- for(i = 0; i < data->state_count; i++)
- {
- if(NV_LS_STATE == data->data[i].state)
- s_hengai_sleep_data.state_duration[0] = data->data[i].duration;
- else if(NV_DS_STATE == data->data[i].state)
- s_hengai_sleep_data.state_duration[1] = data->data[i].duration;
- else if(NV_REM_STATE == data->data[i].state)
- s_hengai_sleep_data.state_duration[2] = data->data[i].duration;
- }
- }
- else
+ s_hengai_sleep_data.total_sleep_time += s_hengai_sdata.total_sleep_time;
+
+ for(i = 0; i < s_hengai_sdata.state_count; i++)
{
- HENGAI_HEALTH_UART_LOG("[@CHENG_DEBUG][%s][%d]: \n", __FUNCTION__, __LINE__);
+ switch(s_hengai_sdata.data[i].state)
+ {
+ case LS_STATE:
+ s_hengai_sleep_data.ls_duration += s_hengai_sdata.data[i].duration;
+ break;
- s_hengai_sleep_data.total_sleep_time += data->total_sleep_time;
+ case DS_STATE:
+ s_hengai_sleep_data.ds_duration += s_hengai_sdata.data[i].duration;
+ break;
- s_hengai_sleep_data.end_sleep_time.year = data->end_sleep_time.year;
- s_hengai_sleep_data.end_sleep_time.month = data->end_sleep_time.month;
- s_hengai_sleep_data.end_sleep_time.day = data->end_sleep_time.day;
- s_hengai_sleep_data.end_sleep_time.hour = data->end_sleep_time.hour;
- s_hengai_sleep_data.end_sleep_time.minute = data->end_sleep_time.minute;
+ case REM_STATE:
+ s_hengai_sleep_data.rem_duration += s_hengai_sdata.data[i].duration;
+ break;
- for(i = 0; i < data->state_count; i++)
- {
- if(NV_LS_STATE == data->data[i].state)
- s_hengai_sleep_data.state_duration[0] += data->data[i].duration;
- else if(NV_DS_STATE == data->data[i].state)
- s_hengai_sleep_data.state_duration[1] += data->data[i].duration;
- else if(NV_REM_STATE == data->data[i].state)
- s_hengai_sleep_data.state_duration[2] += data->data[i].duration;
+ default:
+ break;
}
}
+
mmi_hengai_sleep_data_nv_write();
+
+
+
+#if 1
+ char * temp_buff = NULL;
+ unsigned int temp_len = 0;
+
+ temp_buff = lv_mem_alloc(512);
+ if(NULL == temp_buff)
+ {
+ return;
+ }
+ _lv_memset_00(temp_buff, 512);
+
+ sprintf(temp_buff, "total=%d,ls_duration=%d,ds_duration=%d,rem_duration=%d\n",
+ s_hengai_sleep_data.total_sleep_time,
+ s_hengai_sleep_data.ls_duration,
+ s_hengai_sleep_data.ds_duration,
+ s_hengai_sleep_data.rem_duration);
+ temp_len = strlen(temp_buff);
+
+ mmi_debug_info_write_to_file(__SLEEP_DATA_FILE, temp_buff, temp_len);
+ if(NULL != temp_buff)
+ {
+ lv_mem_free(temp_buff);
+ temp_buff = NULL;
+ }
+#endif
}
lv_obj_t * label_ds_value = lv_label_create(cont, NULL);
lv_obj_add_style(label_ds_value, LV_LABEL_PART_MAIN, &lv_watch_font30);
- mmi_sleep_period_str_get(temp_buf, 128, s_hengai_sleep_data.state_duration[1]);
+ mmi_sleep_period_str_get(temp_buf, 128, s_hengai_sleep_data.ds_duration);
lv_label_set_text(label_ds_value, temp_buf);
lv_label_set_long_mode(label_ds_value, LV_LABEL_LONG_SROLL);
lv_obj_set_width(label_ds_value, LV_HOR_RES / 2);
lv_obj_t * label_ls_value = lv_label_create(cont, NULL);
lv_obj_add_style(label_ls_value, LV_LABEL_PART_MAIN, &lv_watch_font30);
- mmi_sleep_period_str_get(temp_buf, 128, s_hengai_sleep_data.state_duration[0]);
+ mmi_sleep_period_str_get(temp_buf, 128, s_hengai_sleep_data.ls_duration);
lv_label_set_text(label_ls_value, temp_buf);
lv_label_set_long_mode(label_ls_value, LV_LABEL_LONG_SROLL);
lv_obj_set_width(label_ls_value, LV_HOR_RES / 2);
lv_obj_t * label_rem_value = lv_label_create(cont, NULL);
lv_obj_add_style(label_rem_value, LV_LABEL_PART_MAIN, &lv_watch_font30);
- mmi_sleep_period_str_get(temp_buf, 128, s_hengai_sleep_data.state_duration[2]);
+ mmi_sleep_period_str_get(temp_buf, 128, s_hengai_sleep_data.rem_duration);
lv_label_set_text(label_rem_value, temp_buf);
lv_label_set_long_mode(label_rem_value, LV_LABEL_LONG_SROLL);
lv_obj_set_width(label_rem_value, LV_HOR_RES / 2);