Skip to content

Commit

Permalink
Added controller function
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanDuPont committed Feb 12, 2022
1 parent 4a1b516 commit b5f5013
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/v5_hal/firmware/src/nodes/LiftNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,17 @@ 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);
} else {
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);
Expand All @@ -71,7 +73,6 @@ void LiftNode::teleopPeriodic() {
m_left_motor->moveVoltage(0);
m_right_motor->moveVoltage(0);
}

};

void LiftNode::autonPeriodic() {
Expand Down
11 changes: 11 additions & 0 deletions src/v5_hal/firmware/src/nodes/TankDriveNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit b5f5013

Please sign in to comment.