Boogie Board RIP : some more experiments

Ok, so I tried some more things, and managed to get a picture directly from the USB port. Let’s see!

First I dumped a whole lot of events from hidraw. In my case, I did it through

sudo cat /dev/hidraw3 | hexdump > boogie.dat

Calling hexdump without arguments gives us an interesting display, with some lines being just ‘*’. But most interesting is that bytes have a more natural order. So I wrote a little Python script that takes the given dump, and tries to convert it to something « pretty ».

It should be self explaining, and it’s supposed to evolve. But if someone wants to try it, feel free.

from PIL import Image
import sys

sx = 705
sy = 999

if len(sys.argv) < 2:
	print "Usage: boogie.py <dump filename> [output filename]"
	sys.exit(-1)

if len(sys.argv) == 3:
	output = sys.argv[2]
else:
	output = None

f = open(sys.argv[1],'r')
i = Image.new('P',(sx,sy))
mx = 0
my = 0
for l in f:
	if l[0] != '*':
		try:
			r = l.split(' ')[1:]
			y,x = int(r[2],16), int(r[3],16)
		except:
			break
		if x!=0 and y != 0:
			if r[1] == '2101':
				col = 255
			elif r[1] == '2001':
				col = 100
			else:
				col = 50
			i.putpixel((sx - x/20,y/20),col)
		if x > mx:
			mx = x
		if y > my:
			my = y

if output:
	i.save(output)
else:
	i.show()

Use it with a « dump » as argument, and optionnaly an output filename. If no filename is given, the result will be shown (Windowing system needed, of course). The only dependency is PIL (python-imaging).

Image boundaries are somehow empiric. I tried to use different levels of gray for different kind of events : « real » touches are whitest, « close » touches are grey, and if there’s anything else it should be an even darker shade of gray.

And here is an idea of the output. I know it’s ugly, but the code has nothing to do with it.

Comments are disabled for this post