How to use and why to use Sprites (TFT_espi Programing tutorial)

Sdílet
Vložit
  • čas přidán 6. 07. 2022
  • In this tutorial I will show you how easy is to use basic sprites when you are using TFT display for your project. Sprites are great to avoid flickering of display, to avoid delay function. They are great when you need to update your screen very often.
    I decided to use TTGO T-Display because built in tft display.
    You can buy TTGO here: www.banggood.c...
    TUTORIALS
    PART1: • How to use TFT_eSPI li...
    PART2: • How to use TFT_eSPI li...
    PART3: • How to program TTGO T-...
    Here is code:
    You can buy me coffee here: ko-fi.com/volo...
    Don't forget to subscribe! Tnx!
  • Věda a technologie

Komentáře • 137

  • @christopherlawes9286
    @christopherlawes9286 Před rokem +29

    This is the first video of yours I have seen. For me as a beginner, the way you have gone through this is fantastic! Thank you so much.

    • @VolosProjects
      @VolosProjects  Před rokem +2

      Thank you Christopher, i am glad I helped.

    • @kennethbeal
      @kennethbeal Před rokem

      @@VolosProjects Thank you so much for your videos! Just bought you a dozen coffees. Don't drink all at once! :) Thanks again.

    • @qsdrfghgujfddyffguff
      @qsdrfghgujfddyffguff Před rokem

      yes me also

  • @jeffreymorris1752
    @jeffreymorris1752 Před rokem +6

    Great instructional videos! I remember using sprites in 1983 (40 years ago!) on a Commodore 64. Those were 24×21 pixels and if your sprite resembled anything beyond a blocky blob then you were having a very good day.

  • @jamesmor5305
    @jamesmor5305 Před rokem +2

    I really like the way you structure this video, because it reflects the ways a normal beginner will start over and you shot hot to be a pro

  • @Narfusala
    @Narfusala Před 2 lety +7

    I haven't started watching, but already am super happy you made this one... i've been trying to understand what a sprite is/does and how to use it to make a little game... but i was still confused a lot! BTW, i normally dont comment on YT, but i just want to say i love your video's, i bought a couple of these ESP32's with a build-in screen for a little project and learned so much from your video's!!!

    • @VolosProjects
      @VolosProjects  Před 2 lety +3

      Thank you for your support, i hope this tutorial will help you.

  • @raymondmichael4987
    @raymondmichael4987 Před 2 lety +2

    Dude, That's quite huge collection of displays for a single person.
    Thanks

  • @arlo4051
    @arlo4051 Před 2 lety +3

    Thank you for the explanations of how this works, quality information on how to program for the LCD is excellent.

  • @TBoy58_405
    @TBoy58_405 Před 2 lety +7

    Haven’t played with sprites since the days of Commodore 64 (showing my age 😄). Wish I understood them then like I do now. Many thanks! 👍🏾🤓

  • @larsjongkees198
    @larsjongkees198 Před rokem

    thank you so much for making video's with this esp board. I picked it for a school project with basicly 0 programming experience, and then i could find almost zero information on how to program it. Your videos saved my project!

  • @carloslemos6443
    @carloslemos6443 Před 2 lety +4

    Nice job... I was trying to put lots of code on my Lilygo T-watch (with your graphs and others that I like) and now I'm understanding a little better how do it

  • @Egon3k
    @Egon3k Před rokem +1

    i like how you just chill in your garden and make great content for us :)

  • @jimsnodgrass8454
    @jimsnodgrass8454 Před rokem +1

    Very helpful. Seems like learning to use Sprite's is critical to developing great projects. this is a Great video to show why.. Thanks jimS

  • @thadsr240
    @thadsr240 Před 3 měsíci

    not sure when i subscribed but every time i hear you say subscribe i look, this time i'll say thanks for putting so much information out! these display manufacturers should send you free screens every time and pay you!!

  • @fluiditynz
    @fluiditynz Před rokem +1

    Fast to draw front arc and erase rear arc to move circle from an edge.(But beware of undrawn pixels for thin line). Also should always pause after changes to permit persistance of human vision to load the new image to brain. In ideal world, 20ms for recalculations and delay to give 50 frames per second. Ah... I am watching as typing. So I'm theorising that the operations are made to fast ESP32 RAM instead of TFT and then DMA load from RAM to TFT with your img.push operation. Thanks for tutorial!

  • @M.Voelkel
    @M.Voelkel Před 2 měsíci

    Danke dir Volo für die Mühe die du dir gemacht hast - ich konnte viel lernen, zumal mir jetzt vieles klar geworden ist.

  • @qbalsdon
    @qbalsdon Před 2 měsíci

    Simple, practical and even had birds chirping!

  • @chipko
    @chipko Před 2 lety +3

    Once again an interesting and incredibly useful video. Thank you so much!

  • @MPElectronique
    @MPElectronique Před rokem +1

    I'M IN LOVE WITH THE SPRITES NOW :)

  • @marshall100w6
    @marshall100w6 Před rokem +1

    Interesting. Never dis anything with sprites. I’ll try to use them. Thanks one more time. 🤘🏽🤘🏽🤘🏽.

  • @openroot
    @openroot Před 26 dny +1

    So basically drawing to an offscreen buffer, then drawing all in one blit, its goood

  • @sebalew2642
    @sebalew2642 Před 2 lety +2

    Very useful, looking forward to next sprites tutorials!

  • @nicktucker4916
    @nicktucker4916 Před 2 lety +1

    Excellent! That was a very good demo of using sprites

  • @sito3453
    @sito3453 Před 2 lety

    Thank you Volos! I have learned a lot from this video. You explain it in a very clear and funny way. Congratulations!!

    • @VolosProjects
      @VolosProjects  Před 2 lety

      Thank you, i hope this will be usefull for you. Cheers from Croatia

  • @Tony770jr
    @Tony770jr Před 2 lety +1

    Nice example! Looking forward for more with sprites..

  • @brianmiller6320
    @brianmiller6320 Před 2 lety +2

    Nice Pizza oven! Good tutorial.

  • @RicardoPenders
    @RicardoPenders Před rokem

    WOW, that was easy... Thanks for sharing, it is very much appreciated here.

  • @donaldkormos5529
    @donaldkormos5529 Před 2 lety +1

    Thank you very much ... I did learn something new!!!

  • @phaquasystems2685
    @phaquasystems2685 Před 4 měsíci

    Absolutely clear explanation thanks

  • @mashurshalehin4972
    @mashurshalehin4972 Před 2 lety +13

    It would be great if you could explain the theory and why it's smoother and better than the other approach. I want to know the behind the scenes implementation process.

    • @1over137
      @1over137 Před rokem +6

      The sprite library waits and draws with the refresh. Basically "vSync"

    • @mashurshalehin4972
      @mashurshalehin4972 Před rokem +3

      @@1over137 Is it like this, it saves the whole frame in memory and refreshes the whole frame with one shot?

    • @1over137
      @1over137 Před rokem +8

      @@mashurshalehin4972 Not necessarily. There are several ways to do it. The approach you suggest would be called "double frame buffer", where you one complete frame ready to go as soon as the display refreshes and you have another frame which the CPU id drawing into.
      When you complete your drawing, the frames are swapped (usually just by readdressing the memory which is actually read by the display. So no memory moves or is copied, it's just the screen render is pointed to a different frame.
      The flicker is caused by the software writing into the frame that is currently on screen, so you see a series of partial images as one partial frames get drawn on each screen before it switches.
      The other way with single buffer, you just wait for the refresh and write the buffer as fast as the screen draws.
      The better way to have this implemented would be to have a parameter to UpdateDisplay() which is True/False and denotes if the display should wait on the refresh or render immediately.

  • @headbangersworld
    @headbangersworld Před rokem

    Interesantno. Razlika je, da se operacie kod sprite rade u memoriji a ne na ekran, tek na kraju se sprite odlikuje na ekran. Sto ukupno ispadne brze i kao neka vrsta doublebuffera. Mozda bi mogao jos i da uklonis ove dve operatie sa "TFT_BLACK" i da koristis "fillSprite(TFT_BLACK)" na pocetku. Po specifikaciju bi moglo biti jos malo brze :)

  • @qbitsday3438
    @qbitsday3438 Před rokem +1

    Subscribed Instantly!

  • @jamesclifford194
    @jamesclifford194 Před 5 měsíci

    Hey, firstly, thanks for a great video, I'm learning a lot about Arduino/ESP32 at the moment and this has been really informative. Secondly would you mind sharing the sketch for the fuel gauge shown at 20secs? I want to make a speedo gauge and the asthetic of yours is exactly what I'm hoping to achieve. Thanks again!

  • @markfairchild6264
    @markfairchild6264 Před rokem

    Thank you! Coffee coming your way!

  • @zyghom
    @zyghom Před rokem

    perfect! I spent so much time on looking for such thingis ;-)

  • @jonathanshaw5186
    @jonathanshaw5186 Před 5 měsíci

    Thanks for another great video!

  • @psprophet
    @psprophet Před rokem

    Liked, favorited, subscribed and appreciated!

  • @gordsh1
    @gordsh1 Před 6 měsíci

    Please do a tutorial / video on how to design a pcb board from a simple circuit using software.

  • @digihz_data
    @digihz_data Před 2 lety

    Great info.
    Sprite is like a backbufferr I think

  • @StephenLiljedahl
    @StephenLiljedahl Před rokem

    Great tutorial, very informative.

  • @AJB2K3
    @AJB2K3 Před rokem

    6:21 that's actually a useful bug!

  • @nikthefix8918
    @nikthefix8918 Před 2 lety +1

    When ever I hear the word 'Sprite' I think of Mr Claypole in Rentaghost.

  • @Zoonie81
    @Zoonie81 Před rokem

    You rock dude, thanks 👍🏼

  • @yakacm
    @yakacm Před 2 lety

    Very cool, TY for sharing.

  • @steverileyretired
    @steverileyretired Před 4 měsíci

    Very Good

  • @rynait
    @rynait Před rokem

    was commodore user and did use sprite concept alot. my explanation version to newbie. you are drawing graphic to memory (not to screen), after you done draw graphic (into memory), copy the memory to screen., done, rinse and repeat.
    to some (and on old computers) yes, this slightly slow graphics viewing-play. but the slowness is offset by the speed of cpu processing the code, modern computer makes it useless because the cpu is far faster and flicker comes back. interesting is unfazed by small development boards.

  • @Scudmaster11
    @Scudmaster11 Před 11 měsíci

    "Takes a drink of sprite while watching a video that is talking about sprites"

  • @qsdrfghgujfddyffguff
    @qsdrfghgujfddyffguff Před rokem

    great sir..very useful

  • @kunkhmer5246
    @kunkhmer5246 Před 2 lety +1

    Thank you very much for your tutorials,...How do you speed up Sprites? It seems to be very slow as compared to non-Sprites.

  • @eugenecrane6093
    @eugenecrane6093 Před rokem

    Cool!!! thanks l use ttgo t4

  • @raymondmichael4987
    @raymondmichael4987 Před 2 lety

    Please, I need more on this topic

  • @jrathmer
    @jrathmer Před rokem

    Thank you! That helped a lot understanding (:

    • @VolosProjects
      @VolosProjects  Před rokem +1

      Thank you Jan ,for comment and for coffee😀

  • @yakhoubsurya2657
    @yakhoubsurya2657 Před 11 měsíci

    Nice 👍🏻

  • @egorovsa
    @egorovsa Před rokem

    Hey hey Bro! Thanks too much for the tutorial.!

  • @ChrisHalden007
    @ChrisHalden007 Před rokem

    Great video. Thanks

  • @SonalK
    @SonalK Před 4 měsíci

    How do you know which displays are supported? I've a few ST7735 TFT displays, flickers a lot and low resolution

  • @MPElectronique
    @MPElectronique Před 2 lety

    here we go!!!! 😊😮😊😊

  • @saydiy1528
    @saydiy1528 Před rokem

    good job. the orange ball looks nice, is it OK to use a circle image instead of the ball?

  • @cdunne1620
    @cdunne1620 Před rokem

    ..brilliant video, you’re a great teacher, thank you!!
    ..are you looking forward to TTGO t-Display Amoled, should be cool

  • @kamran_aghlami
    @kamran_aghlami Před rokem +1

    Those screen flickers look like image buffer corruption to me. I guess it's because of unaligned memory writes or LCD's driver issue, maybe it has to do with the weird resolution this display has, and I'd say you're essentially bypassing the issue with writing full frame buffer every frame which is less efficient both in terms of CPU cycles and memory usage than the partial screen update the first approach had. I'm interested to figure the real issue out.

    • @wincydelavega653
      @wincydelavega653 Před rokem

      I use the same display and i use a typical esp32 and i am not using any sprite but it works completely fine but i am happy to learn sprite 🐱

  • @j.d.5262
    @j.d.5262 Před 11 měsíci

    OMG where did you get that coffee mug?

  • @MaxSMoke777
    @MaxSMoke777 Před rokem

    Where is part 2??? I haven't been able to figure out how to make a masked sprite, I was hoping you had information on that.

  • @KVEL...
    @KVEL... Před 2 lety

    Thanks for this clear explanation! I have learned a lot!

  • @Darktron
    @Darktron Před rokem

    Can you do a tutorial on using Lvgl library with T-Display S3 make of nice UI, fonts, colors, etc.

  • @buraksonmez1761
    @buraksonmez1761 Před rokem

    Why am I getting this error when I trying to do something with this ttgo?
    Sketch uses 18280 bytes (59%) of program storage space. Maximum is 30720 bytes.
    Global variables use 1882 bytes (91%) of dynamic memory, leaving 166 bytes for local variables. Maximum is 2048 byt

  • @innocent431
    @innocent431 Před rokem

    and willing nice tutoet League teams and players to chose as their editor. More money for tho. It is pretty cool to see the progress I

  • @mibrahim4245
    @mibrahim4245 Před rokem

    Thank you..
    I need your help if possible..
    Im using this TFT_eSPI library with my st7735 128x128 display.. and it works great when I show a 16-bit image using pushImage( ) function.
    but if I print a text on top of it, the text starts flickering.
    I've tried many things to no avail, but if I change the image to the 8-bit bitmaps it works perfectly ! ..
    so can I display an 8-bit color image (not bitmap) using this library ?

  • @HPVIDEO10
    @HPVIDEO10 Před 2 lety

    Thank you !!!

  • @andymouse
    @andymouse Před rokem

    Nice !...cheers.

  • @carlatashkadeh5890
    @carlatashkadeh5890 Před 2 lety

    Thanks!

  • @BlondieSL
    @BlondieSL Před rokem

    Just to confirm, this doesn't have to be on a TTGO, right?
    It can be any ESP32 board, like ESP32 WROOOM ?
    And will any TFT work, like the 4 wire ones, or does it require TFTs that have several wires?

    • @VolosProjects
      @VolosProjects  Před rokem

      This will work on any board that is sušprted by boodmers tft_espi library..

    • @BlondieSL
      @BlondieSL Před rokem

      @@VolosProjects I tried to confirm if what I found was right, but as expected, even without posting an actual like, the algorithm removed my comment.
      I hate the YT algo! It really is horrible. It lets seriously bad comments to remain, then removes normal comments.
      So again, let me try.
      Is what I'm looking for have the title at the top, left corner of
      Bodmer T'F'T'_'e'S'P'I'
      (I add ' to confuse the algo)
      ??
      (LET'S SEE IF THIS COMMENT STICKS... SIGH)

  • @Sergkey42
    @Sergkey42 Před 11 měsíci

    благодарю бро за такое пошаговое объяснение. Можешь рассказать так же про режим DMA на ESP32?

  • @YourDetector
    @YourDetector Před rokem

    Good stuff!! But as far as I can understand, ONE sprite of 135x200 pixels takes all RAM memory of ESP32 :(

  • @Alan123456789876543
    @Alan123456789876543 Před rokem

    Great example of "Arduino code". You just could use a Frame buffer to avoid ANY of this flickers :\

    • @marc.lepage
      @marc.lepage Před rokem

      In this case, the sprite is the frame buffer. Or are you saying the display library has more direct support for frame buffers?

  • @nikthefix8918
    @nikthefix8918 Před 2 lety +3

    Your screen flicker is pacman-esque.

  • @shahabaghai
    @shahabaghai Před rokem

    Hi and thanks for great videos, I am finding them very useful. I am working with ESP32-Vroom and 320*240 TFT(SPI), when I define my sprite with full length it does not work (LCD is black) but when I break it into 2 sprit of 120*320 I have no issue and it successfully updates the LCD? Any ideas?

    • @BlondieSL
      @BlondieSL Před rokem

      Well, you have just answered my question of if an ESP32-WROOM and pretty much any TFT will work.
      Thanks for that.
      As for what you mentioned, have you tried messing with the X/Y screen size numbers?
      Like, perhaps reduce x and y by 1 number and use 1 to 320 (or 1 to 319) instead of 0?
      I know that with Arduino and TFT screens, I ran into issue of the screen not working right when being too "exact" with the numbers.
      I tested by reducing the numbers by 1 (I think it was) and then things would work.
      just an idea.

  • @rickharms1
    @rickharms1 Před měsícem

    What User Setup do you use in "User_Setup_Select.h"?

  • @Johann75
    @Johann75 Před 7 měsíci

    So, Sprite will paint the objects into the memory one by one and then into the screen in one shot?

  • @flashgangster
    @flashgangster Před rokem

    Great video. I followed along using ESP32 and ILI9341 (240x320) and it worked great until I tried to make the full-screen 240x320 sprite (scaled up from your example). It will only go so big before it stops working. I'm guessing it's a memory issue and I need som more teaching. I can't seem to find another tutorial that goes deeper :(

    • @solarprojectuk
      @solarprojectuk Před 9 měsíci +1

      Me too! I found the solution - add the line img.setColorDepth(8); to the loop function. It reduces the memory needed and the sprite works well now.

    • @flashgangster
      @flashgangster Před 9 měsíci

      @@solarprojectuk thank you!

  • @romarioavila1
    @romarioavila1 Před rokem

    Hy! is possible to develop an menu user interface with sprites?

  • @ianchan2624
    @ianchan2624 Před 8 měsíci

    ahhaha thanks xD

  • @edgarmatzinger9742
    @edgarmatzinger9742 Před rokem

    Interesting idea. But why don't you use "real" sprites? A circle sprite you just move over the screen? And a number sprite which you update every loop?

    • @VolosProjects
      @VolosProjects  Před rokem

      i dont understand, what is real sprite?

    • @jonathanshaw5186
      @jonathanshaw5186 Před 5 měsíci

      As a TFT_eSPI newbie, this confused me a bit too at first. I expected the circle to be the sprite rather than the screen (or the portion of the screen) that contains the circle.

  • @xyntaxxian7615
    @xyntaxxian7615 Před 2 lety

    Can you please also tell me what is deleteSprite? What is its importance? How to use it?

    • @VolosProjects
      @VolosProjects  Před 2 lety

      Sprite can use lots of RAM memory, when you dont need sprite anymore you can delete it to free memory

    • @xyntaxxian7615
      @xyntaxxian7615 Před 2 lety

      @@VolosProjects it's because i tried using deleteSprite to clear my screen but it doesn't seem to work, can you please tell me how to use it properly or point me to a tutorial that uses the function

  • @wchen2340
    @wchen2340 Před 8 měsíci

    I think "why you need double buffering" would be a much more suitable title. whatever. i dont care much about strange arduino lib apis. cya

  • @donvukovic7440
    @donvukovic7440 Před 2 lety

    At time 00:05, we can see your pizza oven. Will you create a tutorial on how to build a pizza oven. Please.

    • @VolosProjects
      @VolosProjects  Před 2 lety

      Hello, sorry i dont know how to build it, my father build it. Where are you from, my wife surname is also Vukovic.

    • @donvukovic7440
      @donvukovic7440 Před 2 lety

      @@VolosProjects My father is from Kralievo, I was born in Cleveland.
      I would love to go there some day.

  • @AJB2K3
    @AJB2K3 Před rokem

    Nice video thank you but could you repeat this video but using micropython please?

    • @VolosProjects
      @VolosProjects  Před rokem +1

      sorry, i dont like micropython and i dont know how to program esp32board using micropython

    • @AJB2K3
      @AJB2K3 Před rokem

      @@VolosProjects Never mind, I wouldn't have know if I hadn't asked.

  • @Xavier_Everwhere
    @Xavier_Everwhere Před 2 lety

    I didn't find. Any sprite bottle😅

  • @danielsaccomani6277
    @danielsaccomani6277 Před 4 měsíci

    Do you only provide the code if they buy you a coffee?

    • @VolosProjects
      @VolosProjects  Před 4 měsíci +1

      No, usualy in my videos code is free. But this is tutorial , just fallow along and write code i wroted in tutorial, you will learn easier than just copy and past code. I dont have this code anymore.

    • @danielsaccomani6277
      @danielsaccomani6277 Před 3 měsíci

      @@VolosProjects Ah yes, perfectly fair!
      I looked and couldn't find it, but now I understand. Thanks for the feedback...
      Do you have a tutorial that teaches how to overlay a numeric counter over a background image?
      I'm trying to use the information from several videos on your channel, but without success.... Thank you very much for your answer, big hug.

  • @krafterHD
    @krafterHD Před rokem +1

    Okay. I'm going to try to explain the problem I'm having with your example.
    I have a different size display. Mine is 240x240 (size set in the user_settup.h file). Your code line by line works great but if I change the size of the sprite to 240x240 it won't run. All I get is a black screen. I've change the size of it on both x and y and the only time I can get it to run is if the size of the sprite difference between x and y is >= 10.
    img.createSprite(240, 240); doesn't work.
    img.createSprite(235, 235); works
    img.createSprite(240, 231); doesn't work
    img.createSprite(240, 230); works
    img.createSprite(230, 240); works
    img.createSprite(231, 240); doesn't work
    img.createSprite(239, 231); works
    img.createSprite(235, 235); works.
    I'm confused. Could this be something in the user_setup.h?
    Edit: I found my answer. This may help others. I’m using an ESP32 Wroom 32.
    “A Sprite is notionally an invisible graphics screen that is kept in the processors RAM. Graphics can be drawn into the Sprite just as they can be drawn directly to the screen. Once the Sprite is completed it can be plotted onto the screen in any position. If there is sufficient RAM then the Sprite can be the same size as the screen and used as a frame buffer. Sprites by default use 16 bit colours, the bit depth can be set to 8 bits (256 colours) , or 1 bit (any 2 colours) to reduce the RAM needed. On an ESP8266 the largest 16 bit colour Sprite that can be created is about 160x128 pixels, this consumes 40Kbytes of RAM. On an ESP32 the workspace RAM is more limited than the datasheet implies so a 16 bit colour Sprite is limited to about 200x200 pixels (~80Kbytes), an 8 bit sprite to 320x240 pixels (~76kbytes). A 1 bit per pixel Sprite requires only 9600 bytes for a full 320 x 240 screen buffer, this is ideal for supporting use with 2 colour bitmap fonts.”
    github.com/Bodmer/TFT_eSPI#sprites

    • @mathiasbekker211
      @mathiasbekker211 Před 9 měsíci

      Awesome. Thank you *1000. I'm using an ESP32 WROOM 32D and a 240*240 tft. Changing the sprite size to 240x235 worked for me.

    • @VolosProjects
      @VolosProjects  Před 9 měsíci

      You have older esp32 module which have less psram, so with sprite so big program crashes. You can try with diferent board

  • @IvanEng747
    @IvanEng747 Před rokem

    #include
    TFT_eSPI tft = TFT_eSPI();
    TFT_eSprite img = TFT_eSprite(&tft);
    void setup() {
    tft.init();
    tft.setRotation(1);
    img.setColorDepth(true);
    img.setColorDepth(1);
    //img.setColorDepth(8);// NO IMAGE
    img.fillSprite(TFT_RED);
    img.createSprite(480,320);
    }
    int x = 0;
    void loop() {
    img.fillCircle(x,36,30,TFT_BLACK);
    x = x + 10;
    if (x > 480)
    x = 0;
    img.fillCircle(x,36,30,TFT_GREEN);
    img.pushSprite(0, 0);
    delay(10);
    }
    Not work on stm32f401ccu6

    • @VolosProjects
      @VolosProjects  Před rokem +1

      do you have latest, tft_espi library?

    • @BlondieSL
      @BlondieSL Před rokem

      @@VolosProjects Any chance that you could post that specific link to the latest?
      I loved your video. That's how to get a point across. Show first what doesn't work well, then insert what does.
      This made understanding sprites so easy.
      Oh, to confirm as above, this should work with any ESP32 board, i.e. ESP32 WROOM and any TFT display?
      Thanks in advance.