changes for raspberry pi 3
This commit is contained in:
parent
a2fa8df006
commit
0ba74fd6ed
@ -12,7 +12,7 @@ use_defaults = {"configuration": True, # See notes bel
|
|||||||
settings = { # All settings are stored in this dict
|
settings = { # All settings are stored in this dict
|
||||||
|
|
||||||
"configuration":{ # Program configuration
|
"configuration":{ # Program configuration
|
||||||
'USE_GUI': True, # Whether to display the GUI
|
'USE_GUI': False, # Whether to display the GUI
|
||||||
'DISPLAY_FPS': False, # Whether to print the FPS when running (can reduce performance)
|
'DISPLAY_FPS': False, # Whether to print the FPS when running (can reduce performance)
|
||||||
'MIC_RATE': 48000, # Sampling frequency of the microphone in Hz
|
'MIC_RATE': 48000, # Sampling frequency of the microphone in Hz
|
||||||
'FPS': 60, # Desired refresh rate of the visualization (frames per second)
|
'FPS': 60, # Desired refresh rate of the visualization (frames per second)
|
||||||
@ -32,17 +32,17 @@ settings = { # All settings
|
|||||||
|
|
||||||
# All devices and their respective settings. Indexed by name, call each one what you want.
|
# All devices and their respective settings. Indexed by name, call each one what you want.
|
||||||
"devices":{"Desk Strip":{
|
"devices":{"Desk Strip":{
|
||||||
"configuration":{"TYPE": "ESP8266", # Device type (see below for all supported boards)
|
"configuration":{"TYPE": "RaspberryPi", # Device type (see below for all supported boards)
|
||||||
# Required configuration for device. See below for all required keys per device
|
# Required configuration for device. See below for all required keys per device
|
||||||
"AUTO_DETECT": True, # Set this true if you're using windows hotspot to connect (see below for more info)
|
"LED_INVERT": False, # Set this true if you're using windows hotspot to connect (see below for more info)
|
||||||
"MAC_ADDR": "2c-3a-e8-2f-2c-9f", # MAC address of the ESP8266. Only used if AUTO_DETECT is True
|
"LED_PIN": 18, # MAC address of the ESP8266. Only used if AUTO_DETECT is True
|
||||||
"UDP_IP": "192.168.1.208", # IP address of the ESP8266. Must match IP in ws2812_controller.ino
|
"LED_FREQ_HZ": 800000, # IP address of the ESP8266. Must match IP in ws2812_controller.ino
|
||||||
"UDP_PORT": 7778, # Port number used for socket communication between Python and ESP8266
|
"LED_DMA": 5, # Port number used for socket communication between Python and ESP8266
|
||||||
"MAX_BRIGHTNESS": 250, # Max brightness of output (0-255) (my strip sometimes bugs out with high brightness)
|
"MAX_BRIGHTNESS": 250, # Max brightness of output (0-255) (my strip sometimes bugs out with high brightness)
|
||||||
# Other configuration
|
# Other configuration
|
||||||
"N_PIXELS": 58, # Number of pixels in the LED strip (must match ESP8266 firmware)
|
"N_PIXELS": 150, # Number of pixels in the LED strip (must match ESP8266 firmware)
|
||||||
"N_FFT_BINS": 24, # Number of frequency bins to use when transforming audio to frequency domain
|
"N_FFT_BINS": 24, # Number of frequency bins to use when transforming audio to frequency domain
|
||||||
"current_effect": "Energy" # Currently selected effect for this board, used as default when program launches
|
"current_effect": "Power" # Currently selected effect for this board, used as default when program launches
|
||||||
},
|
},
|
||||||
|
|
||||||
# Configurable options for this board's effects go in this dictionary.
|
# Configurable options for this board's effects go in this dictionary.
|
||||||
@ -77,7 +77,7 @@ settings = { # All settings
|
|||||||
"b_multiplier": 1.0, # How much blue
|
"b_multiplier": 1.0, # How much blue
|
||||||
"blur": 0.2}, # Amount of blur to apply
|
"blur": 0.2}, # Amount of blur to apply
|
||||||
"Power": {"color_mode": "Spectral", # Colour gradient to display
|
"Power": {"color_mode": "Spectral", # Colour gradient to display
|
||||||
"s_count": 20, # Initial number of sparks
|
"s_count": 0, # Initial number of sparks
|
||||||
"s_color": "White", # Color of sparks
|
"s_color": "White", # Color of sparks
|
||||||
"mirror": True, # Mirror output down central axis
|
"mirror": True, # Mirror output down central axis
|
||||||
"flip_lr":False}, # Flip output left-right
|
"flip_lr":False}, # Flip output left-right
|
||||||
@ -102,79 +102,7 @@ settings = { # All settings
|
|||||||
"g": 100,
|
"g": 100,
|
||||||
"b": 100}
|
"b": 100}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"Main Strip":{
|
|
||||||
"configuration":{"TYPE": "ESP8266", # Device type (see below for all supported boards)
|
|
||||||
# Required configuration for device. See below for all required keys per device
|
|
||||||
"AUTO_DETECT": True, # Set this true if you're using windows hotspot to connect (see below for more info)
|
|
||||||
"MAC_ADDR": "5c-cf-7f-f0-8c-f3", # MAC address of the ESP8266. Only used if AUTO_DETECT is True
|
|
||||||
"UDP_IP": "192.168.1.208", # IP address of the ESP8266. Must match IP in ws2812_controller.ino
|
|
||||||
"UDP_PORT": 7778, # Port number used for socket communication between Python and ESP8266
|
|
||||||
"MAX_BRIGHTNESS": 180, # Max brightness of output (0-255) (my strip sometimes bugs out with high brightness)
|
|
||||||
# Other configuration
|
|
||||||
"N_PIXELS": 226, # Number of pixels in the LED strip (must match ESP8266 firmware)
|
|
||||||
"N_FFT_BINS": 24, # Number of frequency bins to use when transforming audio to frequency domain
|
|
||||||
"current_effect": "Single" # Currently selected effect for this board, used as default when program launches
|
|
||||||
},
|
|
||||||
|
|
||||||
# Configurable options for this board's effects go in this dictionary.
|
|
||||||
# Usage: config.settings["devices"][name]["effect_opts"][effect][option]
|
|
||||||
"effect_opts":{"Energy": {"blur": 1, # Amount of blur to apply
|
|
||||||
"scale":0.9, # Width of effect on strip
|
|
||||||
"r_multiplier": 1.0, # How much red
|
|
||||||
"g_multiplier": 1.0, # How much green
|
|
||||||
"b_multiplier": 1.0}, # How much blue
|
|
||||||
"Wave": {"color_wave": "Red", # Colour of moving bit
|
|
||||||
"color_flash": "White", # Colour of flashy bit
|
|
||||||
"wipe_len":5, # Initial length of colour bit after beat
|
|
||||||
"decay": 0.7, # How quickly the flash fades away
|
|
||||||
"wipe_speed":2}, # Number of pixels added to colour bit every frame
|
|
||||||
"Spectrum": {"r_multiplier": 1.0, # How much red
|
|
||||||
"g_multiplier": 1.0, # How much green
|
|
||||||
"b_multiplier": 1.0}, # How much blue
|
|
||||||
"Wavelength":{"roll_speed": 0, # How fast (if at all) to cycle colour overlay across strip
|
|
||||||
"color_mode": "Spectral", # Colour gradient to display
|
|
||||||
"mirror": False, # Reflect output down centre of strip
|
|
||||||
"reverse_grad": False, # Flip (LR) gradient
|
|
||||||
"reverse_roll": False, # Reverse movement of gradient roll
|
|
||||||
"blur": 3.0, # Amount of blur to apply
|
|
||||||
"flip_lr":False}, # Flip output left-right
|
|
||||||
"Scroll": {"lows_color": "Red", # Colour of low frequencies
|
|
||||||
"mids_color": "Green", # Colour of mid frequencies
|
|
||||||
"high_color": "Blue", # Colour of high frequencies
|
|
||||||
"decay": 0.995, # How quickly the colour fades away as it moves
|
|
||||||
"speed": 1, # Speed of scroll
|
|
||||||
"r_multiplier": 1.0, # How much red
|
|
||||||
"g_multiplier": 1.0, # How much green
|
|
||||||
"b_multiplier": 1.0, # How much blue
|
|
||||||
"blur": 0.2}, # Amount of blur to apply
|
|
||||||
"Power": {"color_mode": "Spectral", # Colour gradient to display
|
|
||||||
"s_count": 20, # Initial number of sparks
|
|
||||||
"s_color": "White", # Color of sparks
|
|
||||||
"mirror": True, # Mirror output down central axis
|
|
||||||
"flip_lr":False}, # Flip output left-right
|
|
||||||
"Single": {"color": "Purple"}, # Static color to show
|
|
||||||
"Beat": {"color": "Red", # Colour of beat flash
|
|
||||||
"decay": 0.7}, # How quickly the flash fades away
|
|
||||||
"Bars": {"resolution":4, # Number of "bars"
|
|
||||||
"color_mode":"Spectral", # Multicolour mode to use
|
|
||||||
"roll_speed":0, # How fast (if at all) to cycle colour colours across strip
|
|
||||||
"mirror": False, # Mirror down centre of strip
|
|
||||||
#"reverse_grad": False, # Flip (LR) gradient
|
|
||||||
"reverse_roll": False, # Reverse movement of gradient roll
|
|
||||||
"flip_lr":False}, # Flip output left-right
|
|
||||||
"Gradient": {"color_mode":"Spectral", # Colour gradient to display
|
|
||||||
"roll_speed": 0, # How fast (if at all) to cycle colour colours across strip
|
|
||||||
"mirror": False, # Mirror gradient down central axis
|
|
||||||
"reverse": False}, # Reverse movement of gradient
|
|
||||||
"Fade": {"color_mode":"Spectral", # Colour gradient to fade through
|
|
||||||
"roll_speed": 1, # How fast (if at all) to fade through colours
|
|
||||||
"reverse": False}, # Reverse "direction" of fade (r->g->b or r<-g<-b)
|
|
||||||
"Calibration":{"r": 100,
|
|
||||||
"g": 100,
|
|
||||||
"b": 100}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@ -360,7 +288,7 @@ for board in settings["devices"]:
|
|||||||
settings["devices"][board]["configuration"]["SOFTWARE_GAMMA_CORRECTION"] = False
|
settings["devices"][board]["configuration"]["SOFTWARE_GAMMA_CORRECTION"] = False
|
||||||
else:
|
else:
|
||||||
raise ValueError("Invalid device selected. Device {} not known.".format(settings["devices"][board]["configuration"]["TYPE"]))
|
raise ValueError("Invalid device selected. Device {} not known.".format(settings["devices"][board]["configuration"]["TYPE"]))
|
||||||
settings["devices"][board]["effect_opts"]["Power"]["s_count"] = settings["devices"][board]["configuration"]["N_PIXELS"]//6
|
#settings["devices"][board]["effect_opts"]["Power"]["s_count"] = settings["devices"][board]["configuration"]["N_PIXELS"]//6
|
||||||
# Cheeky lil fix in case the user sets an odd number of LEDs
|
# Cheeky lil fix in case the user sets an odd number of LEDs
|
||||||
if settings["devices"][board]["configuration"]["N_PIXELS"] % 2:
|
if settings["devices"][board]["configuration"]["N_PIXELS"] % 2:
|
||||||
settings["devices"][board]["configuration"]["N_PIXELS"] -= 1
|
settings["devices"][board]["configuration"]["N_PIXELS"] -= 1
|
||||||
|
@ -255,7 +255,7 @@ class RaspberryPi(LEDController):
|
|||||||
rgb = np.bitwise_or(np.bitwise_or(r, g), b)
|
rgb = np.bitwise_or(np.bitwise_or(r, g), b)
|
||||||
# Update the pixels
|
# Update the pixels
|
||||||
for i in range(n_pixels):
|
for i in range(n_pixels):
|
||||||
self.strip._led_data[i] = rgb[i]
|
self.strip._led_data[i] = int(rgb[i])
|
||||||
self.strip.show()
|
self.strip.show()
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,8 +16,9 @@ def start_stream(callback):
|
|||||||
prev_ovf_time = time.time()
|
prev_ovf_time = time.time()
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
y = np.fromstring(stream.read(frames_per_buffer), dtype=np.int16)
|
y = np.fromstring(stream.read(frames_per_buffer, exception_on_overflow=False), dtype=np.int16)
|
||||||
y = y.astype(np.float32)
|
y = y.astype(np.float32)
|
||||||
|
stream.read(stream.get_read_available(), exception_on_overflow=False)
|
||||||
callback(y)
|
callback(y)
|
||||||
except IOError:
|
except IOError:
|
||||||
overflows += 1
|
overflows += 1
|
||||||
|
File diff suppressed because one or more lines are too long
@ -13,12 +13,12 @@ import lib.melbank as melbank
|
|||||||
import lib.devices as devices
|
import lib.devices as devices
|
||||||
import random
|
import random
|
||||||
from PyQt5.QtCore import QSettings
|
from PyQt5.QtCore import QSettings
|
||||||
if config.settings["configuration"]["USE_GUI"]:
|
#if config.settings["configuration"]["USE_GUI"]:
|
||||||
from lib.qrangeslider import QRangeSlider
|
from lib.qrangeslider import QRangeSlider
|
||||||
from lib.qfloatslider import QFloatSlider
|
from lib.qfloatslider import QFloatSlider
|
||||||
import pyqtgraph as pg
|
import pyqtgraph as pg
|
||||||
from PyQt5.QtCore import *
|
from PyQt5.QtCore import *
|
||||||
from PyQt5.QtWidgets import *
|
from PyQt5.QtWidgets import *
|
||||||
|
|
||||||
class Visualizer():
|
class Visualizer():
|
||||||
def __init__(self, board):
|
def __init__(self, board):
|
||||||
@ -1332,7 +1332,7 @@ def microphone_update(audio_samples):
|
|||||||
# Visualization for each board
|
# Visualization for each board
|
||||||
for board in boards:
|
for board in boards:
|
||||||
# Get visualization output for each board
|
# Get visualization output for each board
|
||||||
audio_input = audio_datas[board]["vol"] > config.settings["configuration"]["MIN_VOLUME_THRESHOLD"]
|
audio_input = (audio_datas[board]["vol"]) > (config.settings["configuration"]["MIN_VOLUME_THRESHOLD"])
|
||||||
outputs[board] = visualizers[board].get_vis(audio_datas[board]["mel"], audio_input)
|
outputs[board] = visualizers[board].get_vis(audio_datas[board]["mel"], audio_input)
|
||||||
# Map filterbank output onto LED strip(s)
|
# Map filterbank output onto LED strip(s)
|
||||||
boards[board].show(outputs[board])
|
boards[board].show(outputs[board])
|
||||||
@ -1359,8 +1359,8 @@ def microphone_update(audio_samples):
|
|||||||
app.processEvents()
|
app.processEvents()
|
||||||
|
|
||||||
# Left in just in case prople dont use the gui
|
# Left in just in case prople dont use the gui
|
||||||
elif vol < config.settings["configuration"]["MIN_VOLUME_THRESHOLD"]:
|
elif audio_datas[board]["vol"] < config.settings["configuration"]["MIN_VOLUME_THRESHOLD"]:
|
||||||
print("No audio input. Volume below threshold. Volume: {}".format(vol))
|
print("No audio input. Volume below threshold. Volume: {}".format(audio_datas[board]["vol"]))
|
||||||
if config.settings["configuration"]["DISPLAY_FPS"]:
|
if config.settings["configuration"]["DISPLAY_FPS"]:
|
||||||
print('FPS {:.0f} / {:.0f}'.format(fps, config.settings["configuration"]["FPS"]))
|
print('FPS {:.0f} / {:.0f}'.format(fps, config.settings["configuration"]["FPS"]))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user