From ebbc40e3a090fb91e6107b7546abf4caf32e4989 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 23 Oct 2020 12:01:29 +0200 Subject: mode-button: support inverted blink --- mode-button | 7 +++++-- 1 file 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; } -- cgit v1.2.3-70-g09d2