generated from Galaxia5987/robot-template-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simpler led functions #27
Open
vichik123
wants to merge
27
commits into
district-3
Choose a base branch
from
Simpler-LED-functions
base: district-3
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
4adcae5
Add a command that makes the leds blink when there is game piece in t…
GaiaZano05 8f72575
make new proximitySensor command a default command
GaiaZano05 7b33dac
Rename beam breaker to proximity sensor
GaiaZano05 d2be532
Change default blink time to half a second
GaiaZano05 020667a
Use blink function
GaiaZano05 6453501
change the blink time to a quarter of a second
GaiaZano05 6ae2ad7
Change default blink time to 0 + change secondary color to blue
GaiaZano05 db83ca1
Change time to 0.2 seconds
GaiaZano05 7322277
Add SetColor function
Emma03L c6fb175
Add LED constants
Emma03L 3ac964e
Add take cone command for LED function
Emma03L 422a28c
reset swerve encoders
GaiaZano05 bfa624c
Refactor
GaiaZano05 2e09f15
Try to add Led function to take cone
GaiaZano05 189ee67
Add a blink command
GaiaZano05 c98723d
Use constnats
GaiaZano05 c4e6f34
Change POV buttons' use because Ofri asked
GaiaZano05 6d8bc32
Add blink command when in feeder position
GaiaZano05 1f193d7
Fix rainbow LEDs
GaiaZano05 1cbdb39
Add rainbow button
GaiaZano05 4ab4d36
Remove gripper from add requirements
GaiaZano05 4361b14
Make one default command for blinking when holding a cone or when cub…
GaiaZano05 2aa2d81
Button for toggling the rainbow led-mode
GaiaZano05 c8ec18c
Remove blink command
GaiaZano05 903aac4
Update wpiLib!!!!!!!!!!!!!!!!!!!!!!!!!!
GaiaZano05 e1c65ab
Add lower limit to proximity sensor on arm
GaiaZano05 951953c
Remove unnecessary line
GaiaZano05 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package frc.robot.commandgroups; | ||
|
||
import edu.wpi.first.wpilibj2.command.ConditionalCommand; | ||
import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; | ||
import frc.robot.subsystems.arm.ArmConstants; | ||
import frc.robot.subsystems.gripper.Gripper; | ||
import frc.robot.subsystems.leds.LedConstants; | ||
import frc.robot.subsystems.leds.Leds; | ||
|
||
public class FeederBlink extends SequentialCommandGroup { | ||
|
||
public FeederBlink(){ | ||
Gripper gripper = Gripper.getInstance(); | ||
Leds leds = Leds.getInstance(); | ||
addRequirements(leds); | ||
addCommands( | ||
new ConditionalCommand( | ||
new InstantCommand(() ->leds.setBlink(true, LedConstants.kGalaxiaBlue, LedConstants.FAST_BLINK_TIME)), | ||
new InstantCommand(() -> leds.setBlink(false)), | ||
() -> gripper.getDistance() < ArmConstants.FEEDER_DISTANCE && gripper.isOpen() | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/frc/robot/subsystems/intake/commands/ProximitySensorDefualtCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package frc.robot.subsystems.intake.commands; | ||
|
||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
import frc.robot.subsystems.arm.ArmConstants; | ||
import frc.robot.subsystems.gripper.Gripper; | ||
import frc.robot.subsystems.intake.ProximitySensor; | ||
import frc.robot.subsystems.leds.LedConstants; | ||
import frc.robot.subsystems.leds.Leds; | ||
|
||
|
||
public class ProximitySensorDefualtCommand extends CommandBase { | ||
private final ProximitySensor proximitySensor = ProximitySensor.getInstance(); | ||
private final Leds leds = Leds.getInstance(); | ||
private final Gripper gripper = Gripper.getInstance(); | ||
|
||
private boolean ProximitySensorState = proximitySensor.isBeamBlocked(); | ||
|
||
public ProximitySensorDefualtCommand() { | ||
this.ProximitySensorState = proximitySensor.isBeamBlocked(); | ||
addRequirements(proximitySensor, leds); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
if (proximitySensor.isBeamBlocked() || (gripper.getDistance() < ArmConstants.FEEDER_DISTANCE && gripper.isOpen() && gripper.getDistance() > ArmConstants.FEEDER_MINIMUM_DISTANCE)) | ||
leds.setBlink(true, LedConstants.kGalaxiaBlue, LedConstants.FAST_BLINK_TIME); | ||
else leds.setBlink(false); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
package frc.robot.subsystems.leds; | ||
|
||
import edu.wpi.first.wpilibj.util.Color; | ||
|
||
public final class LedConstants { | ||
public static final int LED_LENGTH = 19; | ||
|
||
public static final Color kGalaxiaBlue = new Color(0, 156, 189); | ||
public static final Color kPurple = Color.kPurple; | ||
public static final Color kRed = Color.kRed; | ||
public static final Color kGreen = Color.kGreen; | ||
|
||
public static final double SLOW_BLINK_TIME = 0.3; | ||
public static final double MID_BLINK_TIME = 0.25; | ||
public static final double FAST_BLINK_TIME = 0.2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
.../frc/robot/subsystems/leds/PurpleLed.java → ...ot/subsystems/leds/command/PurpleLed.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take this with a grain of salt since it's been forever since ive worked in FRC,
but shouldn't if rainbow be checked before the Primary and Secondary colors?
In this scenario for 1 frame you will have a flickering of the leds.
Suggestion: (i forgot how to actually write it in the code:
above
if(blink)
(line 96 or after in line 105)if(isRainbow) {mode = Mode.ELSE}
then you just have a simple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rainbow LEDs work great so I guess if it ain't broke don't fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good rule to follow many times, but not always. The offseason is the best time to improve software and learn, now's the time to make such changes and improvements to the code.