@@ -144,75 +144,49 @@ bool CurieImuClass::accelerometerOffsetEnabled()
144144
145145int CurieImuClass::getGyroOffset (int axis)
146146{
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 ();
159153 }
154+
155+ return -1 ;
160156}
161157
162158int CurieImuClass::getAccelerometerOffset (int axis)
163159{
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 ();
176166 }
167+
168+ return -1 ;
177169}
178170
179171void CurieImuClass::setGyroOffset (int axis, int offset)
180172{
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);
196179 }
197180}
198181
199182void CurieImuClass::setAccelerometerOffset (int axis, int offset)
200183{
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);
216190 }
217191}
218192
@@ -431,7 +405,7 @@ bool CurieImuClass::interruptEnabled(int feature)
431405 case CURIE_IMU_TAP_QUIET:
432406 case CURIE_IMU_TAP_SHOCK:
433407 default :
434- return - 1 ;
408+ return false ;
435409 }
436410}
437411
@@ -468,7 +442,7 @@ int CurieImuClass::getInterruptStatus(int feature)
468442 case CURIE_IMU_TAP_QUIET:
469443 case CURIE_IMU_TAP_SHOCK:
470444 default :
471- return - 1 ;
445+ return false ;
472446 }
473447}
474448
@@ -499,36 +473,28 @@ void CurieImuClass::readRotation(short& x, short& y, short& z)
499473
500474short CurieImuClass::readAccelerometer (int axis)
501475{
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 ();
514482 }
483+
484+ return 0 ;
515485}
516486
517487short CurieImuClass::readGyro (int axis)
518488{
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 ();
531495 }
496+
497+ return 0 ;
532498}
533499
534500short CurieImuClass::readTemperature ()
@@ -539,106 +505,70 @@ short CurieImuClass::readTemperature()
539505bool CurieImuClass::shockDetected (int axis, int direction)
540506{
541507 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 ();
554514 }
555515 } 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 ();
568522 }
569- } else {
570- return -1 ;
571523 }
524+
525+ return false ;
572526}
573527
574528bool CurieImuClass::motionDetected (int axis, int direction)
575529{
576530 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 ();
589537 }
590538 } 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 ();
603545 }
604- } else {
605- return -1 ;
606546 }
547+
548+ return false ;
607549}
608550
609551bool CurieImuClass::tapDetected (int axis, int direction)
610552{
611553 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 ();
624560 }
625561 } 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 ();
638568 }
639- } else {
640- return -1 ;
641569 }
570+
571+ return false ;
642572}
643573
644574bool CurieImuClass::stepsDetected ()
0 commit comments