Easy Raspberry Pi framebuffer screenshots with raspi2png

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:

VM-CLAP1 👏 sensor + gpiozero on Raspberry Pi

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():

clap = Button(4)
clap.when_pressed = clapping

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.

Clap Sensor part for Fritzing

I have no idea if this wiring would work, but it’s pretty …

For work, I blogged about Verbal MachinesHand 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.

Headless Raspberry Pi + VNC: useful resolution

Breadboards of Canada …

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

Enable Boot to Desktop

Select 3 Boot OptionsB1 Desktop / CLIB4 Desktop Autologin:

Enable VNC on Startup

Select 5 Interfacing OptionsP3 VNC, and answer Yes to Would you like the VNC Server to be enabled?:

Set Screen Resolution

Select 7 Advanced OptionsA5 ResolutionDMT 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.)

Before & After

These were taken later on a Raspberry Pi 2 I’m setting up for a maker festival booth:

decidedly smol: 720×480
fix it to 1024×768 …
so much better!

If I was going to design a spinner anyway, at least I tried to make it not too hideous

If I was going to design a spinner anyway, at least I tried to make it not too hideous

If I was going to design a spinner anyway, at least I tried to make it not too hideous

Instagram filter used: Lo-fi

View in Instagram ⇒