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

tft_eSPI printf not using bg colour #21

Open
beng2k opened this issue Feb 1, 2023 · 6 comments
Open

tft_eSPI printf not using bg colour #21

beng2k opened this issue Feb 1, 2023 · 6 comments
Labels
progress: waiting for confirmation and close Waiting for confirmation and close

Comments

@beng2k
Copy link

beng2k commented Feb 1, 2023

Hello there,

I am trying to update text in a sprite. The numbers are displayed in the right position and using the same setCursor position. The numbers are not clearing despite setting the background colour to match the background. Here is a code snippet of the updating of the text. I cant see what I could be doing wrong?

    ofr.setDrawer(DATA3gauge);
    ofr.setFontColor(TFT_ORANGE, TFT_BLACK);
    ofr.setFontSize(35);
    ofr.setCursor(79,55);
    ofr.cprintf("ERR");
    DATA3gauge.pushSprite(320,0);
@takkaO
Copy link
Owner

takkaO commented Feb 2, 2023

Thank you for using this library 😊

Unfortunately, I have never used the sprite feature.
Please tell me the smallest code that can reproduce the issue in my environment.
And what microcontroller you are using.

Thank you.

@MikeyMoMo
Copy link

MikeyMoMo commented Feb 9, 2023

Note: The full demo program for OpenFontRender library I wrote is here: https://github.com/MikeyMoMo/OpenFontRender-Example-program

I have noticed the same thing. Just throw something on screen with foreground and background colors set. The background color is ignored. If you want it, that is a very good thing -- an invisible background color not changing the background of the characters. However, if you want the background color to happen, it is not good the way it is. I am writing to two different sprites and to the base tft screen.

Here is a code snippet I wrote to check out every non-trivial call in your API listing. I posted elsewhere with other errors that came up while writing and testing this program such as text height is wrong and the bounding box is wrong.

Here, the background color setting (done 2 ways) is ignored anyway. The letters come out white on black, not red.

  tft.fillScreen(TFT_BLACK);
  // Alignment Left
  // If the second font color is missing, it will be written invisible and the background color
  //  already on the screen will not be changed.  To change it, use a second color like this:
  render.setFontColor(TFT_WHITE, TFT_RED);  // Foreground, Background (optional)
  // Note, it can also be set by 8 bit hex values.  Foreground only or foreground and background, as above.
  //  render.setFontColor(0x50, 0x70, 0x150); // Mostly blue, a little green and less red. FG only set.
  //  ...or...
  //  render.setFontColor(0x50, 0x70, 0x150, 0x150, 0x70, 0x50);  // Set FG and BG to custom colors.
  //
  // You can also set the background color, only, thus:
  render.setBackgroundColor(TFT_RED);  // Change BG color only, leave font color as already set.
 
  // So far, the background color setting does nothing.  Maybe this is by design.

  // Alignment left
  render.setCursor(0, 0);
  render.printf("Hello\nWorld size ");  // Only foreground color honored.

@beng2k
Copy link
Author

beng2k commented Feb 9, 2023

As above. Sorry for the delay.
I can pull some code but this above looks very similar to what I have done as well.

As above it seems as though the background colour is ignored

@MikeyMoMo
Copy link

MikeyMoMo commented Feb 9, 2023

I just uploaded my full demo code that shows this (not) happening. It also shows how to use all but the most trivial calls to this library and even shows some of the trivial ones. It is my first Github repository. Please be kind... ;-))
It is here:

https://github.com/MikeyMoMo/OpenFontRender-Demo-program

There is a notation that the font BG color is not being used. I am not sure if that is in a sprite but it fails. I could do it to a sprite if necessary. I use OFR for both sprites and background (tft) screen writes and it operates the same both ways. Also under MikeyMoMo is a very full featured clock/calendar program that uses OFR for almost everything, sprites and tft writes. All works pretty well. Just a few little bugs to work out. SO glad to have this library!!!

@takkaO
Copy link
Owner

takkaO commented May 1, 2023

From v1.1, you can select background fill method.
Try using the setBackgroundFillMethod() function.
See GitHub Pages for details.

I am really sorry for the late update🙇‍♂️🙇‍♂️🙇‍♂️

@takkaO takkaO added the progress: waiting for confirmation and close Waiting for confirmation and close label May 1, 2023
@MikeyMoMo
Copy link

This works. The lines I used are:

      scrollSprite.fillRect(trackTimeDate, 0, scrollSpriteW, scrollSpriteH, DarkBlue);
      ofr.setDrawer(scrollSprite);
      ofr.setFontColor(TFT_WHITE, DarkBlue);
      ofr.setBackgroundFillMethod(BgFillMethod::Block);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
progress: waiting for confirmation and close Waiting for confirmation and close
Projects
None yet
Development

No branches or pull requests

3 participants