Add your script examples below...
Blink IP address when local button is 'long' pressed - Electroguard 1/4/18 Long-pressing the local button for 1.5 secs or more will blink out the node IP address on the local LED (10 blinks to represent 0) Short-pressing (less than 1.5 secs) can do something else such as toggle a local relay
Code:Blink IP address
-------------- Shows continual ramfree memory usage, plus clock for reassurance that script is still running. Slider allows setting a danger_level memory threshold anywhere between 10K min to 35K max. If ramfree drops below the threshold, it causes a jump to danger: offering opportunity to take pre-emptive evasive actions before script unavoidably halts from 'out of memory' error.Moving slider towards max will set threshold higher than available ramfree and therefore trigger a jump to danger. When triggered, shows the final low memory value and time it happened.Can be use 'as-is' to develop and test pre-emptive actions, then can be stripped down to essentials for including pre-emptive evasive actions into scripts...such as saving important data to non-volatile file then triggering the module to reboot and autorun before it stops from 'out of memory' error. Update: Be aware that repeatedly calling ramfree can itself cause hanging due to memory problems. . 'Memory Monitor now$=time$ 'current time to show script is running
free_mem$="" danger_level=12000 'minimum memory threshold - allow enough headroom to take evasive action if necessary min=10000 'slider minimum memory setting max=35000 'slider maximum memory setting timer0 1000, ticker cls html$= "Memory Monitor <br>" html$=html$+ "time: " + textbox$(now$,"time")+"<br>" html$=html$+ "free mem: " + textbox$(free_mem$,"mem")+"<br>" html$=html$+ str$(min) + " " + textbox$(danger_level,"thresh") + " " + str$(max) + "<br>" html$=html$+ " adjust " + slider$(danger_level,min,max,"set")+"<br>" html$=html$+ cssid$("time","background-color:white;border:0;color:blue;width:78px;text-align:right;") html$=html$+ cssid$("mem","background-color:white;border:0;color:darkgreen;width:44px;text-align:right;") html$=html$+ cssid$("set","width:100px;") html$=html$+ cssid$("thresh","background-color:yellow;color:blue;width:100px;text-align:center;") html html$ wait ticker: free_mem$=str$(ramfree) now$=time$ if val(free_mem$)<danger_level then goto danger refresh return danger: timer0 0 wlog "DANGER - low memory = " + free_mem$ html$= cssid$("mem","color:darkred;") html$=html$+ cssid$("time","color:magenta;") html$=html$+ cssid$("thresh","background-color:red;color:red;") html$=html$+ "LOW MEMORY - STOPPED<br>" html html$ refresh pause 100 'save important vars 'reboot (assuming module is set to autorun) end '-------------------- End -------------------- LED Flasher - Electroguard 12-2-20
Uses both timers to flash at any rate or duration without blocking other activities LEDpin=2 pin.mode LEDpin, output LEDoff=1 'OFF state depends on whether active low or active high pin(LEDpin)=LEDoff 'init led to off LEDfrequency=1000 'flash rate LEDduration=100 'on time (millis) timer0 LEDfrequency, turnON wait turnON: timer1 LEDduration, turnOFF 'enable OFF timer pin(LEDpin)= 1- LEDoff 'turn led ON return turnOFF: timer1 0 'disable OFF timer pin(LEDpin)=LEDoff 'turn led OFF return '-------------------- End -------------------- |
Your Pages >