Note: This is an old post of a WIP project originally posted on Coding Grace - for this post in dev.to, I'm splitting it up into a series.
This might end up being a multi-part post. It's my learning journey of fails and little delights (or bigger if I'm successful) on learning about generating art via Processing from data obtained from the accelerometer from the Circuit Playground Express.
Components mentioned in this project
- Raspberry Pi
- Adafruit Circuit Playground Express (CPX)
- Adafruit Circuit Playground Tri-Color E-ink Gizmo
- Adafruit Circuit Playgroud TFT Gizmo
- pi-top[4]
Software references
Day 1: PyProcessing, Circuit Python, E-ink Gizmo - lots of experimenting
Ok, what I wanted to do (which made sense in my head) was to create an image with Processing when it detects sensor changes in CPX.
I was thinking of going whole hog with Python as there's a Python library for Processing via py.processing.org but first off I need to get Processing installed on my Raspberry Pi (model 4 on pi-top[4]). I quickly realised the normally version via Processing site doesn't work, but there's a pi.processing.org that has a version of Processing specific for it.
Hit download and untarred it and voila, it worked.
Spent some time going through the tutorials with Python on Processing. That was fun... now I want to get cracking on how to get it working with CPX.
I can get Circuit Python to print to the E-ink Gizmo screen with the text Testing
. That's a good start. π
Was looking at using command line to call it programmatically... not so straight forward because it specifically needs a really old version of Java... and it doesn't support OpenJDK and just ugh...
Anyway, maybe it wouldn't be so bad to play with Processing, it's only Java light, right. I found that it does interact with GPIO on the Raspberry Pi, so that's a positive.
βΉοΈ Reference
- https://learn.adafruit.com/processing-on-the-raspberry-pi-and-pitft/hardware-io
- https://processing.org/reference/libraries/io/GPIO.html
But I want it to work with CPX. I'll be connecting it with a microUSB cable to the Raspberry Pi (which I'm VNC'd into). So playing with GPIO is a moot point.
Ok, there's too many moving parts here that don't necessarily talk to each other, let's roll back a little. What comes out of the box with Python that can generate images? It's Python Turtle. I kind of ignored it as I was teaching kids about Python with it late last year, but I do notice a lot of people create generative art with Python Turtle.
The next question is how to save the output of Python Turtle.
Internetz helped here, between:-
- https://www.assertnotmagic.com/2019/02/02/art-math-python/
- https://stackoverflow.com/questions/36826570/how-to-close-the-python-turtle-window-after-it-does-its-code
I can see that you can generate something simple, save it to an image (note, I had to install pillow to use PIL), and also close the Python Turtle window after it generates the image.
βΉοΈ Reference https://python-pillow.org/
So it's back to Circuit Python after all that. Interesting exercise though.
Ok, back to basics
CPX with E-ink Gizmo -> pi-top[4] with Raspberry Pi Model 4
Remembering how to access the accelerometer data thanks to the following:
- https://learn.adafruit.com/sensor-plotting-with-mu-and-circuitpython/motion
- https://learn.adafruit.com/make-it-shake-rattle-and-roll/more-circuitpython
Adafruit Libaries:
adafruit_display_text
adafruit_gizmo
adafruit_il0373.mpy
Found the following error:
Group Full RunTimeError for label.py: text was too long
βΉοΈ Reference: https://github.com/adafruit/Adafruit_CircuitPython_Display_Text/issues/11
Also realising waiting 180s is very boring!
Top comments (0)