RoundyFi Animated Eye
For quite a while I’ve had a RoundyFi kicking around in my box of things I’ll get around to doing something eventually, but recently I was inspired to pick it up again after buying and assembling an InfoOrbs device from brett.tech. I wondered if I would be able to make a module for the InfoOrbs that would display an eye on each screen?
tl;dr; if you want do dive straight in, the code is here
These are the assembled InfoOrbs:
First things first though, it would be good to understand how to get an animated eye working on the RoundyFi before trying to get five of them working.
Example code
The first step was to find some example code that I could make work, this took a while but I ended up finding some great examples in the TFT_eSPI library that is used to drive these displays, it’s called Animated_Eyes_1. I lofted this code and made only a few changes, mainly this was the platformio configuration for the esp-12e device that controls the display.
Filling the screen
The example code got things mostly up and running, but the eye didn’t fill the screen, only half of it. After taking a deeper look into the code it appears it was setup to work on 128x128 pixels displays, this display is 240x240 pixels.
The image definitions in the example code we pre-defined in headers files, after some investigation it appears these are built using a tool I found in a different code library.
I found some larger definitions over in the Uncanny_Eyes but just lifting the defaultEye.h didn’t work due to array for the sclera definition being too big to build for the esp-12e. So I took the images from that repo, shrunk them down slightly, and regenerated them using the tablegen.py tool.
The sclera image from the Uncanny_Eyes repo looks like this:
The first image I generated was exactly 240x240 pixels, I flashed this to device and it looked ok, the sizing was correct and the eye was blinking. But there was a problem, the eye movement animation was working like it was in the original code that was 128x128 pixels. This took a while to figure out, but was completely obvious once I had the lightbulb moment. Basically the sclera
image needs to be bigger then the display in order for the animation to work, this is because you are only seeing a portion of it on the 240x240 display as it ‘slides’ around behind the eyelids.
To solve this I simply regenerated a sclera image that was 320x320 pixels, this allowed for some movement but was also small enough to be complied for the esp-12e. After building and flashing this code the animation was working again.
The finished product
The finished product looks like this:
It’s pretty cool as it just randomly blinks and looks around. It has no practical purpose currently, but I’ve learnt quite a lot along the way. This included discovering the platform.io IDE for VSCode, and also getting back into come C++ code.
The finished code can be found in GitHub in the roundyfi-eye repo, and hopefully will just build as the platformio config file is included.
The next steps are to take these learnings and make it work for the InfoOrbs