Dynamically Change Orientation? #931
-
In our application, I would like to be able to dynamically change the orientation. Currently we are initializing like so: tft = new TFT_eSPI();
tft->begin();
tft->setFreeFont(&FreeSans12pt7b);
tft->setSwapBytes(true);
tft->initDMA();
if (config.invertTFT)
{
tft->setRotation(1);
delay(20);
}
else
{
tft->setRotation(3);
delay(20);
} There's no tft->deInitDMA();
tft->endWrite();
delete tft; But, while doing a really good job of stopping the display, when I re-init as above the screen does not initialize. I thought maybe there was something simple I was missing and you might be able to point me in the right direction? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi @Bodmer, I was wondering if you had any ideas for me here? Possible and I've missed something easy? |
Beta Was this translation helpful? Give feedback.
-
The library class for the TFT has no destructor and thus can not be "ended". The rationale was that if a TFT is connected then the instance can be global as it is unlikely the dislay will only be used once. The memory footprint is quite low compared to the RTOS etc on an ESP32 so I have never seen the need to end the library instance. You can change the rotation at any time, (example) you do not need to stop and start with a new instance. The display can be re-initialised by calling tft.begin() again as there is a boot lock that only runs part of the initiailisation the second time it is called. This permits the display to be powered down and restarted later. |
Beta Was this translation helpful? Give feedback.
-
Brilliant! Just what I needed, thank you. I'm glad I included the "why" when I asked. |
Beta Was this translation helpful? Give feedback.
The library class for the TFT has no destructor and thus can not be "ended". The rationale was that if a TFT is connected then the instance can be global as it is unlikely the dislay will only be used once. The memory footprint is quite low compared to the RTOS etc on an ESP32 so I have never seen the need to end the library instance.
You can change the rotation at any time, (example) you do not need to stop and start with a new instance. The display can be re-initialised by calling tft.begin() again as there is a boot lock that only runs part of the initiailisation the second time it is called. This permits the display to be powered down and restarted later.