Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/Commands/DriveShifter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <Commands/DriveShifter.h>
#include "Subsystems/OI.h"
#include "Robot.h"
#include "Subsystems/Drive.h"
#include <Commands/Subsystem.h>


DriveShifter::DriveShifter() :
CommandBase("DriveShifter"){
Requires(robot->drive);
}

void DriveShifter::Initialize(){
CommandBase::Initialize();
robot->drive->SetLowGear();
}

bool DriveShifter::IsFinished(){
return false;
}

void DriveShifter::Interrupted(){
CommandBase::Interrupted();
robot->drive->SetHighGear();
}

void DriveShifter::Execute(){

}
22 changes: 22 additions & 0 deletions src/Commands/DriveShifter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* DriveShifter.h
*
* Created on: Dec 28, 2015
* Author: John C
*/

#ifndef SRC_SUBSYSTEMS_DRIVESHIFTER_H_
#define SRC_SUBSYSTEMS_DRIVESHIFTER_H_

#include <CommandBase.h>

class DriveShifter: public CommandBase {
public:
DriveShifter();
void Initialize() override;
bool IsFinished() override;
void Interrupted() override;
void Execute() override;
};

#endif /* SRC_SUBSYSTEMS_DRIVESHIFTER_H_ */
3 changes: 3 additions & 0 deletions src/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "Commands/DriveTank.h"
#include "Commands/DriveLowGear.h"
#include "Commands/DriveHighGear.h"
#include "Commands/DriveShifter.h"

Robot::Robot() {
// define robot pointer
Expand All @@ -30,9 +31,11 @@ void Robot::RobotInit() {
driveCommand = new DriveTank;
driveLowGear = new DriveLowGear;
driveHighGear = new DriveHighGear;
driveShifter = new DriveShifter;

oi->GetDriverButton(5)->WhenPressed(driveHighGear);
oi->GetDriverButton(7)->WhenPressed(driveLowGear);
oi->GetDriverButton(8)->WhileHeld(driveShifter);
}

// disabled init implementation
Expand Down
2 changes: 1 addition & 1 deletion src/Robot.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Robot: public IterativeRobot {

Drive* drive;
OI* oi;
Command *driveCommand, *driveLowGear, *driveHighGear;
Command *driveCommand, *driveLowGear, *driveHighGear, *driveShifter;

void RobotInit() override;

Expand Down
5 changes: 2 additions & 3 deletions src/Subsystems/OI.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include <Joystick.h>
#include <Buttons/JoystickButton.h>
#include "OI.h"
#include <Buttons/JoystickButton.h>
#include "Commands/DriveShifter.h"
OI::OI() :
Subsystem("OI") {
driverJoystick = new Joystick(0);

}
OI::~OI() {
delete driverJoystick;

}

float OI::GetLeftAxis() {
Expand All @@ -17,7 +17,6 @@ float OI::GetLeftAxis() {
}
float OI::GetRightAxis() {
return driverJoystick->GetRawAxis(3);

}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove these unnecessary changes


float OI::GetRightTurn() {
Expand Down
1 change: 0 additions & 1 deletion src/Subsystems/OI.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class OI: public Subsystem {
JoystickButton* GetDriverButton(uint32_t number);
private:
Joystick* driverJoystick;

};

#endif /* SRC_SUBSYSTEMS_OI_H_ */