2015-01-16 19:29:55 -05:00
|
|
|
#include "Elevator.h"
|
|
|
|
#include "../RobotMap.h"
|
2015-02-07 13:08:24 -05:00
|
|
|
Elevator::Elevator(){
|
2015-02-02 19:56:27 -05:00
|
|
|
motor=new CANTalon(ELEVATOR_CAN);
|
2015-02-11 19:22:59 -05:00
|
|
|
elevatorEncoder=new Encoder(ELEVATOR_ENCODERA,ELEVATOR_ENCODERB,false);
|
2015-02-07 13:03:00 -05:00
|
|
|
elevatorBottom=new DigitalInput(ELEVATOR_BOTTOM_DIO);
|
2015-02-15 07:53:19 -05:00
|
|
|
elevatorMiddle=new DigitalInput(ELEVATOR_MIDDLE_DIO);
|
2015-02-07 13:03:00 -05:00
|
|
|
elevatorTop=new DigitalInput(ELEVATOR_TOP_DIO);
|
2015-02-12 21:18:48 -05:00
|
|
|
// Checks if the elevator is drifting
|
|
|
|
useEncoder=false;
|
2015-02-15 07:53:19 -05:00
|
|
|
stoppedAtSensor=false;
|
2015-01-16 19:29:55 -05:00
|
|
|
}
|
2015-01-17 12:21:16 -05:00
|
|
|
void Elevator::InitDefaultCommand(){
|
2015-01-16 19:29:55 -05:00
|
|
|
}
|
2015-01-16 20:46:58 -05:00
|
|
|
void Elevator::Run(double power){
|
2015-02-12 21:18:48 -05:00
|
|
|
// If we're not telling it to stop
|
|
|
|
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-02-01 14:48:01 -05:00
|
|
|
void Elevator::ResetEncoder(){
|
|
|
|
elevatorEncoder->Reset();
|
2015-01-31 12:16:02 -05:00
|
|
|
}
|
|
|
|
double Elevator::GetHeight(){
|
2015-02-11 19:22:59 -05:00
|
|
|
return elevatorEncoder->Get();
|
2015-01-31 12:16:02 -05:00
|
|
|
}
|
2015-02-07 13:03:00 -05: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-02-15 07:53:19 -05:00
|
|
|
bool Elevator::GetElevatorMiddle(){
|
|
|
|
return elevatorMiddle->Get();
|
|
|
|
}
|
2015-02-07 13:03:00 -05: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-02-12 21:18:48 -05:00
|
|
|
void Elevator::SetUseEncoder(bool param){
|
|
|
|
useEncoder=param;
|
|
|
|
}
|
|
|
|
bool Elevator::GetUseEncoder(){
|
|
|
|
return useEncoder;
|
|
|
|
}
|
2015-02-08 12:26:15 -05:00
|
|
|
// vim: ts=2:sw=2:et
|