cat-in-136 / ws2812-esp32-rmt-driver

WS2812 driver using ESP32 RMT for Rust
MIT License
40 stars 21 forks source link

RGB values 1 and 2 == 0 (LED off). Invalid scaling somewhere inside the library? #10

Closed faern closed 2 years ago

faern commented 2 years ago

Code

Using ws2812_esp32_rmt_driver at the latest commit (8625018) and the following code:

use smart_leds_trait::SmartLedsWrite;
use std::thread::sleep;
use std::time::Duration;
use ws2812_esp32_rmt_driver::{Ws2812Esp32Rmt, RGB8};

const INTENSITY: u8 = 2;

fn main() -> ! {
    esp_idf_sys::link_patches();

    let mut ws2812 = Ws2812Esp32Rmt::new(0, 27).unwrap();
    let pixels = std::iter::repeat(RGB8 {
        r: INTENSITY,
        g: 0,
        b: 0,
    })
    .take(25);
    ws2812.write(pixels).unwrap();

    loop {
        sleep(Duration::from_millis(100));
    }
}

Actual results

All leds completely turned off

Expected results

The first 25 LEDs should have the red channel turned on with a low but visible intensity.

Notes

if I change INTENSITY to 3 the first 25 LEDs turn very dim red. The same applies for the green and blue channels. So it seems like somewhere in the library the RGB values 1 and 2 are scaled down to 0? With other ws2812 crates for other microcontrollers I'm able to use the values 1 and 2 for individual color channels and have the LED turn on.

faern commented 2 years ago

I also suspect that intensity 3 is scaled down to 1 before it actually hits the LED strip. Because the brightness I see for INTENSITY = 3 is very similar to what I usually expect a brightness value of 1 to have.

cat-in-136 commented 2 years ago

This behavior is seen with other C++ library such as FastLED. And I believe that threshold is depending on devices (LED strips).

faern commented 2 years ago

Strange. I'm sure it works in https://github.com/jgarff/rpi_ws281x. But maybe that library is doing some scaling up of low values then.. I guess I have to dive in and look more at the code. And also try some other strip models I have laying around.

faern commented 2 years ago

I'm sorry, my bad! You are correct in that it depends on the strip itself. It turns out I tried this library out on a roll of LED-strip I have never used before. When hooked it up to my RPi and used the same software I usually use, this strip is completely turned off for RGB values of 0-2 there as well. And conversely hooking up my "regular" strips to the ESP with this software, they are shining as expected for RGB values 1-2.

Sorry for the confusion. Closing this issue since the error was on my side.