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);
|
2015-02-12 21:18:48 -05:00
|
|
|
// 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) {
|
2015-02-12 21:18:48 -05:00
|
|
|
// If we're not telling it to stop
|
2015-07-31 12:52:15 -04:00
|
|
|
if(power != 0.0) {
|
2015-02-12 21:18:48 -05:00
|
|
|
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() {
|
2015-02-01 14:48:01 -05:00
|
|
|
elevatorEncoder->Reset();
|
2015-01-31 12:16:02 -05:00
|
|
|
}
|
2015-07-31 12:52:15 -04:00
|
|
|
double Elevator::GetHeight() {
|
2015-02-11 19:22:59 -05:00
|
|
|
return elevatorEncoder->Get();
|
2015-01-31 12:16:02 -05:00
|
|
|
}
|
2015-07-31 12:52:15 -04:00
|
|
|
bool Elevator::GetElevatorBottom() {
|
2015-02-27 09:51:02 -05:00
|
|
|
SmartDashboard::PutBoolean("Elevator Bottom", !elevatorBottom->Get());
|
2015-02-07 13:03:00 -05:00
|
|
|
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() {
|
2015-02-27 09:51:02 -05:00
|
|
|
SmartDashboard::PutBoolean("Elevator Top", !elevatorTop->Get());
|
2015-02-07 13:03:00 -05:00
|
|
|
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-02-12 21:18:48 -05:00
|
|
|
}
|
2015-07-31 12:52:15 -04:00
|
|
|
bool Elevator::GetUseEncoder() {
|
2015-02-12 21:18:48 -05:00
|
|
|
return useEncoder;
|
|
|
|
}
|
2015-02-08 12:26:15 -05:00
|
|
|
// vim: ts=2:sw=2:et
|