Transparent Sprites - Programming Tutorial (TFT_eSPI library)

Поделиться
HTML-код
  • Опубликовано: 3 янв 2025

Комментарии • 164

  • @Peter_S_
    @Peter_S_ 2 года назад +27

    Excellent video!
    Your English is not clumsy at all. You are a very clear presenter and every video I have watched has been an excellent presentation. Large parts of America have both English and Spanish as primary languages so your English closely follows the normal English of somebody who speaks multiple languages. Most importantly, you explain everything very clearly. Excellent channel!

  • @louiscelenza8017
    @louiscelenza8017 2 года назад +23

    I really appreciate your videos. You take your time and stay on point. Your English is very good. It has a good tempo and vocal control. I always learn valuable information from your videos, and implement them into my projects. Please continue your quality work. Thank you.

  • @jeffreymorris1752
    @jeffreymorris1752 Год назад +5

    Your English is very good. You've a more effective and comprehensible vocabulary than most Americans.

  • @TYGAMatt
    @TYGAMatt Год назад +3

    Your Tft_espi tutorials are fantastic. Thank you so much for taking your time to share this great information.
    Matt.

  • @arlo4051
    @arlo4051 2 года назад +3

    Thank you Volos, I have been fighting with trying to get transparencies to work for a month now, your the best. Regards to family.

    • @VolosProjects
      @VolosProjects  2 года назад

      tnx Arlo, best wishes to you and your family

  • @newmonengineering
    @newmonengineering 2 года назад +2

    You are doing a great job with English language. And this is an interesting concept. I now know how to eliminate flicker and draw sprites. Very nice. I'm sure it probably took a while to figure these tricks out. But it looks very nice.

  • @michealmorrow1481
    @michealmorrow1481 7 месяцев назад

    Thanks for this tutorial. I really like that you upload and show after every step so we can truly follow along.

  • @briannielsbergh
    @briannielsbergh Год назад

    I've been searching for a way to get rid of the flickering, even been in the official lilygo forum (and in the TFT forum) and not anyone could give a clue... finally I found this video with a simple hack, thank you so much 😊😊

  • @hypnoticatrance
    @hypnoticatrance 6 месяцев назад +2

    Cool stuff, I like your Video Tutorials, and they help me much to get run things I don't had a clue about. My main problem was to get run my new display with tft eSPI, about there was not much Info around how to do with my display. But I find out how, and got it running. Since then i can play around with your nice tutorials! The Idea to use eSPI i got in your videos, and it made my display much faster, as the original library does from my display.

  • @psprophet
    @psprophet 2 года назад

    I love your "clumsy" english, Volo! It makes everything easier for me - as Brazilian. Cheers!

  • @kenworks6068
    @kenworks6068 Год назад

    Your videos are exactly what I need to make some additional gauges in my SUV as I have changed to a different power train. Many vehicle functions were handled by the old engine controller, like the air conditioning compressor logic and I am adding functions like variable speed electric fans as well as additional gauges. I am using Arduino mega2560 A/D to read a lot of sensors, scale data and provide basic control logic. Then the scaled data is going to the LILYGO T-Display-S3 via. I2C to drive multiple gauges. Your examples have been very instructive and with them my code is really improving - Thank You

    • @VolosProjects
      @VolosProjects  Год назад

      I am glad you found something useful. Cheers

  • @philsaunders65
    @philsaunders65 6 месяцев назад

    Thank you for your clear explanation. I learn so much from every video. I think the videos are much better unscripted because we get to understand your thought-processes, and what you say is more authentic and natural.

  • @Anto-ro6ru
    @Anto-ro6ru 2 года назад +2

    Great video, i suggest you to also talk about the approach used in some examples for the moving sprites of the tft library. They use a buffer to “clear” the background as far as i understood.

  • @DBBahnospherix-BahnAtmospherix
    @DBBahnospherix-BahnAtmospherix 5 месяцев назад +1

    14:32 - Great !!! Thank you

  • @tszulpinedo757
    @tszulpinedo757 2 года назад +3

    Como siempre, los mejores códigos y ejemplos. Gracias, profesor.

  • @krusethorsten
    @krusethorsten 2 года назад +4

    Sprites on a ESP32... Since long time I try to understand what you tell us now. But not had a clue before. How crazy is this solution, to put the graphic in a sprite and this graphic in another sprite to stop flickering. .... but finally it makes sense, and it does what you want. Have to see the video more times to really understand this technic. I definitely will use it in one of my projects in the future...

  • @TYGAMatt
    @TYGAMatt 2 года назад +1

    Brilliant. Thank you so much for taking the time to share this with us. Much appreciated

  • @edwilliams9914
    @edwilliams9914 2 года назад

    Thanks! Very informative, like this whole series. Very clearly explained. (And your English is perfectly fine for anyone who actually cares to listen and learn -- and if they *don't*, forget 'em and carry on!).

  • @smpplaza6673
    @smpplaza6673 2 года назад +1

    Awesome work mate thank you for taking the time to teach us these things!! You and lilygo are an awesome team!!

  • @markwinfield1679
    @markwinfield1679 Год назад

    Your English is very good and some of your technical language is better than those who are English. You only seem to get confused with some of the pronunciation and that will be because words are pronounced differently in different parts of the world. Keep up the great work. You have saved me hours of work, I will be buying you a coffee.

    • @VolosProjects
      @VolosProjects  Год назад

      Tnx Mark, yes pronunciation is big problem. I am glad you like content. Tnx

  • @nkbdl
    @nkbdl 7 месяцев назад

    I finally got it working. I am using a LilyGO T-Display S3 and there are some small variations in how to put the code in. But the code works. Thank you! :)

    • @VolosProjects
      @VolosProjects  7 месяцев назад

      i am glad you found way. thank you :)

  • @freddycarrillo9266
    @freddycarrillo9266 2 года назад +2

    OMG, your tutorials are the very best, youre great

  • @hjlc3135
    @hjlc3135 11 месяцев назад

    Excellent tutorial! Many thanks for this! And don't apologize about your english! For other non-english speakers yours is a lot more understandable than the one of many 'native' speakers! 🙂

  • @markwinfield1679
    @markwinfield1679 Год назад +2

    I have a 240x240 display. Your code works with
    background.createSprite(240, 238);
    but fails with anything bigger than 238
    i.e.
    background.createSprite(240, 240);
    I can still work with this, but would love to know why this is happening!

  • @elkakael4369
    @elkakael4369 Год назад +1

    ur so called "clumsy english" has help me alots and im dont have difficulties understanding it 👍🏽🙏🏽👌🏽

  • @anhoanghocgioi3140
    @anhoanghocgioi3140 Год назад

    Wherever, in whichever school this Mister is teaching, I want to attend his classes!

  • @BerndSchmitt-Martinique
    @BerndSchmitt-Martinique Год назад

    Very useful video and very well explained...step by step .
    Perhaps you should mention in one of your sprite videos . that the MAIN TRICK with SPRITES is, that you are drawing directly on a " screen buffer " in your MCUs memory !!!
    You dont draw on the TFT using library functions , which is much more time-consuming. When your IMAGE in your SCREEN BUFFER is complete you push it out in one piece to the TFT.
    This can even be done still faster by using DMA - direct memory access.
    Each frame is drawn on a clean sheet of paper ( the background sprite ) so you dont have to take care of the old graphical content.
    Years ago - without sprites - it was very complex to draw moving graphics , because .... before drawing new content you always had to "neutralize" the old content .
    Thanks a lot for your videos - because you wont find these excellent explanations on any other place .

  • @rocoroco15
    @rocoroco15 Год назад

    Thank you so much! I am waiting for my LilyGo screen to arrive... This will be my first project with it!!!

  • @madcow3417
    @madcow3417 Год назад +1

    A quick tip on using Paint: You don't have to resize the image if you paste it in then hit 'Crop' while it's still selected.

  • @MeinElektronikHobby
    @MeinElektronikHobby 2 года назад

    ... wieder etwas gelernt. Bin gespannt auf das nächste Video - Learned something again. I'm looking forward to the next video

  • @tmiller9099
    @tmiller9099 2 года назад +1

    Thank you. It was helpful to see how some of this comes together.

  • @ReflectingMe2024
    @ReflectingMe2024 Год назад

    Excellent video whip is wonderfully explained, and your English is a million times better than my Russian😂. Suggestion: I think you’d have a decent audience if you did a live stream, maybe coding another interesting program on the excellent T-Display. I’d watch. Thank you for your great work here. John.

  • @tablatronix
    @tablatronix Год назад

    This is impressive, i have one of these sitting in my desk, I need to put it to use!

  • @chadreshpatel2339
    @chadreshpatel2339 Год назад

    TFT_eSPI library is amazing but the documentation is not that extensive. It is difficult to figure out how many amazing things we can do. But thanks to your tutorial, i can understand much more things in details.

  • @thepapatech2067
    @thepapatech2067 2 года назад

    Learning quite a lot watching your videos. Keep up the great work!

  • @beavisul
    @beavisul 2 года назад +2

    I think this is the best video about this topic. Really really impressed how straight-forward it was.
    Do you know if it is possible to create gradient transparency? One side of the image fully transparrent and the other no transparency. Useful to create shadow effects.
    Thank you for the awesome knowledge and content!

  • @fabryz
    @fabryz 2 года назад +1

    Did you see that Lilygo now released also the touch version of the "T-Display S3"?

  • @EasyOne
    @EasyOne 2 года назад +2

    Very well explained

  • @jiginvp4830
    @jiginvp4830 9 месяцев назад

    Great tutorial. Thanks. Very appreciated. Please do more tutorials.

  • @paulpkae
    @paulpkae Год назад

    Thanks for the Video. Have you found any good documentation for the TFT_eSPI library?

  • @dobitaobyte
    @dobitaobyte 2 года назад

    Amazing, man. When I saw you using RGB565 2bytes here, I tried an icon too and now it's working. Probably I did some mistake before.
    But I need to confess that image used in example sketch from LilyGo let me crazy. I can't understand the array of 1 byte to generate rgb565.

  • @PhilWaller
    @PhilWaller 2 месяца назад

    Thank you for sharing, I am learning a lot!

  • @Bestkeiki
    @Bestkeiki 2 года назад

    I hope you will do a video demonstrating the lilygo t-dongle-s3 also

  • @nortronics
    @nortronics 2 года назад

    thanks for sharing this. Very useful to add to my how-to's knowledge

  • @pezictusfish
    @pezictusfish 2 года назад

    The technique is vey clever, thank you for sharing!

  • @bjarkekorsgaard
    @bjarkekorsgaard 10 месяцев назад

    Thank you Volos, for the niece programming example - perfect 🙂
    I have noticed that .png files are not converted perfectly via the rinkydinkelectronics rgb565 converter. I can advice to convert .png to .jpg and then use the rgb565 concerter. Now looks slightly better 🙂

    • @alejandroperez5368
      @alejandroperez5368 9 месяцев назад

      But how does the jpg file conserve the transparency?

  • @РоманизТаганрога
    @РоманизТаганрога 11 месяцев назад

    Very useful video lesson. Thanks a lot!

  • @LQhristian
    @LQhristian 2 года назад

    Volos, thank you for all your effort! Have you thought of connecting bluetooth to phone to receive notifications (then delete after a short time)??

  • @pbart9821
    @pbart9821 Год назад

    Best espi tutorials

  • @HenricoNar
    @HenricoNar 2 года назад

    Really like your video's .You are very accomplished programmer ! Keep up the good work !

  • @localixdots9698
    @localixdots9698 Год назад

    Не пробовали написать небольшую операционную систему с UI ?

  • @electronics.unmessed
    @electronics.unmessed 2 года назад

    Nice gadget, I have to think about it how to use it in my projects!😀

  • @VincentVeak
    @VincentVeak Год назад

    Is there a reason to use two sprites vs just pushing the arrow image to the background sprite? What is the purpose of making an arrow sprite to begin with? Thank you!

  • @akissot1402
    @akissot1402 2 года назад

    Nice info Volos, but help. Sprite is erasing background as it moves, either alone or inside another sprite, any ideas?

  • @shadowmosesmusic
    @shadowmosesmusic 9 месяцев назад

    New to PCB - thinking of doing one that can play an animated gif on loop with sound speaker, on off switch, rechargeable battery and led strip light. Would you know how to do that? There's not a lot of resources out there. Thank you

  • @michealmorrow1481
    @michealmorrow1481 7 месяцев назад

    Great tutorial. I learned something new, as always with your tutorials. But, a problem.
    When I code:
    txtSprite.setSwapBytes(true);
    txtSprite.setTextColor(TFT_RED, TFT_BLACK);
    I get blue text. All colors except white are wrong, too.
    Even if I leave out the SwapByte, the colors are still wrong. Any idea why? I am using a T-Display S3.

  • @heinzodermatt3928
    @heinzodermatt3928 2 года назад

    Hello Volos, I love your videos. I bought my self a TTGO S3 T-Display. I could manage to get it working with arduino IDE. But not with PlatformIDE. Can you give me a hint, where to look, to get PlatformIO working with this nice Display? (After upload it always stays black) Another question, how do you design your pixel screens ? I'm sure there are some kind of UI designer out there.

  • @Windorey
    @Windorey 2 года назад

    Hello. I am trying to do this tutorial on M5Stack Core2, but I cannot draw image in Sprite. Please help me

  • @neurobits
    @neurobits Год назад

    Thnx. I just can’t realize why you fillScreen inside loop, that’s cpu expensive. Sprites aren’t like real full-managed-moving sprites?
    In worst case, is possible to create 2 (or whatever) sprites to be used as save-restore background sections? (excuse my eng)

  • @pezictusfish
    @pezictusfish 2 года назад

    Hey man! Have you used lvgl library with esp32 ttgo's? Also, I was thinking about adding components for cool toys, would be awesome to create an esp32 sonar radar with a graphical twist!

  • @khaldrogo9451
    @khaldrogo9451 Год назад

    How are the screens when it comes to sunlight? Are they visible?

  • @Johann75
    @Johann75 Год назад

    How can you draw the screen quickly within an interrupt for quick user input?

  • @nerijusk9598
    @nerijusk9598 Год назад

    Thank you for you work. I have question how do when arrow move very fast(full speed) and can regulate the speed?

  • @JenkinsUSA
    @JenkinsUSA Год назад

    Volos - thank you for moving the needle on the UI - very good presentation. I bought 4 of these lilygo S3 and can’t get any to display, the code is running, no display, my money is on tft_eSPI - even though I did on PC and Mac. I’m only using the Arduino IDE. I’m a notepad++ guy 😊- No VSCode yet… any ideas? All the boards worked with “factory” code.

    • @VolosProjects
      @VolosProjects  Год назад +1

      Hello, youu need to install right library for display, please fallow this tutorial ruclips.net/video/gpyeMjM9cOU/видео.html

  • @edwinkant
    @edwinkant 6 месяцев назад

    I am confused, why don’t you just convert the gif file to .h file? And why do you have to convert the transparent gif file to a jpeg file in black background?

  • @petricabutnaru9263
    @petricabutnaru9263 8 месяцев назад

    I tried in stm32 with stmduino compiler witl ili9488 display using this library and this code, and on screen appears gray

  • @adrianaxente
    @adrianaxente Год назад +1

    The technique to avoid flickering using "background" sprite is called "double buffering" 😊

  • @bobinou
    @bobinou Год назад

    i am trying to display a jpg or png but it is rendering very slow with about 160 - 300ms per image. the image is stored on the esp32 using littlefs. is there a way to speed that up? i have tried normal tft and sprites.

  • @zyghom
    @zyghom Год назад

    FANTASTIC!

  • @johanneskrijger398
    @johanneskrijger398 2 года назад

    Hello Volo, I have one question about transparent sprites. Is there a way to send you an email. In short, I created an yellow Circle in a Sprite and it is displayed in Purple in Background Sprite.

  • @quaphik4239
    @quaphik4239 2 года назад

    Quick question is this similar to the nfs process

  • @kidrobot.
    @kidrobot. 2 года назад

    where can i buy one of these tiny things? i want one for my keychain

  • @chipko
    @chipko 2 года назад

    Hello! TFT_eSPI is amazing as too your videos!

  • @eldjmasterfreddy4366
    @eldjmasterfreddy4366 2 месяца назад

    Great tutorial Thanks for sharing

  • @leeman3749
    @leeman3749 Год назад

    it worked right up until the pushToSprite function call. My Sprite(My_Logo) is 240x240px, The Background Sprite is also 240x240 pixel (to match screen size). After is did changed the pushToSprite, the Sprite(My_Logo) disappeared and only the purple background shows, the Sprite(My_Logo) disappears. Is there a problem with having the Sprite (My_Logo) the same size as the background Sprite?

    • @VolosProjects
      @VolosProjects  Год назад +1

      It is memory problem, try to use smaller sprite 200x200

    • @leeman3749
      @leeman3749 Год назад

      @@VolosProjects Thanks so much for your fast reply. Can I buy you a coffee?

    • @VolosProjects
      @VolosProjects  Год назад +1

      @@leeman3749 thank you my friend.

  • @esmokebaby
    @esmokebaby 2 года назад

    I wounder if I can cut a hole in my PC case and have it read my CPU GPU temps and my fps

  • @RicardoPenders
    @RicardoPenders 2 года назад

    I tried to buy one of these boards about two months ago, then I bought another one but the older version hoping that they get one of these boards sent to me but these boards aren't available on the Banggood website, this has never happened before that I had to wait as long as I'm waiting on these boards.
    I do really want them but if they aren't sending me at least one board before the end of this year I'm gonna ask for a refund, I'm not sure what's going on at Banggood and I would like to know if this is happening to other people who did buy something at the Banggood store the last 3 months and if you have to wait as long as I.

    • @VolosProjects
      @VolosProjects  2 года назад +1

      bangood have problems with stocking this board. You can ask for refund and try to buy it somewhere else.

    • @RicardoPenders
      @RicardoPenders 2 года назад

      @@VolosProjects Well, to me it looks like Banggood has other problems too because I bought another thing which is unrelated and that item has the same issue getting sent out.
      The weird thing is when I bought these products they showed these were in stock and after I payed the products were suddenly out of stock but I told them I can wait and that was 2 months ago.

  • @jimsnodgrass8454
    @jimsnodgrass8454 Год назад

    Great set of samples and useful techniques well presented.. But rather that simply playing with this subset of functions as examples used in your sample code to see what's possible, is there a useful ref document that would help one to understand what TFT_eSPI functions are possible and useful in certain situations to create a certain behavior on screen. I can tell you have an excellent memory and have spent MANY many hours playing around with the code to learn how to do this.. and I'm assuming that what is going on under the hood is the img sprite files are written to RAM locations in the TTGO T Display's memory and then these are somehow multiplexed by code on to the display in precise locations .. but right now to me these functions are as transparent to me as your videos would be if you spoke in your native language... I'm hoping there is good reference doc on doing this stuff out there somewhere .. is there?

    • @VolosProjects
      @VolosProjects  Год назад

      I am not realy sure what is happening here. Yes i spended many hours playing with code. Did you managed to install tqt on arduino ide?

    • @jimsnodgrass8454
      @jimsnodgrass8454 Год назад

      @@VolosProjects Thanks for asking,.. no I have not done so yet since I'm presently researching if VS Code will allow me to work on my older T Display projects, and easily switch back and forth to the new T-Display S3 environment, and back without having to manually edit where to find the correct tft_esip libruary file needed for each type of device every time. I think I will install the VS Code and PlatformIO but for a novice like me all this stuff is complicated and time consuming as-is so I want to either complete the T-Display / ESP NOW project 1st .. or know for sure the answer to the library switching issue before I do it. :)

    • @VolosProjects
      @VolosProjects  Год назад

      I font use platforma io anymore, i van tell you how i solve that problem, on library folder i have one folder and in that folder i keep many diferent versions od tfr espi lib, when i need library for some board i just copy right one in arduino lobraries folder

    • @jimsnodgrass8454
      @jimsnodgrass8454 Год назад

      I got this S3 demo code to work as well ast the T-QT Pro code working too .. even got one of my T-QT modules that was locket up to reset the Boot loader port and start showing up as a valid I.O port again too.. so yes some progress..

  • @CrazyPit
    @CrazyPit Год назад

    Excellent video!

  • @sakibyousuf1869
    @sakibyousuf1869 Год назад

    Hello, Volos
    How can I achieve this on seed wio terminal.
    I am not able to run img.pushToSprite function.
    Any suggestions please 🥺

    • @VolosProjects
      @VolosProjects  Год назад +1

      Try to update library

    • @sakibyousuf1869
      @sakibyousuf1869 Год назад

      @@VolosProjects already updated to latest version. The thing is it uses the seed inbuilt tft_espi library. And that library has no function named . pushToSprite.
      Please help 🥺

  • @nageshwarrao8629
    @nageshwarrao8629 2 года назад

    I am wonder if you can program Gameboy advance or any arcade emulator in it

  • @mikentx57
    @mikentx57 Год назад

    Question for anyone. If I have multiple sprites. How do I control their front to back order. So when they cross on the screen. I control which sprite will be on top.

  • @beavisul
    @beavisul 2 года назад

    This was great! Thank you!

  • @peterekberg1816
    @peterekberg1816 8 месяцев назад

    Thanks for a super video could not have explained it better, question though why is it not possible to go past background.createSprite(320,170); to background.createSprite(320,240); I have a 320*240 display and it won't fill background.createSprite(320,160); works background.createSprite(320,190); bugs out. Using 320*240 IPS ST7789 and ESP32 Dev Board

    • @VolosProjects
      @VolosProjects  8 месяцев назад

      Tnx...Becouse you are using older esp32 which dont have enougth psram.

    • @peterekberg1816
      @peterekberg1816 8 месяцев назад

      @@VolosProjects I was suspecting this, thank you so much for confirming this :) What ESP32 module would you recomend? IS ESP32S3 better choice?

    • @VolosProjects
      @VolosProjects  8 месяцев назад +1

      Yes any board with s3 will handle 320x240, if board have external psram it will handle even more.

  • @michaelbyron9688
    @michaelbyron9688 2 года назад

    Oops..
    EXCELLENT video!

  • @АртёмПустовой-с5й
    @АртёмПустовой-с5й 2 года назад

    Hi , can you show how to install tft_espi library in ptatformIO?

    • @VolosProjects
      @VolosProjects  2 года назад +1

      ruclips.net/video/57JWlSQ6-v4/видео.html

    • @АртёмПустовой-с5й
      @АртёмПустовой-с5й 2 года назад

      @@VolosProjects it also works with this board?

    • @VolosProjects
      @VolosProjects  2 года назад +1

      @@АртёмПустовой-с5й no , i dont know how to use this board in platformio

  • @timoengelmann3541
    @timoengelmann3541 2 года назад +1

    Thanks, this is great 💪

  • @codecaine
    @codecaine 2 года назад

    Excellent content

  • @guywhoknows
    @guywhoknows 2 года назад

    Good video.
    Good explanations.

  • @chlor7877
    @chlor7877 Год назад

    Paint: If you set the image too small and paste a big image into it, it will size up by itself.

  • @biker2k3
    @biker2k3 2 года назад

    Excelente explicación!

  • @IronRiviera
    @IronRiviera 11 месяцев назад

    Very nice. Thanks

  • @cpocol
    @cpocol Год назад

    Hi Volos, as a very beginner in MCUs, I was inspired by your videos. Now, getting to an intermediate level, I implemented a simplified version of Wolfenstein 3D in ESP32. Please find it on my channel.

  • @michaelbyron9688
    @michaelbyron9688 2 года назад

    EXCEKENT video!

  • @小野寺五郎兵衛
    @小野寺五郎兵衛 2 года назад

    右手人差し指のしつこいトントンは何か意味があるのかな?ボタンある?

  • @DanNV100
    @DanNV100 2 года назад

    Не знаю зачем это, но это классно.

  • @davidrowe9168
    @davidrowe9168 Год назад

    Very useful. Thx

  • @Fusiiiiion
    @Fusiiiiion 2 года назад

    Thanks a lot, this is a great job'

  • @ZacsNotDead
    @ZacsNotDead 2 года назад

    I don't know wut this vid is gonna be I just like mega man

  • @salam__7975
    @salam__7975 9 месяцев назад

    hi volos, amazing work with the project, im curious as how to make a background and foreground sprite. where the background is dynamic and the foreground is static like an aircraft attitude direction indicator? this is the code that I have now, it works perfectly but the 'ArrowSprite' which is the fixed aircraft symbol flickers when pushed onto the screen therefore I was thinking of making a composite sprite but I don't know how to get started. please advise.
    #include
    #include "Back.h"
    #include
    #include
    #include "Arrow.h"
    Adafruit_MPU6050 mpu;
    #define I2C_SDA 20
    #define I2C_SCL 21
    #include "frame.h"
    TFT_eSPI tft = TFT_eSPI(); // Initialize library for the TFT screen
    TFT_eSprite AH_Sprite = TFT_eSprite(&tft); // Create a sprite object
    TFT_eSprite ArrowSprite = TFT_eSprite(&tft); // Create a sprite object
    TFT_eSprite TranSprite = TFT_eSprite(&tft); // Create a sprite object
    void setup() {
    Wire.begin(I2C_SDA, I2C_SCL); // Initialize I2C communication
    tft.begin(); // Initialize TFT display
    tft.setRotation(0); // Set TFT rotation
    AH_Sprite.setSwapBytes(true); // Set byte swapping
    AH_Sprite.createSprite(240, 640); // Create a sprite
    tft.setPivot(120,160);
    ArrowSprite.createSprite(96,23);
    ArrowSprite.setSwapBytes(true);
    TranSprite.createSprite(240,640);
    if (!mpu.begin()) {
    tft.println("Failed to initialize MPU6050! Check wiring and connections.");
    while (1); // Infinite loop to stop further execution if MPU6050 not found
    }
    }
    void loop() {
    sensors_event_t a, g, temp;
    mpu.getEvent(&a, &g, &temp); // Read sensor data
    int angle = map(a.acceleration.y, -10, 10, 90, -90); // Map y-axis tilt to angle range
    int y = map(a.acceleration.x, -10, 10, 0, tft.height() - 640); // Map x-axis tilt to vertical range
    int OF=0;
    y += 160+OF;
    AH_Sprite.fillSprite(TFT_BLACK); // Clear the sprite
    AH_Sprite.pushImage(0, 0, 240, 640, Back); // Place background image on sprite

    // Update sprite's pivot point for rotation and vertical movement
    AH_Sprite.setPivot(120, 320 + y); // Adjust pivot point for both rotation and vertical movement
    // Rotate and draw the sprite based on accelerometer data
    // Since we're not using a physical device to display it immediately, you'd need to handle the sprite display to the TFT after rotation if needed
    ArrowSprite.pushImage(0,0,96,23,Arrow);
    ArrowSprite.pushToSprite(&AH_Sprite,72,145,TFT_BLACK);
    AH_Sprite.pushRotated(angle); // Rotate sprite, making the background transparent
    }