62 lines
1.5 KiB
Plaintext
62 lines
1.5 KiB
Plaintext
# ===== Config =====
|
|
define EnableDayCheck 0
|
|
|
|
# ===== Aliases =====
|
|
alias IsOccupied r0
|
|
alias IsDay r1
|
|
alias wantLights r2
|
|
|
|
# ===== Hashes (sensors) =====
|
|
define HashOcc HASH("StructureOccupancySensor")
|
|
define HashDay HASH("StructureDaylightSensor")
|
|
|
|
# ===== Hashes (lights) from Kit (Lights) page =====
|
|
define HashLightWallRegular -1860064656
|
|
define HashLightWallLong 797794350
|
|
define HashLightWallLongWide 555215790
|
|
define HashLightWallLongAngled 1847265835
|
|
define HashLightWallBattery -1306415132
|
|
define HashLightRound 1514476632
|
|
define HashLightRoundAngled 1592905386
|
|
define HashLightRoundSmall 1436121888
|
|
|
|
|
|
Start:
|
|
move IsOccupied 0
|
|
move IsDay 0
|
|
|
|
LoadVariables:
|
|
lb IsOccupied HashOcc Activate Average
|
|
lb IsDay HashDay Activate Average
|
|
|
|
CheckIfOccupied:
|
|
# Guard Clause
|
|
# If not occupied, branch to Start
|
|
beqz IsOccupied Start
|
|
|
|
# Set wantLights if IsOccupied > 0
|
|
sgtz wantLights IsOccupied
|
|
|
|
CheckIfDay:
|
|
# Guard Clause
|
|
# If day check disabled, branch to SetLights
|
|
beqz EnableDayCheck SetLights
|
|
|
|
# If not day, branch to SetLights
|
|
beqz IsDay SetLights
|
|
# If day, clear wantLights
|
|
move wantLights 0
|
|
|
|
SetLights:
|
|
# Batch write On to each light type
|
|
sb HashLightWallRegular On wantLights
|
|
sb HashLightWallLong On wantLights
|
|
sb HashLightWallLongWide On wantLights
|
|
sb HashLightWallLongAngled On wantLights
|
|
sb HashLightWallBattery On wantLights
|
|
sb HashLightRound On wantLights
|
|
sb HashLightRoundAngled On wantLights
|
|
sb HashLightRoundSmall On wantLights
|
|
|
|
yield
|
|
j Start |