Skip to content
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

Create MarkerCommands #8

Merged
merged 6 commits into from
Jan 13, 2025
Merged
Changes from 1 commit
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
18 changes: 18 additions & 0 deletions src/main/kotlin/frc/robot/lib/MarkerCommands.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package frc.robot.lib

import edu.wpi.first.wpilibj.Alert
import edu.wpi.first.wpilibj.DataLogManager
import edu.wpi.first.wpilibj2.command.Command
import edu.wpi.first.wpilibj2.command.Commands

const val ABNORMAL_EVENT_NAME = "PROBLEM!"
rakrakon marked this conversation as resolved.
Show resolved Hide resolved
val alert = Alert(ABNORMAL_EVENT_NAME, Alert.AlertType.kWarning)

fun markEvent(eventName: String): Command = Commands.runOnce({
katzuv marked this conversation as resolved.
Show resolved Hide resolved
DataLogManager.log(eventName)
alert.set(true)
}).withTimeout(5.0).andThen(Commands.runOnce({
katzuv marked this conversation as resolved.
Show resolved Hide resolved
alert.set(false)
katzuv marked this conversation as resolved.
Show resolved Hide resolved
}))

fun markAbnormalEvent(): Command = markEvent(ABNORMAL_EVENT_NAME)