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

Use of TFT_eSPI_Button corrupts subsequent code causing font size change (& solution) #3507

Open
01010101gene opened this issue Oct 14, 2024 · 0 comments

Comments

@01010101gene
Copy link

The situation is this; Screen A goes to Screen B which has buttons created with TFT_eSPI_Button , then returns to Screen A. After returning to Screen A all the text is wrong size. (2x) Screen A does not use buttons, only Screen B.

This was caused by code in Button.cpp, drawButton() function, line 70 ( _gfx->setTextSize(_textsize); ), that sets the font size multiplier to the value passed in the initialization. In my case 2 for two times base size. That setting is outside of TFT_eSPI_Button and remains set after the button code has finished. Thus the code that comes later still has the font size multiplier set and displays incorrectly.

This was very time consuming to debug but once understood the solution was as simple as calling tft.setTextSize(1) after returning from Screen B, to reset the font size multiplier to unity.

I suggest the code in Button.cpp be modified to reset the font size multiplier to whatever it was upon entry to the drawButton() function. Having global settings like this changed without your knowledge is not unexpected behavior and leads to difficult debugging sessions.

Otherwise, kind regards and thanks for all the good work making this library.

Gene

Version 2.4.80

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

1 participant