From b5f5013ddd8df84d45956e4c671a05dcf2819909 Mon Sep 17 00:00:00 2001 From: NathanDuPont Date: Sat, 12 Feb 2022 02:19:31 -0600 Subject: [PATCH] Added controller function --- src/v5_hal/firmware/src/nodes/LiftNode.cpp | 7 ++++--- src/v5_hal/firmware/src/nodes/TankDriveNode.cpp | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/v5_hal/firmware/src/nodes/LiftNode.cpp b/src/v5_hal/firmware/src/nodes/LiftNode.cpp index 444beda..5a23ef8 100644 --- a/src/v5_hal/firmware/src/nodes/LiftNode.cpp +++ b/src/v5_hal/firmware/src/nodes/LiftNode.cpp @@ -51,7 +51,8 @@ int LiftNode::getPosition() { } void LiftNode::teleopPeriodic() { - if(pros::E_CONTROLLER_DIGITAL_R1 && !pros::E_CONTROLLER_DIGITAL_R2) { + if (m_controller->getController()->get_digital(pros::E_CONTROLLER_DIGITAL_R1) && + !m_controller->getController()->get_digital(pros::E_CONTROLLER_DIGITAL_R2)) { if(m_top_limit_switch->getValue()) { m_left_motor->moveVoltage(0); m_right_motor->moveVoltage(0); @@ -59,7 +60,8 @@ void LiftNode::teleopPeriodic() { m_left_motor->moveVoltage(MAX_MOTOR_VOLTAGE); m_right_motor->moveVoltage(-1 * MAX_MOTOR_VOLTAGE); } - } else if(pros::E_CONTROLLER_DIGITAL_R1 && !pros::E_CONTROLLER_DIGITAL_R2) { + } else if (m_controller->getController()->get_digital(pros::E_CONTROLLER_DIGITAL_R1) && + !m_controller->getController()->get_digital(pros::E_CONTROLLER_DIGITAL_R2)) { if (m_bottom_limit_switch) { m_left_motor->moveVoltage(0); m_right_motor->moveVoltage(0); @@ -71,7 +73,6 @@ void LiftNode::teleopPeriodic() { m_left_motor->moveVoltage(0); m_right_motor->moveVoltage(0); } - }; void LiftNode::autonPeriodic() { diff --git a/src/v5_hal/firmware/src/nodes/TankDriveNode.cpp b/src/v5_hal/firmware/src/nodes/TankDriveNode.cpp index 8634d49..5c5b31b 100644 --- a/src/v5_hal/firmware/src/nodes/TankDriveNode.cpp +++ b/src/v5_hal/firmware/src/nodes/TankDriveNode.cpp @@ -62,6 +62,17 @@ void TankDriveNode::resetEncoders() { m_motors.right_4_motor->resetEncoder(); } +TankDriveNode::FourMotorDriveEncoderVals TankDriveNode::getIntegratedEncoderVals() { + FourMotorDriveEncoderVals encoder_vals = { + m_motors.left_1_motor->getPosition(), + m_motors.left_2_motor->getPosition(), + m_motors.left_3_motor->getPosition(), + m_motors.left_4_motor->getPosition() + }; + + return encoder_vals; +} + void TankDriveNode::initialize() { resetEncoders(); }