From fc728c3da20839534f308188bbd751f84d93e03f Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Thu, 16 Dec 2021 11:57:27 +0100 Subject: [PATCH] Better Speed Adaptation --- wibe.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wibe.py b/wibe.py index f57d430..fefa920 100644 --- a/wibe.py +++ b/wibe.py @@ -5,6 +5,7 @@ import io import colorgram import json import time +import math from pprint import pprint wledPalettes = {'colorsOnly': 5, 'colorGradient': 4, '2Colors': 3} @@ -28,7 +29,7 @@ def main(token, ip='192.168.3.42', bri=51): #pprint(curTrack) #pprint(feat) #pprint(palette) - speed = min(int(feat['tempo']/2),255) + speed = min(int((feat['tempo']/60)**3)*8,255) power = 16 + int(feat['energy'])*64 pprint(requests.post(url, json={"seg": [{"col": palette, "pal": wledPalettes['colorGradient'], 'sx': speed, 'ix': power}]}).json()) time.sleep(3) @@ -42,7 +43,7 @@ def getPalette(curTrack,numColors): return palette def normalizeColor(rgbw): - s = max(rgbw) + s = max(max(rgbw),1) fac = (1 + 255/s)/2 return [min(int(c*fac),255) for c in rgbw]