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
8 changes: 4 additions & 4 deletions Prototypes/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2023.4.1"
id "edu.wpi.first.GradleRIO" version "2023.4.2"
}

sourceCompatibility = JavaVersion.VERSION_11
Expand Down Expand Up @@ -110,6 +110,6 @@ repositories {
}

// AdvantageKit docs say to include this but it breaks the build.
//configurations.all {
// exclude group: "edu.wpi.first.wpilibj"
//}
configurations.all {
exclude group: "edu.wpi.first.wpilibj"
}
5 changes: 3 additions & 2 deletions Prototypes/src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@

package frc.robot;

import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import org.littletonrobotics.junction.LoggedRobot;
import org.littletonrobotics.junction.Logger;

/**
* The VM is configured to automatically run this class, and to call the functions corresponding to
* each mode, as described in the TimedRobot documentation. If you change the name of this class or
* the package after creating this project, you must also update the build.gradle file in the
* project.
*/
public class Robot extends TimedRobot {
public class Robot extends LoggedRobot {
private Command m_autonomousCommand;

private RobotContainer m_robotContainer;
Expand Down
43 changes: 24 additions & 19 deletions Prototypes/src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
// 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;

import frc.robot.Constants.OperatorConstants;
import frc.robot.commands.Autos;
import frc.robot.commands.ExampleCommand;
import frc.robot.subsystems.ExampleSubsystem;
import frc.robot.subsystems.LedSubsystem;
import edu.wpi.first.wpilibj.util.Color;
import edu.wpi.first.wpilibj.util.Color8Bit;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import edu.wpi.first.wpilibj2.command.button.Trigger;

/**
* This class is where the bulk of the robot should be declared.
*/
public class RobotContainer {

// The robot's subsystems and commands are defined here...
private final ExampleSubsystem m_exampleSubsystem = new ExampleSubsystem();
private final LedSubsystem ledSubsystem = new LedSubsystem(0, 1, 2);

private final CommandXboxController m_driverController = new CommandXboxController(
private final CommandXboxController driveController = new CommandXboxController(
OperatorConstants.DRIVE_CONTROLLER_PORT);

private final Color8Bit red = new Color8Bit(255, 0, 0);
private final Color8Bit green = new Color8Bit(0, 255, 0);
private final Color8Bit blue = new Color8Bit(0, 0, 255);
private final Color8Bit yellow = new Color8Bit(255, 255, 0);
private final Color8Bit cubeColor = new Color8Bit(170, 0, 255);
private final Color8Bit coneColor = new Color8Bit(255, 234, 0);
private final Color8Bit darkRed = new Color8Bit(128,0,0);

/**
* The container for the robot. Contains subsystems, OI devices, and commands.
*/
Expand All @@ -37,21 +41,22 @@ public void createSubsystems() {
}

public void createCommands() {

}

/**
* Use this method to define your trigger->command mappings.
*/
private void configureBindings() {
// Schedule `ExampleCommand` when `exampleCondition` changes to `true`
new Trigger(m_exampleSubsystem::exampleCondition)
.onTrue(new ExampleCommand(m_exampleSubsystem));

// Schedule `exampleMethodCommand` when the Xbox controller's B button is
// pressed,
// cancelling on release.
m_driverController.b().whileTrue(m_exampleSubsystem.exampleMethodCommand());
driveController.b().onTrue(new InstantCommand(() -> ledSubsystem.setColor(red)));
driveController.a().onTrue(new InstantCommand(() -> ledSubsystem.setColor(green)));
driveController.x().onTrue(new InstantCommand(() -> ledSubsystem.setColor(blue)));
driveController.y().onTrue(new InstantCommand(() -> ledSubsystem.setColor(yellow)));
driveController.rightBumper().onTrue(new InstantCommand(() -> ledSubsystem.setColor(cubeColor)));
driveController.leftBumper().onTrue(new InstantCommand(() -> ledSubsystem.setColor(coneColor)));

driveController.povLeft().onTrue(new InstantCommand(() -> ledSubsystem.setColor(darkRed)));
driveController.povRight().onTrue(new InstantCommand(() -> ledSubsystem.setColor(red)));
}

/**
Expand All @@ -61,6 +66,6 @@ private void configureBindings() {
*/
public Command getAutonomousCommand() {
// An example command will be run in autonomous
return Autos.exampleAuto(m_exampleSubsystem);
return null;
}
}
20 changes: 0 additions & 20 deletions Prototypes/src/main/java/frc/robot/commands/Autos.java

This file was deleted.

43 changes: 0 additions & 43 deletions Prototypes/src/main/java/frc/robot/commands/ExampleCommand.java

This file was deleted.

This file was deleted.

35 changes: 35 additions & 0 deletions Prototypes/src/main/java/frc/robot/subsystems/LedSubsystem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package frc.robot.subsystems;

import edu.wpi.first.wpilibj.DigitalOutput;
import edu.wpi.first.wpilibj.util.Color8Bit;
import edu.wpi.first.wpilibj2.command.SubsystemBase;


public class LedSubsystem extends SubsystemBase {

private final double pwmRateHz = 100.0;

private DigitalOutput red;
private DigitalOutput green;
private DigitalOutput blue;

public LedSubsystem(int redChannel, int greenChannel, int blueChannel) {

red = new DigitalOutput(redChannel);
red.setPWMRate(pwmRateHz);
red.enablePWM(0);

green = new DigitalOutput(greenChannel);
green.enablePWM(0);

blue = new DigitalOutput(blueChannel);
blue.enablePWM(0);
}

public void setColor(Color8Bit color) {

red.updateDutyCycle((double)color.red / 255.0);
green.updateDutyCycle((double)color.green / 255.0);
blue.updateDutyCycle((double)color.blue / 255.0);
}
}