|
|
|
|
@ -46,7 +46,7 @@ void SF_InitConfig(void){ |
|
|
|
|
// + 0.5 so the rounding is done correctly
|
|
|
|
|
int32_t position = (stepsPerSegment * (float)i + 0.5); |
|
|
|
|
addItem(splitFlapDict, SF_Letters[i], (int32_t*)position); |
|
|
|
|
McuLog_info("Letter '%s': Position %i", SF_Letters[i], (int)position); |
|
|
|
|
//McuLog_info("Letter '%s': Position %i", SF_Letters[i], (int)position);
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -154,13 +154,15 @@ bool SF_MoveMotorToZeroPosition(SF_Handle_t instance){ |
|
|
|
|
// move out of sensor
|
|
|
|
|
while(SF_GetMagSensorAtZeroPosition((SF_t*)instance) == true){ |
|
|
|
|
McuULN2003_IncStep(((SF_t*)instance)->motor); |
|
|
|
|
McuWait_Waitms(20); |
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(20)); |
|
|
|
|
//McuWait_Waitms(20);
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// turn until sensor is on and not reached one full rotation already (timeout)
|
|
|
|
|
while(SF_GetMagSensorAtZeroPosition((SF_t*)instance) == false && numStepsMoved < SPLITFLAP_STEPS_ONE_ROUND ){ |
|
|
|
|
McuULN2003_IncStep(((SF_t*)instance)->motor); |
|
|
|
|
McuWait_Waitms(20); |
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(20)); |
|
|
|
|
//McuWait_Waitms(20);
|
|
|
|
|
numStepsMoved++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -168,7 +170,8 @@ bool SF_MoveMotorToZeroPosition(SF_Handle_t instance){ |
|
|
|
|
if(numStepsMoved < SPLITFLAP_STEPS_ONE_ROUND){ |
|
|
|
|
for(int i=0; i < offsetSteps; i++){ |
|
|
|
|
McuULN2003_IncStep(((SF_t*)instance)->motor); |
|
|
|
|
McuWait_Waitms(20); |
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(20)); |
|
|
|
|
//McuWait_Waitms(20);
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
McuULN2003_SetPos(((SF_t*)instance)->motor, 0); |
|
|
|
|
@ -206,7 +209,8 @@ void SF_MoveSteps(SF_Handle_t instance, uint32_t steps){ |
|
|
|
|
if(McuULN2003_StepCallback(((SF_t*)instance)->motor, true)){ |
|
|
|
|
steps--; |
|
|
|
|
} |
|
|
|
|
McuWait_Waitms(1); |
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(1)); |
|
|
|
|
//McuWait_Waitms(1);
|
|
|
|
|
} |
|
|
|
|
McuULN2003_AccelerationEnd(((SF_t*)instance)->motor); |
|
|
|
|
|
|
|
|
|
@ -264,6 +268,10 @@ int32_t SF_GetMotorPosition(SF_Handle_t instance){ |
|
|
|
|
return McuULN2003_GetPos(((SF_t*)instance)->motor); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
SF_State SF_GetCurrentState(SF_Handle_t instance){ |
|
|
|
|
return ((SF_t*)instance)->state; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**********************/ |
|
|
|
|
/* INTERNAL FUNCTIONS */ |
|
|
|
|
/**********************/ |
|
|
|
|
|