chrismiller / TeensyEyes

Based on adafruit/Uncanny_Eyes, M4_Eyes, and mjs513/GC9A01A_t3n
MIT License
20 stars 7 forks source link

TeensyEyes

Introduction

This project is my take on "Uncanny Eyes", adapted for Teensy 4.x microcontrollers. It renders animated eyes on round GC9A01A LCD screens. See the video below for an example of the eyes in action.

This is all still very much a work in progress. The aim is to turn this into a library that is fully configurable and easily integrated with your own Teensy projects.

This codebase is based on code and ideas from the following projects:

Building and Running

This project is developed with PlatformIO and (optionally) CLion.

Running the "PlatformIO Upload | eyes" target from CLion, or alternatively running platformio run --target upload -e eyes will compile the firmware and upload it to your Teensy 4.x.

What does it Look Like?

Here's a video of the eyes in action:

Teensy Eyes

Creating Your Own Eyes

Each type of eye is defined with a config.eye JSON file specifying various parameters of the eye, pupil, iris and sclera, plus (optional) bitmaps that define the extents of the upper and lower eyelids, along with any textures for the iris and sclera.

Detailed documentation for config.eye is coming, but in the meantime, if you want to try creating your own eyes then copying and editing existing eyes in the resources/eyes/240x240 directory is a good starting point. Note that colors are currently only able to be specified as 5:6:5 RGB decimal or hex values. Try this for help in creating your own 5:6:5 color codes.

Once you have an eye definition that you want to try, you need to generate code from it for use in your firmware. For this you will need a recent version of Python installed, as well as numpy and the imaging library Pillow. You can install these two libraries with:

pip install numpy
pip install Pillow

To generate the data files for a single eye, run the following from the resources/eyes/240x240 directory:

python tablegen.py ../../../src/eyes/graphics/240x240 path/to/your/config.eye

To generate all eyes, run the genall.py command shown below. Note that you may want to make sure the output directory is empty first, so you don't end up with redundant data files in there if your eye's configurations have changed.

python genall.py ../../../src/eyes/graphics/240x240

To use your newly created eye, include it with #include "path/to/eyename.h" and access it in your code using eyename::eye, or with eyename::left and eyename::right if your eye has different parameters for the left and right eyes.