Piston
Constructors
Piston()
Creates a new Piston object.
input_port
ADI port the solenoid is plugged into.
default_state
sets the default state of the piston.
- Prototype
- Example
ez::Piston left_wing('A');
Piston(int input_port, bool default_state = false);
Piston()
Creates a new Piston object where the solenoid is plugged into a 3 wire expander.
input_port
ADI port the solenoid is plugged into.
default_state
sets the default state of the piston.
- Prototype
- Example
ez::Piston left_wing('A', 1);
Piston(int input_port, int expander_smart_port, bool default_state = false);
Setters
set()
Sets the piston to fire.
input
boolean to fire the piston.
- Prototype
- Example
ez::Piston left_wing('A');
void autonomous() {
left_wing.set(true);
}
void set(bool input);
button_toggle()
Toggles the piston back and forward with a single button during opcontrol.
toggle
an input button.
- Prototype
- Example
ez::Piston left_wing('A');
void opcontrol() {
while (true) {
left_wing.button_toggle(master.get_digital(DIGITAL_X));
pros::delay(10);
}
}
void button_toggle(int toggle);
buttons()
Sets the piston to go in and out with 2 buttons during opcontrol.
active
the button to activate the piston.
deactive
the button to retract the piston.
- Prototype
- Example
ez::Piston left_wing('A');
void opcontrol() {
while (true) {
left_wing.buttons(master.get_digital(DIGITAL_L1), master.get_digital(DIGITAL_L2));
pros::delay(10);
}
}
void buttons(int active, int deactive);
Getter
get()
Gets the state of the piston.
- Prototype
- Example
ez::Piston left_wing('A');
void autonomous() {
left_wing.set(!left_wing.get());
}
bool get();