new visualizer for ambient light, replace base_color algorithm
This commit is contained in:
parent
67a40ce98e
commit
afd2fcb9af
@ -40,9 +40,8 @@ def helpmenu():
|
||||
print("-a ambient light")
|
||||
print("-t test function (debug)")
|
||||
|
||||
def base_color(r,g,b):
|
||||
min_value = min([r,g,b])
|
||||
return r//min_value, g//min_value, b//min_value
|
||||
def base_color(color):
|
||||
return [i // min(color) for i in color]
|
||||
|
||||
def visualizer(color):
|
||||
r,g,b = hex_to_rgb(color)
|
||||
@ -66,10 +65,26 @@ def visualizer(color):
|
||||
cava.stdout.close()
|
||||
sed.stdout.close()
|
||||
|
||||
def get_base_color(color):
|
||||
return [i / min(color) for i in color]
|
||||
|
||||
_r,_g,_b = 0,0,0
|
||||
volume_amp = 1
|
||||
|
||||
def visualizer_cava_thread():
|
||||
global volume_amp
|
||||
|
||||
cava = subprocess.Popen(["cava", "-p", "/etc/lc/cava.conf"], stdout=subprocess.PIPE)
|
||||
sed = subprocess.Popen(["sed", "-u", "s/;.*;$//"], stdin=cava.stdout, stdout=subprocess.PIPE)
|
||||
|
||||
for line in sed.stdout:
|
||||
volume_amp = int(line)
|
||||
cava.stdout.close()
|
||||
sed.stdout.close()
|
||||
|
||||
def visualizer_2(color, amp_strength):
|
||||
global volume_amp
|
||||
# amp_strength in percentage
|
||||
amp_factor = (amp_strength*((volume_amp/500)-1)+1)
|
||||
#print(amp_factor, color, volume_amp)
|
||||
return [c*amp_factor for c in color]
|
||||
|
||||
def vibrant(r,g,b):
|
||||
intensity = 50 # usabel range 1-100 max:1000
|
||||
@ -95,13 +110,14 @@ def ambient_light_thread():
|
||||
|
||||
while True:
|
||||
# P-Regler
|
||||
r,g,b = [w+((y-w)*0.08) for y,w in zip((_r,_g,_b),(r,g,b))]
|
||||
r,g,b = [w+((y-w)*0.1) for y,w in zip((_r,_g,_b),(r,g,b))]
|
||||
if ((round(r),round(g),round(b)) == (_r,_g,_b)):
|
||||
active_color = '\033[0;32;40m'
|
||||
else:
|
||||
active_color = '\033[0;31;40m'
|
||||
print(active_color, round(r),round(g),round(b), '\033[0;37;40m')
|
||||
send(rgb_to_hex(int(r*brighness),int(g*brighness),int(b*brighness)))
|
||||
r_out,g_out,b_out = visualizer_2((r,g,b), 0.4)
|
||||
send(rgb_to_hex(int(r_out*brighness),int(g_out*brighness),int(b_out*brighness)))
|
||||
time.sleep(0.01)
|
||||
|
||||
ups_counter = 0
|
||||
@ -125,8 +141,11 @@ def color_correction(r,g,b):
|
||||
|
||||
def ambient_light():
|
||||
|
||||
t = Thread(target=ambient_light_thread)
|
||||
t.start()
|
||||
t1 = Thread(target=ambient_light_thread)
|
||||
t1.start()
|
||||
|
||||
t2 = Thread(target=visualizer_cava_thread)
|
||||
t2.start()
|
||||
|
||||
global _r,_g,_b
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user