Taking a screenshot of the Midiboy screen

I’m almost ready to release a sketch for the Midiboy.
I’m currently writing the documentation and thought it would be nice to add some screenshots.
I have noticed that many sketches are accompanied by such screenshots, but how do you make them? Is there an easy way?

We did it by dumping bitmap data via UART pins and connecting an external USB Serial interface or logic analyzer to the PC to receive it, then using GIMP to open raw bitmap data files, given a 1 bit 128x64 pixels format, or running it through a script. I’ve found the Python script I used for converting the received data from logic analyzer’s .csv files into frame-by-frame images, listed below.

Unfortunately as the USB is emulated in software, it’s too slow for such raw data dumps. The next best option would be to use some code to encode the screen data into a MIDI SysEx stream and use a MIDI interface to receive it on the host, and decode it into an image. I don’t have any code written for this.

import csv
import sys
from PIL import Image

data = bytearray()
with open(sys.argv[1]) as csv_file:
	reader = csv.reader(csv_file, delimiter=',')
	first = True
	counter = 0
	for row in reader:
		if first:
			first = False
		data.append(int(row[1], 16))

def decodeImage(data):
	raw = Image.frombytes('1', (64/8, 128*8), bytes(data))

	result = Image.new('1', (128, 64))

	for i in range(8):
		result.paste(raw.crop((0, i*128, 8, (i+1)*128)).rotate(90, expand=1), (0, i*8))

	return result

lastData = []

for i in range(len(data) / 1024):
	dst = '%d.png' % (i + 1)

	d = data[i*1024:(i+1)*1024]

	if lastData != d:
		print('Outputing %s' % dst)
		img = decodeImage(d).resize((640, 320), Image.NEAREST).save(dst) # .transpose(Image.FLIP_TOP_BOTTOM)
		lastData = d
	lastData = d

Hi Giedrius,

I wouldn’t call those methods exactly easy. :smiley:
The dumping through the UART is a bit to advanced for me.
I had thought of dumping the screen through MIDI data such as SysEx. But I couldn’t find any way to read out the screen (Is this possible? I guess it should be.). Also, my software is using up most of the program space, so I didn’t want to add even more code.

In the end I just made photos with my smartphone and ran them through a Python script I hacked together that semi-automatically extracts the screenshot. It’s a bit clumsy, but good enough.

Thanks for the good support you are given us!

1 Like

This part depends on the underlying library you’re using (like the Arduboy one, which keeps the entire screen data in memory) or whether you’re sending data to the screen directly yourself (which is impossible to read back, but as you’re doing it yourself, you could send necessary things via SysEx at the right places).

Nice! How did you do that?

It is a very basic script.
You take a picture with your phone/camera. Crop the image to the part of the midiboy screen.
Than start the script. You now have to align the pixels manually using the four corners of a pixel grid.

Press enter and it generates the result with the padding and the enlargment that you want.
The original idea was to do auto alignment, but that would have taken too much time to develop.