Initial Commit
This commit is contained in:
commit
933eee69e4
216 changed files with 20588 additions and 0 deletions
68
SCRIPTS/RGBLED/Bback.lua
Executable file
68
SCRIPTS/RGBLED/Bback.lua
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
local function init()
|
||||
colorChangeTime = getTime() -- Initialize time
|
||||
phase = 0
|
||||
currentLed = 0 -- Current lit LED position
|
||||
scroll_oldtime = getTime() -- Initialize scroll_oldtime
|
||||
scroll_cycle = 0 -- Initialize scroll_cycle
|
||||
end
|
||||
|
||||
-- Function to generate smooth cyclic colors
|
||||
local function getColor(phase, length)
|
||||
local position = (phase % length) / length
|
||||
local r, g, b = 0, 0, 0
|
||||
local maxBrightness = 255 -- Maximum brightness value
|
||||
|
||||
-- RGB color transition: red -> green -> blue -> red
|
||||
if position < 1/3 then
|
||||
-- From red to green
|
||||
r = maxBrightness * (1 - 3 * position)
|
||||
g = maxBrightness * (3 * position)
|
||||
elseif position < 2/3 then
|
||||
-- From green to blue
|
||||
position = position - 1/3
|
||||
g = maxBrightness * (1 - 3 * position)
|
||||
b = maxBrightness * (3 * position)
|
||||
else
|
||||
-- From blue to red
|
||||
position = position - 2/3
|
||||
b = maxBrightness * (1 - 3 * position)
|
||||
r = maxBrightness * (3 * position)
|
||||
end
|
||||
|
||||
-- Skip colors that are close to the background color
|
||||
local bg_r, bg_g, bg_b = 0, 0, 72 -- Background color
|
||||
local threshold = 30 -- Color difference threshold
|
||||
if math.abs(r - bg_r) < threshold and math.abs(g - bg_g) < threshold and math.abs(b - bg_b) < threshold then
|
||||
return getColor((phase + 1) % length, length) -- Skip this color and get the next one
|
||||
end
|
||||
|
||||
return r, g, b
|
||||
end
|
||||
|
||||
local colorPhase = 0 -- Initialize color phase
|
||||
|
||||
local function run()
|
||||
for i=LED_STRIP_LENGTH - 1, 0, -1 do -- Reverse iteration
|
||||
if (i == scroll_cycle) then
|
||||
local r, g, b = getColor(colorPhase, 255)
|
||||
setRGBLedColor(i, r, g, b)
|
||||
else
|
||||
setRGBLedColor(i, 0, 0, 72)
|
||||
end
|
||||
end
|
||||
if ((getTime() - scroll_oldtime) > 8) then
|
||||
scroll_oldtime = getTime()
|
||||
scroll_cycle = scroll_cycle - 1 -- Decrement scroll_cycle
|
||||
if (scroll_cycle < 0) then
|
||||
scroll_cycle = LED_STRIP_LENGTH - 1 -- Reset scroll_cycle to the end of the strip
|
||||
end
|
||||
end
|
||||
colorPhase = (colorPhase + 1) % 255 -- Update color phase
|
||||
applyRGBLedColors()
|
||||
end
|
||||
|
||||
local function background()
|
||||
-- Called periodically while the Special Function switch is off
|
||||
end
|
||||
|
||||
return { run=run, background=background, init=init }
|
||||
68
SCRIPTS/RGBLED/Bfwrd.lua
Executable file
68
SCRIPTS/RGBLED/Bfwrd.lua
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
local function init()
|
||||
colorChangeTime = getTime() -- Initialize time
|
||||
phase = 0
|
||||
currentLed = 0 -- Current lit LED position
|
||||
scroll_oldtime = getTime() -- Initialize scroll_oldtime
|
||||
scroll_cycle = 0 -- Initialize scroll_cycle
|
||||
end
|
||||
|
||||
-- Function to generate smooth cyclic colors
|
||||
local function getColor(phase, length)
|
||||
local position = (phase % length) / length
|
||||
local r, g, b = 0, 0, 0
|
||||
local maxBrightness = 255 -- Maximum brightness value
|
||||
|
||||
-- RGB color transition: red -> green -> blue -> red
|
||||
if position < 1/3 then
|
||||
-- From red to green
|
||||
r = maxBrightness * (1 - 3 * position)
|
||||
g = maxBrightness * (3 * position)
|
||||
elseif position < 2/3 then
|
||||
-- From green to blue
|
||||
position = position - 1/3
|
||||
g = maxBrightness * (1 - 3 * position)
|
||||
b = maxBrightness * (3 * position)
|
||||
else
|
||||
-- From blue to red
|
||||
position = position - 2/3
|
||||
b = maxBrightness * (1 - 3 * position)
|
||||
r = maxBrightness * (3 * position)
|
||||
end
|
||||
|
||||
-- Skip colors that are close to the background color
|
||||
local bg_r, bg_g, bg_b = 0, 0, 72 -- Background color
|
||||
local threshold = 30 -- Color difference threshold
|
||||
if math.abs(r - bg_r) < threshold and math.abs(g - bg_g) < threshold and math.abs(b - bg_b) < threshold then
|
||||
return getColor((phase + 1) % length, length) -- Skip this color and get the next one
|
||||
end
|
||||
|
||||
return r, g, b
|
||||
end
|
||||
|
||||
local colorPhase = 0 -- Initialize color phase
|
||||
|
||||
local function run()
|
||||
for i=0, LED_STRIP_LENGTH - 1, 1 do
|
||||
if (i == scroll_cycle) then
|
||||
local r, g, b = getColor(colorPhase, 255)
|
||||
setRGBLedColor(i, r, g, b)
|
||||
else
|
||||
setRGBLedColor(i, 0, 0, 72)
|
||||
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
|
||||
colorPhase = (colorPhase + 1) % 255 -- Update color phase
|
||||
applyRGBLedColors()
|
||||
end
|
||||
|
||||
local function background()
|
||||
-- Called periodically while the Special Function switch is off
|
||||
end
|
||||
|
||||
return { run=run, background=background, init=init }
|
||||
68
SCRIPTS/RGBLED/Pback.lua
Executable file
68
SCRIPTS/RGBLED/Pback.lua
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
local function init()
|
||||
colorChangeTime = getTime() -- Initialize time
|
||||
phase = 0
|
||||
currentLed = 0 -- Current lit LED position
|
||||
scroll_oldtime = getTime() -- Initialize scroll_oldtime
|
||||
scroll_cycle = 0 -- Initialize scroll_cycle
|
||||
end
|
||||
|
||||
-- Function to generate smooth cyclic colors
|
||||
local function getColor(phase, length)
|
||||
local position = (phase % length) / length
|
||||
local r, g, b = 0, 0, 0
|
||||
local maxBrightness = 255 -- Maximum brightness value
|
||||
|
||||
-- RGB color transition: red -> green -> blue -> red
|
||||
if position < 1/3 then
|
||||
-- From red to green
|
||||
r = maxBrightness * (1 - 3 * position)
|
||||
g = maxBrightness * (3 * position)
|
||||
elseif position < 2/3 then
|
||||
-- From green to blue
|
||||
position = position - 1/3
|
||||
g = maxBrightness * (1 - 3 * position)
|
||||
b = maxBrightness * (3 * position)
|
||||
else
|
||||
-- From blue to red
|
||||
position = position - 2/3
|
||||
b = maxBrightness * (1 - 3 * position)
|
||||
r = maxBrightness * (3 * position)
|
||||
end
|
||||
|
||||
-- Skip colors that are close to the background color
|
||||
local bg_r, bg_g, bg_b = 72, 0, 72 -- Background color
|
||||
local threshold = 30 -- Color difference threshold
|
||||
if math.abs(r - bg_r) < threshold and math.abs(g - bg_g) < threshold and math.abs(b - bg_b) < threshold then
|
||||
return getColor((phase + 1) % length, length) -- Skip this color and get the next one
|
||||
end
|
||||
|
||||
return r, g, b
|
||||
end
|
||||
|
||||
local colorPhase = 0 -- Initialize color phase
|
||||
|
||||
local function run()
|
||||
for i=LED_STRIP_LENGTH - 1, 0, -1 do -- Reverse iteration
|
||||
if (i == scroll_cycle) then
|
||||
local r, g, b = getColor(colorPhase, 255)
|
||||
setRGBLedColor(i, r, g, b)
|
||||
else
|
||||
setRGBLedColor(i, 72, 0, 72)
|
||||
end
|
||||
end
|
||||
if ((getTime() - scroll_oldtime) > 8) then
|
||||
scroll_oldtime = getTime()
|
||||
scroll_cycle = scroll_cycle - 1 -- Decrement scroll_cycle
|
||||
if (scroll_cycle < 0) then
|
||||
scroll_cycle = LED_STRIP_LENGTH - 1 -- Reset scroll_cycle to the end of the strip
|
||||
end
|
||||
end
|
||||
colorPhase = (colorPhase + 1) % 255 -- Update color phase
|
||||
applyRGBLedColors()
|
||||
end
|
||||
|
||||
local function background()
|
||||
-- Called periodically while the Special Function switch is off
|
||||
end
|
||||
|
||||
return { run=run, background=background, init=init }
|
||||
BIN
SCRIPTS/RGBLED/Pback.luac
Executable file
BIN
SCRIPTS/RGBLED/Pback.luac
Executable file
Binary file not shown.
68
SCRIPTS/RGBLED/Pfwrd.lua
Executable file
68
SCRIPTS/RGBLED/Pfwrd.lua
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
local function init()
|
||||
colorChangeTime = getTime() -- Initialize time
|
||||
phase = 0
|
||||
currentLed = 0 -- Current lit LED position
|
||||
scroll_oldtime = getTime() -- Initialize scroll_oldtime
|
||||
scroll_cycle = 0 -- Initialize scroll_cycle
|
||||
end
|
||||
|
||||
-- Function to generate smooth cyclic colors
|
||||
local function getColor(phase, length)
|
||||
local position = (phase % length) / length
|
||||
local r, g, b = 0, 0, 0
|
||||
local maxBrightness = 255 -- Maximum brightness value
|
||||
|
||||
-- RGB color transition: red -> green -> blue -> red
|
||||
if position < 1/3 then
|
||||
-- From red to green
|
||||
r = maxBrightness * (1 - 3 * position)
|
||||
g = maxBrightness * (3 * position)
|
||||
elseif position < 2/3 then
|
||||
-- From green to blue
|
||||
position = position - 1/3
|
||||
g = maxBrightness * (1 - 3 * position)
|
||||
b = maxBrightness * (3 * position)
|
||||
else
|
||||
-- From blue to red
|
||||
position = position - 2/3
|
||||
b = maxBrightness * (1 - 3 * position)
|
||||
r = maxBrightness * (3 * position)
|
||||
end
|
||||
|
||||
-- Skip colors that are close to the background color
|
||||
local bg_r, bg_g, bg_b = 72, 0, 72 -- Background color
|
||||
local threshold = 30 -- Color difference threshold
|
||||
if math.abs(r - bg_r) < threshold and math.abs(g - bg_g) < threshold and math.abs(b - bg_b) < threshold then
|
||||
return getColor((phase + 1) % length, length) -- Skip this color and get the next one
|
||||
end
|
||||
|
||||
return r, g, b
|
||||
end
|
||||
|
||||
local colorPhase = 0 -- Initialize color phase
|
||||
|
||||
local function run()
|
||||
for i=0, LED_STRIP_LENGTH - 1, 1 do
|
||||
if (i == scroll_cycle) then
|
||||
local r, g, b = getColor(colorPhase, 255)
|
||||
setRGBLedColor(i, r, g, b)
|
||||
else
|
||||
setRGBLedColor(i, 72, 0, 72)
|
||||
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
|
||||
colorPhase = (colorPhase + 1) % 255 -- Update color phase
|
||||
applyRGBLedColors()
|
||||
end
|
||||
|
||||
local function background()
|
||||
-- Called periodically while the Special Function switch is off
|
||||
end
|
||||
|
||||
return { run=run, background=background, init=init }
|
||||
BIN
SCRIPTS/RGBLED/Pfwrd.luac
Executable file
BIN
SCRIPTS/RGBLED/Pfwrd.luac
Executable file
Binary file not shown.
1
SCRIPTS/RGBLED/README.md
Executable file
1
SCRIPTS/RGBLED/README.md
Executable file
|
|
@ -0,0 +1 @@
|
|||
This folder contains sample RGB Lua scripts, for radios which support this capability.
|
||||
16
SCRIPTS/RGBLED/blue.lua
Executable file
16
SCRIPTS/RGBLED/blue.lua
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
local function init()
|
||||
end
|
||||
|
||||
local function run()
|
||||
for i=0, LED_STRIP_LENGTH - 1, 1
|
||||
do
|
||||
setRGBLedColor(i, 0, 0, 128)
|
||||
end
|
||||
applyRGBLedColors()
|
||||
end
|
||||
|
||||
local function background()
|
||||
-- Called periodically while the Special Function switch is off
|
||||
end
|
||||
|
||||
return { run=run, background=background, init=init }
|
||||
BIN
SCRIPTS/RGBLED/blue.luac
Executable file
BIN
SCRIPTS/RGBLED/blue.luac
Executable file
Binary file not shown.
52
SCRIPTS/RGBLED/flow.lua
Executable file
52
SCRIPTS/RGBLED/flow.lua
Executable file
|
|
@ -0,0 +1,52 @@
|
|||
local function init()
|
||||
colorChangeTime = getTime() -- Initialize time
|
||||
phase = 0
|
||||
end
|
||||
|
||||
local minBrightness = 0 -- Minimum brightness value
|
||||
local maxBrightness = 255 -- Maximum brightness value
|
||||
|
||||
local function getColor(phase, length)
|
||||
local position = (phase % length) / length
|
||||
local r, g, b = minBrightness, minBrightness, minBrightness
|
||||
|
||||
-- RGB color transition: red -> green -> blue -> red
|
||||
if position < 1/3 then
|
||||
-- From red to green
|
||||
r = maxBrightness * (1 - 32 * position)
|
||||
g = maxBrightness * (32 * position)
|
||||
elseif position < 2/3 then
|
||||
-- From green to blue
|
||||
position = position - 1/3
|
||||
g = maxBrightness * (1 - 32 * position)
|
||||
b = maxBrightness * (32 * position)
|
||||
else
|
||||
-- From blue to red
|
||||
position = position - 2/3
|
||||
b = maxBrightness * (1 - 32 * position)
|
||||
r = maxBrightness * (32 * position)
|
||||
end
|
||||
|
||||
return r, g, b
|
||||
end
|
||||
|
||||
local colorChangeTime = 0 -- The time of the last color change
|
||||
|
||||
local function run()
|
||||
if ((getTime() - colorChangeTime) > 1) then -- Use an interval of 2 time units
|
||||
colorChangeTime = getTime()
|
||||
phase = (phase + 1) % 255 -- Update color phase
|
||||
|
||||
for i = 0, LED_STRIP_LENGTH - 1, 1 do
|
||||
local r, g, b = getColor(phase + i * 64, 255) -- Increase phase offset for each LED
|
||||
setRGBLedColor(i, r, g, b)
|
||||
end
|
||||
applyRGBLedColors()
|
||||
end
|
||||
end
|
||||
|
||||
local function background()
|
||||
-- Called periodically while the Special Function switch is off
|
||||
end
|
||||
|
||||
return { run=run, background=background, init=init }
|
||||
16
SCRIPTS/RGBLED/green.lua
Executable file
16
SCRIPTS/RGBLED/green.lua
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
local function init()
|
||||
end
|
||||
|
||||
local function run()
|
||||
for i=0, LED_STRIP_LENGTH - 1, 1
|
||||
do
|
||||
setRGBLedColor(i, 0, 255, 0)
|
||||
end
|
||||
applyRGBLedColors()
|
||||
end
|
||||
|
||||
local function background()
|
||||
-- Called periodically while the Special Function switch is off
|
||||
end
|
||||
|
||||
return { run=run, background=background, init=init }
|
||||
BIN
SCRIPTS/RGBLED/green.luac
Executable file
BIN
SCRIPTS/RGBLED/green.luac
Executable file
Binary file not shown.
16
SCRIPTS/RGBLED/off.lua
Executable file
16
SCRIPTS/RGBLED/off.lua
Executable file
|
|
@ -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 }
|
||||
16
SCRIPTS/RGBLED/orange.lua
Executable file
16
SCRIPTS/RGBLED/orange.lua
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
local function init()
|
||||
end
|
||||
|
||||
local function run()
|
||||
for i=0, LED_STRIP_LENGTH - 1, 1
|
||||
do
|
||||
setRGBLedColor(i, 255, 100, 0) -- Change RGB values to represent orange color
|
||||
end
|
||||
applyRGBLedColors()
|
||||
end
|
||||
|
||||
local function background()
|
||||
-- Called periodically while the Special Function switch is off
|
||||
end
|
||||
|
||||
return { run=run, background=background, init=init }
|
||||
BIN
SCRIPTS/RGBLED/orange.luac
Normal file
BIN
SCRIPTS/RGBLED/orange.luac
Normal file
Binary file not shown.
26
SCRIPTS/RGBLED/police.lua
Executable file
26
SCRIPTS/RGBLED/police.lua
Executable file
|
|
@ -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 }
|
||||
BIN
SCRIPTS/RGBLED/police.luac
Executable file
BIN
SCRIPTS/RGBLED/police.luac
Executable file
Binary file not shown.
16
SCRIPTS/RGBLED/purple.lua
Executable file
16
SCRIPTS/RGBLED/purple.lua
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
local function init()
|
||||
end
|
||||
|
||||
local function run()
|
||||
for i=0, LED_STRIP_LENGTH - 1, 1
|
||||
do
|
||||
setRGBLedColor(i, 255, 0, 255) -- Set to purple color
|
||||
end
|
||||
applyRGBLedColors()
|
||||
end
|
||||
|
||||
local function background()
|
||||
-- Called periodically while the Special Function switch is off
|
||||
end
|
||||
|
||||
return { run=run, background=background, init=init }
|
||||
52
SCRIPTS/RGBLED/rainbw.lua
Executable file
52
SCRIPTS/RGBLED/rainbw.lua
Executable file
|
|
@ -0,0 +1,52 @@
|
|||
local function init()
|
||||
colorChangeTime = getTime() -- Initialize time
|
||||
phase = 0
|
||||
end
|
||||
|
||||
local minBrightness = 0 -- Minimum brightness value
|
||||
local maxBrightness = 255 -- Maximum brightness value
|
||||
|
||||
local function getColor(phase, length)
|
||||
local position = (phase % length) / length
|
||||
local r, g, b = minBrightness, minBrightness, minBrightness
|
||||
|
||||
-- RGB color transition: red -> green -> blue -> red
|
||||
if position < 1/3 then
|
||||
-- From red to green
|
||||
r = maxBrightness * (1 - 3 * position)
|
||||
g = maxBrightness * (3 * position)
|
||||
elseif position < 2/3 then
|
||||
-- From green to blue
|
||||
position = position - 1/3
|
||||
g = maxBrightness * (1 - 3 * position)
|
||||
b = maxBrightness * (3 * position)
|
||||
else
|
||||
-- From blue to red
|
||||
position = position - 2/3
|
||||
b = maxBrightness * (1 - 3 * position)
|
||||
r = maxBrightness * (3 * position)
|
||||
end
|
||||
|
||||
return r, g, b
|
||||
end
|
||||
|
||||
local colorChangeTime = 0 -- The time of the last color change
|
||||
|
||||
local function run()
|
||||
if ((getTime() - colorChangeTime) > 2) then -- Use an interval of 4 time units
|
||||
colorChangeTime = getTime()
|
||||
phase = (phase + 1) % 255 -- Update color phase
|
||||
|
||||
for i = 0, LED_STRIP_LENGTH - 1, 1 do
|
||||
local r, g, b = getColor(phase + i * 64, 255) -- Increase phase offset for each LED
|
||||
setRGBLedColor(i, r, g, b)
|
||||
end
|
||||
applyRGBLedColors()
|
||||
end
|
||||
end
|
||||
|
||||
local function background()
|
||||
-- Called periodically while the Special Function switch is off
|
||||
end
|
||||
|
||||
return { run=run, background=background, init=init }
|
||||
BIN
SCRIPTS/RGBLED/rainbw.luac
Executable file
BIN
SCRIPTS/RGBLED/rainbw.luac
Executable file
Binary file not shown.
16
SCRIPTS/RGBLED/red.lua
Executable file
16
SCRIPTS/RGBLED/red.lua
Executable file
|
|
@ -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 }
|
||||
BIN
SCRIPTS/RGBLED/red.luac
Executable file
BIN
SCRIPTS/RGBLED/red.luac
Executable file
Binary file not shown.
53
SCRIPTS/RGBLED/rgbLop.lua
Executable file
53
SCRIPTS/RGBLED/rgbLop.lua
Executable file
|
|
@ -0,0 +1,53 @@
|
|||
local function init()
|
||||
cycleTime = getTime() -- Initialize time
|
||||
phase = 0
|
||||
end
|
||||
|
||||
-- Function to generate smooth cyclic colors
|
||||
local function getColor(phase, length)
|
||||
local position = (phase % length) / length
|
||||
local r, g, b = 5, 5, 5
|
||||
local maxBrightness = 255 -- Maximum brightness value
|
||||
local minBrightness = 0 -- Minimum brightness value
|
||||
|
||||
-- RGB color transition: red -> green -> blue -> red
|
||||
if position < 1/3 then
|
||||
-- From red to green
|
||||
r = minBrightness + (maxBrightness - minBrightness) * (1 - 3 * position)
|
||||
g = maxBrightness * (3 * position)
|
||||
b = minBrightness
|
||||
elseif position < 2/3 then
|
||||
-- From green to blue
|
||||
position = position - 1/3
|
||||
g = minBrightness + (maxBrightness - minBrightness) * (1 - 3 * position)
|
||||
b = maxBrightness * (3 * position)
|
||||
r = minBrightness
|
||||
else
|
||||
-- From blue to red
|
||||
position = position - 2/3
|
||||
b = minBrightness + (maxBrightness - minBrightness) * (1 - 3 * position)
|
||||
r = maxBrightness * (3 * position)
|
||||
g = minBrightness
|
||||
end
|
||||
|
||||
return math.max(0, math.min(r, maxBrightness)), math.max(0, math.min(g, maxBrightness)), math.max(0, math.min(b, maxBrightness))
|
||||
end
|
||||
|
||||
local function run()
|
||||
if ((getTime() - cycleTime) > 2) then -- Use an interval of 8 time units
|
||||
cycleTime = getTime()
|
||||
phase = phase + 1 -- Update color phase
|
||||
end
|
||||
|
||||
for i = 0, LED_STRIP_LENGTH - 1, 1 do
|
||||
local r, g, b = getColor(phase, 255)
|
||||
setRGBLedColor(i, r, g, b)
|
||||
end
|
||||
applyRGBLedColors()
|
||||
end
|
||||
|
||||
local function background()
|
||||
-- Called periodically while the Special Function switch is off
|
||||
end
|
||||
|
||||
return { run=run, background=background, init=init }
|
||||
BIN
SCRIPTS/RGBLED/rgbLop.luac
Normal file
BIN
SCRIPTS/RGBLED/rgbLop.luac
Normal file
Binary file not shown.
77
SCRIPTS/RGBLED/runner.lua
Executable file
77
SCRIPTS/RGBLED/runner.lua
Executable file
|
|
@ -0,0 +1,77 @@
|
|||
local function init()
|
||||
colorChangeTime = getTime() -- Initialize time
|
||||
phase = 0
|
||||
currentLed = 0 -- Current lit LED position
|
||||
end
|
||||
|
||||
local minBrightness = 0 -- Minimum brightness value
|
||||
local maxBrightness = 255 -- Maximum brightness value
|
||||
|
||||
local function getColor(phase, length)
|
||||
local position = (phase % length) / length
|
||||
local r, g, b = minBrightness, minBrightness, minBrightness
|
||||
|
||||
-- RGB color transition: red -> green -> blue -> red
|
||||
if position < 1/3 then
|
||||
-- From red to green
|
||||
r = maxBrightness * (1 - 3 * position)
|
||||
g = maxBrightness * (3 * position)
|
||||
elseif position < 2/3 then
|
||||
-- From green to blue
|
||||
position = position - 1/3
|
||||
g = maxBrightness * (1 - 3 * position)
|
||||
b = maxBrightness * (3 * position)
|
||||
else
|
||||
-- From blue to red
|
||||
position = position - 2/3
|
||||
b = maxBrightness * (1 - 3 * position)
|
||||
r = maxBrightness * (3 * position)
|
||||
end
|
||||
|
||||
return r, g, b
|
||||
end
|
||||
|
||||
local maxBackgroundBrightness = 255 -- Maximum brightness value for the background
|
||||
|
||||
local function run()
|
||||
if ((getTime() - colorChangeTime) > 2) then -- Use an interval of 4 time units
|
||||
colorChangeTime = getTime()
|
||||
phase = phase + 1 -- Update color phase
|
||||
currentLed = (currentLed + 1) % LED_STRIP_LENGTH -- Move to the next LED
|
||||
end
|
||||
|
||||
for i = 0, LED_STRIP_LENGTH - 1, 1 do
|
||||
local r, g, b = getColor(phase, 255)
|
||||
if i <= currentLed then
|
||||
setRGBLedColor(i, r, g, b)
|
||||
else
|
||||
-- Set the background color to the opposite of the main color in the RGB color space
|
||||
local bg_r = (r + 128) % 256
|
||||
local bg_g = (g + 128) % 256
|
||||
local bg_b = (b + 128) % 256
|
||||
|
||||
-- Ensure the brightness of the background color does not exceed 72
|
||||
bg_r = math.min(bg_r, maxBackgroundBrightness)
|
||||
bg_g = math.min(bg_g, maxBackgroundBrightness)
|
||||
bg_b = math.min(bg_b, maxBackgroundBrightness)
|
||||
|
||||
-- Ensure at least one color channel is always off
|
||||
if bg_r > bg_g and bg_r > bg_b then
|
||||
bg_r = 0
|
||||
elseif bg_g > bg_r and bg_g > bg_b then
|
||||
bg_g = 0
|
||||
else
|
||||
bg_b = 0
|
||||
end
|
||||
|
||||
setRGBLedColor(i, bg_r, bg_g, bg_b)
|
||||
end
|
||||
end
|
||||
applyRGBLedColors()
|
||||
end
|
||||
|
||||
local function background()
|
||||
-- Called periodically while the Special Function switch is off
|
||||
end
|
||||
|
||||
return { run=run, background=background, init=init }
|
||||
BIN
SCRIPTS/RGBLED/runner.luac
Executable file
BIN
SCRIPTS/RGBLED/runner.luac
Executable file
Binary file not shown.
16
SCRIPTS/RGBLED/sapp.lua
Executable file
16
SCRIPTS/RGBLED/sapp.lua
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
local function init()
|
||||
end
|
||||
|
||||
local function run()
|
||||
for i=0, LED_STRIP_LENGTH - 1, 1
|
||||
do
|
||||
setRGBLedColor(i, 0, 255, 255) -- Set to sapphire color
|
||||
end
|
||||
applyRGBLedColors()
|
||||
end
|
||||
|
||||
local function background()
|
||||
-- Called periodically while the Special Function switch is off
|
||||
end
|
||||
|
||||
return { run=run, background=background, init=init }
|
||||
16
SCRIPTS/RGBLED/white.lua
Executable file
16
SCRIPTS/RGBLED/white.lua
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
local function init()
|
||||
end
|
||||
|
||||
local function run()
|
||||
for i=0, LED_STRIP_LENGTH - 1, 1
|
||||
do
|
||||
setRGBLedColor(i, 255, 255, 255) -- Set to white color
|
||||
end
|
||||
applyRGBLedColors()
|
||||
end
|
||||
|
||||
local function background()
|
||||
-- Called periodically while the Special Function switch is off
|
||||
end
|
||||
|
||||
return { run=run, background=background, init=init }
|
||||
16
SCRIPTS/RGBLED/yellow.lua
Executable file
16
SCRIPTS/RGBLED/yellow.lua
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
local function init()
|
||||
end
|
||||
|
||||
local function run()
|
||||
for i=0, LED_STRIP_LENGTH - 1, 1
|
||||
do
|
||||
setRGBLedColor(i, 255, 255, 0)
|
||||
end
|
||||
applyRGBLedColors()
|
||||
end
|
||||
|
||||
local function background()
|
||||
-- Called periodically while the Special Function switch is off
|
||||
end
|
||||
|
||||
return { run=run, background=background, init=init }
|
||||
BIN
SCRIPTS/RGBLED/yellow.luac
Normal file
BIN
SCRIPTS/RGBLED/yellow.luac
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue