#include "runtime.h"
#include <stdlib.h>
#include <math.h>
+#include "autoconf.h"
#include "mphalport.h"
#include "compile.h"
#include "repl.h"
#include "mperrno.h"
#include "binary.h"
+
+#if CONFIG_GH301x
#include "hbd_ctrl.h"
+#endif
#include <string.h>
-
-#if 1//MICROPY_QPY_Gsensor_SC7A20
+#if CONFIG_SC7A20
#include "helios_gpio.h"
#include "helios_iic.h"
#include "helios_fs.h"
#include "helios_pin.h"
-#ifdef CONFIG_LVGL
-#include "lvgl.h"
+// #ifdef CONFIG_LVGL
+// #include "lvgl.h"
-#endif
+// #endif
#include "helios_debug.h"
return 0;
}
-
+#if CONFIG_GH301x
static ST_GS_DATA_TYPE s_sc7a20_read_data[32] = {0};
-signed short SC7A20_XYZ_Buf_tmp[3][32];
-unsigned int SC7A20_XYZ_Buf_tmp_len =0;
static unsigned int s_sc7a20_read_data_len = 0;
static unsigned char s_sc7a20_read_data_counter = 0;
+#endif
+signed short SC7A20_XYZ_Buf_tmp[3][32];
+unsigned int SC7A20_XYZ_Buf_tmp_len =0;
+
unsigned char Gsensor_init_flag = 0;
float x,y,z;
unsigned int SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO(void)
SC7A20_XYZ_Buf_tmp_len += SC7A20_FIFO_NUM;
//dump2
-
+ #if CONFIG_GH301x
// s_sc7a20_read_data_counter++;
if(SC7A20_XYZ_Buf_tmp_len >= 25)
{
SC7A20_XYZ_Buf_tmp_len = 0;
//SC7A20_LOG("SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO:s_sc7a20_read_data_len:%d\r\n",s_sc7a20_read_data_len);
}
+ #endif
//SC7A20_LOG("SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO:SC7A20_FIFO_NUM:%d\r\n",SC7A20_FIFO_NUM);
x = s_acc.x;
}
return SL_STEP;
}
+#if CONFIG_GH301x
//获取Gsensor数据,填充到buf,返回长度,data长度需要32*3个short大小
unsigned int get_Gsensor_buf(ST_GS_DATA_TYPE *buf)
{
memset(s_sc7a20_read_data,0,sizeof(s_sc7a20_read_data));
s_sc7a20_read_data_len = 0;
}
+#endif
/**
* 设置算法库灵敏度
* Please modify the following parameters according to the actual situation**/
#include "binary.h"
#include <string.h>
-
-#if 1//MICROPY_QPY_Hsensor_GH3018
+Helios_Thread_t sensor_thread_id = 0;
+void sensor_thread_entry(void * argv);
+Helios_ThreadAttr ThreadAttr = {
+ .name = "HealthSensor",
+ .stack_size = 1024*20,
+ .priority = 100,
+ .entry = sensor_thread_entry,
+ .argv = NULL
+ };
+#if CONFIG_GH301x
#include "helios_gpio.h"
#include "helios_iic.h"
#include "helios_debug.h"
#include "gh3011_example.h"
+#include "autoconf.h"
#define GH3018_LOG(msg, ...) custom_log("GH3018", msg, ##__VA_ARGS__)
//////////////////////////////////////////////////////////////////////////////
typedef struct _GH3018_obj_t
#define HEART_RATE_BUFF_LEN 10
unsigned char s_gh3018_heart_rate_buff[HEART_RATE_BUFF_LEN]={0};
unsigned short s_gh3018_heart_rate_buff_count = 0;
-void sensor_thread_entry(void * argv);
+
+Helios_ThreadAttr ThreadAttr;
char GH3018_sleep_flag = 0;
#include "helios_extint.h"
-Helios_Thread_t sensor_thread_id = 0;
+
int sensor_timer = 0;
#define TIMER_TIME_MS 100 //10ms
#define IS_CYCLICAL 1
uint32_t gh3018_run_mode =RUN_MODE_INVALID;
#define RUN_MODE_CLOSE 0xffff
static uint32_t timer_Gsensor_count = 0;
-int SC7A20_init(void);
+#if CONFIG_SC7A20
+extern int SC7A20_init(void);
extern signed char SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO(void);
extern unsigned char Gsensor_init_flag ;
+
+#endif
extern void hal_gh30x_int_handler(void);
+
char GH3018_irq_lock = 0;
// int test_count1 = 0;
// int test_count2 = 0;
void sensor_timerout_cb(void);
-Helios_ThreadAttr ThreadAttr = {
- .name = "GH3018",
- .stack_size = 1024*20,
- .priority = 100,
- .entry = sensor_thread_entry,
- .argv = NULL
- };
+
void GH3018_result_set_heart_rate(unsigned char heart_rate)
{
// s_gh3018_heart_rate_buff[HEART_RATE_BUFF_LEN]={0};
void GH3018_test(uint32_t mode);
void gh3018_close(void);
-void sensor_thread_entry(void * argv)
-{
- //GH3018_LOG("sensor_thread_entry: 11111111!!!!!!!!\r\n");
-
-
- while(1)
- {
-
- if(gh3018_run_mode == RUN_MODE_CLOSE)
- {
- gh3018_close();
- //GH3018_LOG("GH3018_irq_cb: 1111111111111!!!!!!!!\r\n");
- gh3018_run_mode = RUN_MODE_INVALID;
- GH3018_irq_flag = 0;
- continue;
- }
- if(gh3018_run_mode != RUN_MODE_INVALID )
- {
- GH3018_test(gh3018_run_mode);
-
- gh3018_run_mode = RUN_MODE_INVALID;
- }
- if(is_gh3018 == 1 && is_open_gh3018 == 1)//处理Hsensor中断数据
- {
- if(GH3018_irq_flag)
- {
- GH3018_irq_lock = 1;
- hal_gh30x_int_handler();
-
- GH3018_irq_lock = 0;
- //GH3018_LOG("GH3018_irq_cb: 1111111111111!!!!!!!!\r\n");
- //GH3018_LOG("hal_gh30x_int_handler:test_count1:%d test_count2:%d\r\n",test_count1,test_count2);
- GH3018_irq_flag = 0;
- }
- if(timer_Gsensor_count>(1000/TIMER_TIME_MS))//1秒定时,轮询更新Gsensor数据
- {
- timer_Gsensor_count = 0;
- //Helios_msleep(5);
- SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO();
- }
- }
- else
- {
- SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO();
- Helios_msleep(1000);
- if(GH3018_sleep_flag == 1)
- {
- GH3018_sleep_flag = 0;
- Helios_msleep(3000);
- }
- }
- Helios_msleep(5);
- }
-}
void sensor_timerout_cb(void)
{
is_gh3018 = 1;
Helios_ExtInt_Init(self->irq, &extint_struct1);//初始化中断
Helios_ExtInt_Enable(self->irq);//打开中断
+ #if CONFIG_SC7A20
if(Gsensor_init_flag == 0)//初始化Gsensor
SC7A20_init();
+ #endif
}
return mp_obj_new_int(ret);
.locals_dict = (mp_obj_dict_t*)&GH3018_locals_dict,
};
+#endif
+void sensor_thread_entry(void * argv)
+{
+ //GH3018_LOG("sensor_thread_entry: 11111111!!!!!!!!\r\n");
+
+ #if CONFIG_GH301x
+ while(1)
+ {
+
+ if(gh3018_run_mode == RUN_MODE_CLOSE)
+ {
+ gh3018_close();
+ //GH3018_LOG("GH3018_irq_cb: 1111111111111!!!!!!!!\r\n");
+ gh3018_run_mode = RUN_MODE_INVALID;
+ GH3018_irq_flag = 0;
+ continue;
+ }
+ if(gh3018_run_mode != RUN_MODE_INVALID )
+ {
+ GH3018_test(gh3018_run_mode);
+
+ gh3018_run_mode = RUN_MODE_INVALID;
+ }
+ if(is_gh3018 == 1 && is_open_gh3018 == 1)//处理Hsensor中断数据
+ {
+ if(GH3018_irq_flag)
+ {
+ GH3018_irq_lock = 1;
+ hal_gh30x_int_handler();
+
+ GH3018_irq_lock = 0;
+ //GH3018_LOG("GH3018_irq_cb: 1111111111111!!!!!!!!\r\n");
+ //GH3018_LOG("hal_gh30x_int_handler:test_count1:%d test_count2:%d\r\n",test_count1,test_count2);
+ GH3018_irq_flag = 0;
+ }
+ if(timer_Gsensor_count>(1000/TIMER_TIME_MS))//1秒定时,轮询更新Gsensor数据
+ {
+ timer_Gsensor_count = 0;
+ //Helios_msleep(5);
+ #if CONFIG_SC7A20
+ SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO();
+ #endif
-
-
-
-
-
-#endif /* MICROPY_QPY_ */
\ No newline at end of file
+ }
+ }
+ else
+ {
+ #if CONFIG_SC7A20
+ SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO();
+ #endif
+ Helios_msleep(1000);
+ if(GH3018_sleep_flag == 1)
+ {
+ GH3018_sleep_flag = 0;
+ Helios_msleep(3000);
+ }
+ }
+ Helios_msleep(5);
+ }
+ #else
+ while(1)
+ {
+ #if CONFIG_SC7A20
+ SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO();
+ #endif
+ Helios_msleep(1000);
+
+ }
+ #endif
+
+}