@ Override public void setState ( MotorState state ) { switch ( state ) { case STOP : { // set internal tracking state currentState = MotorState . STOP ; // turn all GPIO pins to OFF state for ( GpioPinDigitalOutput pin : pins ) pin . setState ( offState ) ; break ; } case FORWARD : { // set internal tracking state currentState = MotorState . FORWARD ; // start control thread if not already running if ( ! controlThread . isAlive ( ) ) { controlThread = new GpioStepperMotorControl ( ) ; controlThread . start ( ) ; } break ; } case REVERSE : { // set internal tracking state currentState = MotorState . REVERSE ; // start control thread if not already running if ( ! controlThread . isAlive ( ) ) { controlThread = new GpioStepperMotorControl ( ) ; controlThread . start ( ) ; } break ; } default : { throw new UnsupportedOperationException ( "Cannot set motor state: " + state . toString ( ) ) ; } } }
change the current stepper motor state