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:
+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