mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 13:46:44 -04:00
Add initial LED implementation for an E1.31 DMX over Ethernet controller.
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/Team254/cheesy-arena/field"
|
||||
"github.com/Team254/cheesy-arena/model"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Shows the field configuration page.
|
||||
@@ -25,12 +26,12 @@ func (web *Web) fieldGetHandler(w http.ResponseWriter, r *http.Request) {
|
||||
data := struct {
|
||||
*model.EventSettings
|
||||
AllianceStationDisplays map[string]string
|
||||
FieldTestMode string
|
||||
Inputs []bool
|
||||
Counters []uint16
|
||||
Coils []bool
|
||||
}{web.arena.EventSettings, web.arena.AllianceStationDisplays, web.arena.FieldTestMode, web.arena.Plc.Inputs[:],
|
||||
web.arena.Plc.Registers[:], web.arena.Plc.Coils[:]}
|
||||
LedMode int
|
||||
}{web.arena.EventSettings, web.arena.AllianceStationDisplays, web.arena.Plc.Inputs[:],
|
||||
web.arena.Plc.Registers[:], web.arena.Plc.Coils[:], web.arena.RedSwitchLedStrip.Mode}
|
||||
err = template.ExecuteTemplate(w, "base", data)
|
||||
if err != nil {
|
||||
handleWebErr(w, err)
|
||||
@@ -72,53 +73,8 @@ func (web *Web) fieldTestPostHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// TODO(patrick): Update for 2018.
|
||||
mode := r.PostFormValue("mode")
|
||||
/*
|
||||
switch mode {
|
||||
case "boiler":
|
||||
web.arena.Plc.SetBoilerMotors(true)
|
||||
web.arena.Plc.SetRotorMotors(0, 0)
|
||||
web.arena.Plc.SetRotorLights(0, 0)
|
||||
web.arena.Plc.SetTouchpadLights([3]bool{false, false, false}, [3]bool{false, false, false})
|
||||
case "rotor1":
|
||||
web.arena.Plc.SetBoilerMotors(false)
|
||||
web.arena.Plc.SetRotorMotors(1, 1)
|
||||
web.arena.Plc.SetRotorLights(1, 1)
|
||||
web.arena.Plc.SetTouchpadLights([3]bool{true, false, false}, [3]bool{true, false, false})
|
||||
case "rotor2":
|
||||
web.arena.Plc.SetBoilerMotors(false)
|
||||
web.arena.Plc.SetRotorMotors(2, 2)
|
||||
web.arena.Plc.SetRotorLights(2, 2)
|
||||
web.arena.Plc.SetTouchpadLights([3]bool{false, true, false}, [3]bool{false, true, false})
|
||||
case "rotor3":
|
||||
web.arena.Plc.SetBoilerMotors(false)
|
||||
web.arena.Plc.SetRotorMotors(3, 3)
|
||||
web.arena.Plc.SetRotorLights(2, 2)
|
||||
web.arena.Plc.SetTouchpadLights([3]bool{false, false, true}, [3]bool{false, false, true})
|
||||
case "rotor4":
|
||||
web.arena.Plc.SetBoilerMotors(false)
|
||||
web.arena.Plc.SetRotorMotors(4, 4)
|
||||
web.arena.Plc.SetRotorLights(2, 2)
|
||||
web.arena.Plc.SetTouchpadLights([3]bool{false, false, false}, [3]bool{false, false, false})
|
||||
case "red":
|
||||
web.arena.Plc.SetBoilerMotors(false)
|
||||
web.arena.Plc.SetRotorMotors(4, 0)
|
||||
web.arena.Plc.SetRotorLights(2, 0)
|
||||
web.arena.Plc.SetTouchpadLights([3]bool{true, true, true}, [3]bool{false, false, false})
|
||||
case "blue":
|
||||
web.arena.Plc.SetBoilerMotors(false)
|
||||
web.arena.Plc.SetRotorMotors(0, 4)
|
||||
web.arena.Plc.SetRotorLights(0, 2)
|
||||
web.arena.Plc.SetTouchpadLights([3]bool{false, false, false}, [3]bool{true, true, true})
|
||||
default:
|
||||
web.arena.Plc.SetBoilerMotors(false)
|
||||
web.arena.Plc.SetRotorMotors(0, 0)
|
||||
web.arena.Plc.SetRotorLights(0, 0)
|
||||
web.arena.Plc.SetTouchpadLights([3]bool{false, false, false}, [3]bool{false, false, false})
|
||||
}
|
||||
*/
|
||||
mode, _ := strconv.Atoi(r.PostFormValue("mode"))
|
||||
web.arena.RedSwitchLedStrip.SetMode(mode)
|
||||
|
||||
web.arena.FieldTestMode = mode
|
||||
http.Redirect(w, r, "/setup/field", 303)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestSetupField(t *testing.T) {
|
||||
assert.Contains(t, recorder.Body.String(), "12345")
|
||||
assert.Contains(t, recorder.Body.String(), "selected")
|
||||
|
||||
recorder = web.postHttpResponse("/setup/field/test", "mode=rotor2")
|
||||
recorder = web.postHttpResponse("/setup/field/test", "mode=1")
|
||||
assert.Equal(t, 303, recorder.Code)
|
||||
assert.Equal(t, "rotor2", web.arena.FieldTestMode)
|
||||
assert.Equal(t, 1, web.arena.RedSwitchLedStrip.Mode)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user