From b671632f7872893f9a13cba66d05286faf6336c1 Mon Sep 17 00:00:00 2001 From: CodingMaster121 Date: Tue, 9 Jan 2024 19:25:48 -0500 Subject: [PATCH 1/3] Added LEDIO File --- .../config/constants/LedConstants.kt | 7 ++++++ .../robot2023/subsystems/led/LedIO.kt | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/main/kotlin/com/team4099/robot2023/config/constants/LedConstants.kt create mode 100644 src/main/kotlin/com/team4099/robot2023/subsystems/led/LedIO.kt 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..114d4eb5 --- /dev/null +++ b/src/main/kotlin/com/team4099/robot2023/config/constants/LedConstants.kt @@ -0,0 +1,7 @@ +package com.team4099.robot2023.config.constants + +object LedConstants { + enum class LEDMode { + IDLE + } +} \ 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 From 9fae23ab3756a500136fe8d1718cb145add2e554 Mon Sep 17 00:00:00 2001 From: CodingMaster121 Date: Tue, 9 Jan 2024 19:51:52 -0500 Subject: [PATCH 2/3] Added Led.kt File --- .../team4099/robot2023/subsystems/led/Led.kt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/kotlin/com/team4099/robot2023/subsystems/led/Led.kt 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 From c055019595a32ab88a6e969b9b72ac3b12e41c6e Mon Sep 17 00:00:00 2001 From: CodingMaster121 Date: Wed, 10 Jan 2024 20:44:41 -0500 Subject: [PATCH 3/3] Added LED states --- .../robot2023/config/constants/LedConstants.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/team4099/robot2023/config/constants/LedConstants.kt b/src/main/kotlin/com/team4099/robot2023/config/constants/LedConstants.kt index 114d4eb5..f5af5363 100644 --- a/src/main/kotlin/com/team4099/robot2023/config/constants/LedConstants.kt +++ b/src/main/kotlin/com/team4099/robot2023/config/constants/LedConstants.kt @@ -1,7 +1,17 @@ package com.team4099.robot2023.config.constants object LedConstants { + // TODO: Review states and change them if needed enum class LEDMode { - IDLE + IDLE, + AUTO, + INTAKE, + OUTTAKE, + TELEOP, + NOTE, + SOURCE, + MOVEMENT, + SCORE_SPEAKER, + SCORE_AMP } } \ No newline at end of file