release version should remove #if 1 in sleep_k18.c
author@CHENG <2393524978@qq.com>
Fri, 6 Dec 2024 08:44:57 +0000 (16:44 +0800)
committer@CHENG <2393524978@qq.com>
Fri, 6 Dec 2024 08:44:57 +0000 (16:44 +0800)
2.sdk/sdk/gui/lv_watch/include/ui_nvm_interface.h
2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_sleep_k18.c

index 2375238..4455123 100644 (file)
@@ -490,13 +490,6 @@ typedef struct
 
 #if 1
 
-typedef enum
-{
-       NV_LS_STATE = 11,                               // light sleep
-       NV_DS_STATE = 12,                               // deep sleep
-       NV_REM_STATE = 2,                               // rapid eye movement
-} NV_SLEEP_STATE_E;
-
 typedef struct
 {
        uint16_t year;
@@ -511,7 +504,9 @@ typedef struct
        uint32_t total_sleep_time;                      // minutes
        nv_sleep_time_t begin_sleep_time;               // sleep_time_t
        nv_sleep_time_t end_sleep_time;
-       uint32_t state_duration[3]; //0-NV_LS_STATE; 1-NV_DS_STATE; 2-NV_REM_STATE
+       uint32_t ls_duration; // state 11
+       uint32_t ds_duration; // state 12
+       uint32_t rem_duration; // state 2
 } __packed nv_watch_hengai_sleep_data_t;
 
 #else
index 75514e0..72577d0 100644 (file)
@@ -20,6 +20,9 @@ static bool s_sleep_data_in_same_cycle = false;
 
 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)
@@ -341,6 +344,10 @@ void __gsensor_data_set(unsigned char * next_buff, unsigned int next_buff_len)
 #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;
@@ -388,6 +395,13 @@ static bool mmi_hengai_k18_sleep_data_send(void)
        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);
@@ -428,7 +442,7 @@ static void mmi_hengai_k18_sleep_data_get(void)
                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)
                {
@@ -631,12 +645,9 @@ void mmi_hengai_sleep_data_nv_read(void)
        }
 }
 
-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)
        {
@@ -644,53 +655,74 @@ void mmi_hengai_sleep_data_set(sleep_data_t * data) // (nv_watch_hengai_sleep_da
 
                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
 }
 
 
@@ -775,7 +807,7 @@ lv_obj_t * mmi_sleep_second_tab_create(lv_obj_t * tileview, uint16_t id)
 
        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);
@@ -800,7 +832,7 @@ lv_obj_t * mmi_sleep_second_tab_create(lv_obj_t * tileview, uint16_t id)
 
        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);
@@ -825,7 +857,7 @@ lv_obj_t * mmi_sleep_second_tab_create(lv_obj_t * tileview, uint16_t id)
 
        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);