Better MUX probe: 5 rounds, CLK before/after DI reads, single LED test
This commit is contained in:
@@ -23,13 +23,21 @@ bool UsbMidiTransport::begin() {
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
Serial.println("[MIDI] USB MIDI ready");
|
||||
Serial.println("[MIDI] USB MIDI ready - enumerating...");
|
||||
return true;
|
||||
}
|
||||
|
||||
void UsbMidiTransport::update() {
|
||||
if (!initialized) return;
|
||||
|
||||
static uint32_t last_status = 0;
|
||||
uint32_t now = millis();
|
||||
if (now - last_status > 5000) {
|
||||
last_status = now;
|
||||
Serial.printf("[MIDI] USB mounted: %s\n",
|
||||
TinyUSBDevice.mounted() ? "YES" : "NO");
|
||||
}
|
||||
|
||||
while (usb_midi.available()) {
|
||||
uint8_t packet[4];
|
||||
if (usb_midi.readPacket(packet)) {
|
||||
|
||||
+38
-22
@@ -1,7 +1,7 @@
|
||||
#include "pixel_stomp_mux.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
#define ROXMUX_DELAY 1
|
||||
#define ROXMUX_DELAY 2
|
||||
|
||||
PixelStompMux::PixelStompMux(uint8_t dat, uint8_t ld, uint8_t clk, uint8_t di)
|
||||
: pin_dat(dat), pin_ld(ld), pin_clk(clk), pin_di(di),
|
||||
@@ -9,35 +9,41 @@ PixelStompMux::PixelStompMux(uint8_t dat, uint8_t ld, uint8_t clk, uint8_t di)
|
||||
}
|
||||
|
||||
void PixelStompMux::begin() {
|
||||
pinMode(pin_di, INPUT);
|
||||
pinMode(pin_clk, OUTPUT);
|
||||
pinMode(pin_ld, OUTPUT);
|
||||
pinMode(pin_di, INPUT);
|
||||
|
||||
digitalWrite(pin_clk, LOW);
|
||||
digitalWrite(pin_ld, HIGH);
|
||||
|
||||
FastLED.addLeds<WS2812, 9, GRB>(leds, NUM_LEDS);
|
||||
FastLED.setBrightness(80);
|
||||
delay(100);
|
||||
|
||||
FastLED.addLeds<WS2812B, 9, GRB>(leds, NUM_LEDS);
|
||||
FastLED.setBrightness(128);
|
||||
fill_solid(leds, NUM_LEDS, CRGB::Black);
|
||||
FastLED.show();
|
||||
|
||||
Serial.printf("[MUX] Init DAT=%d LD=%d CLK=%d DI=%d\n",
|
||||
pin_dat, pin_ld, pin_clk, pin_di);
|
||||
Serial.printf("[MUX] 74HC165 x2 daisy-chain, WS2812C x%d LEDs (FastLED)\n", NUM_LEDS);
|
||||
Serial.printf("[MUX] DI raw at init: %d\n", digitalRead(pin_di));
|
||||
}
|
||||
|
||||
uint8_t PixelStompMux::read_buttons() {
|
||||
digitalWrite(pin_clk, LOW);
|
||||
delayMicroseconds(ROXMUX_DELAY);
|
||||
|
||||
digitalWrite(pin_ld, LOW);
|
||||
delayMicroseconds(ROXMUX_DELAY);
|
||||
digitalWrite(pin_ld, HIGH);
|
||||
delayMicroseconds(ROXMUX_DELAY);
|
||||
|
||||
uint8_t data = 0;
|
||||
for (int i = 7; i >= 0; i--) {
|
||||
digitalWrite(pin_clk, LOW);
|
||||
delayMicroseconds(ROXMUX_DELAY);
|
||||
bitWrite(data, i, digitalRead(pin_di));
|
||||
digitalWrite(pin_clk, HIGH);
|
||||
delayMicroseconds(ROXMUX_DELAY);
|
||||
digitalWrite(pin_clk, LOW);
|
||||
delayMicroseconds(ROXMUX_DELAY);
|
||||
}
|
||||
|
||||
last_button_state = data;
|
||||
@@ -85,33 +91,43 @@ void PixelStompMux::dump() {
|
||||
|
||||
void PixelStompMux::probe() {
|
||||
Serial.println("[MUX] === Hardware Probe ===");
|
||||
Serial.printf(" DI (GPIO %d) raw: %d\n", pin_di, digitalRead(pin_di));
|
||||
|
||||
Serial.println(" Testing LD pin (RoxMux protocol)...");
|
||||
digitalWrite(pin_ld, LOW);
|
||||
delayMicroseconds(10);
|
||||
Serial.printf(" LD=LOW, DI=%d\n", digitalRead(pin_di));
|
||||
for (int round = 0; round < 5; round++) {
|
||||
Serial.printf("--- Round %d ---\n", round);
|
||||
|
||||
digitalWrite(pin_clk, LOW);
|
||||
digitalWrite(pin_ld, HIGH);
|
||||
delayMicroseconds(10);
|
||||
Serial.printf(" LD=HIGH, DI=%d\n", digitalRead(pin_di));
|
||||
|
||||
Serial.println(" Toggling CLK 16 times, reading DI...");
|
||||
Serial.printf(" Before latch: DI=%d\n", digitalRead(pin_di));
|
||||
|
||||
digitalWrite(pin_ld, LOW);
|
||||
delayMicroseconds(10);
|
||||
Serial.printf(" LD=LOW: DI=%d\n", digitalRead(pin_di));
|
||||
|
||||
digitalWrite(pin_ld, HIGH);
|
||||
delayMicroseconds(10);
|
||||
Serial.printf(" LD=HIGH: DI=%d\n", digitalRead(pin_di));
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
bool bit = digitalRead(pin_di);
|
||||
Serial.printf(" CLK %2d: DI=%d\n", i, bit);
|
||||
digitalWrite(pin_clk, HIGH);
|
||||
delayMicroseconds(5);
|
||||
digitalWrite(pin_clk, LOW);
|
||||
delayMicroseconds(5);
|
||||
bool bit_before = digitalRead(pin_di);
|
||||
digitalWrite(pin_clk, HIGH);
|
||||
delayMicroseconds(5);
|
||||
bool bit_after = digitalRead(pin_di);
|
||||
Serial.printf(" CLK %2d: before=%d after=%d\n", i, bit_before, bit_after);
|
||||
}
|
||||
|
||||
Serial.println(" Testing FastLED DAT pin...");
|
||||
fill_solid(leds, NUM_LEDS, CRGB::White);
|
||||
delay(500);
|
||||
}
|
||||
|
||||
Serial.println(" LED test: pixel 0 RED (max brightness)...");
|
||||
leds[0] = CRGB(255, 0, 0);
|
||||
FastLED.setBrightness(255);
|
||||
FastLED.show();
|
||||
Serial.println(" All pixels WHITE (max brightness) - check if they light up");
|
||||
delay(2000);
|
||||
fill_solid(leds, NUM_LEDS, CRGB::Black);
|
||||
leds[0] = CRGB::Black;
|
||||
FastLED.show();
|
||||
|
||||
Serial.println("[MUX] === Probe Complete ===");
|
||||
|
||||
Reference in New Issue
Block a user