From fee2523a226e28e08dd2e2264ff857650a886702 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 23 Oct 2020 21:33:38 +0200 Subject: mode-button: make LED configurable --- doc/mode-button.md | 3 ++- global-config | 4 +++- global-config-overlay | 2 +- global-config.changes | 1 + global-functions | 2 +- mode-button | 4 +++- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/doc/mode-button.md b/doc/mode-button.md index a44b571..8d037e5 100644 --- a/doc/mode-button.md +++ b/doc/mode-button.md @@ -46,9 +46,10 @@ To use the reset button instead: Configuration ------------- -The configuration goes to `global-config-overlay`, the only parameter is: +The configuration goes to `global-config-overlay`, these are the parameters: * `ModeButton`: an array with defined actions +* `ModeButtonLED`: led to give visual feedback Usage and invocation -------------------- diff --git a/global-config b/global-config index 68d12e7..fc8d010 100644 --- a/global-config +++ b/global-config @@ -8,7 +8,7 @@ # Make sure all configuration properties are up to date and this # value is in sync with value in script 'global-functions'! -:global GlobalConfigVersion 34; +:global GlobalConfigVersion 35; # This is used for DNS and backup file. :global Domain "example.com"; @@ -105,6 +105,8 @@ 5="/ system script run bridge-port-toggle;"; # add more here... }; +# This led gives visual feedback if type is 'on' or 'off'. +:global ModeButtonLED "user-led"; # Run commands on SMS action. :global SmsAction { diff --git a/global-config-overlay b/global-config-overlay index 99295e6..250f697 100644 --- a/global-config-overlay +++ b/global-config-overlay @@ -9,7 +9,7 @@ # Make sure all configuration properties are up to date and this # value is in sync with value in script 'global-functions'! # Comment or remove to disable change notifications. -:global GlobalConfigVersion 34; +:global GlobalConfigVersion 35; # Copy configuration from global-config here and modify it. diff --git a/global-config.changes b/global-config.changes index 7d14e85..8082344 100644 --- a/global-config.changes +++ b/global-config.changes @@ -38,4 +38,5 @@ 32="Merged mode (& reset) button scripts in single new script 'mode-button'."; 33="Added configurable deviation on health temperature recovery threshold against notification flooding."; 34="Introduced script 'ospf-to-leds' to visualize OSPF instance state via LEDs."; + 35="Implemented visual feedback for 'mode-button' with configurable LED."; }; diff --git a/global-functions b/global-functions index ab3247a..f8716fe 100644 --- a/global-functions +++ b/global-functions @@ -8,7 +8,7 @@ # https://git.eworm.de/cgit/routeros-scripts/about/ # expected configuration version -:global ExpectedConfigVersion 34; +:global ExpectedConfigVersion 35; # global variables not to be changed by user :global GlobalFunctionsReady false; diff --git a/mode-button b/mode-button index c189ad2..217c0cc 100644 --- a/mode-button +++ b/mode-button @@ -23,9 +23,11 @@ :global ModeButtonScheduler; :local LEDInvert do={ + :global ModeButtonLED; + :global IfThenElse; - :local LED [ / system leds find where leds="user-led" type~"^(on|off)\$" interface=[] ]; + :local LED [ / system leds find where leds=$ModeButtonLED type~"^(on|off)\$" interface=[] ]; :if ([ :len $LED ] = 0) do={ :return false; } -- cgit v1.2.3-70-g09d2