diff --git a/Lights/OccupancyBasedSimple.ic10 b/Lights/OccupancyBasedSimple.ic10 new file mode 100644 index 0000000..8b2ad8b --- /dev/null +++ b/Lights/OccupancyBasedSimple.ic10 @@ -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 \ No newline at end of file diff --git a/Lights/OccupancyBasedWithDay.ic10 b/Lights/OccupancyBasedWithDay.ic10 new file mode 100644 index 0000000..9bdcbec --- /dev/null +++ b/Lights/OccupancyBasedWithDay.ic10 @@ -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 \ No newline at end of file diff --git a/Lights/OccupancyOld.ic10 b/Lights/OccupancyOld.ic10 new file mode 100644 index 0000000..9f98320 --- /dev/null +++ b/Lights/OccupancyOld.ic10 @@ -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 \ No newline at end of file diff --git a/Plants/GrowLightSimple.ic10 b/Plants/GrowLightSimple.ic10 new file mode 100644 index 0000000..d70c67d --- /dev/null +++ b/Plants/GrowLightSimple.ic10 @@ -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