diff --git a/boards/BANGLEJS2.py b/boards/BANGLEJS2.py index 91641c0cf7..bc813fdadc 100644 --- a/boards/BANGLEJS2.py +++ b/boards/BANGLEJS2.py @@ -70,12 +70,8 @@ 'WRAPPERSOURCES += libs/graphics/jswrap_font_12x20.c', 'SOURCES += libs/misc/nmea.c', 'SOURCES += libs/misc/stepcount.c', - 'SOURCES += libs/misc/hrm_vc31.c', -# Standard open-source heart rate algorithm: -# 'SOURCES += libs/misc/heartrate.c', -# Proprietary heart rate algorithm: - 'SOURCES += libs/misc/heartrate_vc31_binary.c', 'DEFINES += -DHEARTRATE_VC31_BINARY=1', 'PRECOMPILED_OBJS += libs/misc/vc31_binary/algo.o libs/misc/vc31_binary/modle5_10.o libs/misc/vc31_binary/modle5_11.o libs/misc/vc31_binary/modle5_12.o libs/misc/vc31_binary/modle5_13.o libs/misc/vc31_binary/modle5_14.o libs/misc/vc31_binary/modle5_15.o libs/misc/vc31_binary/modle5_16.o libs/misc/vc31_binary/modle5_17.o libs/misc/vc31_binary/modle5_18.o libs/misc/vc31_binary/modle5_1.o libs/misc/vc31_binary/modle5_2.o libs/misc/vc31_binary/modle5_3.o libs/misc/vc31_binary/modle5_4.o libs/misc/vc31_binary/modle5_5.o libs/misc/vc31_binary/modle5_6.o libs/misc/vc31_binary/modle5_7.o libs/misc/vc31_binary/modle5_8.o libs/misc/vc31_binary/modle5_9.o', -# ------------------------ + 'SOURCES += libs/misc/heartrate.c', + 'SOURCES += libs/misc/hrm_vc31.c', 'SOURCES += libs/misc/unistroke.c', 'WRAPPERSOURCES += libs/misc/jswrap_unistroke.c', 'DEFINES += -DESPR_BANGLE_UNISTROKE=1', diff --git a/libs/banglejs/jswrap_bangle.c b/libs/banglejs/jswrap_bangle.c index 22a3798dda..91bd8ca516 100644 --- a/libs/banglejs/jswrap_bangle.c +++ b/libs/banglejs/jswrap_bangle.c @@ -566,6 +566,9 @@ Can be used for housekeeping tasks that don't want to be run during the day. #define ACCEL_HISTORY_LEN 50 ///< Number of samples of accelerometer history +typedef struct { + short x,y,z; +} Vector3; // ========================================================================= // DEVICE SPECIFIC CONFIG @@ -853,7 +856,7 @@ bool magOnWhenCharging; #ifdef MAG_DEVICE_GMC303 uint8_t magCalib[3]; // Magnetic Coefficient Registers - used to rescale the magnetometer values #endif -/// accelerometer data. 8192 = 1G +/// accelerometer data Vector3 acc; /// squared accelerometer magnitude int accMagSquared; @@ -1696,7 +1699,7 @@ void peripheralPollHandler() { #ifdef HEARTRATE static void hrmHandler(int ppgValue) { - if (hrm_new(ppgValue, &acc)) { + if (hrm_new(ppgValue)) { bangleTasks |= JSBT_HRM_DATA; // keep track of best HRM sample during this period if (hrmInfo.confidence >= healthCurrent.bpmConfidence) { @@ -4315,11 +4318,11 @@ bool jswrap_banglejs_idle() { JsVar *o = hrm_sensor_getJsVar(); if (o) { jsvObjectSetChildAndUnLock(o,"raw",jsvNewFromInteger(hrmInfo.raw)); - jsvObjectSetChildAndUnLock(o,"bpm",jsvNewFromFloat(hrmInfo.bpm10 / 10.0)); - jsvObjectSetChildAndUnLock(o,"confidence",jsvNewFromInteger(hrmInfo.confidence)); jsvObjectSetChildAndUnLock(o,"filt",jsvNewFromInteger(hrmInfo.filtered)); jsvObjectSetChildAndUnLock(o,"avg",jsvNewFromInteger(hrmInfo.avg)); - hrm_get_hrm_raw_info(o); + jsvObjectSetChildAndUnLock(o,"isBeat",jsvNewFromBool(hrmInfo.isBeat)); + jsvObjectSetChildAndUnLock(o,"bpm",jsvNewFromFloat(hrmInfo.bpm10 / 10.0)); + jsvObjectSetChildAndUnLock(o,"confidence",jsvNewFromInteger(hrmInfo.confidence)); jsiQueueObjectCallbacks(bangle, JS_EVENT_PREFIX"HRM-raw", &o, 1); jsvUnLock(o); } @@ -4329,7 +4332,16 @@ bool jswrap_banglejs_idle() { if (o) { jsvObjectSetChildAndUnLock(o,"bpm",jsvNewFromInteger(hrmInfo.bpm10 / 10.0)); jsvObjectSetChildAndUnLock(o,"confidence",jsvNewFromInteger(hrmInfo.confidence)); - hrm_get_hrm_info(o); + JsVar *a = jsvNewEmptyArray(); + if (a) { + int n = hrmInfo.timeIdx; + for (int i=0;iHRMVALUE_MAX) hrmValue=HRMVALUE_MAX; hrmInfo.raw = hrmValue; @@ -379,22 +379,3 @@ bool hrm_new(int hrmValue, Vector3 *acc) { return hadBeat; } - -// Append extra information to an existing HRM event object -void hrm_get_hrm_info(JsVar *o) { - JsVar *a = jsvNewEmptyArray(); - if (a) { - int n = hrmInfo.timeIdx; - for (int i=0;i -#include - -typedef enum -{ - SPORT_TYPE_NORMAL =0x00, // 日常 - SPORT_TYPE_RUNNING =0x01, // 跑步 - SPORT_TYPE_RIDE_BIKE =0X02, // 骑行 - SPORT_TYPE_JUMP_ROPE =0X03, // 跳绳 - SPORT_TYPE_SWIMMING =0X04, // 游泳 - SPORT_TYPE_BADMINTON =0X05, // 羽毛球 - SPORT_TYPE_TABLE_TENNIS=0X06, // 乒乓球 - SPORT_TYPE_TENNIS =0X07, // 网球 - SPORT_TYPE_CLIMBING =0X08, // 爬山 - SPORT_TYPE_WALKING =0X09, // 徒步 - SPORT_TYPE_BASKETBALL =0X0A, // 篮球 - SPORT_TYPE_FOOTBALL =0X0B, // 足球 - SPORT_TYPE_BASEBALL =0X0C, // 棒球 - SPORT_TYPE_VOLLEYBALL =0X0D, // 排球 - SPORT_TYPE_CRICKET = 0X0E, // 板球 - SPORT_TYPE_RUGBY = 0X0F, // 橄榄球 - SPORT_TYPE_HOCKEY =0X10, // 曲棍球 - SPORT_TYPE_DANCE = 0X11, // 跳舞 - SPORT_TYPE_SPINNING = 0X12, // 动感单车 - SPORT_TYPE_YOGA = 0X13, // 瑜伽 - SPORT_TYPE_SIT_UP =0X14, // 仰卧起坐 - SPORT_TYPE_TREADMILL =0X15, // 跑步机 - SPORT_TYPE_GYMNASTICS =0X16, // 体操 - SPORT_TYPE_BOATING = 0X17, // 划船 - SPORT_TYPE_JUMPING_JACK = 0X18, // 开合跳 - SPORT_TYPE_FREE_TRAINING = 0X19,// 自由训练 -} AlgoSportMode; -//未出现在上表中的运动形式均先以跑步输入 - - -typedef struct -{ - int32_t x; - int32_t y; - int32_t z; -}AlgoAxesData_t; - -typedef struct -{ - int32_t hrData; - int32_t reliability; -}AlgoOutputData_t; - -typedef struct -{ - AlgoAxesData_t axes; - int32_t ppgSample; - int32_t envSample; -}AlgoInputData_t; - -void Algo_Init(void); -void Algo_Input(AlgoInputData_t *pInputData,int32_t gaptime,AlgoSportMode sportMode,int16_t surfaceRecogMode,int16_t opticalAidMode); -void Algo_Output(AlgoOutputData_t *pOutputData); -void Algo_Version(char *pVersionOutput); - - - -#endif /* APP_ALGO_ALGO_H_ */ - - - diff --git a/make/family/NRF52.make b/make/family/NRF52.make index d492a63dc0..d4564f840f 100644 --- a/make/family/NRF52.make +++ b/make/family/NRF52.make @@ -100,7 +100,7 @@ INCLUDE += -I$(SOFTDEVICE_PATH)/headers INCLUDE += -I$(SOFTDEVICE_PATH)/headers/nrf52 DEFINES += -DBLE_STACK_SUPPORT_REQD -DEFINES += -DSWI_DISABLE0 -DSOFTDEVICE_PRESENT +DEFINES += -DSWI_DISABLE0 -DSOFTDEVICE_PRESENT -DFLOAT_ABI_HARD DEFINES += -DNRF52_SERIES # Nordic screwed over anyone who used -DNRF52 in new SDK versions # but then old SDKs won't work without it