Getting Started
Adafruit Playground is a wonderful and safe place to share your interests with Adafruit's vibrant community of makers and doers. Have a cool project you are working on? Have a bit of code that you think others will find useful? Want to show off your electronics workbench? You have come to the right place.
The goal of Adafruit Playground is to make it as simple as possible to share your work. On the Adafruit Playground users can create Notes. A note is a single-page space where you can document your topic using Adafruit's easy-to-use editor. Notes are like Guides on the Adafruit Learning System but guides are high-fidelity content curated and maintained by Adafuit. Notes are whatever you want them to be. Have fun and be kind.
Click here to learn more about Adafruit Playground and how to get started.
-
Pinned by jepler
About Jeff
I’ve been a software developer ever since I first started typing in program listings on an 80s home computer.
I’ve been a contributor to Free and Open Source software for over 20 years. See my github profile for my contributions and original software.
I'm proud to be working with Adafruit, mainly on CircuitPython, and helping enable people learn and create fun projects with whatever environment works best for them.
-
E-Ink Countdown in CircuitPython with Custom Stand
Along the way I learned a few things:
- How to take an Adafruit PCB design in Eagle format and import the board outline all the way into FreeCAD for locating dimensions and features
- How to make my code robust against transient errors like network errors
- How to make my code deep sleep for the right length of time
There are also a few things this code demonstrates that are less common knowledge:
- Using fonts from the font bundle
- Using the datetime module for arithmetic on dates & times
- Increasing reliability by re-trying operations that can fail
- Reducing battery usage by deep sleeping and avoiding connecting to WiFi
This project uses FreeCAD & KiCAD, both of which are Open Source software that are free to download & use.
Parts Needed
Code & Installation
I recommend using Adafruit circup to install the needed libraries for projects. Here's what you need to do:
- Install circup on your desktop computer
- Enable the "fonts bundle" by running this command (just once, circup remembers this setting):
circup bundle-add adafruit/circuitpython-fonts
- Copy code.py to your CIRCUITPY drive (Download it via the "raw" link at https://gist.github.com/jepler/b2c020a6caa65a31297053b7216fcc15)
- Run the following command to auto-install required libraries:
circup install -a
You'll also want to configure wifi on your device using settings.toml. For lower power usage, configure WIFI_SSID and WIFI_PASSWORD options. For web workflow but higher power usage, configure CIRCUITPY_WIFI_SSID and CIRCUITPY_WIFI_PASSWORD options.
-
Archiving Xerox 820 8" Floppies
My Xerox 820 CP/M computer has a large external drive enclosure with two 8" SS/DD floppy drives in it. They have a "shugart" interface inside, brought out to a proprietary-but-documented 37-pin D-style connector. Because the data signals used by floppy drives changed very little over the decades (at least in the CP/M and PC worlds; Commodore and Apple users, don't @ me) all the signals mostly map closely enough onto IBM PC 34-pin connector.
I previously made a passive adapter board so that a "Gotek" floppy drive emulator could replace the drive enclosure, and it worked! (and is a LOT less loud than 2 8" floppy drives spinning all the time!!!)
That got me thinking: could I make a 2nd adapter board that would let me archive 8" floppies? Then, inspiration struck: I didn't even need a 2nd board design. Instead of fitting a plug ("male") connector on the board's top side, I could simply fit a socket ("female") connector on the board's bottom side.
Since I'd gotten 5 boards in my PCB order, I just had to wait for delivery of the connector and solder everything up.
Both archiving and writing worked on the first try, with greaseweazle host software and an Adafruit Floppsy prototype board; a genuine GreaseWeazle should work just the same.
You can grab the kicad design files from my xerox 820 repository on github and order them from the board house of your choice.
Soldering the PCB
- Take a 2x36 pin header strip and snip off a 2x17 portion of it, reseving the rest for another project
- Solder this header on the top side of the board (where the silk is visible)
- Solder a 37-pin receptacle ("female") connector on the bottom side of the board (opposite the silk)
- The "mod" area is unused
- The 4-pin floppy power connector is ununsed
Connecting the board
Plug the floppy enclosure into the "D" connector; this is polarized so it can go only one way. Then, noting the "pin 1" location on both the GreaseWeazle/floppsy and the converter PCB, connect a straight through 34-pin ribbon cable.
Invoking greaseweazle
First, install greaseweazle host software according to the directions, and install a greaseweazle-compatible firmware on your device. Check that "
gw info" can find and report your device info; you may need to provide a "--device" flag to all greaseweazle commands if you are using a greaseweazle-compatible device, not a genuine greasweazle. (e.g., "gw info --port COM31")To archive a floppy:
- For safety against unintentionally writing to a floppy, the Adafruit Floppsy has a write enable switch. Slide it to the "OFF" position.
- Insert a floppy. For Floppsy, use the "B" drive. For a genuine GreaseWeazle you can use either "A" or "B" via the
--driveflag. - Create the disk image:
gw read --format dec.rx01 cpm.img
When the process completes, you will be shown a summary of any parts of the floppy that could not successfully be read.
To write a previously read floppy image note that this will irrevocably destroy the data previously on the floppy:
- If you're using an Adafruit Floppsy, make sure the write enable switch is in the ON position
- The floppy must also be write-enabled. On 8" floppies, this is done by covering the "write protect" notch on the right side of the bottom edge. Some 8" floppies were manufactured with no notch, in which case they are never write protected (this is opposite to the situation with 5.25" floppies)
- Insert the floppy you want to write to. For Floppsy, use the "B" drive. For a genuine GreaseWeazle you can use either "A" or "B" via the
--driveflag. - Write the disk image:
gw write --format dec.rx01 cpm.img
When the process completes, you will be shown a summary of any parts of the floppy that could not successfully be verified. All 8" floppy media is decades old, and unreadable/unwritable sectors are an unfortunate fact of life.
On the internal organization of image files
These images come out in the correct format & organization to use with the flashfloppy configuration I posted on my earlier playground note. CP/M had some complicated rules relating to sector numbering & interleaving, and each manufacturer could actually use different formats & organizations from every other manufacturer! Different conventions for archival images can place the sectors in a different organization, so when it comes to using images from the internet you may have to use conversion software to make sure the data is in the correct order. Unfortunately, the only way to do this is by trial and error.
-
Xerox 820 Gotek Adapter
The Xerox 820 CP/M computer could interface with dual 8" floppy drives (or up to 4 5.25" drives!).
While I did have a working pair of drives, I wanted the ability to run my 820 off of a floppy emulator. I picked a "Gotek" branded floppy emulator with the open source Flash Floppy firmware.
The Xerox has a bespoke 37-pin D-style connector for its floppy drives, so I created a passive adapter PCB.
After configuring Flash Floppy and loading up a CP/M disk image I was able to boot to CP/M without the pair of incredibly loud drives spinning in the background.
The "mod" section was for bodges but it turned out no bodge wires were needed. (it's not a header for a 2nd drive, sadly)
The gotek's default "S1" jumper position is for the CP/M "B" drive and the "S0" position is for the CP/M "A" drive, so most of the time you'll want to move the gotek's selection jumper to the "S0" position.
You can grab the kicad design files from my xerox 820 repository on github. A bootable CP/M image is also in the repo
Here's the content of ff.cfg:
-
Unicomp Mini M with CircuitPython
Unicomp Mini M with CircuitPython
Unicomp is the heir to the IBM Buckling Spring legacy. This style of keyboard has a distinctive sound & feel which some people just can't get enough of. I'm one of them, having used a crusty old Model M for at least a decade at work.
Their "Mini M" is an 87-key ("tenkeyless") layout, and in late summer 2023 the controller was replaced with a board that has a Raspberry Pi Pico soldered on to it.
It's too soon for me to have formed a strong opinion about this keyboard, though I will note that the cable seems to be in the category of "incredibly cursed": It is a USB A-A cable, which should not exist. If your computer is USB-C only you're entering dongle city, but, you're probably used to that.
In this mini-guide, you'll learn how to replace the factory firmware with a fully customizable CircuitPython firmware. Of course, once you have the controller in UF2 bootloader mode, you could also use Arduino or Pico-SDK to program it with the software of your choice.
Note that this involves opening up the keyboard enclosure and there is always the possibility that you will damage the keyboard while doing so.
Reverse Engineering
I don't know who all to credit for the reverse engineering, but all the information I needed was in a fork of the open source keyboard controller "Vial-QMK". Here are the basics:
- Keyboard is organized as a 16x12 matrix, with the columns controlled by a pair of 8-channel muxes. Together, pico pins GP0 through GP4 select one of 16 column channels, with just one of GP3 or GP4 selected by setting to a False pin value
- The 12 row inputs are GP11 through GP22
- The LEDs are on GP6 through 8, with a common anode on GP5 (so set GP5 True always, and GP6 through 8 to False to light the corresponding LED; GP6 is Num Lock)
- The matrix has no diodes, so anti-ghosting must be done in software
-
RunCPM with USB Host Featherwing
The original RunCPM project I did used two feathers with RP2040 microcontrollers: one for DVI output and one for USB input.
Now, with the USB Host Featherwing, there's theoretically no need for the second microcontroller.
The Adalogger Featherwing and the USB Host Featherwing need to have separate CS (Chip Select) pins.
For this project, I modified the USB Host Featherwing. I cut the small trace next to the pad labeled "CS", then soldered in a small jumper wire from CS to GPIO11, the spot just above the one labeled "GPX".
-
Archiving Old Github Forks with PyGithub
Over the years I've been using github, and especially while I've been working with Adafruit, I have quite the collection of forked repositories on github. Most of them haven't been updated in years. I decided that I wanted to archive all my forks that hadn't been updated in the last 2 years—over 200 repositories. This would take a long time manually on the github website, so I wrote a script to do it instead.
To use the script (included below), you'll need to
- Create an authorization token for your github account. It needs access to all your repositories to perform administration tasks. You can create a "fine grained" token within your user's settings on github.
- Edit the script to set the correct owner_name and token
Next, run the script once in the terminal. It'll print a line for each repository it will archive. If the list looks correct, then uncomment the "repo.edit" line and run the script a second time. This will actually archive the repositories.
These images show the permissions you need to give the token created for this purpose. They reflect github's web UI in early 2024: