-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathShifter.cpp
47 lines (39 loc) · 986 Bytes
/
Shifter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "Shifter.h"
#include "612.h"
#include "main.h"
Shifter::Shifter(main_robot* r, uint8_t mod,uint32_t chanF,uint32_t chanR)
{
robot = r;
shifter=new DoubleSolenoid(mod,chanF,chanR);
robot -> driverJoy -> addJoyFunctions(&buttonHelper,(void*)this,SHIFT_LOW);
robot -> driverJoy -> addJoyFunctions(&buttonHelper,(void*)this,SHIFT_HIGH);
}
Shifter::~Shifter()
{
delete shifter;
}
void Shifter::shiftGear()
{
if(gear == low)
setHigh();
else if(gear == high)
setLow();
}
void Shifter::setHigh()
{
gear=high;
robot->pnum->setVectorValues(TIME, shifter, DoubleSolenoid::kReverse);
}
void Shifter::setLow()
{
gear=low;
robot->pnum->setVectorValues(TIME, shifter, DoubleSolenoid::kForward);
}
void Shifter::buttonHelper(void* objPtr, uint32_t button)
{
Shifter* ShifterObj=(Shifter*)objPtr;
if(button == SHIFT_LOW)
ShifterObj->setLow();
else if(button == SHIFT_HIGH)
ShifterObj->setHigh();
}