androdlang / TFTShape

2D graphics library for ESP8266/ESP32
MIT License
68 stars 14 forks source link

Help #2

Closed momosh13 closed 5 years ago

momosh13 commented 5 years ago

Hello. I'm dreaming to use "MacBook Pro Touch Bar Volume control" graphics in me project with touch screen. Please see this

.

I'm using TFT-eSPI, this is the best library i think. I'm having no lock to stop the flicker. I'm using ILI9488 or ILI9341 with capacitive touch, the "Touch" part is fine, no problem, but the i'm having hard time with graphics, let say moving white slider on top of the gray. This is part of me code

include

include

TFT_eSPI tft = TFT_eSPI();

int x=70, old_x=70, a=1;

void setup(void) { tft.begin(); tft.setRotation(3); tft.fillScreen(TFT_BLACK);

} void loop() { tft.fillRoundRect(65, 190, 345, 45, 7, 0x31C7 ); tft.fillRoundRect(90, 210, (x-60), 8, 1, TFT_BLUE ); tft.fillRoundRect((40+x), 210, (350-x), 8, 1, TFT_WHITE ); x=x+a; if (x==60 || x==350) { a = -a; } delay(5); if(old_x!=x){
tft.fillRoundRect((old_x+10), 190, 50, 45, 7, 0x31C7 ); } tft.fillRoundRect((x+10), 190, 50, 45, 7, 0xFFFF ); old_x=x;
}

So Please if possible, if you have time help me with this on. Thank you in advanced !!!

androdlang commented 5 years ago

Hi, to have flicker-free content, you'll need an offscreen surface (TFT-eSprite ist the equivalent object). See the example in the examples dir and trace the usage of the preprocesser macro #define OFFSCREEN, this will help you for your problem.

momosh13 commented 5 years ago

Thank you very much. Looks like OFFSCREEN did what I need. I'm having only one issue with my screen which is bigger (480x320) ILI9488 Your library is supporting up to 320x320. So is it possible to correct or change your library that will work correctly with my screen? Thanks.

image

androdlang commented 5 years ago

Your library is supporting up to 320x320 No, there is no restriction at the resolution at all.

You have to adapt following code to your need (see the sample code):

tft2.createSprite(240,320); //Display dimension <= change it here Depending on your need, you can create an offscreen sprite for the whole screen, but you can also specify one or more sprites with a lower dimension (which is much faster for redraw). Hope this helps, Greetings

momosh13 commented 5 years ago

Thank you for replay. I know about tft2.createSprite(240,320); but when I'm trying to increase 240 to higher number, it goes up to 320 fine, but 320 and higher numbers the screen goes Black, the screen not printing any graphics. Please help me. Thank you

androdlang commented 5 years ago

Well maybe I can help you, but I first want to say your issue has nothing to do with the TShape library but of the underlying library TFT_eSPI. Anyway, I think I can help because I guess where your problem is: I think you are running out of memory. Which hardware do you use? ESP32-WROOM or WROVER? WROVER has enough SPI-memory (4MB) which can be activated with a compiler setting... First check your memory with "Serial.println(esp_get_free_heap_size());".

androdlang commented 5 years ago

Log esp_get_free_heap_size() before and after the createSprite call

momosh13 commented 5 years ago

This is the board 4 MB Flash WEMOS Lolin32

momosh13 commented 5 years ago

And one more thing. I'm using ESP32_PARALLEL Mode, it's lot faster then SPI mode

momosh13 commented 5 years ago

One more thing The part of the screen where I have a picture, it's unbelievable, it's working just like on MacBook Pro Touch screen. it's perfect!!! You're Genius !!!

androdlang commented 5 years ago

Parallel or SPI doesn't matter for offscreen memory. A quick look into wikipedia -> 4MB ram, but check it for sure with esp_get_free_heap_size() ! I'm pretty sure your memory is to small, I had the same modue and the same problem. There are two options to resolve your problem: 1) Do you really wand a full offscreen memory? If not, you can design partial areas, where your screen remains untouched and you push a smaller sprite only to the areas where needed. I use this technique a lot because mostly not all of the screen has to be updated and it's much faster then to update the whole screen! 2) you can config your memtable and reseve smaller amount of memory for other modules. Google for this subject, I've no experience with that, but I red that this can be done. Anyway, I would prefere the first option.

androdlang commented 5 years ago

One more thing!!!!!!!!! You can save memory if you're using setColorDepth(8); before creating the sprite. If you dont't specify, the defaut setting of TFT_eSPI is 16, which uses double of the memory.

momosh13 commented 5 years ago

I'm not home right now, in couple hours I'll test everything, and I'll let you know. Thank you

momosh13 commented 5 years ago

Hi You're 100% right, I cut the Sprite area, and everything works, see the picture. When i'm trying to ready memory size ( Serial.println(esp_get_free_heap_size()); ) before tft2.pushSprite(0,150); i'm geting same number 193212, maybe i'm doing somthing wrong, please tell me how to do it. And one more thing, this board is from ebay/china, you thing i can find WEMOS Lolin32 with right memory?

Thank you !!!

image

androdlang commented 5 years ago

with pushSprite(0,150); you will never allocate memory (width=zero), you mut have at least one pixel height. Well, to find th right memory, I only can say the Esp-WROVER chip has 4M extra memory on chip. I'm using an ODROID-Go whoch has the WROVER on board, for other systems google.

momosh13 commented 5 years ago

First, Happy New year !!!! Thank you for helping me last time. Question, can I use this some how for drawFloat and drawNumber to stop flickering? Thank you again.