Add raw GPIO test command to diagnose pin connectivity
This commit is contained in:
@@ -80,6 +80,36 @@ void handle_serial_command(const String& cmd) {
|
|||||||
mux.set_led_color(1, 255, 255, 255);
|
mux.set_led_color(1, 255, 255, 255);
|
||||||
mux.show();
|
mux.show();
|
||||||
Serial.println("[CMD] Pixel 1 WHITE (max brightness)");
|
Serial.println("[CMD] Pixel 1 WHITE (max brightness)");
|
||||||
|
} else if (cmd == "gpiotest") {
|
||||||
|
Serial.println("[CMD] === Raw GPIO Test ===");
|
||||||
|
uint8_t pins[] = {9, 10, 11, 12};
|
||||||
|
const char* names[] = {"DAT(9)", "LD(10)", "CLK(11)", "DI(12)"};
|
||||||
|
for (int p = 0; p < 4; p++) {
|
||||||
|
uint8_t pin = pins[p];
|
||||||
|
pinMode(pin, INPUT_PULLUP);
|
||||||
|
delay(10);
|
||||||
|
int hi = digitalRead(pin);
|
||||||
|
pinMode(pin, INPUT_PULLDOWN);
|
||||||
|
delay(10);
|
||||||
|
int lo = digitalRead(pin);
|
||||||
|
pinMode(pin, INPUT);
|
||||||
|
delay(10);
|
||||||
|
int fl = digitalRead(pin);
|
||||||
|
Serial.printf(" %s: PULLUP=%d PULLDOWN=%d FLOAT=%d\n", names[p], hi, lo, fl);
|
||||||
|
}
|
||||||
|
Serial.println(" Testing DAT(9) output toggle...");
|
||||||
|
pinMode(9, OUTPUT);
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
digitalWrite(9, HIGH);
|
||||||
|
delayMicroseconds(100);
|
||||||
|
int readback = digitalRead(9);
|
||||||
|
Serial.printf(" HIGH -> readback=%d\n", readback);
|
||||||
|
digitalWrite(9, LOW);
|
||||||
|
delayMicroseconds(100);
|
||||||
|
readback = digitalRead(9);
|
||||||
|
Serial.printf(" LOW -> readback=%d\n", readback);
|
||||||
|
}
|
||||||
|
Serial.println("[CMD] === GPIO Test Complete ===");
|
||||||
} else if (cmd == "help") {
|
} else if (cmd == "help") {
|
||||||
Serial.println("[CMD] Commands:");
|
Serial.println("[CMD] Commands:");
|
||||||
Serial.println(" dump - show button states");
|
Serial.println(" dump - show button states");
|
||||||
@@ -90,6 +120,7 @@ void handle_serial_command(const String& cmd) {
|
|||||||
Serial.println(" read - raw button read");
|
Serial.println(" read - raw button read");
|
||||||
Serial.println(" red/green/blue - solid colour");
|
Serial.println(" red/green/blue - solid colour");
|
||||||
Serial.println(" pixel0/pixel1 - single pixel test");
|
Serial.println(" pixel0/pixel1 - single pixel test");
|
||||||
|
Serial.println(" gpiotest - raw GPIO pin diagnostic");
|
||||||
} else {
|
} else {
|
||||||
Serial.println("[CMD] Unknown command. Type 'help'");
|
Serial.println("[CMD] Unknown command. Type 'help'");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user