Add rawled bit-bang command, restore FastLED

This commit is contained in:
2026-06-23 14:39:46 +00:00
parent 6c678ce18a
commit bec8025f0a
4 changed files with 46 additions and 21 deletions
+28
View File
@@ -121,6 +121,34 @@ void handle_serial_command(const String& cmd) {
Serial.println(" red/green/blue - solid colour");
Serial.println(" pixel0/pixel1 - single pixel test");
Serial.println(" gpiotest - raw GPIO pin diagnostic");
Serial.println(" rawled - bit-bang WS2812 (no library)");
} else if (cmd == "rawled") {
uint8_t pin = 9;
Serial.println("[CMD] Bit-bang WS2812: pixel 0 = RED on GPIO 9");
uint32_t colour = 0x00FF00;
noInterrupts();
for (int i = 0; i < 24; i++) {
if (colour & (1 << (23 - i))) {
digitalWrite(pin, HIGH);
esp_rom_delay_us(800);
digitalWrite(pin, LOW);
esp_rom_delay_us(450);
} else {
digitalWrite(pin, HIGH);
esp_rom_delay_us(400);
digitalWrite(pin, LOW);
esp_rom_delay_us(850);
}
}
for (int i = 0; i < 7; i++) {
digitalWrite(pin, LOW);
esp_rom_delay_us(50);
}
interrupts();
Serial.println("[CMD] Sent. Wait 2 sec...");
delay(2000);
digitalWrite(pin, LOW);
Serial.println("[CMD] Done");
} else {
Serial.println("[CMD] Unknown command. Type 'help'");
}