NB: this version doesn’t actually do the rebooting or shutting down: it’s a demo. This one does, though …
Here’s how you might have just one button being a reset button (hold down for two seconds) or a shutdown button (hold down for five):
work as if you live in the early days of a better nation
NB: this version doesn’t actually do the rebooting or shutting down: it’s a demo. This one does, though …
Here’s how you might have just one button being a reset button (hold down for two seconds) or a shutdown button (hold down for five):
Hey! This process permanently modifies your Raspberry Pi and may prevent it from working with many HATs and add-ons … It also has some really fiddly soldering. If in doubt, don’t.
Pimoroni’s OnOff SHIM adds what the Raspberry Pi should have had all along: a power button. While there are lots of soft power switches out there, the OnOff Shim adds circuitry to cut power to the Raspberry Pi after shutdown.
While the shim comes with a 12-socket header, that prevents you from using any other device that uses the leftmost GPIO pins. I wanted access to all the pins, and not have the shim create an unsightly bump on the pins. So this is what I did …
The OnOff SHIM uses GPIO pin BCM 17 (physical pin 11) as the power button sensor and BCM 4 as the power off signal. Any device that also uses BCM 17 (and possibly BCM 4) will likely cause the reset process to be triggered. This means that I can’t use the shim with my Inky pHAT EPD. You would have thought that Pimoroni might’ve considered that, since they made both. Consulting pinout.xyz suggests that 41 boards that likely may not work with the OnOff shim: Cirrus Logic Audio Card, Display-o-Tron 3000, DOTs, Enviro pHAT, ESP IoT pHAT, Explorer HAT, Explorer HAT Pro, Flex, GertVGA 666, High-Precision AD/DA Board, Hyperpixel, Inky pHAT, IoT pHAT, LEDBorg, MotoZero, Navio2 Autopilot, PaPiRus HAT, PaPiRus Zero, Piano HAT, Pibrella, Picade HAT, Pi Cap, PiGRRL Gamepad, Pi-LITE-r, Pi-mote, Pi PoE Switch HAT, PiStep2 Dual, PiStep2 Quad, Pi Stop, Propeller HAT, RoboHat, RTK Motor Controller, Servo PWM Pi Zero, Skywriter HAT, Ultimate GPS HAT, Voice HAT, Witty Pi, Witty Pi 2, Zero2Go, Zero LiPo and ZeroSeg.
While I like the OnOff SHIM, check carefully that it will work with your application.
Updated 2020-11-28: thanks, Ennio! Should now build after new Raspberry Pi OS and Vice changes
As requested on our local Commodore user group mailing list, how to install VICE on a Raspberry Pi running Raspberry Pi OS:
sudo apt install autoconf automake build-essential byacc dos2unix flex libavcodec-dev libavformat-dev libgtk2.0-cil-dev libgtkglext1-dev libmp3lame-dev libmpg123-dev libpcap-dev libpulse-dev libreadline-dev libswscale-dev libvte-dev libxaw7-dev subversion yasm libgtk3.0-cil-dev xa65 libsdl2-dev libsdl2-image-dev libgtk-3-dev libglew-dev mkdir -p src cd src svn checkout https://svn.code.sf.net/p/vice-emu/code/trunk trunk cd trunk/vice ./autogen.sh ./configure --disable-pdf-docs make -j4 sudo make install
This was freely adapted from the build docs, Linux-Native-Howto.txt, which has more info if you get stuck.
If you’re feeling fancy and want nice GUI controls and sound recording and menu stuff, try
./configure --disable-pdf-docs --enable-lame --with-mpg123 --enable-shared-ffmpeg --enable-x64 --enable-native-gtk3ui --enable-desktop-files
This will give you desktop icons too. I’m not sure in the apt line is quite right, though — but I’ve had my doubts about all those CIL entries, ‘cos I think they pull in Mono/.Net, and who would want to use that?
gpiozero (‘A simple interface to GPIO devices with Raspberry Pi’) continues to impress me. One of its newer features is a pinout guide, accessed by the pinout command:
I’m trying to resist running it on every generation of Raspberry Pi that I have (B, A, 2B, 3B, Zero, Zero W) just for these pretty displays.
(ANSI console colours captured using script, then fed through ansi2html [from the Ubuntu colorized-logs package], printed to PDF from Firefox then mucked about a bit with in Inkscape)
A bit dusty, and no sound, but worked out pretty well. (YouTube link if embed doesn’t work — inky phat draws a design)
This is a 600 dpi scan of a Pimoroni Inky pHAT EPD display. EPDs — electrophoretic displays, aka ‘e-ink’ or ‘e-paper’ — retain their image when turned off, so this Raspberry Pi had no power when I scanned it.
The image I made to fit the display is really small —
It’s a bit of a process making the images with just the right palette in GIMP, but I’m pleased how it turned out. I’d like to be able to write the vector images directly to the screen from SVG, but that might take some time.
I gave a talk about retro-gaming on the Raspberry Pi yesterday. I was describing RetroPie, and I really needed lots of screenshots to illustrate games. I’m used to grabbing screens under X, but RetroPie runs without it, so all my usual tools were of no use.
I’d just found out about raspi2png, and it works really well! Usage is simple: just call it like
raspi2png -p outfile.png
and it’ll save whatever’s on the screen. It doesn’t play well with X, but there are already tools to take screenshots with that. As I was playing games, I didn’t want to have to pause the computer to take a shot, so I ran the command every five seconds for 30*5 seconds like this:
for f in {1..30}; do raspi2png -p retro_$(date -Iseconds).png; sleep 5; done
Here are some quality shots via raspi2png from Deathchase, officially the best ZX Spectrum game ever:
Well, that was easy!
Since the Verbal Machines VM-CLAP1 sensor is an open collector type — that is, it sinks current when triggered — it behaves like a simple button to gpiozero, the Raspberry Pi Python GPIO library. If you attach a callback function to the sensor’s when_pressed event, your Python script will call that function every time it registers a clap.
The wiring is as simple as it could be:
VM-CLAP1: Raspberry Pi:  ========= =============  GND → GND  PWR → 3V3  OUT → GPIO 4
This example code just prints clap! when the board picks up a ðŸ‘:
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Raspberry Pi gpiozero test for # Verbal Machines VM-CLAP1 clap sensor # scruss - 2017-06 # # Wiring: # # VM-CLAP1: Raspberry Pi: # ========= ============= # GND → GND # PWR → 3V3 # OUT → GPIO 4 from gpiozero import Button from signal import pause def clapping(): print("clap!") clap = Button(4) clap.when_pressed = clapping pause()
This is a trivial example, but at least it shows that anything you can do with a button, you can also do with this hand-clap sensor.
For work, I blogged about Verbal Machines‘ Hand Clap Sensor VM-CLAP1 (“Clap on ðŸ‘ðŸ‘, Clap off ðŸ‘👠– Elmwood Electronicsâ€). I’ve made a preliminary part for Fritzing for the board: VM-CLAP1 Clap Sensor for Fritzing.zip
It should work in Breadboard and Schematic mode, but absolutely doesn’t work in PCB mode. This shouldn’t be a problem, as it’s only available as a standalone board. Fritzing doesn’t have any way to create new parts from scratch any more, so I had to base it on a somewhat similar-looking board, the SparkFun Electret Microphone Breakout.
I’m looking forward to see what I can do with gpiozero and the clap sensor.
I just set up a Raspberry Pi Zero to be a little breadboard computer. Running a headless machine only through SSH gets a bit dull at times, so the inclusion of VNC Connect in Raspbian is handy.
Only problem was that the default screen size — something like 720×480 — was too small for most dialogue windows. Here’s how to enable a more useful resolution of 1024 × 768.
All of these are enabled from the raspi-config tool, so open a terminal and start it with:
sudo raspi-config
Select 3 Boot Options → B1 Desktop / CLI → B4 Desktop Autologin:
Select 5 Interfacing Options → P3 VNC, and answer Yes to Would you like the VNC Server to be enabled?:
Set Screen Resolution
Select 7 Advanced Options → A5 Resolution → DMT Mode 16 (1024×768) …:
Once you’ve enabled all of these, raspi-config will ask if you wish to reboot your Raspberry Pi. Once it has rebooted, you should have a usable remote desktop.
(All of the above screenshots were taken from a headless Raspberry Pi Zero via VNC.)
These were taken later on a Raspberry Pi 2 I’m setting up for a maker festival booth:
Digital (aka DEC) used to make some very solid minicomputers back when a minicomputer was fridge-sized and people were still building nuclear power stations to be controlled by them. The Raspberry Pi Zero is a very mini computer indeed, and in USB gadget mode running SimH it makes a nice little emulation platform.
The case is from Thingiverse: One Piece Raspberry Pi Zero + Camera Case (with GPIO) by Superrei, but with the DEC PDP logo in relief on the top.
DEC minis were famous for their arrays of blinkenlights. The Pocket DEC Pretender, not so much: it has one tiny green light that flickers a bit now and again:
But it’s a genuinely useful (for my values of useful) emulation platform. Here it is pretending to be a PDP-8, running BASIC under OS-8:
(background in case pictures woven in Toronto by Deftly Weft)
Update: You probably want to use https://github.com/linappleii/linapple instead of Linapple-Pie these days.
Building and installing the linapple-pie Apple IIe emulator is relatively easy on the Raspberry Pi:
sudo apt install libcurl4-openssl-dev libzip-dev zlib1g-dev libsdl1.2-dev libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-sound1.2-dev build-essential git git clone https://github.com/dabonetn/linapple-pie.git cd linapple-pie/src make sudo make install
This also works on an x86_64 Ubuntu machine. It does also install on a PocketCHIP (even if it takes a really long time) but I can’t get the display resolution to fit correctly.
The Raspberry Pi Zero can be set up to appear as one of several USB OTG “gadgets†if you plug it into another computer. The most popular setting seems to be the virtual network gadget that turns your Zero into a computer on the end of your USB cable. Andrew Mulholland’s guide Raspberry Pi Zero – Programming over USB! (Part 2) (along with his super-short simple guide) seems to be the definitive source on how to set these modes up.
One problem, though, is that the Zero would show up on different network addresses every time it was restarted. The changing addresses made ssh access no fun at all. A suggestion on the Raspberry Pi forum helped me come up with a solution. On the Raspberry Pi Zero, run this command once:
echo 'options g_ether host_addr='$(dmesg | awk '/: HOST MAC/{print $NF}')' dev_addr='$(dmesg | awk '/: MAC/{print $NF}') | sudo tee /etc/modprobe.d/g_ether.conf
This will set the USB port’s hardware addresses to a fixed value, and you should always get a connection on the same IP address if it’s available.
Update: For some reason, this seemed to stop working, and I was getting the old random addresses again. I was resisting putting more stuff in /boot/cmdline.txt, but it seems to me it’s more reliable than what I proposed. So if your g_ether.conf looked like:
options g_ether host_addr=66:e0:94:40:44:74 dev_addr=de:82:66:79:e2:66
right at the end of your /boot/cmdline.txt (which is all one line, btw), add
g_ether.host_addr=66:e0:94:40:44:74 g_ether.dev_addr=de:82:66:79:e2:66
You’ll probably also want to share the IPv4 connection so your Raspberry Pi Zero can use the network of the device it’s attached to:
Running Mini vMac on a Raspberry Pi is hardly news. But maybe running it as a colour Mac II is. The screen size I’ve chosen is closer to a Color Classic, for no other reason that I like it.
To build a Mac II-capable version of Mini vMac, you’ll need the Alpha source code. You’ll also need a working Mini vMac setup, as it uses a 68k Mac program to set up the source. Pretty much any basic setup and bootable disk will run this okay:
The build options I chose are:
-t larm -ccs -m II -hres 512 -vres 384 -depth 3 -mf 2 -magnify 1 -em-cpu 2 -mem 8M
I’ve chosen to swap the Ctrl key with the Command (⌘) key, as most non-Mac keyboards work better with this.
The build program will export a file out/minivmac-3.5.0-larm.tar that you can unpack into the full source code. It’s a really simple build, and fast, too.
Now you’ll need a Mac IIx ROM image (which I’m not supposed to help you find, but it’s an easy search) and OS image disks from the Mini vMac System Software page. Have fun!
I wanted to have a “Hey, be here now!†ping throughout the working day. Something loud enough to hear, but not irritating.
Doing this with cron was harder than you might expect. It seems that sound is typically part of the X11 display infrastructure, so you need to give the command permission to make a noise on this particular machine’s display. Here’s the crontab line I came up with:
# m h dom mon dow  command 0 9-17 * * 1-5 export DISPLAY=:0 && /usr/bin/play -q /home/scruss/sounds/ting/ting.wav
That translates as: at 0 minutes past the hours of 09:00 to 17:00 on any weekday (day of week = 1-5, and we don’t care about day of month or which month it is), execute the command play (part of the sox package) with no text output (-q). cron needs environment variables like DISPLAY set, and prefers full command paths. It may trigger a second or so after the turn of the hour; this is good enough for me.
As for the alert, I wanted something distinctive — percussive, short, bright — but with a tiny bit of modulation to stop it sounding like a bland computer-generated sine wave. This is what I made; click on the image and the sound should play or download:
It’s essentially a 2093 Hz (C7) sine wave, mixed with itself frequency-modulated at 7 Hz. Why 7 Hz? Apart from sounding about right, 2093 is exactly divisible by 7, 13 & 23, so I used a factor for neatness.
There was some later messing about in Audacity (mostly fades and length edits; I forget exactly what). The two components were generated using sox:
sox -n ting-plain.wav synth 1 sine C7 fade l 0 1 1 sox -n ting-vibrato.wav synth 1 sin C7 synth 1 sine fmod 7 fade l 0 1 1
Yes, sox does have pretty horrible syntax, doesn’t it?
The frequency-modulated one seems to be pretty close to the final result. It would be less time spent trying to save time …
micro – https://github.com/zyedidia/micro – is a terminal-based text editor. Unlike vi, emacs and nano, it has sensible default command keys: Ctrl+S saves, Ctrl+Q quits, Ctrl+X/C/V cuts/copies/pastes, etc. micro also supports full mouse control (even over ssh), Unicode and colour syntax highlighting.
micro is written in Go – https://golang.org – so is very easy to install:
go get -u github.com/zyedidia/micro/...
If you don’t already have Go installed, it’s pretty simple, even on a Raspberry Pi: https://golang.org/doc/install
If your running under Linux, you probably want to have xclip installed for better cut/paste support.
Overall, I really like micro. It’s much easier to use than any of the standard Linux text editors. It uses key commands that most people expect. Creating code should not be made harder than it needs to be.
(I was about to suggest FTE, as it appears to be the closest thing to the old MS-DOS 6 editor that I’ve seen under Linux. While it’s a great plain text editor, its Unicode support isn’t where it needs to be in 2016.
micro suggestion came via MetaFilter’s Ctrl + Q to quit. Need I say more?)
My previous adventures with my Sinclair ZX Spectrum 48K in Canada were not resounding successes. I couldn’t get the display to work, and tapes wouldn’t load well, so I’d been using Fuse while the hardware sulked in a cupboard.
I’d previously got a proper power supply (9 V DC, ≥ 1.4 A, centre negative) and bypassed the PAL UHF modulator to give composite video. No television, monitor or converter box that I had tried seemed to give a useful display.
Back in May, Walter Miraglia brought a tiny 7″ composite colour monitor to TPUG‘s Retrocomputing Night. He let me try it with the Spectrum, and it worked very well. Walter said it was an extension monitor for a car DVD player.
I dug around, and found that local surplus clearout store Tech Source Canada had the Philips 7″ portable DVD Player PD7016/37 for $60. This gives you two identical DVD players with composite input. I think my other one will be destined for a Raspberry Pi project somewhere.
To get these monitors running, you’ll need:
Connect it up , and — success! Well, slightly qualified success. The screens do not have the greatest resolution, so pixels are slightly smeared together. The screens do have a decently fast refresh, and the whole look is just right. With its colour clash and dot crawl, nobody ever expected great video from the Speccy anyway.
Here are some screen shots taken with my phone, and a couple of pixel-sharp screenshots from Fuse to compare:
So I can now definitely view the screens. Huge thanks to Walter for tipping me off to these DVD players.
[Incidentally, the screens are designed for car use, so don’t stand up properly unless you get creative with some supports. I laser-cut these out of 3 mm plywood:
Glue the little sticks on to the flat ends, and they’ll fit into the slots in the back of the monitor. Here are the feet with the sticks fitted:
There are better-designed feet than these, but they work, mostly.]
I was still having game loading problems. Try as I might, I couldn’t get anything to load reliably. Retrocomputing Stack Exchange came to the rescue, in the shape of mcleod_ideafix’s very helpful answer. If your audio player is running from batteries and you can use a stereo cable, you can convert the normal mono loading audio into stereo with one channel inverted. This gives you effectively double the volume, and works quite well with my audio player, an old Edirol R-1*.
This audio will not load into an emulator, or work with a mono cable. Some audio players even render it as silence.
Here’s a script to take monophonic loading data and convert it to this faux-differential stereo format using Sox:
#!/bin/bash # wav2differential.sh - convert mono game tape audio to 2× stereo # usage:  wav2differential.sh infile.wav #         (creates infile-differential.wav) # scruss - 2016-06-07 # method by ‘mcleod_ideafix’; many thanks / greetz #  — https://retrocomputing.stackexchange.com/a/774/439 base="${1%.wav}" sox -q --norm=-3 "$1" -b 16 "${base}-n.wav" sox -q "${base}-n.wav" "${base}-ni.wav" vol -1.0 sox -q --norm=-0.1 -M -c 1 "${base}-n.wav" -c 1 "${base}-ni.wav" -c 2 -b 8 "${base}-differential.wav" rm -f "${base}-n.wav" "${base}-ni.wav"
If you want to check your audio levels, sox can also create the 800 Hz header tone used by the Spectrum. Run the output of the command below through the script above, load it onto your audio player and fiddle with the volume until the border flickers steadily:
sox -n -b 8 -r 8000 800hz-header.wav synth 30 square 800
I was also looking for the games to load fairly quickly. Tapes used to take over three minutes to load, and while retrogaming all is about the experience, I haven’t got time for that. Fuse has some utility programs which will convert a .Z80 game snapshot into an audio file that loads in about 1¼ minutes.
To convert the snapshot to a speed-load TZX tape image:
snap2tzx -o game.tzx -s 3 game.z80
To convert that virtual tape image into audio:
tape2wav -r 16000 game.tzx game.wav
You can then run that WAV file through the stereo/differential script I listed above. Have fun!
Laser cut template: coo-coo-rpi_zero-acryl.zip
Build notes: The “Coo~Coo†Raspberry Pi Zero Case