Add hardware probe and single-pixel test commands
- probe: toggles LD/CLK, reads DI state at each step, tests single pixel - pixel0/pixel1: single pixel at max brightness for testing - Increased LD pulse timing to 20us - Increased CLK timing to 2us - NeoPixel brightness raised to 80
This commit is contained in:
@@ -21,6 +21,7 @@ public:
|
||||
void show();
|
||||
|
||||
void dump();
|
||||
void probe();
|
||||
|
||||
private:
|
||||
uint8_t pin_dat;
|
||||
|
||||
+24
-2
@@ -30,12 +30,14 @@ void midi_task(void* parameter) {
|
||||
void handle_serial_command(const String& cmd) {
|
||||
if (cmd == "dump" || cmd == "d") {
|
||||
mux.dump();
|
||||
} else if (cmd == "probe" || cmd == "p") {
|
||||
mux.probe();
|
||||
} else if (cmd == "ledon") {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
mux.set_led_color(i, 255, 255, 255);
|
||||
}
|
||||
mux.show();
|
||||
Serial.println("[CMD] All LEDs ON");
|
||||
Serial.println("[CMD] All LEDs WHITE");
|
||||
} else if (cmd == "ledoff") {
|
||||
mux.clear_all();
|
||||
} else if (cmd == "ledtest") {
|
||||
@@ -68,8 +70,28 @@ void handle_serial_command(const String& cmd) {
|
||||
} else if (cmd == "blue") {
|
||||
for (int i = 0; i < 8; i++) mux.set_led_color(i, 0, 0, 255);
|
||||
mux.show();
|
||||
} else if (cmd == "pixel0") {
|
||||
mux.set_led_brightness(255);
|
||||
mux.set_led_color(0, 255, 255, 255);
|
||||
mux.show();
|
||||
Serial.println("[CMD] Pixel 0 WHITE (max brightness)");
|
||||
} else if (cmd == "pixel1") {
|
||||
mux.set_led_brightness(255);
|
||||
mux.set_led_color(1, 255, 255, 255);
|
||||
mux.show();
|
||||
Serial.println("[CMD] Pixel 1 WHITE (max brightness)");
|
||||
} else if (cmd == "help") {
|
||||
Serial.println("[CMD] Commands:");
|
||||
Serial.println(" dump - show button states");
|
||||
Serial.println(" probe - hardware diagnostic");
|
||||
Serial.println(" ledon - all LEDs white");
|
||||
Serial.println(" ledoff - all LEDs off");
|
||||
Serial.println(" ledtest - colour cycle");
|
||||
Serial.println(" read - raw button read");
|
||||
Serial.println(" red/green/blue - solid colour");
|
||||
Serial.println(" pixel0/pixel1 - single pixel test");
|
||||
} else {
|
||||
Serial.println("[CMD] Commands: dump, ledon, ledoff, ledtest, read, red, green, blue");
|
||||
Serial.println("[CMD] Unknown command. Type 'help'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+47
-8
@@ -16,21 +16,22 @@ void PixelStompMux::begin() {
|
||||
|
||||
strip = new Adafruit_NeoPixel(NUM_LEDS, pin_dat, NEO_GRB + NEO_KHZ800);
|
||||
strip->begin();
|
||||
strip->setBrightness(50);
|
||||
strip->setBrightness(80);
|
||||
strip->clear();
|
||||
strip->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 for %d buttons, WS2812C for %d LEDs\n",
|
||||
NUM_BUTTONS, NUM_LEDS);
|
||||
Serial.printf("[MUX] 74HC165 x2 daisy-chain for %d buttons\n", NUM_BUTTONS);
|
||||
Serial.printf("[MUX] WS2812C for %d LEDs\n", NUM_LEDS);
|
||||
Serial.printf("[MUX] DI pin reads: %d\n", digitalRead(pin_di));
|
||||
}
|
||||
|
||||
uint8_t PixelStompMux::read_buttons() {
|
||||
digitalWrite(pin_ld, HIGH);
|
||||
delayMicroseconds(5);
|
||||
delayMicroseconds(20);
|
||||
digitalWrite(pin_ld, LOW);
|
||||
delayMicroseconds(5);
|
||||
delayMicroseconds(20);
|
||||
|
||||
last_button_state = shift_in_74hc165();
|
||||
return last_button_state;
|
||||
@@ -65,7 +66,7 @@ void PixelStompMux::show() {
|
||||
|
||||
void PixelStompMux::dump() {
|
||||
uint8_t buttons = read_buttons();
|
||||
Serial.printf("[MUX] Buttons: 0x%02X (binary: ", buttons);
|
||||
Serial.printf("[MUX] Buttons: 0x%02X (", buttons);
|
||||
for (int i = 7; i >= 0; i--) {
|
||||
Serial.print((buttons >> i) & 1);
|
||||
}
|
||||
@@ -85,10 +86,48 @@ uint8_t PixelStompMux::shift_in_74hc165() {
|
||||
data |= (1 << i);
|
||||
}
|
||||
digitalWrite(pin_clk, HIGH);
|
||||
delayMicroseconds(1);
|
||||
delayMicroseconds(2);
|
||||
digitalWrite(pin_clk, LOW);
|
||||
delayMicroseconds(1);
|
||||
delayMicroseconds(2);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
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...");
|
||||
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));
|
||||
digitalWrite(pin_ld, LOW);
|
||||
delayMicroseconds(10);
|
||||
|
||||
Serial.println(" Toggling CLK 16 times, reading 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);
|
||||
}
|
||||
|
||||
Serial.println(" Testing NeoPixel DAT pin...");
|
||||
if (strip) {
|
||||
strip->setPixelColor(0, strip->Color(255, 255, 255));
|
||||
strip->show();
|
||||
Serial.println(" Set pixel 0 to WHITE - check if it lights up");
|
||||
delay(1000);
|
||||
strip->clear();
|
||||
strip->show();
|
||||
}
|
||||
|
||||
Serial.println("[MUX] === Probe Complete ===");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user