From 4a6359fa8bea43dba4e1b7671098e718b9c6863d Mon Sep 17 00:00:00 2001 From: Richard Li Date: Fri, 24 Nov 2023 12:09:56 +0800 Subject: [PATCH] Added RGBLED scripts for PL18 series. --- sdcard/c480x320/SCRIPTS/RGBLED/blue.lua | 16 +++++++++++++ sdcard/c480x320/SCRIPTS/RGBLED/green.lua | 16 +++++++++++++ sdcard/c480x320/SCRIPTS/RGBLED/off.lua | 16 +++++++++++++ sdcard/c480x320/SCRIPTS/RGBLED/police.lua | 26 ++++++++++++++++++++ sdcard/c480x320/SCRIPTS/RGBLED/red.lua | 16 +++++++++++++ sdcard/c480x320/SCRIPTS/RGBLED/scl.lua | 29 +++++++++++++++++++++++ sdcard/c480x320/SCRIPTS/RGBLED/scr.lua | 29 +++++++++++++++++++++++ 7 files changed, 148 insertions(+) create mode 100644 sdcard/c480x320/SCRIPTS/RGBLED/blue.lua create mode 100644 sdcard/c480x320/SCRIPTS/RGBLED/green.lua create mode 100644 sdcard/c480x320/SCRIPTS/RGBLED/off.lua create mode 100644 sdcard/c480x320/SCRIPTS/RGBLED/police.lua create mode 100644 sdcard/c480x320/SCRIPTS/RGBLED/red.lua create mode 100644 sdcard/c480x320/SCRIPTS/RGBLED/scl.lua create mode 100644 sdcard/c480x320/SCRIPTS/RGBLED/scr.lua diff --git a/sdcard/c480x320/SCRIPTS/RGBLED/blue.lua b/sdcard/c480x320/SCRIPTS/RGBLED/blue.lua new file mode 100644 index 00000000..56385d99 --- /dev/null +++ b/sdcard/c480x320/SCRIPTS/RGBLED/blue.lua @@ -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 } diff --git a/sdcard/c480x320/SCRIPTS/RGBLED/green.lua b/sdcard/c480x320/SCRIPTS/RGBLED/green.lua new file mode 100644 index 00000000..57677ffc --- /dev/null +++ b/sdcard/c480x320/SCRIPTS/RGBLED/green.lua @@ -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 } diff --git a/sdcard/c480x320/SCRIPTS/RGBLED/off.lua b/sdcard/c480x320/SCRIPTS/RGBLED/off.lua new file mode 100644 index 00000000..f86c824b --- /dev/null +++ b/sdcard/c480x320/SCRIPTS/RGBLED/off.lua @@ -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 } diff --git a/sdcard/c480x320/SCRIPTS/RGBLED/police.lua b/sdcard/c480x320/SCRIPTS/RGBLED/police.lua new file mode 100644 index 00000000..8af18cd5 --- /dev/null +++ b/sdcard/c480x320/SCRIPTS/RGBLED/police.lua @@ -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 } diff --git a/sdcard/c480x320/SCRIPTS/RGBLED/red.lua b/sdcard/c480x320/SCRIPTS/RGBLED/red.lua new file mode 100644 index 00000000..d169693b --- /dev/null +++ b/sdcard/c480x320/SCRIPTS/RGBLED/red.lua @@ -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 } diff --git a/sdcard/c480x320/SCRIPTS/RGBLED/scl.lua b/sdcard/c480x320/SCRIPTS/RGBLED/scl.lua new file mode 100644 index 00000000..3cb6cfdf --- /dev/null +++ b/sdcard/c480x320/SCRIPTS/RGBLED/scl.lua @@ -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 } diff --git a/sdcard/c480x320/SCRIPTS/RGBLED/scr.lua b/sdcard/c480x320/SCRIPTS/RGBLED/scr.lua new file mode 100644 index 00000000..4bb20c94 --- /dev/null +++ b/sdcard/c480x320/SCRIPTS/RGBLED/scr.lua @@ -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 }