init commit
This commit is contained in:
51
Lights/OccupancyBasedSimple.ic10
Normal file
51
Lights/OccupancyBasedSimple.ic10
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# ===== Config =====
|
||||||
|
# seconds to hold lights on after activate
|
||||||
|
define HoldOnTime 10
|
||||||
|
|
||||||
|
# ===== Aliases =====
|
||||||
|
alias IsOccupied r0
|
||||||
|
alias ProximityDetected r1
|
||||||
|
alias wantLights r2
|
||||||
|
|
||||||
|
# ===== Hashes (sensors) =====
|
||||||
|
define HashOcc HASH("StructureOccupancySensor")
|
||||||
|
define HashProx HASH("StructureProximitySensor")
|
||||||
|
|
||||||
|
|
||||||
|
# ===== 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:
|
||||||
|
LoadVariables:
|
||||||
|
lb IsOccupied HashOcc Activate Average
|
||||||
|
lb ProximityDetected HashProx Activate Sum
|
||||||
|
|
||||||
|
# Set wantLights if IsOccupied > 0
|
||||||
|
sgtz wantLights IsOccupied
|
||||||
|
add wantLights wantLights ProximityDetected
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
beqz wantLights End
|
||||||
|
sleep HoldOnTime
|
||||||
|
|
||||||
|
End:
|
||||||
|
yield
|
||||||
|
j Start
|
||||||
62
Lights/OccupancyBasedWithDay.ic10
Normal file
62
Lights/OccupancyBasedWithDay.ic10
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
# ===== 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
|
||||||
53
Lights/OccupancyOld.ic10
Normal file
53
Lights/OccupancyOld.ic10
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# ===== Config =====
|
||||||
|
# 1 = require darkness too, 0 = ignore day/night
|
||||||
|
define EnableDayCheck 0
|
||||||
|
# any avg > this turns lights on
|
||||||
|
define MotionOnThresh 0.5
|
||||||
|
|
||||||
|
# ===== 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
|
||||||
|
|
||||||
|
# r0 = occAvg,r1 = dayAvg,r2 = wantLights,r3 = tmp
|
||||||
|
|
||||||
|
Start:
|
||||||
|
# Average all Occupancy sensors' Activate
|
||||||
|
lb r0 HashOcc Activate Average
|
||||||
|
|
||||||
|
move r1 0
|
||||||
|
beq EnableDayCheck 0 SkipDay
|
||||||
|
# Average all Daylight sensors' Activate
|
||||||
|
lb r1 HashDay Activate Average
|
||||||
|
SkipDay:
|
||||||
|
|
||||||
|
# wantLights = (occAvg > threshold)
|
||||||
|
sgt r2 r0 MotionOnThresh
|
||||||
|
|
||||||
|
# If day-check is enabled: require darkness too
|
||||||
|
beq EnableDayCheck 0 Decide
|
||||||
|
seqz r3 r1
|
||||||
|
and r2 r2 r3
|
||||||
|
Decide:
|
||||||
|
|
||||||
|
# Batch write On to each light type
|
||||||
|
sb HashLightWallRegular On r2
|
||||||
|
sb HashLightWallLong On r2
|
||||||
|
sb HashLightWallLongWide On r2
|
||||||
|
sb HashLightWallLongAngled On r2
|
||||||
|
sb HashLightWallBattery On r2
|
||||||
|
sb HashLightRound On r2
|
||||||
|
sb HashLightRoundAngled On r2
|
||||||
|
sb HashLightRoundSmall On r2
|
||||||
|
|
||||||
|
yield
|
||||||
|
j Start
|
||||||
24
Plants/GrowLightSimple.ic10
Normal file
24
Plants/GrowLightSimple.ic10
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# ===== Config =====
|
||||||
|
define OnDuration 10 # minutes to stay on
|
||||||
|
define OffDuration 5 # minutes to stay off
|
||||||
|
|
||||||
|
# ===== Aliases =====
|
||||||
|
# none
|
||||||
|
|
||||||
|
# ===== Hashes =====
|
||||||
|
define GrowLights HASH("StructureGrowLight")
|
||||||
|
|
||||||
|
|
||||||
|
start:
|
||||||
|
|
||||||
|
TurnLightsOn:
|
||||||
|
sb GrowLights On 1
|
||||||
|
mul r1 60 OnDuration
|
||||||
|
sleep r1
|
||||||
|
|
||||||
|
TurnLightsOff:
|
||||||
|
sb GrowLights On 0
|
||||||
|
mul r1 60 OffDuration
|
||||||
|
sleep r1
|
||||||
|
|
||||||
|
j start
|
||||||
Reference in New Issue
Block a user