leds
This commit is contained in:
parent
3669e079bd
commit
eb141ac2ba
@ -9,18 +9,20 @@ import edu.wpi.first.wpilibj2.command.Commands;
|
||||
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
|
||||
import frc.robot.commands.GrimperHaut;
|
||||
import frc.robot.commands.GrimpeurBas;
|
||||
import frc.robot.subsystems.Bougie;
|
||||
import frc.robot.subsystems.Grimpeur;
|
||||
|
||||
public class RobotContainer {
|
||||
CommandXboxController manette1 = new CommandXboxController(0);
|
||||
CommandXboxController manette2 = new CommandXboxController(1);
|
||||
Grimpeur grimpeur = new Grimpeur();
|
||||
Bougie bougie = new Bougie();
|
||||
public RobotContainer() {
|
||||
configureBindings();
|
||||
}
|
||||
|
||||
private void configureBindings() {
|
||||
manette1.leftBumper().whileTrue(new GrimperHaut(grimpeur));
|
||||
manette1.leftBumper().whileTrue(new GrimperHaut(grimpeur,bougie));
|
||||
manette1.rightBumper().whileTrue(new GrimpeurBas(grimpeur));
|
||||
}
|
||||
|
||||
|
@ -5,15 +5,18 @@
|
||||
package frc.robot.commands;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import frc.robot.subsystems.Bougie;
|
||||
import frc.robot.subsystems.Grimpeur;
|
||||
|
||||
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
|
||||
public class GrimperHaut extends Command {
|
||||
private Grimpeur grimpeur;
|
||||
private Bougie bougie;
|
||||
/** Creates a new Grimper. */
|
||||
public GrimperHaut(Grimpeur grimpeur) {
|
||||
public GrimperHaut(Grimpeur grimpeur, Bougie bougie) {
|
||||
this.grimpeur = grimpeur;
|
||||
addRequirements(grimpeur);
|
||||
this.bougie = bougie;
|
||||
addRequirements(grimpeur,bougie);
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
}
|
||||
|
||||
@ -27,9 +30,11 @@ public class GrimperHaut extends Command {
|
||||
if(grimpeur.stop()==true){
|
||||
grimpeur.grimpe(0);
|
||||
grimpeur.reset();
|
||||
bougie.RainBow();
|
||||
}
|
||||
else{
|
||||
grimpeur.grimpe(0.5);
|
||||
bougie.RainBowStop();
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,6 +42,10 @@ public class GrimperHaut extends Command {
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
grimpeur.grimpe(0);
|
||||
if(grimpeur.stop()){
|
||||
bougie.RainBow();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
|
41
src/main/java/frc/robot/commands/RainBow.java
Normal file
41
src/main/java/frc/robot/commands/RainBow.java
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package frc.robot.commands;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import frc.robot.subsystems.Bougie;
|
||||
|
||||
/* You should consider using the more terse Command factories API instead https://docs.wpilib.org/en/stable/docs/software/commandbased/organizing-command-based.html#defining-commands */
|
||||
public class RainBow extends Command {
|
||||
/** Creates a new RainBow. */
|
||||
private Bougie bougie;
|
||||
public RainBow(Bougie bougie) {
|
||||
this.bougie = bougie;
|
||||
addRequirements(bougie);
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@Override
|
||||
public void initialize() {}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
bougie.RainBow();
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {
|
||||
bougie.RainBowStop();
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
}
|
38
src/main/java/frc/robot/subsystems/Bougie.java
Normal file
38
src/main/java/frc/robot/subsystems/Bougie.java
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
package frc.robot.subsystems;
|
||||
|
||||
import com.ctre.phoenix.led.CANdle;
|
||||
import com.ctre.phoenix.led.CANdleConfiguration;
|
||||
import com.ctre.phoenix.led.RainbowAnimation;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
|
||||
public class Bougie extends SubsystemBase {
|
||||
CANdle candle = new CANdle(5);
|
||||
CANdleConfiguration config = new CANdleConfiguration();
|
||||
RainbowAnimation rainbowAnim = new RainbowAnimation(1, 0.5, 64);
|
||||
/** Creates a new Bougie. */
|
||||
public Bougie() {
|
||||
config.brightnessScalar = 0.5;
|
||||
candle.configAllSettings(config);
|
||||
}
|
||||
public void Rouge() {
|
||||
candle.setLEDs(255, 0, 0);
|
||||
}
|
||||
public void Vert() {
|
||||
candle.setLEDs(0, 255, 0);
|
||||
}
|
||||
public void Bleu() {
|
||||
candle.setLEDs(0, 0, 255);
|
||||
}
|
||||
public void RainBow(){candle.animate(rainbowAnim);}
|
||||
public void RainBowStop(){candle.animate(null);}
|
||||
@Override
|
||||
public void periodic() {
|
||||
// This method will be called once per scheduler run
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user