|
|
|
|
@ -48,22 +48,61 @@ void MultiSplitFlap_AddFlap(SF_Handle_t splitflap){ |
|
|
|
|
addedFlaps++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool MultiSplitFlap_MoveAllToZeroPosition(void){ |
|
|
|
|
McuLog_info("MultiSplitFlap_MoveAllToZeroPosition: Initializing split flap motors."); |
|
|
|
|
|
|
|
|
|
// start all inits
|
|
|
|
|
for (uint8_t num = 0; num < NUM_FLAPS; ++num) { |
|
|
|
|
// get handle
|
|
|
|
|
SF_Handle_t sfHandle = (SF_Handle_t)(getItem(*flapDict, flapKeys[num])); |
|
|
|
|
// start init
|
|
|
|
|
SF_MoveMotorToZeroPositionAsync(sfHandle); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// timeout of 35sec
|
|
|
|
|
bool initSuccess = false; |
|
|
|
|
for (int i = 0; i < 700; ++i) { |
|
|
|
|
initSuccess = true; |
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(50)); |
|
|
|
|
// check each splitflap if it is finished with init
|
|
|
|
|
for (uint8_t num = 0; num < NUM_FLAPS; ++num) { |
|
|
|
|
// get handle
|
|
|
|
|
SF_Handle_t sfHandle = (SF_Handle_t)(getItem(*flapDict, flapKeys[num])); |
|
|
|
|
// check if init done
|
|
|
|
|
if(SF_IS_RDY_TO_MOVE(sfHandle) == false){ |
|
|
|
|
initSuccess = false; |
|
|
|
|
break; // end loop when one is not yet initialized
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(initSuccess == true){ |
|
|
|
|
break; // end loop when all split flaps are initialized
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
McuLog_info("MultiSplitFlap_MoveAllToZeroPosition: Init of splitflaps done. success=%s\n\n", initSuccess ? "true" : "false"); |
|
|
|
|
return initSuccess; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool MultiSplitFlap_Display(char sentence[]){ |
|
|
|
|
// Start movements
|
|
|
|
|
for (uint8_t num = 0; num < NUM_FLAPS; ++num) { |
|
|
|
|
// get handle
|
|
|
|
|
SF_Handle_t sfHandle = (SF_Handle_t)(getItem(*flapDict, flapKeys[num])); |
|
|
|
|
char letter = sentence[num]; |
|
|
|
|
char letter_move[] = " "; |
|
|
|
|
letter_move[0] = letter; |
|
|
|
|
SF_MoveToFlapAsync(sfHandle, letter_move); |
|
|
|
|
McuLog_info("Multi splitflap: Commanded Flap nr. %i to letter '%c'.\n", num+1, letter); |
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(100)); |
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(100)); // delay loop
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// wait until finished
|
|
|
|
|
bool done = false; |
|
|
|
|
while(done == false){ |
|
|
|
|
done = true; |
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(100)); // delay loop
|
|
|
|
|
|
|
|
|
|
done = true; // default is successful
|
|
|
|
|
// go through all splitflaps
|
|
|
|
|
for (uint8_t num = 0; num < NUM_FLAPS; ++num) { |
|
|
|
|
SF_Handle_t sfHandle = (SF_Handle_t)(getItem(*flapDict, flapKeys[num])); |
|
|
|
|
if(SF_GetCurrentState(sfHandle) == SF_STATE_MOVING){ |
|
|
|
|
@ -73,11 +112,28 @@ bool MultiSplitFlap_Display(char sentence[]){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return done; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool MultiSplitFlap_SetHardwareIdentifier(SetupIdentifier_t id, HardwareIdentifier_t hwId){ |
|
|
|
|
// number too high (not that many split flaps can be added to the combination)
|
|
|
|
|
if(id >= NUM_FLAPS){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
// number too high (not that many split flaps were added added to the combination)
|
|
|
|
|
if(id >= MultiSplitFlap_GetAmountOfAddedSplitFlaps()){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
// number negative
|
|
|
|
|
if(id < 0){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// get handle
|
|
|
|
|
SF_Handle_t sfHandle = (SF_Handle_t)(getItem(*flapDict, flapKeys[id])); |
|
|
|
|
// set hardware identifier
|
|
|
|
|
SF_SetHardwareIdentifier(sfHandle, hwId); |
|
|
|
|
|
|
|
|
|
// for testing purposes only
|
|
|
|
|
//SF_t* sf0 = (SF_t*)(SF_Handle_t)(getItem(*flapDict, flapKeys[0]));
|
|
|
|
|
//SF_t* sf1 = (SF_t*)(SF_Handle_t)(getItem(*flapDict, flapKeys[1]));
|
|
|
|
|
//int32_t test = McuULN2003_GetPos(sf1->motor);
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uint8_t MultiSplitFlap_GetAmountOfAddedSplitFlaps(void){ |
|
|
|
|
|