From ec5145cecc0f3ff7a9601ebdce362835bd7347dc Mon Sep 17 00:00:00 2001 From: Trenton-Ruf Date: Wed, 4 Sep 2019 20:24:48 -0700 Subject: [PATCH 01/12] Brightness Slider --- .vscode/settings.json | 3 +++ python/visualization.py | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..56fb648d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "/usr/sbin/python" +} \ No newline at end of file diff --git a/python/visualization.py b/python/visualization.py index 18d9486b..9354d66f 100644 --- a/python/visualization.py +++ b/python/visualization.py @@ -312,6 +312,15 @@ def freq_slider_change(tick): freq_label.setText('Frequency range: {} - {} Hz'.format( config.MIN_FREQUENCY, config.MAX_FREQUENCY)) + # Brightness label + bright_label = pg.LabelItem('') + # Brightness slider + def bright_slider_change(tick): + bright_label.setText('Brightness level: {:.0f}%'.format(bright_slider.tickValue(0)*100)) + bright_slider = pg.TickSliderItem(orientation='bottom', allowAdd=True) + bright_slider.addTick(1, color='#16dbeb' , movable=True) + bright_slider.tickMoveFinished = bright_slider_change + bright_label.setText('Brightness level: {}%'.format(bright_slider.tickValue(0)*100)) # Effect selection active_color = '#16dbeb' inactive_color = '#FFFFFF' @@ -350,6 +359,10 @@ def spectrum_click(x): layout.addItem(energy_label) layout.addItem(scroll_label) layout.addItem(spectrum_label) + layout.nextRow() + layout.addItem(bright_label, colspan=3) + layout.nextRow() + layout.addItem(bright_slider, colspan=3) # Initialize LEDs led.update() # Start listening to live audio stream From 31b00372b2c2169e4d38eafa6f44de12bd95656e Mon Sep 17 00:00:00 2001 From: Trenton-Ruf Date: Wed, 4 Sep 2019 20:49:58 -0700 Subject: [PATCH 02/12] test brightness changes --- python/led.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/led.py b/python/led.py index d8e79945..5cbed5f8 100644 --- a/python/led.py +++ b/python/led.py @@ -57,6 +57,7 @@ def _update_esp8266(): g (0 to 255): Green value of LED b (0 to 255): Blue value of LED """ + brightness = 0.1 #between 0 and 1 global pixels, _prev_pixels # Truncate values and cast to integer pixels = np.clip(pixels, 0, 255).astype(int) @@ -75,9 +76,9 @@ def _update_esp8266(): m += chr(i) + chr(p[0][i]) + chr(p[1][i]) + chr(p[2][i]) else: m.append(i) # Index of pixel to change - m.append(p[0][i]) # Pixel red value - m.append(p[1][i]) # Pixel green value - m.append(p[2][i]) # Pixel blue value + m.append(int(p[0][i]*brightness)) # Pixel red value + m.append(int(p[1][i]*brightness)) # Pixel green value + m.append(int(p[2][i]*brightness)) # Pixel blue value m = m if _is_python_2 else bytes(m) _sock.sendto(m, (config.UDP_IP, config.UDP_PORT)) _prev_pixels = np.copy(p) From bd1b626cb88daaf9a7517ac33dbbcf24d178d5b4 Mon Sep 17 00:00:00 2001 From: Trenton-Ruf Date: Wed, 4 Sep 2019 23:20:51 -0700 Subject: [PATCH 03/12] added my personal IP address for esp --- python/config.py | 4 ++-- python/led.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/config.py b/python/config.py index a25b93cf..3479c389 100644 --- a/python/config.py +++ b/python/config.py @@ -17,7 +17,7 @@ """ if DEVICE == 'esp8266': - UDP_IP = '192.168.0.150' + UDP_IP = '192.168.1.150' """IP address of the ESP8266. Must match IP in ws2812_controller.ino""" UDP_PORT = 7777 """Port number used for socket communication between Python and ESP8266""" @@ -48,7 +48,7 @@ DISPLAY_FPS = True """Whether to display the FPS when running (can reduce performance)""" -N_PIXELS = 60 +N_PIXELS = 144 """Number of pixels in the LED strip (must match ESP8266 firmware)""" GAMMA_TABLE_PATH = os.path.join(os.path.dirname(__file__), 'gamma_table.npy') diff --git a/python/led.py b/python/led.py index 5cbed5f8..78447063 100644 --- a/python/led.py +++ b/python/led.py @@ -73,7 +73,7 @@ def _update_esp8266(): m = '' if _is_python_2 else [] for i in packet_indices: if _is_python_2: - m += chr(i) + chr(p[0][i]) + chr(p[1][i]) + chr(p[2][i]) + m += chr(i) + chr(int(p[0][i]*brightness)) + chr(int(p[1][i]*brightness)) + chr(int(p[2][i]*brightness)) else: m.append(i) # Index of pixel to change m.append(int(p[0][i]*brightness)) # Pixel red value From 6aa6de35527bd9c660ae4e48a7e97ec2c6e38e4f Mon Sep 17 00:00:00 2001 From: Trenton-Ruf Date: Wed, 4 Sep 2019 23:50:52 -0700 Subject: [PATCH 04/12] Might have added Brightness control for blinkstick --- python/config.py | 9 ++++++--- python/led.py | 11 +++++------ python/visualization.py | 6 ++++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/python/config.py b/python/config.py index 3479c389..3779c6e6 100644 --- a/python/config.py +++ b/python/config.py @@ -3,7 +3,7 @@ from __future__ import division import os -DEVICE = 'esp8266' +DEVICE = 'blinkstick' """Device used to control LED strip. Must be 'pi', 'esp8266' or 'blinkstick' 'esp8266' means that you are using an ESP8266 module to control the LED strip @@ -16,6 +16,9 @@ to control the leds connected to it. """ +BRIGHTNESS = 1 +"""Set between 0 and 1 to control LED brightness for pi,esp8266,and blinkstick""" + if DEVICE == 'esp8266': UDP_IP = '192.168.1.150' """IP address of the ESP8266. Must match IP in ws2812_controller.ino""" @@ -31,7 +34,7 @@ """LED signal frequency in Hz (usually 800kHz)""" LED_DMA = 5 """DMA channel used for generating PWM signal (try 5)""" - BRIGHTNESS = 255 + PI_BRIGHTNESS = 255 * BRIGHTNESS """Brightness of LED strip between 0 and 255""" LED_INVERT = True """Set True if using an inverting logic level converter""" @@ -57,7 +60,7 @@ MIC_RATE = 44100 """Sampling frequency of the microphone in Hz""" -FPS = 60 +FPS = 100 """Desired refresh rate of the visualization (frames per second) FPS indicates the desired refresh rate, or frames-per-second, of the audio diff --git a/python/led.py b/python/led.py index 78447063..34a6f223 100644 --- a/python/led.py +++ b/python/led.py @@ -14,7 +14,7 @@ import neopixel strip = neopixel.Adafruit_NeoPixel(config.N_PIXELS, config.LED_PIN, config.LED_FREQ_HZ, config.LED_DMA, - config.LED_INVERT, config.BRIGHTNESS) + config.LED_INVERT, config.PI_BRIGHTNESS) strip.begin() elif config.DEVICE == 'blinkstick': from blinkstick import blinkstick @@ -57,7 +57,6 @@ def _update_esp8266(): g (0 to 255): Green value of LED b (0 to 255): Blue value of LED """ - brightness = 0.1 #between 0 and 1 global pixels, _prev_pixels # Truncate values and cast to integer pixels = np.clip(pixels, 0, 255).astype(int) @@ -73,12 +72,12 @@ def _update_esp8266(): m = '' if _is_python_2 else [] for i in packet_indices: if _is_python_2: - m += chr(i) + chr(int(p[0][i]*brightness)) + chr(int(p[1][i]*brightness)) + chr(int(p[2][i]*brightness)) + m += chr(i) + chr(int(p[0][i]*config.BRIGHTNESS)) + chr(int(p[1][i]*config.BRIGHTNESS)) + chr(int(p[2][i]*config.BRIGHTNESS)) else: m.append(i) # Index of pixel to change - m.append(int(p[0][i]*brightness)) # Pixel red value - m.append(int(p[1][i]*brightness)) # Pixel green value - m.append(int(p[2][i]*brightness)) # Pixel blue value + m.append(int(p[0][i]*config.BRIGHTNESS)) # Pixel red value + m.append(int(p[1][i]*config.BRIGHTNESS)) # Pixel green value + m.append(int(p[2][i]*config.BRIGHTNESS)) # Pixel blue value m = m if _is_python_2 else bytes(m) _sock.sendto(m, (config.UDP_IP, config.UDP_PORT)) _prev_pixels = np.copy(p) diff --git a/python/visualization.py b/python/visualization.py index 9354d66f..07ddab72 100644 --- a/python/visualization.py +++ b/python/visualization.py @@ -316,11 +316,13 @@ def freq_slider_change(tick): bright_label = pg.LabelItem('') # Brightness slider def bright_slider_change(tick): - bright_label.setText('Brightness level: {:.0f}%'.format(bright_slider.tickValue(0)*100)) + newBrightness = bright_slider.tickValue(0) + bright_label.setText('Brightness level: {:.0f}%'.format(newBrightness*100)) + config.BRIGHTNESS = newBrightness bright_slider = pg.TickSliderItem(orientation='bottom', allowAdd=True) bright_slider.addTick(1, color='#16dbeb' , movable=True) bright_slider.tickMoveFinished = bright_slider_change - bright_label.setText('Brightness level: {}%'.format(bright_slider.tickValue(0)*100)) + bright_label.setText('Brightness: {}%'.format(bright_slider.tickValue(0)*100)) # Effect selection active_color = '#16dbeb' inactive_color = '#FFFFFF' From 5e84620c261750911b38ad3ec641cc718eedcca7 Mon Sep 17 00:00:00 2001 From: Trenton-Ruf Date: Wed, 4 Sep 2019 23:51:46 -0700 Subject: [PATCH 05/12] might have added brightness for blinkstick --- python/led.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/led.py b/python/led.py index 34a6f223..7f418adf 100644 --- a/python/led.py +++ b/python/led.py @@ -119,9 +119,9 @@ def _update_blinkstick(): # Optional gamma correction p = _gamma[pixels] if config.SOFTWARE_GAMMA_CORRECTION else np.copy(pixels) # Read the rgb values - r = p[0][:].astype(int) - g = p[1][:].astype(int) - b = p[2][:].astype(int) + r = (config.BRIGHTNESS*p[0][:]).astype(int) + g = (config.BRIGHTNESS*p[1][:]).astype(int) + b = (config.BRIGHTNESS*p[2][:]).astype(int) #create array in which we will store the led states newstrip = [None]*(config.N_PIXELS*3) From cfd4f1b2ba136f1985e1d715bf6ead1e7937d1bd Mon Sep 17 00:00:00 2001 From: Trenton-Ruf <48610149+Trenton-Ruf@users.noreply.github.com> Date: Wed, 4 Sep 2019 23:57:16 -0700 Subject: [PATCH 06/12] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index af935e4f..d6967362 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ $RECYCLE.BIN/ .TemporaryItems .Trashes .VolumeIcon.icns +.vscode # Directories potentially created on remote AFP share .AppleDB From dc2008a7b7965e7bf85a7f3dc210105d93585152 Mon Sep 17 00:00:00 2001 From: Trenton-Ruf <48610149+Trenton-Ruf@users.noreply.github.com> Date: Wed, 4 Sep 2019 23:57:51 -0700 Subject: [PATCH 07/12] Delete settings.json --- .vscode/settings.json | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 56fb648d..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "python.pythonPath": "/usr/sbin/python" -} \ No newline at end of file From 07340ccc10ee94001e2e5b3ea08140de081217bb Mon Sep 17 00:00:00 2001 From: Trenton-Ruf Date: Wed, 4 Sep 2019 23:58:45 -0700 Subject: [PATCH 08/12] device esp8266 --- python/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/config.py b/python/config.py index 3779c6e6..10aeb55e 100644 --- a/python/config.py +++ b/python/config.py @@ -3,7 +3,7 @@ from __future__ import division import os -DEVICE = 'blinkstick' +DEVICE = 'esp8266' """Device used to control LED strip. Must be 'pi', 'esp8266' or 'blinkstick' 'esp8266' means that you are using an ESP8266 module to control the LED strip From 6f8c6181db013761c143d995b6b136280d247662 Mon Sep 17 00:00:00 2001 From: Trenton-Ruf Date: Fri, 6 Sep 2019 14:12:08 -0700 Subject: [PATCH 09/12] Initial brightness from config --- python/visualization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/visualization.py b/python/visualization.py index 07ddab72..166cd9fd 100644 --- a/python/visualization.py +++ b/python/visualization.py @@ -320,7 +320,7 @@ def bright_slider_change(tick): bright_label.setText('Brightness level: {:.0f}%'.format(newBrightness*100)) config.BRIGHTNESS = newBrightness bright_slider = pg.TickSliderItem(orientation='bottom', allowAdd=True) - bright_slider.addTick(1, color='#16dbeb' , movable=True) + bright_slider.addTick(config.BRIGHTNESS, color='#16dbeb' , movable=True) bright_slider.tickMoveFinished = bright_slider_change bright_label.setText('Brightness: {}%'.format(bright_slider.tickValue(0)*100)) # Effect selection From 903ea16c821955cb70c13988154018df2d377285 Mon Sep 17 00:00:00 2001 From: Trenton-Ruf Date: Fri, 6 Sep 2019 14:20:19 -0700 Subject: [PATCH 10/12] Starting brightness from config --- python/visualization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/visualization.py b/python/visualization.py index 166cd9fd..1af1b039 100644 --- a/python/visualization.py +++ b/python/visualization.py @@ -322,7 +322,7 @@ def bright_slider_change(tick): bright_slider = pg.TickSliderItem(orientation='bottom', allowAdd=True) bright_slider.addTick(config.BRIGHTNESS, color='#16dbeb' , movable=True) bright_slider.tickMoveFinished = bright_slider_change - bright_label.setText('Brightness: {}%'.format(bright_slider.tickValue(0)*100)) + bright_label.setText('Brightness: {:.0f}%'.format(bright_slider.tickValue(0)*100)) # Effect selection active_color = '#16dbeb' inactive_color = '#FFFFFF' From 85a83c631a859ac8821a700f4d6c2856d656da18 Mon Sep 17 00:00:00 2001 From: Joey Babcock Date: Wed, 23 Oct 2019 18:42:29 -0700 Subject: [PATCH 11/12] Revert to original values --- python/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/config.py b/python/config.py index 10aeb55e..a5cfae4e 100644 --- a/python/config.py +++ b/python/config.py @@ -20,7 +20,7 @@ """Set between 0 and 1 to control LED brightness for pi,esp8266,and blinkstick""" if DEVICE == 'esp8266': - UDP_IP = '192.168.1.150' + UDP_IP = '192.168.0.150' """IP address of the ESP8266. Must match IP in ws2812_controller.ino""" UDP_PORT = 7777 """Port number used for socket communication between Python and ESP8266""" @@ -51,7 +51,7 @@ DISPLAY_FPS = True """Whether to display the FPS when running (can reduce performance)""" -N_PIXELS = 144 +N_PIXELS = 60 """Number of pixels in the LED strip (must match ESP8266 firmware)""" GAMMA_TABLE_PATH = os.path.join(os.path.dirname(__file__), 'gamma_table.npy') From ea8638d3e9c604ff23d98a7e84750ae6a78acc7b Mon Sep 17 00:00:00 2001 From: Joey Babcock Date: Wed, 23 Oct 2019 18:43:21 -0700 Subject: [PATCH 12/12] Revert to original value --- python/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/config.py b/python/config.py index a5cfae4e..c9607982 100644 --- a/python/config.py +++ b/python/config.py @@ -60,7 +60,7 @@ MIC_RATE = 44100 """Sampling frequency of the microphone in Hz""" -FPS = 100 +FPS = 60 """Desired refresh rate of the visualization (frames per second) FPS indicates the desired refresh rate, or frames-per-second, of the audio