Creating an Animation sprite on TTGO T-Watch
for understanding to easy please read this article.
Material you need:
- TTGO T-Watch board
- KBIDE v1.0.1
- microUSB
STEP 1 : Download and Install TTGO T-Watch v1.0.1
STEP 2 : Select T-Watch
STEP 3 : Click Example & Tutorials
STEP 4 : Board Example → 02-DISPLAY → 04-Animation
STEP 5 : You will have another windows
STEP 6 : How is work ?
Setup:
1) Set IO36 to INPUT_PULLUP
2) Set display rotation to TOP.
3) Fill screen display to WHITE.
4) Create variable delayAnime (Time(ms) to display animation)
5) posX (Position X)
6) posY (Position Y)
7) pevX (Previous Position X)
8) walk state
9) Display Text on Screen
10 ) add your animation image to variable name basePage
11) draw image from basePage to display screen
Loop:
1) Condition IF : GPIO36 (USER Button was Press)
2) Set variable walk to True
3) Condition IF : variable walk is True
4) add your animation image to variable name img1
5) draw image from img1 to display screen
6) delay image to display
X) Follow number 4–6 to display your animation sprite
Task:
1) Run task
2) Do task every 0.5 Seconds
3) Condition IF : variable walk is True
4) update position X
5) update previous position X
6) Remove Screen before display next image
7) Condition IF : variable posX ≥ 240 (display pixel 240x240) will set position X to 0 (zero) and set variable walk is False to stop the animation
NOTE:
Example folder already contains example images. You can try it at Board Folder → ttgo-t-watch→ examples → 02-DISPLAY → 04-Animation
STEP 8 : Add your image
STEP 9 : Compile & Run to see what happen !
Contract us
FB page: KBIDE
Website: www.kbide.org
FB page: Chiang Mai Maker Club
FB Group: Chiang Mai Maker Club