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