Skip to content

Commit

Permalink
running instead of runOnceing
Browse files Browse the repository at this point in the history
  • Loading branch information
elwo-boop committed Mar 6, 2025
1 parent 1769ead commit de4e51a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/main/kotlin/frc/team449/ControllerBindings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ class ControllerBindings(

private fun score_l4() {
driveController.y().onTrue(
robot.superstructureManager.requestGoal(SuperstructureGoal.L4)
robot.superstructureManager.requestGoal(SuperstructureGoal.L4).andThen(
robot.light.rainbow()
)
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/frc/team449/RobotLoop.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class RobotLoop : TimedRobot() {
robot.wrist.startupZero()
}

robot.light.defaultCommand = robot.light.progressMask({ robot.elevator.positionSupplier.get() })
// robot.light.defaultCommand = robot.light.progressMask({ robot.elevator.positionSupplier.get() })
}

override fun driverStationConnected() {
Expand Down
13 changes: 8 additions & 5 deletions src/main/kotlin/frc/team449/subsystems/light/Light.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ class Light(
}

fun rainbow(): Command {
return this.runOnce {
return this.run {
val rainbow: LEDPattern = LEDPattern.rainbow(255, 128)
val scrollingRainbow = rainbow.scrollAtAbsoluteSpeed(MetersPerSecond.of(1.0), ledSpacing)
val scrollingRainbow = rainbow.scrollAtAbsoluteSpeed(
MetersPerSecond.of(LightConstants.LED_TRANSLATION_SPEED),
ledSpacing
)

scrollingRainbow.applyTo(lightBuffer)

Expand All @@ -45,7 +48,7 @@ class Light(
}

fun solidColor(color: Color): Command {
return this.runOnce {
return this.run {
val colorSolid: LEDPattern = LEDPattern.solid(color)

colorSolid.applyTo(lightBuffer)
Expand All @@ -55,7 +58,7 @@ class Light(
}

fun gradient(continuous: Boolean = true, speedMetersPerSecond: Double, vararg colors: Color): Command {
return this.runOnce {
return this.run {
// continuous is optimal for scrolling, discontinuous for static
val continuousness: GradientType = if (continuous) GradientType.kContinuous else GradientType.kDiscontinuous
val gradient: LEDPattern = LEDPattern.gradient(continuousness, *colors)
Expand All @@ -68,7 +71,7 @@ class Light(
}

fun progressMask(maskValue: DoubleSupplier): Command {
return this.runOnce {
return this.run {
val base: LEDPattern = LEDPattern.gradient(GradientType.kDiscontinuous, Color.kRed, Color.kGreen)
val maskAmount: LEDPattern = LEDPattern.progressMaskLayer(maskValue)
val heightDisplay: LEDPattern = base.mask(maskAmount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ object LightConstants {
// number of LEDs per meter (for WPILib calc)
// todo(buscalo este numero)
const val LED_PER_METER: Int = 120
const val LED_TRANSLATION_SPEED: Double = 0.5 // m/s
}

0 comments on commit de4e51a

Please sign in to comment.