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