Skip to content

Commit

Permalink
Merge pull request #535 from hello/integration
Browse files Browse the repository at this point in the history
Pill MP RC1
  • Loading branch information
zer0page authored Nov 29, 2016
2 parents 32aee86 + 9345762 commit 55c54f3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions common/app_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.2"

//pill only
#define FIRMWARE_VERSION_8BIT (0x50)
#define FIRMWARE_VERSION_8BIT (0x52)

#define BLE_SIG_COMPANY_ID 1002

Expand Down
4 changes: 2 additions & 2 deletions pill/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions pill/message_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
13 changes: 12 additions & 1 deletion pill/shake_detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -30,14 +34,21 @@ void ShakeDetectDecWindow(void){
if(self._shake_detection_callback){
self._shake_detection_callback();
}
if(self.factory_shake_cnt){
self.factory_shake_cnt--;
}
}
_reset();
}

}

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.
}
Expand Down
1 change: 1 addition & 0 deletions pill/shake_detect.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 55c54f3

Please sign in to comment.