mode-button: make LED configurable

This commit is contained in:
Christian Hesse 2020-10-23 21:33:38 +02:00
parent 2e4658e49a
commit fee2523a22
6 changed files with 11 additions and 5 deletions

View file

@ -46,9 +46,10 @@ To use the reset button instead:
Configuration 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 * `ModeButton`: an array with defined actions
* `ModeButtonLED`: led to give visual feedback
Usage and invocation Usage and invocation
-------------------- --------------------

View file

@ -8,7 +8,7 @@
# Make sure all configuration properties are up to date and this # Make sure all configuration properties are up to date and this
# value is in sync with value in script 'global-functions'! # value is in sync with value in script 'global-functions'!
:global GlobalConfigVersion 34; :global GlobalConfigVersion 35;
# This is used for DNS and backup file. # This is used for DNS and backup file.
:global Domain "example.com"; :global Domain "example.com";
@ -105,6 +105,8 @@
5="/ system script run bridge-port-toggle;"; 5="/ system script run bridge-port-toggle;";
# add more here... # add more here...
}; };
# This led gives visual feedback if type is 'on' or 'off'.
:global ModeButtonLED "user-led";
# Run commands on SMS action. # Run commands on SMS action.
:global SmsAction { :global SmsAction {

View file

@ -9,7 +9,7 @@
# Make sure all configuration properties are up to date and this # Make sure all configuration properties are up to date and this
# value is in sync with value in script 'global-functions'! # value is in sync with value in script 'global-functions'!
# Comment or remove to disable change notifications. # Comment or remove to disable change notifications.
:global GlobalConfigVersion 34; :global GlobalConfigVersion 35;
# Copy configuration from global-config here and modify it. # Copy configuration from global-config here and modify it.

View file

@ -38,4 +38,5 @@
32="Merged mode (& reset) button scripts in single new script 'mode-button'."; 32="Merged mode (& reset) button scripts in single new script 'mode-button'.";
33="Added configurable deviation on health temperature recovery threshold against notification flooding."; 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."; 34="Introduced script 'ospf-to-leds' to visualize OSPF instance state via LEDs.";
35="Implemented visual feedback for 'mode-button' with configurable LED.";
}; };

View file

@ -8,7 +8,7 @@
# https://git.eworm.de/cgit/routeros-scripts/about/ # https://git.eworm.de/cgit/routeros-scripts/about/
# expected configuration version # expected configuration version
:global ExpectedConfigVersion 34; :global ExpectedConfigVersion 35;
# global variables not to be changed by user # global variables not to be changed by user
:global GlobalFunctionsReady false; :global GlobalFunctionsReady false;

View file

@ -23,9 +23,11 @@
:global ModeButtonScheduler; :global ModeButtonScheduler;
:local LEDInvert do={ :local LEDInvert do={
:global ModeButtonLED;
:global IfThenElse; :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={ :if ([ :len $LED ] = 0) do={
:return false; :return false;
} }