Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some a bit incorrect color and shade gradations #373

Closed
Kouzeru opened this issue Jan 19, 2023 · 3 comments · Fixed by #374
Closed

Some a bit incorrect color and shade gradations #373

Kouzeru opened this issue Jan 19, 2023 · 3 comments · Fixed by #374

Comments

@Kouzeru
Copy link
Contributor

Kouzeru commented Jan 19, 2023

I'm putting some sort of image test to display some hue and value spectrum,
I got some noticeable color banding when using this driver:
20230114_193023

I had deployed another technique to actually do the BCM properly, thus, displaying more faithful hue and value spectrum:
20230114_193048
(with the cost of sacrificing 1/4 of the total brightness of course, due to limitation of my driver)

Here;s the code of the test image

  char t = millis()>>4;
  for(int x=0;x<128;x++)
    for(int y=0;y<64;y++)
      dma_display->drawPixelRGB888(x,y,
      (uint8_t)((max(min(cosf(2.f*PI*((x-t)/128.f+0.f/3.f))+0.5f,1.f),0.f)*((y+1.f)/64.f))*255.f),
      (uint8_t)((max(min(cosf(2.f*PI*((x-t)/128.f+1.f/3.f))+0.5f,1.f),0.f)*((y+1.f)/64.f))*255.f),
      (uint8_t)((max(min(cosf(2.f*PI*((x-t)/128.f+2.f/3.f))+0.5f,1.f),0.f)*((y+1.f)/64.f))*255.f)
      );
@mrcodetastic
Copy link
Owner

Can you confirm if you get this issue when using version 3.0.0 of the library?

I may have introduced a bug when I fiddled with the way brightness is managed in the most recent version

@Kouzeru
Copy link
Contributor Author

Kouzeru commented Jan 19, 2023

I had tested the version 3.0.0; it still yields the exact same result:
20230119_223835

But I'd think I could try reproduce how your driver translate the colors:
128x32

which was plotted pixel by pixel in python code

u -= 2
r = int((max(min(sin((u/8+0/3)*pi*2)+0.5,1),0)*(1-v)/2)*255)
g = int((max(min(sin((u/8+1/3)*pi*2)+0.5,1),0)*(1-v)/2)*255)
b = int((max(min(sin((u/8+2/3)*pi*2)+0.5,1),0)*(1-v)/2)*255)
r0,r1,r2,r3,r4,r5=r>>7&1,r>>6&1,r>>5&1,r>>4&1,r>>3&1,r>>2&1
g0,g1,g2,g3,g4,g5=g>>7&1,g>>6&1,g>>5&1,g>>4&1,g>>3&1,g>>2&1
b0,b1,b2,b3,b4,b5=b>>7&1,b>>6&1,b>>5&1,b>>4&1,b>>3&1,b>>2&1
r,g,b=r0*4+r1*2+r2+r3+r4,g0*4+g1*2+g2+g3+g4,b0*4+b1*2+b2+b3+b4
sqrt(r/9)*256,sqrt(g/9)*256,sqrt(b/9)*256

@Kouzeru
Copy link
Contributor Author

Kouzeru commented Jan 20, 2023

The pull request #374 will fix the following artifacts
128x64
213625174-24d5bac6-34f6-48c6-922f-afb42b16d496
into
128x64
213625222-f4a95251-7afc-4b6b-b17a-c82908cb26c4

And I already had thorough tests, and only this is was complaint of the driver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants