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

Bug? TFT_eFEX ignores screen offset set on TFT_eSPI #33

Open
zaraken opened this issue Feb 5, 2021 · 2 comments
Open

Bug? TFT_eFEX ignores screen offset set on TFT_eSPI #33

zaraken opened this issue Feb 5, 2021 · 2 comments

Comments

@zaraken
Copy link

zaraken commented Feb 5, 2021

I have roughly the following setup

I have an ESP32 TTGO with ST7789_DRIVER
CGRAM_OFFSET is defined
my code is:

TFT_eSPI tft = TFT_eSPI();
TFT_eFEX tft_x = TFT_eFEX(&tft);

tft.begin();
// tft.setOrientation(1); // setting the orientation on tft object

tft_x.drawJpg(img_buff, buff_size, 0, 0); // ESP32 optimized 

The problem is (was) that the TFT_eFEX::drawJpg was not applying the necessary offset to the picture and as a result the picture was cropped/not centered. And in fact it looked like it was ignoring configurations that are applied to the TFT_eSPI object such as the setOrientation.

I traced it to this line

jpeg.tft = this;

where jpeg.tft is assigned the extended TFT_eFEX object (this same as tft_x from my code above) which is itself also a TFT_eSPI object but not the original one on which the configurations are applied. The original object (tft from my code) is stored in tft_x during TFT_eFEX instantiation here

_tft = tft; // Pointer to tft class so we can call member functions

So I changed the line 1488 to
jpeg.tft = _tft;
and that fixed this particular problem that I had. But I'm not sure if this would create other problems. Is this a bug that I found, or is this just a workaround for my lack of understanding on how to use the library properly?

Alternatively could I instead apply configurations on the extended object directly like so

TFT_eSPI tft = TFT_eSPI();
TFT_eFEX tft_x = TFT_eFEX(&tft);

tft_x.begin();
// tft_x.setOrientation(1); // setting the orientation on tft object

tft_x.drawJpg(img_buff, buff_size, 0, 0); // ESP32 optimized 

And if that is possible do I need to instantiate TFT_eSPI at all ? Can't I just use TFT_eFEX?

@zaraken
Copy link
Author

zaraken commented Feb 5, 2021

One clarification, my code was based on the library's examples https://github.com/Bodmer/TFT_eFEX/blob/master/examples/Jpeg_ESP32/Jpeg_ESP32.ino

@jsmestad
Copy link

jsmestad commented May 9, 2021

@zaraken thanks for the fix. I was having the same issue 👍

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