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

Added LEDIO File #11

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -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
}
}
23 changes: 23 additions & 0 deletions src/main/kotlin/com/team4099/robot2023/subsystems/led/Led.kt
Original file line number Diff line number Diff line change
@@ -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)
}
}
23 changes: 23 additions & 0 deletions src/main/kotlin/com/team4099/robot2023/subsystems/led/LedIO.kt
Original file line number Diff line number Diff line change
@@ -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) {}
}
Loading