Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Commit

Permalink
Fix #159, #163, #151, #116, #43 (duplicates)
Browse files Browse the repository at this point in the history
  • Loading branch information
ixjf committed Aug 23, 2021
1 parent 30cb97c commit 7dec096
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 22 deletions.
9 changes: 5 additions & 4 deletions Scripts/Heartbeat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ local colours = {
--
local n = 1

Lighting.SetBreathingModeEnabled(false)
Lighting.SetFlashingSpeed(0)
Lighting.SetStepDuration(511)

while true do
Lighting.BatchBegin()
Lighting.SetBreathingModeEnabled(false)
Lighting.SetFlashingSpeed(0)
Lighting.SetStepDuration(511)

for i = 1, 8 do
Lighting.SetColour(i, colours[n][1], colours[n][2], colours[n][3])
end

Lighting.BatchEnd()
n = (n % #colours) + 1
os.sleep(speed)
Expand Down
8 changes: 4 additions & 4 deletions Scripts/Hue Wheel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ local delay = 80 -- delay between each colour update, in milliseconds
local colour_step = 98 -- ]0, 360], the higher, the smaller the step between colours

--
Lighting.SetStepDuration(511)
Lighting.SetFlashingSpeed(0)
Lighting.SetBreathingModeEnabled(false)

local i = 0
while true do
Lighting.SetStepDuration(511)
Lighting.SetFlashingSpeed(0)
Lighting.SetBreathingModeEnabled(false)

local r, g, b = Lighting.ColourUtils.HSVtoRGB((i % colour_step) / colour_step, saturation, value)

r = tonumber(("%x"):format(r * 15), 16)
Expand Down
8 changes: 5 additions & 3 deletions Scripts/Police Lights.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ local alt_flash_colour = {["r"] = 0xf, ["g"] = 0xf, ["b"] = 0x2}
--
local flash = require('utils.custom_flash')

Lighting.SetFlashingSpeed(0)
Lighting.SetBreathingModeEnabled(false)

local alt_color = true

local function change_colour()
Expand All @@ -32,6 +29,11 @@ local function change_colour()
end

while true do
Lighting.BatchBegin()
Lighting.SetFlashingSpeed(0)
Lighting.SetBreathingModeEnabled(false)
Lighting.BatchEnd()

change_colour()
flash(flashes_per_second, pulse_time)
os.sleep(pulse_delay)
Expand Down
14 changes: 10 additions & 4 deletions Scripts/Pumpkin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
local pumpkin_colour = {["r"] = 0xf, ["g"] = 0x2, ["b"] = 0x0}

--
Lighting.SetFlashingSpeed(0)
Lighting.SetBreathingModeEnabled(true)
local Timer = require('base.timer')

for i = 1, 8 do
Lighting.SetColour(i, pumpkin_colour.r, pumpkin_colour.g, pumpkin_colour.b)
function effect()
Lighting.SetFlashingSpeed(0)
Lighting.SetBreathingModeEnabled(true)

for i = 1, 8 do
Lighting.SetColour(i, pumpkin_colour.r, pumpkin_colour.g, pumpkin_colour.b)
end
end

Timer.Set(effect, Timer.DefaultInterval)
16 changes: 9 additions & 7 deletions Scripts/Strobe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ local flash_colour = {["r"] = 0x2, ["g"] = 0x7, ["b"] = 0xf}
--
local flash = require('utils.custom_flash')

Lighting.SetFlashingSpeed(0)
Lighting.SetBreathingModeEnabled(false)

for i = 1, 8 do
Lighting.SetColour(i, flash_colour.r, flash_colour.g, flash_colour.b)
end

while true do
Lighting.BatchBegin()
Lighting.SetFlashingSpeed(0)
Lighting.SetBreathingModeEnabled(false)

for i = 1, 8 do
Lighting.SetColour(i, flash_colour.r, flash_colour.g, flash_colour.b)
end
Lighting.BatchEnd()

flash(flashes_per_second, pulse_time)
os.sleep(pulse_delay)
end
14 changes: 14 additions & 0 deletions Scripts/base/timer.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
local Timer = {}

Timer.DefaultInterval = 3000 -- 3 seconds

function Timer.Set(f, ms) -- f should not be a long running function, but either way, ms is time (in milliseconds)
-- between complete executions of f (so if f takes ~ ms or > ms, f will be called again after ms have ellapsed since the last
-- return from f)
while true do
f()
os.sleep(ms)
end
end

return Timer

0 comments on commit 7dec096

Please sign in to comment.