Merge branch 'kyleexperimentalbranch' of https://git.karx.xyz/karx/FtcRobotController

This commit is contained in:
RiftBladeMc 2022-02-11 21:13:27 -06:00
commit ca483abd5a

View file

@ -4,6 +4,8 @@ public abstract class Gamepad extends OpModeWithMovement {
protected double speed = 0.7;
protected boolean slowMode = false;
protected boolean prevX = false;
protected double lastTime = 0;
protected double speedIncreasePerS = 0.5;
@Override
public void init() {
@ -21,11 +23,13 @@ public abstract class Gamepad extends OpModeWithMovement {
@Override
public void start() {
api.clear();
lastTime = getRuntime();
}
@Override
public void loop() {
double ms = getRuntime() / 1000;
double thisTime = getRuntime();
double diffTime = thisTime-lastTime;
double currentSpeed = gamepad1.y ? 1 : slowMode ? 0.35 : speed;
movement.move(-gamepad1.left_stick_y, gamepad1.left_stick_x, gamepad1.right_stick_x, currentSpeed, true);
@ -34,15 +38,13 @@ public abstract class Gamepad extends OpModeWithMovement {
api.print("Slow mode", slowMode ? "true" : "false");
if (gamepad1.x && !prevX) slowMode = !slowMode;
if (gamepad1.right_bumper) speed = Math.min(speed + 0.01, 1);
else if (gamepad1.left_bumper) speed = Math.max(speed - 0.01, 0.2);
if (gamepad1.right_bumper) speed = Math.min(speed + diffTime*speedIncreasePerS, 1);
else if (gamepad1.left_bumper) speed = Math.max(speed - diffTime*speed, 0.2);
motors.intake.controlWithTwoButtons(gamepad2.a, gamepad2.b);
motors.lift.controlWithTwoButtons(gamepad2.dpad_up, gamepad2.dpad_down, 0.25);
motors.carousel.controlWithTwoButtons(gamepad2.x, gamepad2.y, 0.9);
prevX = gamepad1.x;
while (getRuntime() / 1000 - ms < 15) ; // no empty while loop here!
}
}