generated from Patribots4738/Swerve-Command-Based
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pico power cycling system + QoL changes (#296)
- Loading branch information
Showing
7 changed files
with
66 additions
and
10 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package frc.robot.util.custom; | ||
|
||
import edu.wpi.first.wpilibj.AnalogOutput; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.Commands; | ||
|
||
public class TransistorPower extends AnalogOutput { | ||
public TransistorPower(int port) { | ||
super(port); | ||
} | ||
|
||
public TransistorPower(int port, boolean state) { | ||
super(port); | ||
set(state); | ||
} | ||
|
||
public void setState(boolean state) { | ||
setVoltage(state ? 5 : 0); | ||
} | ||
|
||
public void set(boolean state) { | ||
setState(state); | ||
} | ||
|
||
public boolean get() { | ||
return getVoltage() > 0.5; | ||
} | ||
|
||
public Command getPowerCycleCommand() { | ||
return Commands.runOnce(() -> set(false)) | ||
.andThen(Commands.waitSeconds(1), | ||
Commands.runOnce(() -> set(true))).ignoringDisable(true); | ||
} | ||
|
||
public void schedulePowerCycleCommand() { | ||
getPowerCycleCommand().schedule(); | ||
} | ||
} |