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

how to clearRect or setColor on SSD1306 ?? #74

Open
RoboDurden opened this issue Nov 24, 2021 · 2 comments
Open

how to clearRect or setColor on SSD1306 ?? #74

RoboDurden opened this issue Nov 24, 2021 · 2 comments

Comments

@RoboDurden
Copy link

Sorry for another simple question :-/
Have found nothing in your nice https://codedocs.xyz/lexus2k/lcdgfx/index.html

I only want to clear a small region like a clearRect(0,0,32,16); to prevent the flickering of display.clear();.
Or is there a way to set the color to black like display.setColor(RGB_COLOR8(0,0,0)); ?

My workaround: display.printFixed(x, y, " ");

Thanks again :-)

@lexus2k
Copy link
Owner

lexus2k commented Nov 25, 2021

Hi

I only want to clear a small region like a clearRect(0,0,32,16); to prevent the flickering of display.clear();.
Or is there a way to set the color to black like display.setColor(RGB_COLOR8(0,0,0)); ?

The way for you is to use fillRect() and setColor() methods.

Best regards

@RoboDurden
Copy link
Author

Thank you, this indeed works:

      display.setColor(RGB_COLOR8(0,0,0));
      display.fillRect(x,y,x+32,y+16);

I had only tested this with no success:

      display.setColor(RGB_COLOR8(0,0,0));
      display.printFixed(x, y, s, STYLE_BOLD);

This however has an effect:

      display.setColor(RGB_COLOR8(0,0,0));
      display.invertColors();
      display.printFixed(x, y, s, STYLE_BOLD);

That setColor(0) makes invertColors having no effect.

setColor(255) enables it again:

  display.setColor(RGB_COLOR8(255,255,255));
  display.invertColors();    
  display.printFixed(x, y, s, STYLE_BOLD);

So what confuses me is that this has no effect:

    display.setColor(RGB_COLOR8(0,0,0));
   display.printFixed(x, y, s, STYLE_BOLD);

So for printFixed, the setColor function is rather a setBackgroundColor.
Whereas for fillRect the setColor function is setting the paint color.

It is still nice because printing text will overwrite the area anyway (which i had not been aware of and therefore wanted a clearRect). So no need to set background and forground color but one call to invertColor will do it.

A bit confusing but i have no idea for you how to do it better :-)

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

No branches or pull requests

2 participants