aboutsummaryrefslogblamecommitdiffstats
path: root/mode-button-event
blob: 82c1f4b21a9c2d1e0959614d22ddf2d74a4d8ff9 (plain) (tree)
1
2
3
4
5
6
7
8
9
     
                                    
                                                         

                                                   
                   
 
                                                       
 
                                                                                
 
                                  


                                                                                               
                                                                          
 
#!rsc
# RouterOS script: mode-button-event
# Copyright (c) 2018-2019 Christian Hesse <mail@eworm.de>
#
# run on mode-button event and count button presses

:global ModeButton;

:set ($ModeButton->"count") ($ModeButton->"count" + 1);

:local Scheduler [ / system scheduler find where name="mode-button-scheduler" ];

:if ([ :len $Scheduler ] = 0) do={
  :log info "Creating mode-button scheduler, counting presses...";
  / system scheduler add name=mode-button-scheduler on-event=mode-button-scheduler interval=3s;
} else={
  :log debug "Updating mode-button-scheduler...";
  / system scheduler set $Scheduler start-time=[ /system clock get time ];
}