mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 13:46:44 -04:00
Implement PLC integration for all outputs.
This commit is contained in:
37
plc/plc.go
37
plc/plc.go
@@ -224,6 +224,11 @@ func (plc *Plc) GetPowerPorts() ([3]int, [3]int) {
|
||||
}
|
||||
}
|
||||
|
||||
// Returns whether each of the red and blue power ports are jammed.
|
||||
func (plc *Plc) GetPowerPortJams() (bool, bool) {
|
||||
return plc.inputs[redPowerPortJam], plc.inputs[bluePowerPortJam]
|
||||
}
|
||||
|
||||
// Returns the current color and number of segment transitions for each of the red and blue control panels.
|
||||
func (plc *Plc) GetControlPanels() (game.ControlPanelColor, int, game.ControlPanelColor, int) {
|
||||
return game.ControlPanelColor(plc.registers[redControlPanelColor]), int(plc.registers[redControlPanelSegments]),
|
||||
@@ -235,7 +240,7 @@ func (plc *Plc) GetRungs() (bool, bool) {
|
||||
return plc.inputs[redRungIsLevel], plc.inputs[blueRungIsLevel]
|
||||
}
|
||||
|
||||
// Set the on/off state of the stack lights on the scoring table.
|
||||
// Sets the on/off state of the stack lights on the scoring table.
|
||||
func (plc *Plc) SetStackLights(red, blue, orange, green bool) {
|
||||
plc.coils[stackLightRed] = red
|
||||
plc.coils[stackLightBlue] = blue
|
||||
@@ -243,15 +248,43 @@ func (plc *Plc) SetStackLights(red, blue, orange, green bool) {
|
||||
plc.coils[stackLightGreen] = green
|
||||
}
|
||||
|
||||
// Set the on/off state of the stack lights on the scoring table.
|
||||
// Triggers the "match ready" chime if the state is true.
|
||||
func (plc *Plc) SetStackBuzzer(state bool) {
|
||||
plc.coils[stackLightBuzzer] = state
|
||||
}
|
||||
|
||||
// Sets the on/off state of the field reset light.
|
||||
func (plc *Plc) SetFieldResetLight(state bool) {
|
||||
plc.coils[fieldResetLight] = state
|
||||
}
|
||||
|
||||
// Sets the on/off state of the agitator motors within each power port.
|
||||
func (plc *Plc) SetPowerPortMotors(state bool) {
|
||||
plc.coils[powerPortMotors] = state
|
||||
}
|
||||
|
||||
// Sets the on/off state of the lights mounted within the shield generator trussing.
|
||||
func (plc *Plc) SetStageActivatedLights(red, blue [3]bool) {
|
||||
plc.coils[redStage1Light] = red[0]
|
||||
plc.coils[redStage2Light] = red[1]
|
||||
plc.coils[redStage3Light] = red[2]
|
||||
plc.coils[blueStage1Light] = blue[0]
|
||||
plc.coils[blueStage2Light] = blue[1]
|
||||
plc.coils[blueStage3Light] = blue[2]
|
||||
}
|
||||
|
||||
// Sets the on/off state of the red and blue alliance stack lights mounted to the control panel.
|
||||
func (plc *Plc) SetControlPanelLights(red, blue bool) {
|
||||
plc.coils[redControlPanelLight] = red
|
||||
plc.coils[blueControlPanelLight] = blue
|
||||
}
|
||||
|
||||
// Sets the on/off state of the red and blue alliance stack lights mounted to the top of the shield generator.
|
||||
func (plc *Plc) SetShieldGeneratorLights(red, blue bool) {
|
||||
plc.coils[redTrussLight] = red
|
||||
plc.coils[blueTrussLight] = blue
|
||||
}
|
||||
|
||||
func (plc *Plc) GetCycleState(max, index, duration int) bool {
|
||||
return plc.cycleCounter/duration%max == index
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user