diff options
Diffstat (limited to 'config.h')
-rw-r--r-- | config.h | 112 |
1 files changed, 79 insertions, 33 deletions
@@ -1,41 +1,87 @@ +/** + * @file config.h + * @brief Defines motor and digital port configurations. + */ + #ifndef CONFIG_H_ #define CONFIG_H_ -// Digi IO configuration -static vexDigiCfg dConfig[kVexDigital_Num] = { - { kVexDigital_1, kVexSensorQuadEncoder, kVexConfigQuadEnc1, kVexQuadEncoder_1 }, - { kVexDigital_2, kVexSensorQuadEncoder, kVexConfigQuadEnc2, kVexQuadEncoder_1 }, - { kVexDigital_3, kVexSensorDigitalInput, kVexConfigInput, 0 }, - { kVexDigital_4, kVexSensorDigitalInput, kVexConfigInput, 0 }, - { kVexDigital_5, kVexSensorDigitalInput, kVexConfigInput, 0 }, - { kVexDigital_6, kVexSensorDigitalInput, kVexConfigInput, 0 }, - { kVexDigital_7, kVexSensorDigitalInput, kVexConfigInput, 0 }, - { kVexDigital_8, kVexSensorDigitalInput, kVexConfigInput, 0 }, - { kVexDigital_9, kVexSensorDigitalInput, kVexConfigInput, 0 }, - { kVexDigital_10, kVexSensorDigitalInput, kVexConfigInput, 0 }, - { kVexDigital_11, kVexSensorDigitalInput, kVexConfigInput, 0 }, - { kVexDigital_12, kVexSensorDigitalInput, kVexConfigInput, 0 } +/** + * Creates a default entry in the digital port configuration. + * @param pin the pin to configure + * @return the entry for the configuration + */ +constexpr auto digiDefault(const auto& pin) +{ + return vexDigiCfg { pin, kVexSensorDigitalInput, kVexConfigInput, 0 }; +} + +/** + * Creates a default entry in the motor port configuration. + * @param port the port to configure + * @param type the type of the motor + * @return the entry for the configuration + */ +constexpr auto motorDefault(const auto& port, const tVexMotorType& type = kVexMotorUndefined) +{ + return vexMotorCfg { port, type, kVexMotorNormal, kVexSensorNone, 0 }; +} + +/** The left drive motor's port. */ +constexpr auto mDriveLeft = kVexMotor_5; + +/** The right drive motor's port. */ +constexpr auto mDriveRight = kVexMotor_6; + +/** The lower right lift motor's port. */ +constexpr auto mLiftLowRight = kVexMotor_7; + +/** The upper right lift motor's port. */ +constexpr auto mLiftHighRight = kVexMotor_8; + +/** The lower left lift motor's port. */ +constexpr auto mLiftLowLeft = kVexMotor_3; + +/** The upper left lift motor's port. */ +constexpr auto mLiftHighLeft = kVexMotor_4; + +/** The claw motor's port. */ +constexpr auto mClaw = kVexMotor_1; + +/** The IME channel for the lower left lift motor. */ +constexpr auto iLiftLowLeft = kImeChannel_1; +/** The IME channel for the lower right lift motor. */ +constexpr auto iLiftLowRight = kImeChannel_2; + +/** + * Defines the motor port configuration for the cortex. + */ +constexpr vexMotorCfg mConfig[kVexMotorNum] = { + motorDefault( mDriveLeft ), + motorDefault( mDriveRight ), + motorDefault( mClaw ), + motorDefault( mLiftHighLeft, kVexMotor393S ), + motorDefault( mLiftHighRight, kVexMotor393S ), + { mLiftLowLeft, kVexMotor393S, kVexMotorNormal, kVexSensorIME, iLiftLowLeft }, + { mLiftLowRight, kVexMotor393S, kVexMotorNormal, kVexSensorIME, iLiftLowRight }, }; -#define mDriveLeft kVexMotor_5 -#define mDriveRight kVexMotor_6 -#define mLiftLowRight kVexMotor_7 -#define mLiftHighRight kVexMotor_8 -#define mLiftLowLeft kVexMotor_3 -#define mLiftHighLeft kVexMotor_4 -#define mClaw kVexMotor_1 - -#define iLiftLowLeft kImeChannel_1 -#define iLiftLowRight kImeChannel_2 - -static vexMotorCfg mConfig[kVexMotorNum] = { - { mDriveLeft, kVexMotorUndefined, kVexMotorNormal, kVexSensorNone, 0 }, - { mDriveRight, kVexMotorUndefined, kVexMotorNormal, kVexSensorNone, 0 }, - { mLiftHighLeft, kVexMotor393S, kVexMotorNormal, kVexSensorNone, 0 }, - { mLiftHighRight, kVexMotor393S, kVexMotorNormal, kVexSensorNone, 0 }, - { mLiftLowLeft, kVexMotor393S, kVexMotorNormal, kVexSensorIME, iLiftLowLeft }, - { mLiftLowRight, kVexMotor393S, kVexMotorNormal, kVexSensorIME, iLiftLowRight }, - { mClaw, kVexMotorUndefined, kVexMotorNormal, kVexSensorNone, 0 }, +/** + * Defines the digital port configuration for the cortex. + */ +constexpr vexDigiCfg dConfig[kVexDigital_Num] = { + { kVexDigital_1, kVexSensorQuadEncoder, kVexConfigQuadEnc1, kVexQuadEncoder_1 }, + { kVexDigital_2, kVexSensorQuadEncoder, kVexConfigQuadEnc2, kVexQuadEncoder_1 }, + digiDefault(kVexDigital_3), + digiDefault(kVexDigital_4), + digiDefault(kVexDigital_5), + digiDefault(kVexDigital_6), + digiDefault(kVexDigital_7), + digiDefault(kVexDigital_8), + digiDefault(kVexDigital_9), + digiDefault(kVexDigital_10), + digiDefault(kVexDigital_11), + digiDefault(kVexDigital_12), }; #endif // CONFIG_H_ |