Skip to content

Minimum turn ON threshold (including smitt-trigger) #1968

@starkillerOG

Description

@starkillerOG

Feature request

What problem does this feature solve?

My LEDs are very close to the wall (ultra thin TV) and therefore even RGB values like (1,0,0) are already very visable.
This causes anoying and distracting flickering in dark scenes.
In a dark picture the only colors possible are pure RED(1,0,0), pure Green(0,1,0) or pure Blue (0,0,1). So you get sudden shifts from green to blue while the actual picture is same dark color of something inbetween that.
These are rounding issues.
This also has to do with the applied gamma values.

One could use the constant background light as a "solution", but personally I think that is awefull. On a very dark scene with a OLED TV, I want to have the LEDs just OFF. and only highlighting for instance a beam of light from a flashlight on the screen with a couple of LEDs.

Moreover you can get anoying flickering when the LEDs are on the brinck of turning on/off. This is worsend by my HDMI grabber which has some noise.

What does the proposed API look like?

I would like a configurable threshold value, below that value the individual LED would just be off.
This needs to be evaluated for each LED.
In my setup I think I would set a threshold value of 10.

So for example this would happen to the following LED RGB values with a threshold of 10:
(1,0,0) -> (0,0,0)
(3,4,2) -> (0,0,0)
(0,0,9) -> (0,0,0)
(0,9,9) -> (0,0,0)
(10,2,4) -> (10,2,4)
(0,11,0) -> (0,11,0)
(0,0,10) -> (0,0,10)

If possible I smitt-trigger for this threshold would be ideal to minimize flickering.
So for instance a Turn-ON threshold of >=10 and a Turn-OFF threshold of <7.
For instance when tracking 1 LED in time with a pure RED signal:
(1,0,0) -> (0,0,0)
(9,0,0) -> (0,0,0)
(8,0,0) -> (0,0,0)
(10,0,0) -> (10,0,0) went over Turn-ON threshold -> turn on
(11,0,0) -> (11,0,0)
(9,0,0) -> (9,0,0) still above Turn-OFF threshold but below Turn-ON threshold -> keep it on
(8,0,0) -> (8,0,0)
(9,0,0) -> (9,0,0)
(6,0,0) -> (0,0,0) went below Turn-OFF threshold -> turn off
(8,0,0) -> (0,0,0) goes over Turn-OFF threshold but still below Turn-ON threshold -> keep off

Of course this would need to be done for each LED.

How should this be implemented in your opinion?

2 new configuration parameters in the image processing section:

  • Turn-ON threshold
  • Turn-OFF threshold (must always be equal or lower than the Turn-ON threshold)

Default values would be 0, then you have the current behaviour.

1 new memory array with at least the amount of bytes equal to the number of LEDs. This memory array can store in binary for each LED the on/off state (boolean). This is needed for the smitt-trigger.

After all other image processing is applied (brightness gain, gamma etc) evaluate for each pixel if it should be ON or OFF. This is some C example code (not knowing exactly what all the correct variables are etc.

for (int idx=0;idx++;idx<N_LEDs) {
     bool is_on = (ON_MEMORY  >> idx) & 1;
     uint8_t threshold = TURN_ON_THRESHOLD;
     if (is_on) {
         threshold = TURN_OFF_THRESHOLD
     }
     if (red_val[idx] < threshold && green_val[idx] < threshold && blue_val[idx] < threshold) {
         red_val[idx] = 0;
         green_val[idx] = 0;
         blue_val[idx] = 0;
         if (is_on) {
              ON_MEMORY =  ON_MEMORY ^ (1 << idx);  // bitwise XOR
         }
     } else if (!is_on) {
         ON_MEMORY =  ON_MEMORY  |  (1 << idx);    // bitwise OR
     }
}

Are you willing to work on this yourself?

I don't know enough about the project to work on it.
However I know the princeple as shown in the code above, so once there is a basic PR, I can review and test it and probably fix it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions