@@ -144,75 +144,49 @@ bool CurieImuClass::accelerometerOffsetEnabled()
144
144
145
145
int CurieImuClass::getGyroOffset (int axis)
146
146
{
147
- switch (axis) {
148
- case X_AXIS:
149
- return getXGyroOffset ();
150
-
151
- case Y_AXIS:
152
- return getYGyroOffset ();
153
-
154
- case Z_AXIS:
155
- return getZGyroOffset ();
156
-
157
- default :
158
- return -1 ;
147
+ if (axis == X_AXIS) {
148
+ return getXGyroOffset ();
149
+ } else if (axis == Y_AXIS) {
150
+ return getYGyroOffset ();
151
+ } else if (axis == Z_AXIS) {
152
+ return getZGyroOffset ();
159
153
}
154
+
155
+ return -1 ;
160
156
}
161
157
162
158
int CurieImuClass::getAccelerometerOffset (int axis)
163
159
{
164
- switch (axis) {
165
- case X_AXIS:
166
- return getXAccelOffset ();
167
-
168
- case Y_AXIS:
169
- return getYAccelOffset ();
170
-
171
- case Z_AXIS:
172
- return getZAccelOffset ();
173
-
174
- default :
175
- return -1 ;
160
+ if (axis == X_AXIS) {
161
+ return getXAccelOffset ();
162
+ } else if (axis == Y_AXIS) {
163
+ return getYAccelOffset ();
164
+ } else if (axis == Z_AXIS) {
165
+ return getZAccelOffset ();
176
166
}
167
+
168
+ return -1 ;
177
169
}
178
170
179
171
void CurieImuClass::setGyroOffset (int axis, int offset)
180
172
{
181
- switch (axis) {
182
- case X_AXIS:
183
- setXGyroOffset (axis);
184
- break ;
185
-
186
- case Y_AXIS:
187
- setYGyroOffset (axis);
188
- break ;
189
-
190
- case Z_AXIS:
191
- setZGyroOffset (axis);
192
- break ;
193
-
194
- default :
195
- break ;
173
+ if (axis == X_AXIS) {
174
+ setXGyroOffset (axis);
175
+ } else if (axis == Y_AXIS) {
176
+ setYGyroOffset (axis);
177
+ } else if (axis == Z_AXIS) {
178
+ setZGyroOffset (axis);
196
179
}
197
180
}
198
181
199
182
void CurieImuClass::setAccelerometerOffset (int axis, int offset)
200
183
{
201
- switch (axis) {
202
- case X_AXIS:
203
- setXAccelOffset (axis);
204
- break ;
205
-
206
- case Y_AXIS:
207
- setYAccelOffset (axis);
208
- break ;
209
-
210
- case Z_AXIS:
211
- setZAccelOffset (axis);
212
- break ;
213
-
214
- default :
215
- break ;
184
+ if (axis == X_AXIS) {
185
+ setXAccelOffset (axis);
186
+ } else if (axis == Y_AXIS) {
187
+ setYAccelOffset (axis);
188
+ } else if (axis == Z_AXIS) {
189
+ setZAccelOffset (axis);
216
190
}
217
191
}
218
192
@@ -431,7 +405,7 @@ bool CurieImuClass::interruptEnabled(int feature)
431
405
case CURIE_IMU_TAP_QUIET:
432
406
case CURIE_IMU_TAP_SHOCK:
433
407
default :
434
- return - 1 ;
408
+ return false ;
435
409
}
436
410
}
437
411
@@ -468,7 +442,7 @@ int CurieImuClass::getInterruptStatus(int feature)
468
442
case CURIE_IMU_TAP_QUIET:
469
443
case CURIE_IMU_TAP_SHOCK:
470
444
default :
471
- return - 1 ;
445
+ return false ;
472
446
}
473
447
}
474
448
@@ -499,36 +473,28 @@ void CurieImuClass::readRotation(short& x, short& y, short& z)
499
473
500
474
short CurieImuClass::readAccelerometer (int axis)
501
475
{
502
- switch (axis) {
503
- case X_AXIS:
504
- return getAccelerationX ();
505
-
506
- case Y_AXIS:
507
- return getAccelerationY ();
508
-
509
- case Z_AXIS:
510
- return getAccelerationZ ();
511
-
512
- default :
513
- return -1 ;
476
+ if (axis == X_AXIS) {
477
+ return getAccelerationX ();
478
+ } else if (axis == Y_AXIS) {
479
+ return getAccelerationY ();
480
+ } else if (axis == Z_AXIS) {
481
+ return getAccelerationZ ();
514
482
}
483
+
484
+ return 0 ;
515
485
}
516
486
517
487
short CurieImuClass::readGyro (int axis)
518
488
{
519
- switch (axis) {
520
- case X_AXIS:
521
- return getRotationX ();
522
-
523
- case Y_AXIS:
524
- return getRotationY ();
525
-
526
- case Z_AXIS:
527
- return getRotationZ ();
528
-
529
- default :
530
- return -1 ;
489
+ if (axis == X_AXIS) {
490
+ return getRotationX ();
491
+ } else if (axis == Y_AXIS) {
492
+ return getRotationY ();
493
+ } else if (axis == Z_AXIS) {
494
+ return getRotationZ ();
531
495
}
496
+
497
+ return 0 ;
532
498
}
533
499
534
500
short CurieImuClass::readTemperature ()
@@ -539,106 +505,70 @@ short CurieImuClass::readTemperature()
539
505
bool CurieImuClass::shockDetected (int axis, int direction)
540
506
{
541
507
if (direction == POSITIVE) {
542
- switch (axis) {
543
- case X_AXIS:
544
- return getXPosShockDetected ();
545
-
546
- case Y_AXIS:
547
- return getYPosShockDetected ();
548
-
549
- case Z_AXIS:
550
- return getZPosShockDetected ();
551
-
552
- default :
553
- return -1 ;
508
+ if (axis == X_AXIS) {
509
+ return getXPosShockDetected ();
510
+ } else if (axis == Y_AXIS) {
511
+ return getYPosShockDetected ();
512
+ } else if (axis == Z_AXIS) {
513
+ return getZPosShockDetected ();
554
514
}
555
515
} else if (direction == NEGATIVE) {
556
- switch (axis) {
557
- case X_AXIS:
558
- return getXNegShockDetected ();
559
-
560
- case Y_AXIS:
561
- return getYNegShockDetected ();
562
-
563
- case Z_AXIS:
564
- return getZNegShockDetected ();
565
-
566
- default :
567
- return -1 ;
516
+ if (axis == X_AXIS) {
517
+ return getXNegShockDetected ();
518
+ } else if (axis == Y_AXIS) {
519
+ return getYNegShockDetected ();
520
+ } else if (axis == Z_AXIS) {
521
+ return getZNegShockDetected ();
568
522
}
569
- } else {
570
- return -1 ;
571
523
}
524
+
525
+ return false ;
572
526
}
573
527
574
528
bool CurieImuClass::motionDetected (int axis, int direction)
575
529
{
576
530
if (direction == POSITIVE) {
577
- switch (axis) {
578
- case X_AXIS:
579
- return getXPosMotionDetected ();
580
-
581
- case Y_AXIS:
582
- return getYPosMotionDetected ();
583
-
584
- case Z_AXIS:
585
- return getZPosMotionDetected ();
586
-
587
- default :
588
- return -1 ;
531
+ if (axis == X_AXIS) {
532
+ return getXPosMotionDetected ();
533
+ } else if (axis == Y_AXIS) {
534
+ return getYPosMotionDetected ();
535
+ } else if (axis == Z_AXIS) {
536
+ return getZPosMotionDetected ();
589
537
}
590
538
} else if (direction == NEGATIVE) {
591
- switch (axis) {
592
- case X_AXIS:
593
- return getXNegMotionDetected ();
594
-
595
- case Y_AXIS:
596
- return getYNegMotionDetected ();
597
-
598
- case Z_AXIS:
599
- return getZNegMotionDetected ();
600
-
601
- default :
602
- return -1 ;
539
+ if (axis == X_AXIS) {
540
+ return getXNegMotionDetected ();
541
+ } else if (axis == Y_AXIS) {
542
+ return getYNegMotionDetected ();
543
+ } else if (axis == Z_AXIS) {
544
+ return getZNegMotionDetected ();
603
545
}
604
- } else {
605
- return -1 ;
606
546
}
547
+
548
+ return false ;
607
549
}
608
550
609
551
bool CurieImuClass::tapDetected (int axis, int direction)
610
552
{
611
553
if (direction == POSITIVE) {
612
- switch (axis) {
613
- case X_AXIS:
614
- return getXPosTapDetected ();
615
-
616
- case Y_AXIS:
617
- return getYPosTapDetected ();
618
-
619
- case Z_AXIS:
620
- return getZPosTapDetected ();
621
-
622
- default :
623
- return -1 ;
554
+ if (axis == X_AXIS) {
555
+ return getXPosTapDetected ();
556
+ } else if (axis == Y_AXIS) {
557
+ return getYPosTapDetected ();
558
+ } else if (axis == Z_AXIS) {
559
+ return getZPosTapDetected ();
624
560
}
625
561
} else if (direction == NEGATIVE) {
626
- switch (axis) {
627
- case X_AXIS:
628
- return getXNegTapDetected ();
629
-
630
- case Y_AXIS:
631
- return getYNegTapDetected ();
632
-
633
- case Z_AXIS:
634
- return getZNegTapDetected ();
635
-
636
- default :
637
- return -1 ;
562
+ if (axis == X_AXIS) {
563
+ return getXNegTapDetected ();
564
+ } else if (axis == Y_AXIS) {
565
+ return getYNegTapDetected ();
566
+ } else if (axis == Z_AXIS) {
567
+ return getZNegTapDetected ();
638
568
}
639
- } else {
640
- return -1 ;
641
569
}
570
+
571
+ return false ;
642
572
}
643
573
644
574
bool CurieImuClass::stepsDetected ()
0 commit comments