@@ -266,7 +266,7 @@ class Flight1Service {
266266 uint8_t buff[LEN_DISTANCE];
267267
268268 /* To discriminate the long proximity range from 53L1A1*/
269- Distance= Distance | (1 << 15 );
269+ Distance = Distance | (1 << 15 );
270270
271271 STORE_LE_16 (buff, millis ());
272272 STORE_LE_16 (buff + 2 , Distance);
@@ -461,18 +461,35 @@ void configCB(BLEDevice unused1, BLECharacteristic unused2)
461461 uint8_t data = buf[5 ];
462462 uint8_t signalEvents [4 ] = {0x00 , 0x00 , 0x04 , 0x00 };
463463
464- if (!memcmp (buf, signalEvents, 4 ) && data) {
465- enableAllFunc ();
464+ if (!memcmp (buf, signalEvents, 4 )) {
466465 switch (command) {
467- case ' o ' :
468- Flight1. shortMode = true ;
466+ case ' m ' :
467+ data ? enableAllFunc () : disableAllFunc () ;
469468 break ;
470- default :
471- Flight1.shortMode = false ;
469+ case ' f' :
470+ data ? AccGyr.Enable_Free_Fall_Detection (LSM6DSO_INT1_PIN) : AccGyr.Disable_Free_Fall_Detection ();
471+ break ;
472+ case ' d' :
473+ data ? AccGyr.Enable_Double_Tap_Detection (LSM6DSO_INT1_PIN) : AccGyr.Disable_Double_Tap_Detection ();
474+ break ;
475+ case ' s' :
476+ data ? AccGyr.Enable_Single_Tap_Detection (LSM6DSO_INT1_PIN) : AccGyr.Disable_Single_Tap_Detection ();
477+ break ;
478+ case ' p' :
479+ data ? AccGyr.Enable_Pedometer () : AccGyr.Disable_Pedometer ();
480+ data ? AccGyr.Step_Counter_Reset () : 0 ;
481+ break ;
482+ case ' w' :
483+ data ? AccGyr.Enable_Wake_Up_Detection (LSM6DSO_INT2_PIN) : AccGyr.Disable_Wake_Up_Detection ();
484+ break ;
485+ case ' t' :
486+ data ? AccGyr.Enable_Tilt_Detection (LSM6DSO_INT1_PIN) : AccGyr.Disable_Tilt_Detection ();
487+ break ;
488+ case ' o' :
489+ data ? Flight1.shortMode = true : Flight1.shortMode = false ;
490+ data ? AccGyr.Enable_6D_Orientation (LSM6DSO_INT1_PIN) : AccGyr.Disable_6D_Orientation ();;
472491 break ;
473492 }
474- } else {
475- disableAllFunc ();
476493 }
477494
478495 // Either way, respond by repeating the command
@@ -564,6 +581,7 @@ void setup()
564581 Mag.begin ();
565582 Mag.Enable ();
566583
584+ disableAllFunc ();
567585 configC.setEventHandler (BLEWritten, configCB);
568586}
569587
0 commit comments