2
0
mirror of https://github.com/team2059/Dent synced 2024-12-28 21:02:30 -05:00
dent/Subsystems/Elevator.cpp

45 lines
1.2 KiB
C++
Raw Normal View History

2015-01-16 19:29:55 -05:00
#include "Elevator.h"
#include "../RobotMap.h"
2015-07-31 12:52:15 -04:00
Elevator::Elevator() {
2015-03-23 10:52:02 -04:00
motor = new CANTalon(ELEVATOR_CAN);
elevatorEncoder = new Encoder(ELEVATOR_ENCODERA, ELEVATOR_ENCODERB, false);
elevatorBottom = new DigitalInput(ELEVATOR_BOTTOM_DIO);
elevatorMiddle = new DigitalInput(ELEVATOR_MIDDLE_DIO);
elevatorTop = new DigitalInput(ELEVATOR_TOP_DIO);
// Checks if the elevator is drifting
2015-03-23 10:52:02 -04:00
useEncoder = false;
2015-01-16 19:29:55 -05:00
}
2015-07-31 12:52:15 -04:00
void Elevator::InitDefaultCommand() {
2015-01-16 19:29:55 -05:00
}
2015-07-31 12:52:15 -04:00
void Elevator::Run(double power) {
// If we're not telling it to stop
2015-07-31 12:52:15 -04:00
if(power != 0.0) {
SetUseEncoder(false);
}
2015-02-02 18:53:02 -05:00
motor->Set(power);
2015-01-16 20:46:58 -05:00
}
2015-07-31 12:52:15 -04:00
void Elevator::ResetEncoder() {
elevatorEncoder->Reset();
}
2015-07-31 12:52:15 -04:00
double Elevator::GetHeight() {
return elevatorEncoder->Get();
}
2015-07-31 12:52:15 -04:00
bool Elevator::GetElevatorBottom() {
SmartDashboard::PutBoolean("Elevator Bottom", !elevatorBottom->Get());
return elevatorBottom->Get();
}
2015-07-31 12:52:15 -04:00
bool Elevator::GetElevatorMiddle() {
2015-02-15 07:53:19 -05:00
return elevatorMiddle->Get();
}
2015-07-31 12:52:15 -04:00
bool Elevator::GetElevatorTop() {
SmartDashboard::PutBoolean("Elevator Top", !elevatorTop->Get());
return elevatorTop->Get();
}
2015-07-31 12:52:15 -04:00
void Elevator::SetUseEncoder(bool use) {
2015-03-23 10:52:02 -04:00
useEncoder = use;
}
2015-07-31 12:52:15 -04:00
bool Elevator::GetUseEncoder() {
return useEncoder;
}
2015-02-08 12:26:15 -05:00
// vim: ts=2:sw=2:et