From 9406ac5cccd761b49b52697b84f38fd12eeb244d Mon Sep 17 00:00:00 2001 From: Jackson Chen Date: Mon, 28 Nov 2016 11:50:29 -0800 Subject: [PATCH 1/6] shake detect in jabil --- pill/message_time.c | 1 + pill/shake_detect.c | 13 ++++++++++++- pill/shake_detect.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pill/message_time.c b/pill/message_time.c index d222d636..1189e749 100644 --- a/pill/message_time.c +++ b/pill/message_time.c @@ -217,6 +217,7 @@ static MSG_Status _send(MSG_Address_t src, MSG_Address_t dst, MSG_Data_t * data) app_timer_stop(self.timer_id_1sec); app_timer_start(self.timer_id_1sec, ticks, NULL); self.onesec_runtime = 0; + ShakeDetectFactoryTest(); } break; case MSG_TIME_SET_START_1MIN: diff --git a/pill/shake_detect.c b/pill/shake_detect.c index 0316dafe..42ed429c 100644 --- a/pill/shake_detect.c +++ b/pill/shake_detect.c @@ -5,6 +5,7 @@ static struct{ uint32_t thmag, cnt; uint8_t shaking_time_sec; + uint8_t factory_shake_cnt; shake_detection_callback_t _shake_detection_callback; }self; @@ -17,6 +18,9 @@ void ShakeDetectReset(uint32_t threshold){ _reset(); } +void ShakeDetectFactoryTest(void){ + self.factory_shake_cnt = 3; +} void ShakeDetectDecWindow(void){ //increase sliding window if started @@ -37,7 +41,11 @@ void ShakeDetectDecWindow(void){ } bool ShakeDetect(uint32_t accelmag){ - if(accelmag >= self.thmag){ + uint32_t mag = self.thmag; + if(self.factory_shake_cnt){ + mag = self.thmag / 2; + } + if(accelmag >= mag){ if(!self.shaking_time_sec){ ++self.shaking_time_sec; // initialize the sliding window timer. } @@ -49,5 +57,8 @@ bool ShakeDetect(uint32_t accelmag){ } void set_shake_detection_callback(shake_detection_callback_t callback){ + if(self.factory_shake_cnt){ + self.factory_shake_cnt--; + } self._shake_detection_callback = callback; } diff --git a/pill/shake_detect.h b/pill/shake_detect.h index a710752c..cc9c0560 100644 --- a/pill/shake_detect.h +++ b/pill/shake_detect.h @@ -13,6 +13,7 @@ typedef void(*shake_detection_callback_t)(void); void ShakeDetectReset(uint32_t threshold); void ShakeDetectDecWindow(void); bool ShakeDetect(uint32_t accelmag); +void ShakeDetectFactoryTest(void);//enable hi sensitivity for N shakes void set_shake_detection_callback(shake_detection_callback_t callback); From 635afc7212e44037d8e97a837861cb83260616b5 Mon Sep 17 00:00:00 2001 From: Jackson Chen Date: Mon, 28 Nov 2016 13:03:14 -0800 Subject: [PATCH 2/6] update version --- common/app_info.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/app_info.h b/common/app_info.h index 3ba7d091..e6d44bb6 100644 --- a/common/app_info.h +++ b/common/app_info.h @@ -3,10 +3,10 @@ * A place to put all common defines */ //make sure the FW_VERSION_STRING fits in MorpheusCommand.top_version (16 bytes) -#define FW_VERSION_STRING "1.8.0" +#define FW_VERSION_STRING "1.8.1" //pill only -#define FIRMWARE_VERSION_8BIT (0x50) +#define FIRMWARE_VERSION_8BIT (0x51) #define BLE_SIG_COMPANY_ID 1002 From 951552de12d6bb4eb6ed3764f121de62197acc8f Mon Sep 17 00:00:00 2001 From: Jackson Chen Date: Mon, 28 Nov 2016 13:55:41 -0800 Subject: [PATCH 3/6] logic rearrange --- pill/shake_detect.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pill/shake_detect.c b/pill/shake_detect.c index 42ed429c..4822f0fb 100644 --- a/pill/shake_detect.c +++ b/pill/shake_detect.c @@ -34,6 +34,9 @@ void ShakeDetectDecWindow(void){ if(self._shake_detection_callback){ self._shake_detection_callback(); } + if(self.factory_shake_cnt){ + self.factory_shake_cnt--; + } } _reset(); } @@ -57,8 +60,5 @@ bool ShakeDetect(uint32_t accelmag){ } void set_shake_detection_callback(shake_detection_callback_t callback){ - if(self.factory_shake_cnt){ - self.factory_shake_cnt--; - } self._shake_detection_callback = callback; } From d4055a02f6f09e7db3bdd949f9dd1b31f4db503d Mon Sep 17 00:00:00 2001 From: Jackson Chen Date: Mon, 28 Nov 2016 15:24:15 -0800 Subject: [PATCH 4/6] exit ship state only --- pill/message_time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pill/message_time.c b/pill/message_time.c index 1189e749..a1ea8199 100644 --- a/pill/message_time.c +++ b/pill/message_time.c @@ -188,6 +188,7 @@ static void _1sec_timer_handler(void * ctx){ hble_advertising_start(); self.central->dispatch( ADDR(TIME, 0), ADDR(TIME, MSG_TIME_SET_START_1MIN), NULL); APP_OK(app_gpiote_user_enable(_gpiote_user)); + ShakeDetectFactoryTest(); } else if(self.reed_states && self.reed_states != POWER_STATE_MASK){ battery_update_droop(); } @@ -217,7 +218,6 @@ static MSG_Status _send(MSG_Address_t src, MSG_Address_t dst, MSG_Data_t * data) app_timer_stop(self.timer_id_1sec); app_timer_start(self.timer_id_1sec, ticks, NULL); self.onesec_runtime = 0; - ShakeDetectFactoryTest(); } break; case MSG_TIME_SET_START_1MIN: From e6968ba0de4411987f78365989c389d3d95229d4 Mon Sep 17 00:00:00 2001 From: Jackson Chen Date: Mon, 28 Nov 2016 15:43:07 -0800 Subject: [PATCH 5/6] update version --- common/app_info.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/app_info.h b/common/app_info.h index e6d44bb6..7e4578d2 100644 --- a/common/app_info.h +++ b/common/app_info.h @@ -3,10 +3,10 @@ * A place to put all common defines */ //make sure the FW_VERSION_STRING fits in MorpheusCommand.top_version (16 bytes) -#define FW_VERSION_STRING "1.8.1" +#define FW_VERSION_STRING "1.8.2" //pill only -#define FIRMWARE_VERSION_8BIT (0x51) +#define FIRMWARE_VERSION_8BIT (0x52) #define BLE_SIG_COMPANY_ID 1002 From c950374594fdf7561d9148216757802be2968599 Mon Sep 17 00:00:00 2001 From: Jackson Chen Date: Mon, 28 Nov 2016 15:44:28 -0800 Subject: [PATCH 6/6] reduced count to 12 --- pill/app.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pill/app.h b/pill/app.h index 4a2fd5e0..336a94ba 100644 --- a/pill/app.h +++ b/pill/app.h @@ -118,7 +118,7 @@ enum { #define BATT_MEASURE_INTERVAL_MIN (1200/60) /* Measure battery level every 20 minutes */ #define SHAKING_MOTION_THRESHOLD (500000000) -#define SLIDING_WINDOW_SIZE_SEC (4) // shake second timer runs on imu active timer at 2hz now, so this is 1/2 secs -#define SHAKING_DATA_COUNT_THRESHOLD (15) +#define SLIDING_WINDOW_SIZE_SEC (4) // shake second timer runs on imu active timer at 2hz now, so this is 2 secs +#define SHAKING_DATA_COUNT_THRESHOLD (12) #define TF_CONDENSED_BUFFER_SIZE (1)