k18 sleep lib
author@CHENG <2393524978@qq.com>
Tue, 3 Dec 2024 02:11:45 +0000 (10:11 +0800)
committer@CHENG <2393524978@qq.com>
Tue, 3 Dec 2024 02:11:45 +0000 (10:11 +0800)
2.sdk/project/Z5_HA_K18/product/craneg_modem/cust/heng_ai_sleep/inc/lib_hr.h
2.sdk/project/Z5_HA_K18/product/craneg_modem/cust/heng_ai_sleep/inc/lib_sleep.h [deleted file]
2.sdk/sdk/gui/lv_watch/lv_apps/custom_function/heng_ai_sleep_k18.c
2.sdk/sdk/product/craneg_modem/CMakeLists.txt
2.sdk/sdk/product/craneg_modem/cust/heng_ai_sleep/inc/lib_sleep.h [deleted file]
2.sdk/sdk/product/craneg_modem/cust/heng_ai_sleep/lib/lib_hr_yll_v0.5.3.120224.lib [new file with mode: 0644]

index 0ada9b3..7e3ac2e 100644 (file)
@@ -10,9 +10,12 @@ extern "C"{
 
 
 #define SAMPLERATE 81          // sampling rate
+//#define SAMPLERATE 100
 #define SAMPLETIME 5           // sampling time (seconds) data of which will be processed every time
 #define EMOTIONTIME 60
+#define HRVTIME 300
 #define BPTIME 30
+#define DDTIME 20                      // measure duration of drinking degree
 #define SINGLETIME 5
 #define MAX_SLEEP_STATE 50
 
@@ -70,26 +73,46 @@ typedef struct
 } sleep_data_t;
 
 
-void init_sleep_data(sleep_data_t* sdata);
-int get_sleep_time(gsensor_data_t gdata[], const int datalen, const sleep_time_t curtime, sleep_data_t* sdata);
+typedef struct
+{
+       uint16_t sbp;
+       uint16_t dbp;
+       int32_t timestamp;              // timestamp in measuretime
+} bps_t;
 
 
-// callback function
-typedef void (*extern_get_hr_run_time_cb_t)(int *type, int *sec);
-unsigned int extern_get_hr_run_time_cb_reg(extern_get_hr_run_time_cb_t fun);
+
+// base api (include callback function)
 typedef void (*extern_printf_cb_t)(const char* format, ...);
 unsigned int extern_printf_cb_reg(extern_printf_cb_t fun);
-// api
 int init_algorithm(unsigned char* buf, unsigned int len);
+
+// heart rate variability algorithm api (include callback function)
+typedef void (*extern_get_hr_run_time_cb_t)(int* type, int* sec);
+unsigned int extern_get_hr_run_time_cb_reg(extern_get_hr_run_time_cb_t fun);
 int get_hr(int data[], int datalen, int fs, int* hr);
+
+// emotion algorithm api
 int ppg_midvalue(int data[], int datalen, int fs, float Fm[25][8], int* fmlen);
 int get_emotion_pi(int data[], int datalen, int fs, int* emo, int* pi);
-int ppg_hrv_midvalue(int data[], int datalen, int fs, float midv[25], int* midvlen);
+int get_dd_index(int data[], int datalen, int fs, int* dd, int* hr);
+
+// blood pressure algorithm api
 int load_bp_model(unsigned char str_model[], const unsigned int str_model_len);
 int get_bp(int data[], int datalen, int fs, int* sbp, int* dbp);
 int load_gen_info(int height, int weight, int age, int gender);
 int get_bp_general(int data[], int datalen, int fs, int* sbp, int* dbp);
 
+// sleep algorithm api (include callback function)
+typedef void (*extern_get_wear_state_cb_t)(int8_t* worn);
+unsigned int extern_get_wear_state_cb_reg(extern_get_wear_state_cb_t fun);
+typedef void (*extern_get_inst_hr_cb_t)(uint8_t* hr, sleep_time_t* hr_time);
+unsigned int extern_get_inst_hr_cb_reg(extern_get_inst_hr_cb_t fun);
+void init_sleep_algo_ex(sleep_data_t* sdata, int gfs, int pfs);
+int get_sleep_data_ex(gsensor_data_t gdata[], const int glen, int pdata[], const int plen, const sleep_time_t curtime, sleep_data_t* sdata);
+
+
+// authentication api
 void request_validation(
        const unsigned char fact[], const unsigned int fact_len,
        const unsigned char imei[], const unsigned int imei_len,
@@ -99,9 +122,11 @@ int activate_algorithm(
        const unsigned char req_code[], const unsigned int req_code_len,
        const unsigned char key_code[], const unsigned int key_code_len);
 
+
+// version api
 void version_get_string(char* string, unsigned int* str_len);
 
-int is_good_ppg(int ppg[], unsigned int ppglen, int fs);
+
 
 #ifdef __cplusplus  
 }
diff --git a/2.sdk/project/Z5_HA_K18/product/craneg_modem/cust/heng_ai_sleep/inc/lib_sleep.h b/2.sdk/project/Z5_HA_K18/product/craneg_modem/cust/heng_ai_sleep/inc/lib_sleep.h
deleted file mode 100644 (file)
index 0ada9b3..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-#ifndef __LIB_EMOTION_H__
-#define __LIB_EMOTION_H__
-
-#ifdef __cplusplus
-extern "C"{
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-#define SAMPLERATE 81          // sampling rate
-#define SAMPLETIME 5           // sampling time (seconds) data of which will be processed every time
-#define EMOTIONTIME 60
-#define BPTIME 30
-#define SINGLETIME 5
-#define MAX_SLEEP_STATE 50
-
-
-/* Integer data types */
-#if ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) && \
-     (!defined(__ICC8051__) || (__ICC8051__ == 0)))
-#include <stdint.h>
-#else
-       typedef signed char int8_t;
-       typedef unsigned char uint8_t;
-       typedef signed short int16_t;
-       typedef unsigned short uint16_t;
-       typedef signed long int32_t;
-       typedef unsigned long uint32_t;
-       typedef unsigned long long uint64_t;
-#endif
-
-typedef struct
-{
-       short int x;
-       short int y;
-       short int z;
-} gsensor_data_t;
-
-typedef enum
-{
-       LS_STATE = 11,                          // light sleep
-       DS_STATE = 12,                          // deep sleep
-       REM_STATE = 2,                          // rapid eye movement
-} SLEEP_STATE_E;
-
-typedef struct
-{
-       uint16_t year;
-       uint8_t month;
-       uint8_t day;
-       uint8_t hour;
-       uint8_t minute;
-} sleep_time_t;
-
-typedef struct
-{
-       uint32_t duration;                      // the duration of corresponding state
-       SLEEP_STATE_E state;            // state
-} sleep_detail_data_t;
-
-typedef struct
-{
-       uint32_t total_sleep_time;                      // minutes
-       sleep_time_t begin_sleep_time;          // sleep_time_t
-       sleep_time_t end_sleep_time;
-       uint16_t state_count;                           // number of some sleep state
-       sleep_detail_data_t data[MAX_SLEEP_STATE];
-} sleep_data_t;
-
-
-void init_sleep_data(sleep_data_t* sdata);
-int get_sleep_time(gsensor_data_t gdata[], const int datalen, const sleep_time_t curtime, sleep_data_t* sdata);
-
-
-// callback function
-typedef void (*extern_get_hr_run_time_cb_t)(int *type, int *sec);
-unsigned int extern_get_hr_run_time_cb_reg(extern_get_hr_run_time_cb_t fun);
-typedef void (*extern_printf_cb_t)(const char* format, ...);
-unsigned int extern_printf_cb_reg(extern_printf_cb_t fun);
-// api
-int init_algorithm(unsigned char* buf, unsigned int len);
-int get_hr(int data[], int datalen, int fs, int* hr);
-int ppg_midvalue(int data[], int datalen, int fs, float Fm[25][8], int* fmlen);
-int get_emotion_pi(int data[], int datalen, int fs, int* emo, int* pi);
-int ppg_hrv_midvalue(int data[], int datalen, int fs, float midv[25], int* midvlen);
-int load_bp_model(unsigned char str_model[], const unsigned int str_model_len);
-int get_bp(int data[], int datalen, int fs, int* sbp, int* dbp);
-int load_gen_info(int height, int weight, int age, int gender);
-int get_bp_general(int data[], int datalen, int fs, int* sbp, int* dbp);
-
-void request_validation(
-       const unsigned char fact[], const unsigned int fact_len,
-       const unsigned char imei[], const unsigned int imei_len,
-       unsigned char req_code[], unsigned int* req_code_len);
-
-int activate_algorithm(
-       const unsigned char req_code[], const unsigned int req_code_len,
-       const unsigned char key_code[], const unsigned int key_code_len);
-
-void version_get_string(char* string, unsigned int* str_len);
-
-int is_good_ppg(int ppg[], unsigned int ppglen, int fs);
-
-#ifdef __cplusplus  
-}
-#endif
-
-
-#endif
index b86973f..9f86728 100644 (file)
@@ -5,7 +5,7 @@
 
 #ifdef __MMI_CUSTOM_HENGAI_SLEEP_K18__
 
-#include "../../../../product/craneg_modem/cust/heng_ai_sleep/inc/lib_sleep.h"
+#include "../../../../product/craneg_modem/cust/heng_ai_sleep/inc/lib_hr.h"
 
 
 
index e564629..21d6648 100644 (file)
@@ -546,7 +546,8 @@ set_property(TARGET modem PROPERTY IMPORTED_OBJECTS
   softutil/fotadm/lib/lib_fotadm.a
   softutil/rsfota/redstone/lib/librsdl.a
        cust/heng_ai_sleep/lib/lib_sleep_yll_v0.2.6.111623.a
-       cust/heng_ai_sleep/lib/lib_hr_yll_v0.5.3.090324.lib
+       #cust/heng_ai_sleep/lib/lib_hr_yll_v0.5.3.090324.lib
+  cust/heng_ai_sleep/lib/lib_hr_yll_v0.5.3.120224.lib
   # MODEM_LIB_ALIOS_LTEGSM_END
 )
 endif() # if($ENV{PS_MODE} STREQUAL "LTEGSM")
diff --git a/2.sdk/sdk/product/craneg_modem/cust/heng_ai_sleep/inc/lib_sleep.h b/2.sdk/sdk/product/craneg_modem/cust/heng_ai_sleep/inc/lib_sleep.h
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/2.sdk/sdk/product/craneg_modem/cust/heng_ai_sleep/lib/lib_hr_yll_v0.5.3.120224.lib b/2.sdk/sdk/product/craneg_modem/cust/heng_ai_sleep/lib/lib_hr_yll_v0.5.3.120224.lib
new file mode 100644 (file)
index 0000000..25bdb06
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4497f147cda742ae1023055118d4aa8fef6ca2d8f63c994762fd7eae3617be75
+size 222712