@@ -266,7 +266,7 @@ class Flight1Service {
266
266
uint8_t buff[LEN_DISTANCE];
267
267
268
268
/* To discriminate the long proximity range from 53L1A1*/
269
- Distance= Distance | (1 << 15 );
269
+ Distance = Distance | (1 << 15 );
270
270
271
271
STORE_LE_16 (buff, millis ());
272
272
STORE_LE_16 (buff + 2 , Distance);
@@ -461,18 +461,35 @@ void configCB(BLEDevice unused1, BLECharacteristic unused2)
461
461
uint8_t data = buf[5 ];
462
462
uint8_t signalEvents [4 ] = {0x00 , 0x00 , 0x04 , 0x00 };
463
463
464
- if (!memcmp (buf, signalEvents, 4 ) && data) {
465
- enableAllFunc ();
464
+ if (!memcmp (buf, signalEvents, 4 )) {
466
465
switch (command) {
467
- case ' o ' :
468
- Flight1. shortMode = true ;
466
+ case ' m ' :
467
+ data ? enableAllFunc () : disableAllFunc () ;
469
468
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 () : false ;
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 ();;
472
491
break ;
473
492
}
474
- } else {
475
- disableAllFunc ();
476
493
}
477
494
478
495
// Either way, respond by repeating the command
@@ -564,6 +581,7 @@ void setup()
564
581
Mag.begin ();
565
582
Mag.Enable ();
566
583
584
+ disableAllFunc ();
567
585
configC.setEventHandler (BLEWritten, configCB);
568
586
}
569
587
0 commit comments