Add rawled bit-bang command, restore FastLED
This commit is contained in:
@@ -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'");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user