Open schw4rzlicht opened 10 months ago
Interesting, I believe a similar issue might be present in here https://github.com/ph1p/ikea-led-obegraensad/blob/5ad09fa4c06fedfa00d01e3898202d4ef1ea0244/src/screen.cpp#L19
Could it be that some data is written beyond the render buffer? My guess is that this might be the actual cause of #49 instead.
Can this be closed with #64 being merged?
I am not really sure as it's unclear to me how to interpret value
and brightness
. Imo there are two ways:
value
should be the brightness of the pixel which is then scaled based on brightness
→ result = round( value * brightness / 255 )
value
doesn't matter and is more or less only an indicator for on / off
(that's how it was implemented in #64) which makes it redundant and can therefore be removed (only rely on brightness
from now on)Of course the overflow issue is fixed now but I think the intended usage of setPixel / setPixelAtIndex
became less intuitive.
Hey there,
I just noticed that when calculating brightness when using
Screen.setPixelAtIndex()
orScreen.setPixel()
,uint8_t value
is multiplied withuint8_t brightness
and the result is stored to therenderBuffer
which is an array ofunit8_t
.https://github.com/ph1p/ikea-led-obegraensad/blob/5ad09fa4c06fedfa00d01e3898202d4ef1ea0244/src/screen.cpp#L96-L110
I would interpret
value
as well asbrightness
to be something between 0 and 255, but that would quickly lead to an integer overflow, e.g.value = 255, brightness = 255 → renderBuffer[i] = 1
.Is this really the desired behavior? If not, I'd volunteer to implement a fix, but I'd like to discuss the how first.
Thanks!