Unicorn HAT HD story project


#1

Hi
I have started a project where I would like to show different pieces of pixel art on the Unicorn HAT HD. Ideally I would like to have the images coming up on button pushes, and some images animated on button pushes too e.g push button get either a still or animated person/object (I have a pianoHAT that I was hoping to use as buttons), both attached to the pHAT stack.

I am struggling with the python code, I can easily modify the show_png.py script to show my own single .png pixel art image, and I can get the pianoHAT to show colour on the Unicorn HD HAT, however combining the two is proving challenging.

I am a novice python users but happy to learn, guidance would be great.

So the help I require is in two parts:

  1. How do I get to push a button on the pianoHAT and have an image appear on the Unicorn HD HAT
  2. Is it possible to animate the images on the Unicorn HD HAT with multiple single images rather than the matrix style used in snow_png.py example (lofi.py).

Thanks


Pixel Art
#2

It’s possible to animate using single images, but you have to preload them into memory to avoid a delay between each frame, so the “spritesheet” approach used in lofi.png is generally an easier way to go.

In your case, if you want a number of different animations at 16x16 pixels you could align your spritesheet with your different animations running from left to right along the horizontal axis, and then frames running from top to bottom.

I’ve whipped up this example which uses the 8 white keys on Piano HAT to cycle through 8 2-frame animations: https://gist.github.com/Gadgetoid/5c1f52b8a1478f79af772b30a76590bc


#3

Wow thank you very much for this I will have a play with that code and study it closely to I can figure out exactly what each bit is doing.
Also going to have to create some pixel art story boards I think should be fun.

Thanks again.