|
|
|
|
@ -28,9 +28,23 @@ SF_Handle_t SF_Init(SF_Config_t* instance, int id){ |
|
|
|
|
return splitflap; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool SF_MoveMotorToZeroPosition(SF_Handle_t instance){ |
|
|
|
|
int numStepsMoved = 0; |
|
|
|
|
|
|
|
|
|
while(SF_GetMagSensorAtZeroPosition((SF_t*)instance) == false && numStepsMoved < SPLITFLAP_STEPS_ONE_ROUND ){ |
|
|
|
|
McuULN2003_IncStep(((SF_t*)instance)->motor); |
|
|
|
|
McuWait_Waitms(20); |
|
|
|
|
numStepsMoved++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// success if less than one rotation
|
|
|
|
|
return numStepsMoved < SPLITFLAP_STEPS_ONE_ROUND; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SF_MoveSteps(SF_Handle_t instance, uint8_t steps){ |
|
|
|
|
|
|
|
|
|
// run move with acceleration & deceleration
|
|
|
|
|
McuULN2003_AccelerationStart(((SF_t*)instance)->motor); |
|
|
|
|
// maybe move callback?
|
|
|
|
|
while(steps>0){ |
|
|
|
|
if(McuULN2003_StepCallback(((SF_t*)instance)->motor, true) == true){ |
|
|
|
|
steps--; |
|
|
|
|
@ -38,7 +52,10 @@ void SF_MoveSteps(SF_Handle_t instance, uint8_t steps){ |
|
|
|
|
McuWait_Waitms(1); |
|
|
|
|
} |
|
|
|
|
McuULN2003_AccelerationEnd(((SF_t*)instance)->motor); |
|
|
|
|
// Power off necessary? -> what to do after power off? init again?
|
|
|
|
|
|
|
|
|
|
// Power off disables all outputs of the ULN,
|
|
|
|
|
// required since it is possible that one is still active, which would result in the motor getting hot
|
|
|
|
|
// no re-init is required
|
|
|
|
|
McuULN2003_PowerOff(((SF_t*)instance)->motor); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|