dived pos by steps per pos (not tested yet)

main
Simon Frei 4 years ago
parent 2821ca6670
commit 5655d3149a
  1. 6
      ADIS_tinyK22_SplitFlap/source/splitflap.c

@ -108,7 +108,6 @@ bool SF_MoveMotorToZeroPosition(SF_Handle_t instance){
numStepsMoved++;
}
}
McuULN2003_SetPos(((SF_t*)instance)->motor, 0);
McuULN2003_PowerOff(((SF_t*)instance)->motor);
// success if less than one rotation
@ -141,7 +140,7 @@ void SF_MoveToFlap(SF_Handle_t instance, char* flap){
// get flap pos from dictonary
int32_t flapPos = (int32_t)getItem(*splitFlapDict, flap);
// get current motor pos
int32_t currentPos = McuULN2003_GetPos(((SF_t*)instance)->motor);
int32_t currentPos = SF_GetMotorPosition(instance);
// calc steps to move
int32_t stepsToReachFlap = 0;
// not already there
@ -153,11 +152,10 @@ void SF_MoveToFlap(SF_Handle_t instance, char* flap){
}
SF_MoveSteps(((SF_t*)instance)->motor, stepsToReachFlap);
}
}
int32_t SF_GetMotorPosition(SF_Handle_t instance){
return McuULN2003_GetPos(((SF_t*)instance)->motor);
return McuULN2003_GetPos(((SF_t*)instance)->motor) % SPLITFLAP_STEPS_ONE_ROUND;
}
void SF_Deinit(SF_Handle_t instance){

Loading…
Cancel
Save