moving encoder code to motor.h