Updated Script Cookbook (markdown)

gemu 2019-07-28 19:35:14 +02:00
parent 2cb0205d31
commit e402decac2
1 changed files with 88 additions and 89 deletions

@ -524,107 +524,106 @@ endif
[Back To Top](#top) [Back To Top](#top)
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
#### Ledbar Display with WS2812 ledchain #### Ledbar Display with WS2812 ledchain
used as display for solar house power input/output (+-5000 Watts) used as display for solar house power input/output (+-5000 Watts)
>D >D
m:array=0 60 ;defines array for 60 led pixels m:array=0 60 ;defines array for 60 led pixels
cnt=0 cnt=0
val=0 val=0
ind=0 ind=0
; rgb values for grid ; rgb values for grid
colr1=0x050000 colr1=0x050000
colr2=0x050100 colr2=0x050100
colg1=0x000300 colg1=0x000300
colg2=0x020300 colg2=0x020300
ledbar=0 ledbar=0
blue=64 blue=64
pixels=60 pixels=60
steps=10 steps=10
div=0 div=0
tog=0 tog=0
max=5000 max=5000
min=-5000 min=-5000
pos=0 pos=0
>B >B
div=pixels/steps div=pixels/steps
=#prep =#prep
ws2812(array) ws2812(array)
; ledbar is set from broker ; ledbar is set from broker
>S >S
if ledbar<min if ledbar<min
then ledbar=min then ledbar=min
endif endif
if ledbar>max if ledbar>max
then ledbar=max then ledbar=max
endif endif
pos=(ledbar/max)*(pixels/2) pos=(ledbar/max)*(pixels/2)
if ledbar>0 if ledbar>0
then then
pos+=(pixels/2); pos+=(pixels/2)
if pos>pixels-1 if pos>pixels-1
then pos=pixels then pos=pixels
endif endif
else else
pos+=(pixels/2)+1 pos+=(pixels/2)+1
if pos>pixels-1 if pos>pixels-1
then pos=1 then pos=1
endif endif
endif endif
if pos<1 if pos<1
or pos>pixels or pos>pixels
then pos=1 then pos=1
endif endif
=#prep =#prep
if ledbar==0 if ledbar==0
then then
array[pos]=blue array[pos]=blue
array[pos-1]=blue array[pos-1]=blue
else else
array[pos]=blue array[pos]=blue
endif endif
; only used if power is off ; only used if power is off
; so lets may be used normally if on ; so lets may be used normally if on
if pwr[1]==0 if pwr[1]==0
then then
ws2812(array) ws2812(array)
endif endif
; subroutine for grid
#prep
for cnt 1 pixels 1
ind+=1
if ind>div
then ind=1
tog^=1
endif
#prep if cnt<=pixels/2
for cnt 1 pixels 1 then
ind+=1 if tog>0
if ind>div then val=colr1
then ind=1 else val=colr2
tog^=1 endif
endif else
if tog>0
if cnt<=pixels/2 then val=colg1
then else val=colg2
if tog>0 endif
then val=colr1 endif
else val=colr2 array[cnt]=val
endif next
else
if tog>0
then val=colg1
else val=colg2
endif
endif
;->print %cnt% %tog%
array[cnt]=val
next
>R
>R
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
#### Multiple IR Receiver Synchronization #### Multiple IR Receiver Synchronization
since i own a magic home with ir receiver i made a script to show how it works since i own a magic home with ir receiver i made a script to show how it works