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.
- Raspberry Pi
- Adafruit Circuit Playground Express (CPX)
- Adafruit Circuit Playground Tri-Color E-ink Gizmo
- Adafruit Circuit Playgroud TFT Gizmo
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). 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.
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:-
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.
CPX with E-ink Gizmo -> pi-top with Raspberry Pi Model 4
Remembering how to access the accelerometer data thanks to the following:
Found the following error:
Group Full RunTimeError for label.py: text was too long
Also realising waiting 180s is very boring!