From 6c678ce18a47247f49f1877503b53b525c55c05c Mon Sep 17 00:00:00 2001 From: Ashley Strahle Date: Tue, 23 Jun 2026 14:35:15 +0000 Subject: [PATCH] Add raw GPIO test command to diagnose pin connectivity --- src/main.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 10f1e62..559fe40 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -80,6 +80,36 @@ void handle_serial_command(const String& cmd) { mux.set_led_color(1, 255, 255, 255); mux.show(); 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") { Serial.println("[CMD] Commands:"); 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(" red/green/blue - solid colour"); Serial.println(" pixel0/pixel1 - single pixel test"); + Serial.println(" gpiotest - raw GPIO pin diagnostic"); } else { Serial.println("[CMD] Unknown command. Type 'help'"); }