Fix rawled: GRB RED={0x00,0xFF,0x00}, differentiate 0/1 bit timing
This commit is contained in:
+14
-17
@@ -125,29 +125,26 @@ void handle_serial_command(const String& cmd) {
|
|||||||
} else if (cmd == "rawled") {
|
} else if (cmd == "rawled") {
|
||||||
uint8_t pin = 9;
|
uint8_t pin = 9;
|
||||||
Serial.println("[CMD] Bit-bang WS2812: pixel 0 = RED on GPIO 9");
|
Serial.println("[CMD] Bit-bang WS2812: pixel 0 = RED on GPIO 9");
|
||||||
uint32_t colour = 0x00FF00;
|
uint8_t colour[] = {0x00, 0xFF, 0x00};
|
||||||
noInterrupts();
|
noInterrupts();
|
||||||
for (int i = 0; i < 24; i++) {
|
for (int byte_idx = 0; byte_idx < 3; byte_idx++) {
|
||||||
if (colour & (1 << (23 - i))) {
|
uint8_t val = colour[byte_idx];
|
||||||
digitalWrite(pin, HIGH);
|
for (int bit = 7; bit >= 0; bit--) {
|
||||||
esp_rom_delay_us(800);
|
gpio_set_level((gpio_num_t)pin, 1);
|
||||||
digitalWrite(pin, LOW);
|
if (val & (1 << bit)) {
|
||||||
esp_rom_delay_us(450);
|
esp_rom_delay_us(1);
|
||||||
} else {
|
}
|
||||||
digitalWrite(pin, HIGH);
|
gpio_set_level((gpio_num_t)pin, 0);
|
||||||
esp_rom_delay_us(400);
|
if (!(val & (1 << bit))) {
|
||||||
digitalWrite(pin, LOW);
|
esp_rom_delay_us(1);
|
||||||
esp_rom_delay_us(850);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 7; i++) {
|
gpio_set_level((gpio_num_t)pin, 0);
|
||||||
digitalWrite(pin, LOW);
|
esp_rom_delay_us(50);
|
||||||
esp_rom_delay_us(50);
|
|
||||||
}
|
|
||||||
interrupts();
|
interrupts();
|
||||||
Serial.println("[CMD] Sent. Wait 2 sec...");
|
Serial.println("[CMD] Sent. Wait 2 sec...");
|
||||||
delay(2000);
|
delay(2000);
|
||||||
digitalWrite(pin, LOW);
|
|
||||||
Serial.println("[CMD] Done");
|
Serial.println("[CMD] Done");
|
||||||
} else {
|
} else {
|
||||||
Serial.println("[CMD] Unknown command. Type 'help'");
|
Serial.println("[CMD] Unknown command. Type 'help'");
|
||||||
|
|||||||
Reference in New Issue
Block a user