Microchip_Examples/ClearPathModeExamples/ClearPath-MC_Series/Abs2PositionsHomeToSwitch/Abs2PositionsHomeToSwitch.cpp
bool MoveToPosition(uint8_t positionNum) {
    SerialPort.Send("Moving to position: ");
    SerialPort.Send(positionNum);

    switch (positionNum) {
        case 1:
            // Sets Input A "off" for position 1
            motor.MotorInAState(false);
            SerialPort.SendLine(" (Input A Off)");
            break;
        case 2:
            // Sets Input A "on" for position 2
            motor.MotorInAState(true);
            SerialPort.SendLine(" (Input A On)");
            break;
        default:
            // If this case is reached then an incorrect positionNum was entered
            return false;
    }

    // Ensures this delay is at least 2ms longer than the Input A, B filter
    // setting in MSP
    Delay_ms(2 + INPUT_A_B_FILTER);

    // Waits for HLFB to assert (signaling the move has successfully completed)
    SerialPort.SendLine("Moving... Waiting for HLFB");
    while (motor.HlfbState() != MotorDriver::HLFB_ASSERTED) {
        continue;
    }

    SerialPort.SendLine("Move Done");
    return true;
}
/*------------------------------------------------------------------------------
 * MoveToPosition
 *
 *    Move to position number positionNum (defined in MSP)
 *    Prints the move status to the USB serial port
 *    Returns when HLFB asserts (indicating the motor has reached the commanded
 *    position)
 *
 * Parameters:
 *    int positionNum  - The position number to command (defined in MSP)
 *
 * Returns: True/False depending on whether a valid position was
 * successfully commanded and reached.
 */
MoveToPosition
Move to position number positionNum (defined in MSP)
Prints the move status to the USB serial port
Returns when HLFB asserts (indicating the motor has reached the commanded
position)

int positionNum  - The position number to command (defined in MSP)

True/False depending on whether a valid position was
successfully commanded and reached.
MoveToPosition Move to position number positionNum ( defined in MSP ) Prints the move status to the USB serial port Returns when HLFB asserts ( indicating the motor has reached the commanded position ) int positionNum - The position number to command ( defined in MSP ) True / False depending on whether a valid position was successfully commanded and reached .
bool MoveToPosition(uint8_t positionNum) {
    SerialPort.Send("Moving to position: ");
    SerialPort.Send(positionNum);
    switch (positionNum) {
        case 1:
            motor.MotorInAState(false);
            SerialPort.SendLine(" (Input A Off)");
            break;
        case 2:
            motor.MotorInAState(true);
            SerialPort.SendLine(" (Input A On)");
            break;
        default:
            return false;
    }
    Delay_ms(2 + INPUT_A_B_FILTER);
    SerialPort.SendLine("Moving... Waiting for HLFB");
    while (motor.HlfbState() != MotorDriver::HLFB_ASSERTED) {
        continue;
    }
    SerialPort.SendLine("Move Done");
    return true;
}
bool MoveToPosition ( uint8_t positionNum ) { SerialPort . Send ( " " ) ; SerialPort . Send ( positionNum ) ; switch ( positionNum ) { case 1 : motor . MotorInAState ( false ) ; SerialPort . SendLine ( " " ) ; break ; case 2 : motor . MotorInAState ( true ) ; SerialPort . SendLine ( " " ) ; break ; default : return false ; } Delay_ms ( 2 + INPUT_A_B_FILTER ) ; SerialPort . SendLine ( " " ) ; while ( motor . HlfbState ( ) != MotorDriver :: HLFB_ASSERTED ) { continue ; } SerialPort . SendLine ( " " ) ; return true ; }
MoveToPosition
    Move to position number positionNum (defined in MSP)
    Prints the move status to the USB serial port
    Returns when HLFB asserts (indicating the motor has reached the commanded
    position)
MoveToPosition Move to position number positionNum ( defined in MSP ) Prints the move status to the USB serial port Returns when HLFB asserts ( indicating the motor has reached the commanded position )
// Sets Input A "off" for position 1 // Sets Input A "on" for position 2 // If this case is reached then an incorrect positionNum was entered // Ensures this delay is at least 2ms longer than the Input A, B filter // setting in MSP // Waits for HLFB to assert (signaling the move has successfully completed)