Skip to content
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ $RECYCLE.BIN/
.TemporaryItems
.Trashes
.VolumeIcon.icns
.vscode

# Directories potentially created on remote AFP share
.AppleDB
Expand Down
11 changes: 7 additions & 4 deletions python/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
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.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"""
Expand All @@ -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"""
Expand All @@ -48,7 +51,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')
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions python/led.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -72,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(p[0][i]) + chr(p[1][i]) + chr(p[2][i])
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(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]*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)
Expand Down Expand Up @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions python/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,17 @@ 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):
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(config.BRIGHTNESS, color='#16dbeb' , movable=True)
bright_slider.tickMoveFinished = bright_slider_change
bright_label.setText('Brightness: {:.0f}%'.format(bright_slider.tickValue(0)*100))
# Effect selection
active_color = '#16dbeb'
inactive_color = '#FFFFFF'
Expand Down Expand Up @@ -350,6 +361,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
Expand Down