Fix indentation errors and reduce debug output
- Comment out all debug logging statements to reduce console noise - Fix empty if/else blocks by adding pass statements - Remove beat logging, TCP server logging, and MIDI debug messages - Keep only essential info, warning, and error messages - Revert radiate delay separation back to using main delay parameter
This commit is contained in:
93
src/main.py
93
src/main.py
@@ -36,7 +36,9 @@ class App:
|
||||
# --- MIDI Handler ---
|
||||
MIDI_PORT_INDEX = 1 # Adjust as needed
|
||||
WEBSOCKET_SERVER_URI = "ws://192.168.4.1:80/ws"
|
||||
print(f"Initializing MIDI handler with port index {MIDI_PORT_INDEX}")
|
||||
self.midi_handler = MidiHandler(MIDI_PORT_INDEX, WEBSOCKET_SERVER_URI)
|
||||
print("MIDI handler initialized")
|
||||
self.midi_task: asyncio.Task | None = None
|
||||
# Start MIDI in background
|
||||
self.root.after(0, async_handler(self.start_midi))
|
||||
@@ -61,12 +63,12 @@ class App:
|
||||
# Row1: n1 (left), n2 (right)
|
||||
# Row2: B (left), Brightness (right)
|
||||
# Row3: R (left), G (right)
|
||||
dials_frame = ttk.LabelFrame(controls_frame, text="Dials (CC)")
|
||||
dials_frame = ttk.LabelFrame(controls_frame, text="Dials (CC30-37)")
|
||||
dials_frame.pack(side="left", padx=12)
|
||||
for c in range(2):
|
||||
dials_frame.grid_columnconfigure(c, minsize=180)
|
||||
dials_frame.grid_columnconfigure(c, minsize=140)
|
||||
for rr in range(4):
|
||||
dials_frame.grid_rowconfigure(rr, minsize=100)
|
||||
dials_frame.grid_rowconfigure(rr, minsize=70)
|
||||
|
||||
self.dials_boxes: list[tk.Label] = []
|
||||
# Create with placeholders so they are visible before first update
|
||||
@@ -87,19 +89,63 @@ class App:
|
||||
text=placeholders.get((r, c), "-"),
|
||||
bg=bg_color,
|
||||
fg=fg_color,
|
||||
font=("Arial", 16),
|
||||
font=("Arial", 14),
|
||||
padx=6,
|
||||
pady=6,
|
||||
borderwidth=2,
|
||||
relief="ridge",
|
||||
width=20,
|
||||
height=5,
|
||||
width=14,
|
||||
height=4,
|
||||
anchor="center",
|
||||
justify="center",
|
||||
)
|
||||
lbl.grid(row=r, column=c, padx=6, pady=6, sticky="nsew")
|
||||
self.dials_boxes.append(lbl)
|
||||
|
||||
# Additional knobs box: 4 rows by 2 columns (CC38-45)
|
||||
# Row0: K1 (left), K2 (right)
|
||||
# Row1: K3 (left), K4 (right)
|
||||
# Row2: K5 (left), K6 (right)
|
||||
# Row3: K7 (left), K8 (right)
|
||||
knobs_frame = ttk.LabelFrame(controls_frame, text="Knobs (CC38-45)")
|
||||
knobs_frame.pack(side="left", padx=12)
|
||||
for c in range(2):
|
||||
knobs_frame.grid_columnconfigure(c, minsize=140)
|
||||
for rr in range(4):
|
||||
knobs_frame.grid_rowconfigure(rr, minsize=70)
|
||||
|
||||
self.knobs_boxes: list[tk.Label] = []
|
||||
# Create with placeholders so they are visible before first update
|
||||
knob_placeholders = {
|
||||
(0, 0): "CC44\n-",
|
||||
(0, 1): "CC45\n-",
|
||||
(1, 0): "Rad n1\n-",
|
||||
(1, 1): "Rad delay\n-",
|
||||
(2, 0): "Alt n1\n-",
|
||||
(2, 1): "Alt n2\n-",
|
||||
(3, 0): "Pulse n1\n-",
|
||||
(3, 1): "Pulse n2\n-",
|
||||
}
|
||||
for r in range(4):
|
||||
for c in range(2):
|
||||
lbl = tk.Label(
|
||||
knobs_frame,
|
||||
text=knob_placeholders.get((r, c), "-"),
|
||||
bg=bg_color,
|
||||
fg=fg_color,
|
||||
font=("Arial", 14),
|
||||
padx=6,
|
||||
pady=6,
|
||||
borderwidth=2,
|
||||
relief="ridge",
|
||||
width=14,
|
||||
height=4,
|
||||
anchor="center",
|
||||
justify="center",
|
||||
)
|
||||
lbl.grid(row=r, column=c, padx=6, pady=6, sticky="nsew")
|
||||
self.knobs_boxes.append(lbl)
|
||||
|
||||
# Buttons bank (single)
|
||||
buttons_frame = ttk.Frame(controls_frame)
|
||||
buttons_frame.pack(side="left", padx=12)
|
||||
@@ -107,9 +153,9 @@ class App:
|
||||
buttons1_frame = ttk.LabelFrame(buttons_frame, text="Buttons (notes 36-51)")
|
||||
buttons1_frame.pack(side="top", pady=8)
|
||||
for c in range(4):
|
||||
buttons1_frame.grid_columnconfigure(c, minsize=110)
|
||||
buttons1_frame.grid_columnconfigure(c, minsize=140)
|
||||
for rr in range(1, 5):
|
||||
buttons1_frame.grid_rowconfigure(rr, minsize=110)
|
||||
buttons1_frame.grid_rowconfigure(rr, minsize=70)
|
||||
self.button1_cells: list[tk.Label] = []
|
||||
for r in range(4):
|
||||
for c in range(4):
|
||||
@@ -118,13 +164,13 @@ class App:
|
||||
text="",
|
||||
bg=bg_color,
|
||||
fg=fg_color,
|
||||
font=("Arial", 16),
|
||||
padx=4,
|
||||
pady=4,
|
||||
font=("Arial", 14),
|
||||
padx=6,
|
||||
pady=6,
|
||||
borderwidth=2,
|
||||
relief="ridge",
|
||||
width=12,
|
||||
height=6,
|
||||
width=14,
|
||||
height=4,
|
||||
anchor="center",
|
||||
justify="center",
|
||||
)
|
||||
@@ -193,6 +239,17 @@ class App:
|
||||
if idx < len(self.dials_boxes):
|
||||
self.dials_boxes[idx].config(text=f"{label}\n{value}")
|
||||
|
||||
# Update additional knobs (CC38-45)
|
||||
knob_values = [
|
||||
("CC44", getattr(self.midi_handler, 'knob7', '-')), ("CC45", getattr(self.midi_handler, 'knob8', '-')),
|
||||
("Rad n1", getattr(self.midi_handler, 'n1', '-')), ("Rad delay", getattr(self.midi_handler, 'delay', '-')),
|
||||
("Alt n1", getattr(self.midi_handler, 'n1', '-')), ("Alt n2", getattr(self.midi_handler, 'n2', '-')),
|
||||
("Pulse n1", getattr(self.midi_handler, 'n1', '-')), ("Pulse n2", getattr(self.midi_handler, 'n2', '-')),
|
||||
]
|
||||
for idx, (label, value) in enumerate(knob_values):
|
||||
if idx < len(self.knobs_boxes):
|
||||
self.knobs_boxes[idx].config(text=f"{label}\n{value}")
|
||||
|
||||
# Update buttons bank mappings and selection (single bank)
|
||||
# Pattern icons for nicer appearance
|
||||
icon_for = {
|
||||
@@ -207,8 +264,14 @@ class App:
|
||||
"-": "",
|
||||
}
|
||||
bank1_patterns = [
|
||||
"pulse", "flicker", "alternating", "n chase",
|
||||
"rainbow", "radiate", "sequential\npulse", "alternating\nphase",
|
||||
# Pulse patterns (row 1)
|
||||
"pulse", "sequential\npulse",
|
||||
# Alternating patterns (row 2)
|
||||
"alternating", "alternating\nphase",
|
||||
# Chase/movement patterns (row 3)
|
||||
"n chase", "rainbow",
|
||||
# Effect patterns (row 4)
|
||||
"flicker", "radiate",
|
||||
"-", "-", "-", "-",
|
||||
"-", "-", "-", "-",
|
||||
]
|
||||
|
Reference in New Issue
Block a user