aboutsummaryrefslogtreecommitdiffstats
path: root/mode-button
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2020-10-23 12:01:29 +0200
committerGravatar Christian Hesse <mail@eworm.de>2020-10-23 12:01:29 +0200
commitebbc40e3a090fb91e6107b7546abf4caf32e4989 (patch)
tree96769db8f8331332fed47afbf50ea22ffd8a4662 /mode-button
parentdd39049d36a4ec34c6bc11936c3f680cd31b24c9 (diff)
mode-button: support inverted blink
Diffstat (limited to 'mode-button')
-rw-r--r--mode-button7
1 files changed, 5 insertions, 2 deletions
diff --git a/mode-button b/mode-button
index 3aee63e..a555044 100644
--- a/mode-button
+++ b/mode-button
@@ -19,11 +19,14 @@
:global ModeButtonScheduler do={
:global ModeButton;
+ :global IfThenElse;
:global LogPrintExit;
:global ModeButtonScheduler;
:local Count ($ModeButton->"count");
:local Code ($ModeButton->[ :tostr $Count ]);
+ :local LEDState [ / system leds get [ find where leds="user-led" ] type ];
+ :local LEDInvert [ $IfThenElse ($LEDState = "on") "off" "on" ];
:set ($ModeButton->"count") 0;
:set ModeButtonScheduler;
@@ -33,13 +36,13 @@
$LogPrintExit info ("Acting on " . $Count . " mode-button presses: " . $Code) false;
:for I from=1 to=$Count do={
- / system leds set type=on [ find where leds="user-led" type=off ];
+ / system leds set type=$LEDInvert [ find where leds="user-led" type=$LEDState ];
:if ([ / system routerboard settings get silent-boot ] = false) do={
:beep length=200ms;
} else={
:delay 200ms;
}
- / system leds set type=off [ find where leds="user-led" type=on ];
+ / system leds set type=$LEDState [ find where leds="user-led" type=$LEDInvert ];
:delay 200ms;
}