Skip to content

Commit

Permalink
feat(pl18): RGBLED LUA Scripts (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardclli authored Nov 27, 2023
1 parent 803c318 commit 98902e7
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 0 deletions.
16 changes: 16 additions & 0 deletions sdcard/c480x320/SCRIPTS/RGBLED/blue.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local function init()
end

local function run()
for i=0, LED_STRIP_LENGTH - 1, 1
do
setRGBLedColor(i, 0, 0, 50)
end
applyRGBLedColors()
end

local function background()
-- Called periodically while the Special Function switch is off
end

return { run=run, background=background, init=init }
16 changes: 16 additions & 0 deletions sdcard/c480x320/SCRIPTS/RGBLED/green.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local function init()
end

local function run()
for i=0, LED_STRIP_LENGTH - 1, 1
do
setRGBLedColor(i, 0, 50, 0)
end
applyRGBLedColors()
end

local function background()
-- Called periodically while the Special Function switch is off
end

return { run=run, background=background, init=init }
16 changes: 16 additions & 0 deletions sdcard/c480x320/SCRIPTS/RGBLED/off.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local function init()
end

local function run()
for i=0, LED_STRIP_LENGTH - 1, 1
do
setRGBLedColor(i, 0, 0, 0)
end
applyRGBLedColors()
end

local function background()
-- Called periodically while the Special Function switch is off
end

return { run=run, background=background, init=init }
26 changes: 26 additions & 0 deletions sdcard/c480x320/SCRIPTS/RGBLED/police.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
local function init()
police_oldtime = getTime()
police_cycle = 0
end

local function run()
for i=0, LED_STRIP_LENGTH - 1, 1
do
if (i % 2 == police_cycle) then
setRGBLedColor(i, 0, 0, 50)
else
setRGBLedColor(i, 50, 0, 0)
end
end
if ((getTime() - police_oldtime) > 8) then
police_oldtime = getTime()
police_cycle = 1 - police_cycle
end
applyRGBLedColors()
end

local function background()
-- Called periodically while the Special Function switch is off
end

return { run=run, background=background, init=init }
16 changes: 16 additions & 0 deletions sdcard/c480x320/SCRIPTS/RGBLED/red.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local function init()
end

local function run()
for i=0, LED_STRIP_LENGTH - 1, 1
do
setRGBLedColor(i, 50, 0, 0)
end
applyRGBLedColors()
end

local function background()
-- Called periodically while the Special Function switch is off
end

return { run=run, background=background, init=init }
29 changes: 29 additions & 0 deletions sdcard/c480x320/SCRIPTS/RGBLED/scl.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
local function init()
scroll_oldtime = getTime()
scroll_cycle = LED_STRIP_LENGTH - 1
end

local function run()
for i=0, LED_STRIP_LENGTH - 1, 1
do
if (i == scroll_cycle) then
setRGBLedColor(i, 0, 50, 0)
else
setRGBLedColor(i, 0, 0, 50)
end
end
if ((getTime() - scroll_oldtime) > 8) then
scroll_oldtime = getTime()
scroll_cycle = scroll_cycle - 1
if (scroll_cycle < 0) then
scroll_cycle = LED_STRIP_LENGTH - 1
end
end
applyRGBLedColors()
end

local function background()
-- Called periodically while the Special Function switch is off
end

return { run=run, background=background, init=init }
29 changes: 29 additions & 0 deletions sdcard/c480x320/SCRIPTS/RGBLED/scr.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
local function init()
scroll_oldtime = getTime()
scroll_cycle = 0
end

local function run()
for i=0, LED_STRIP_LENGTH - 1, 1
do
if (i == scroll_cycle) then
setRGBLedColor(i, 0, 50, 0)
else
setRGBLedColor(i, 0, 0, 50)
end
end
if ((getTime() - scroll_oldtime) > 8) then
scroll_oldtime = getTime()
scroll_cycle = scroll_cycle + 1
if (scroll_cycle >= LED_STRIP_LENGTH) then
scroll_cycle = 0
end
end
applyRGBLedColors()
end

local function background()
-- Called periodically while the Special Function switch is off
end

return { run=run, background=background, init=init }

0 comments on commit 98902e7

Please sign in to comment.