Instagram filter used: Clarendon
Author: scruss
-
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:
The best words ever to appear on a computer screen Baddies off in the distance I appear to be shooting small jellyfish, or lumps of ice cream Ooh, night patrol … splatoo! menaced by trees red sky means level up kablooie and missing tree tops new level, new sky color narrowly missing trees -
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(): 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.
-
Clap Sensor part for Fritzing
I have no idea if this wiring would work, but it’s pretty … 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.
-
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 Options → B1 Desktop / CLI → B4 Desktop Autologin:
Enable VNC on Startup
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.)
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! -
creature so smol
This little one was napping in the sun on the bike path.
morning snooze tall shadow, smol critter vole sundial vole nap breakfast doin a hide vole’s eye view more napping in the tall grass