Better Speed Adaptation
This commit is contained in:
parent
cca9b4bb8d
commit
fc728c3da2
5
wibe.py
5
wibe.py
@ -5,6 +5,7 @@ import io
|
|||||||
import colorgram
|
import colorgram
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
import math
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
wledPalettes = {'colorsOnly': 5, 'colorGradient': 4, '2Colors': 3}
|
wledPalettes = {'colorsOnly': 5, 'colorGradient': 4, '2Colors': 3}
|
||||||
@ -28,7 +29,7 @@ def main(token, ip='192.168.3.42', bri=51):
|
|||||||
#pprint(curTrack)
|
#pprint(curTrack)
|
||||||
#pprint(feat)
|
#pprint(feat)
|
||||||
#pprint(palette)
|
#pprint(palette)
|
||||||
speed = min(int(feat['tempo']/2),255)
|
speed = min(int((feat['tempo']/60)**3)*8,255)
|
||||||
power = 16 + int(feat['energy'])*64
|
power = 16 + int(feat['energy'])*64
|
||||||
pprint(requests.post(url, json={"seg": [{"col": palette, "pal": wledPalettes['colorGradient'], 'sx': speed, 'ix': power}]}).json())
|
pprint(requests.post(url, json={"seg": [{"col": palette, "pal": wledPalettes['colorGradient'], 'sx': speed, 'ix': power}]}).json())
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
@ -42,7 +43,7 @@ def getPalette(curTrack,numColors):
|
|||||||
return palette
|
return palette
|
||||||
|
|
||||||
def normalizeColor(rgbw):
|
def normalizeColor(rgbw):
|
||||||
s = max(rgbw)
|
s = max(max(rgbw),1)
|
||||||
fac = (1 + 255/s)/2
|
fac = (1 + 255/s)/2
|
||||||
return [min(int(c*fac),255) for c in rgbw]
|
return [min(int(c*fac),255) for c in rgbw]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user