Make the 'On' button cycle between lights
This commit is contained in:
parent
6e6a600e3c
commit
451d8b09f1
2 changed files with 11 additions and 3 deletions
|
|
@ -124,7 +124,10 @@ type NightLightTests() =
|
||||||
(fun state interaction ->
|
(fun state interaction ->
|
||||||
match state, interaction with
|
match state, interaction with
|
||||||
| _, RemotePressedOffButton -> BothOff
|
| _, RemotePressedOffButton -> BothOff
|
||||||
| _, RemotePressedOnButton -> BothOn
|
| BothOff, RemotePressedOnButton -> BothOn
|
||||||
|
| BothOn, RemotePressedOnButton -> LeftOn
|
||||||
|
| LeftOn, RemotePressedOnButton -> RightOn
|
||||||
|
| RightOn, RemotePressedOnButton -> BothOn
|
||||||
| _, RemotePressedLeftButton -> LeftOn)
|
| _, RemotePressedLeftButton -> LeftOn)
|
||||||
BothOn
|
BothOn
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,8 +95,13 @@ type NightLightStateMachine private (maybeState: NightLightState option) =
|
||||||
| PressedOn ->
|
| PressedOn ->
|
||||||
currentState
|
currentState
|
||||||
|> withAlarmOff
|
|> withAlarmOff
|
||||||
|> withStateFor RightBedroomLamp On
|
|> match
|
||||||
|> withStateFor LeftBedroomLamp On
|
currentState.LightToManualState[LeftBedroomLamp],
|
||||||
|
currentState.LightToManualState[RightBedroomLamp]
|
||||||
|
with
|
||||||
|
| Off, _ -> withStateFor LeftBedroomLamp On >> withStateFor RightBedroomLamp On
|
||||||
|
| On, On -> withStateFor LeftBedroomLamp On >> withStateFor RightBedroomLamp Off
|
||||||
|
| On, Off -> withStateFor LeftBedroomLamp Off >> withStateFor RightBedroomLamp On
|
||||||
| PressedOff ->
|
| PressedOff ->
|
||||||
currentState
|
currentState
|
||||||
|> withAlarmOff
|
|> withAlarmOff
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue