MagTag Day of Week

I’ve been very excited by CircuitPython’s move into the ESP32-S2 space. The ESP32-S2 is a WiFi-enabled microcontroller with built-in USB and a crypto engine so it can do HTTPS properly. And in Python! CircuitPython is much more pleasant than Arduino for network-based tasks, where there’s lots of string processing.

So for this week’s Deep Fried Neurons Happy Hour, I decided to take a cue from Carlyn’s revisiting a DFN project and revisit my “day of week” device. The first one was an orange 3d printed “week wheel”, partially seen above. Now it’s an ePaper- and ESP32-S2-based MagTag from Adafruit. The MagTag device is really nice. And it’s got little magnet feet! I put the code up on github. It’s basically a clock, but one that only updates once a day. Each day’s display is a typographic take on what I often feel on each day. Monday is serious and tilted up: “We’re gonna do this!”. Tuesday is a “work day, just work”. By Wednesday I’m starting to slip. Thursday my energy is regained! On Friday (above) I’m optimistic for all I’m going to do on the weekend, but with a little trepidation. (I usually just slack). Saturday is all relaxed, yup I’m slacking. And with Sunday, I’m worried about the upcoming week, I can’t believe the weekend’s already over!

Currently the code updates the display once an hour. Since ePaper displays require no power when not changing, it really could only wake up once-a-day. The battery should last for weeks. The CircuitPython team is continuing work on low-power modes to reduce power consumption, so battery life could get even better. It solves one of the main problems I had with my 3d printed “week wheel”: it required me to update it manually every day. Now the fridge can tell me what day it is because… what day is it?

Converting Pixel Art for Matrix Portal

“The spice must flow”

I tried my hand at pixel art and discovered I cannot do it. But I wanted to honor Justin in a pixel arty way, so I instead tried my hand at converting some of his pixel art for display on a 32×64 RGB LED matrix driven by a Matrix Portal driving. This wasn’t so easy. First, scaling down the already abstracted ~250×250 pixel images to something around 32×64 doesn’t look right if you use normal resize techniques: the results are too fuzzy. Thankfully ImageMagick has an “–adaptive-resize” option that preserves the sharp color transitions of pixel art. Secondly, most of his art was relatively 1:1 square in proportion but the LED matrix is a 2:1. This means some editorial cropping of the images to keep the most salient parts visible. Not an easy task when every pixel counts. I hope I did them justice.

Spoooky CircuitPython Circuits!

After using Python for a decade, I’ve decided to finally get better at it. I think diving into CircuitPython will be a nice scaled-down universe to learn to write concise “Pythonic” code. For hardware I’m using Adafruit’s new QT Py board and CircuitPython’s new ESP32-S2 support. And for a theme this month I want to do “spooky circuits”, sort of a callback to my Spooky Arduino class from 2006.

I’ve been working on a “QT Py Tricks” page on github, where I’m cataloging for myself how to do basic microcontroller things in CircuitPython, in the even more reduced footprint that the QT Py and Trinket M0 boards provide (they don’t have the extra flash space that enables about half of CircuitPython’s abilities, e.g. see the support matrix)

Here’s two of the spooky projects I have so far: a tiny fire simulation and a scary servo eyeball. For the code, check out the QT Py Tricks page. Stay tuned for more!

Prevent annoying Mac ._ files on CIRCUITPY

Example: Unzip & Download files to CIRCUITPY

The entire process in a single session, using a neopixel example:

% unzip adafruit-circuitpython-bundle-6.x-mpy-20201003.zip
% xattr -cr adafruit-circuitpython-bundle-6.x-mpy-20201003
% cd adafruit-circuitpython-bundle-6.x-mpy-20201003
% cp lib/{neopixel.mpy, adafruit_pypixelbuf.mpy} /Volumes/CIRCUITPY/lib
% cp examples/neopixel_simpletest.py /Volumes/CIRCUITPY/code.py

(Or like JP suggests in the comments, you can use “cp -X” to not copy extended attributes: e.g. cp -X /examples/neopixel_simpletest.py /Volumes/CIRCUITPY )

Background

On the Mac, the OS stores a bunch of different meta information about files inside those files. These are called “Extended Attributes” or “xattrs”. If you copy a file on a Mac to a thumbdrive or network share that doesn’t support extended attributes, macOS attempts to convert those xattrs to a plain file format. That’s what the ._ and .DS_Store files are.

These files are normally just an annoyance, but for CircuitPython devices with little flash storage space, like the Trinket M0 or QT Py, it can be a real problem. So here’s some tips.

Treat files as contaminated and No Finder

If you have a folder on your Mac with files you want to copy to the CIRCUITPY drive, do not use the Finder to copy the files. Or to look at the directory those files are in. Or to look at the CIRCUITPY drive. Instead you must use the command-line. Any time the Finder shows you files, it may recreate these xattrs or the ._ files on CIRCUITPY.

See extended attributes with xattrs

The system tool xattrs lets you examine extended attributes. For instance, let’s say you just downloaded and unzipped the latest CircuitPython library bundle. In the Terminal, you can run xattr -r on the directory to see all attributes on all files in that directory. The example below shows how they all have the quarantine attribute set because it’s a file downloaded from the Internet.

% xattr -r adafruit-circuitpython-bundle-6.x-mpy-20201003
adafruit-circuitpython-bundle-6.x-mpy-20201003/VERSIONS.txt: com.apple.quarantine
adafruit-circuitpython-bundle-6.x-mpy-20201003/examples/lsm303_simpletest.py: com.apple.quarantine
adafruit-circuitpython-bundle-6.x-mpy-20201003/examples/is31fl3731_pillow_numbers.py: com.apple.quarantine
[...]

Delete extended attributes with xattrs

You can delete these attributes on all files in a directory with one command. Copy the files immediately after doing so before the Finder recreates them.

% xattr -cr adafruit-circuitpython-bundle-6.x-mpy-20201003

Remove existing ._ files with dot_clean

If you accidentally copied files without using xattr -c or otherwise have ._ files. You can delete them by hand or use the system tool dot_clean to remove them from the whole drive:

% dot_clean /Volumes/CIRCUITPY

Any time it feels you’re running low on CIRCUITPY disk space, check to see it’s not full of these dang meta info files.

Most of the stuff about xattr came from this nice post by JayRizzo on StackOverflow.

Touring Machine First PCBs!

Last week I submitted PCBs to be fabbed and got them back this week. They look pretty good! I’ve not soldered anything down yet but the footprints are all good except for the rotary encoder mounting holes. The Eagle part I used has them at 2.05mm but they need to be 2.4mm. I need to track down where I got that footprint because it’s clearly wrong. In the next few days I’ll be soldering it up in sections and testing them out. On the UI front, I’ve been using my “knobtester” board and a small neopixel strip to explore UI thoughts. It’s been fun. But otherwise not much movement on this project, so please enjoy this little chill jam I did instead of working on it, and ostensibly part of the “30 sounds” effort.

The Start of the Touring Machine Eurorack module

The original goal of my month-long Deep Fried Neurons project was “30 sounds, one per day”, an exploration into making sounds with Eurorack gear that doesn’t use sequencers or keyboards. While I only created 15 sounds so far (I’ll still do all 30 I think), I’ve been increasingly using some home-built modules like my TrinketTrigger and TrinketTouringMachine, and that’s given me ideas.

So for my next month project, I’m going to design and build a production-ready module that expands on what I’ve learned. It will be a better “Touring Machine” algorithmic melody generator that builds on the TrinketTouringMachine, but offers proper modular synth signal in/out and additional control knobs. It’s also a platform for getting over my reluctance to designing opamp circuits, something I was okay at once many years ago. I’ve got the start of a design based on an ItsyBitsy M4 and will be prototyping next week.

30 sounds, one per day

I’ve decided to do “30 sounds, one per day”.  I’m a bit behind, but here’s a Youtube playlist of what I have so far and the corresponding Bandcamp album. These are to be sounds. Not tracks, not songs. Just interesting sonic experiments. I want to make sounds I’ve never heard before, or sounds I’ve always wanted to create. For tools, I’m making myself use only hardware music gear, no Ableton Live, no VSTs. And minimize the use of MIDI sequencers. (The tracks thus far are made rhythmic purely from envelope generators) Some homemade gear might make an appearance and that could fun too.