diff --git a/src/main/kotlin/com/team4099/robot2023/config/constants/LedConstants.kt b/src/main/kotlin/com/team4099/robot2023/config/constants/LedConstants.kt new file mode 100644 index 00000000..f5af5363 --- /dev/null +++ b/src/main/kotlin/com/team4099/robot2023/config/constants/LedConstants.kt @@ -0,0 +1,17 @@ +package com.team4099.robot2023.config.constants + +object LedConstants { + // TODO: Review states and change them if needed + enum class LEDMode { + IDLE, + AUTO, + INTAKE, + OUTTAKE, + TELEOP, + NOTE, + SOURCE, + MOVEMENT, + SCORE_SPEAKER, + SCORE_AMP + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/team4099/robot2023/subsystems/led/Led.kt b/src/main/kotlin/com/team4099/robot2023/subsystems/led/Led.kt new file mode 100644 index 00000000..91a4f1bd --- /dev/null +++ b/src/main/kotlin/com/team4099/robot2023/subsystems/led/Led.kt @@ -0,0 +1,23 @@ +package com.team4099.robot2023.subsystems.led + +import com.team4099.robot2023.config.constants.LedConstants +import org.littletonrobotics.junction.Logger + +class Led(val io: LedIO) { + var inputs = LedIO.LedIOInputs() + var state = LedConstants.LEDMode.IDLE + set(value) { + io.setState(value) + field = value + } + + init { + state = state + } + + fun periodic() { + io.updateInputs(inputs) + Logger.processInputs("LED", inputs) + Logger.recordOutput("LED/state", state.name) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/team4099/robot2023/subsystems/led/LedIO.kt b/src/main/kotlin/com/team4099/robot2023/subsystems/led/LedIO.kt new file mode 100644 index 00000000..1252802d --- /dev/null +++ b/src/main/kotlin/com/team4099/robot2023/subsystems/led/LedIO.kt @@ -0,0 +1,23 @@ +package com.team4099.robot2023.subsystems.led + +import com.team4099.robot2023.config.constants.LedConstants +import org.littletonrobotics.junction.LogTable +import org.littletonrobotics.junction.inputs.LoggableInputs + +interface LedIO { + class LedIOInputs: LoggableInputs { + var ledState = LedConstants.LEDMode.IDLE.name + + override fun toLog(table: LogTable?) { + table?.put("ledState", ledState) + } + + override fun fromLog(table: LogTable?) { + table?.getString("ledState", ledState)?.let { ledState = it } + } + } + + fun setState(newState: LedConstants.LEDMode) {} + + fun updateInputs(inputs: LedIOInputs) {} +} \ No newline at end of file