Software apps and online services
In my previous project, I created a NeoPixel emulator that could simulate a string of NeoPixels. It had a basic change pixel color function and effects library that contained functions like rainbow and color wipe.
This was working fine initially, but someone commented that I should also create a way to emulate a NeoPixel matrix. Since matrices often contain more complex animations and designs, being able to experiment on new animations would be very beneficial.New Features
This new iteration of my NeoPixel Python library has a matrix constructor that lets users create matrices up to about 1600 total pixels.
The window now dynamically resizes to the correct size based on the dimensions of the matrix. I also created a class based off Adafruit’s GFX library that has the following functions:
- Rotate the display 90, 180, 270 degrees
- Draw a line
- Filled rectangle
- Drawn rectangle
- Fill screen
- Clear screen
- Filled circle
- Drawn circle
- Rounded rectangles
- Filled triangle
- Drawn triangle
- Bitmap from array
I started by making a basic draw pixel functions that could map a pixel to a specific x/y coordinate on the matrix. It works by converting the coordinate pair to [y*width+x]. Next, I started working on the Adafruit GFX port by basically copying over each graphics primitive drawing function.
Each function can be called in the same way it’s called in C++, just with Python syntax. The arguments are in the same order, along with the function names. There is also a built-in delay functions for making smoothly-timed animations possible. Lastly, there is the drawBitmap() function. By using LCDAssisstant, users can create simple arrays from 1-bit bitmaps. You can follow Adafruit’s tutorial here to know how to use it.
All-in-all, using this library to emulate a NeoPixel matrix is extremely simple and easy to do.