brandorf.com The everyday ramblings of one nerd.

20May/13

Annoying people with a Raspberry Pi

The Raspberry Pi is a neat little device. First and foremost, it's a complete little computer, secondly it's very easy to program for, allowing a software guy like myself to have a much lower learning curve to AVR-style programming than you would have on an Arduino or Launchpad. I've had one for a while, but nothing immediately sprung to mind about anything fun to do with it, so it disappeared into the big bucket of projects-that-might-be.

I eventually decided to use it for evil. To sic Navi on the poor victim, like a more annoying version of the Annoy-a-tron
(If that's possible?).

Principal ingredients for this is the Pi itself, and some speakers. I'm using one of those speaker case jobs designed for a MP3 players, runs off of 2 AA batteries for a very long time, unfortunately this won't power the Pi, so the Pi still needs to be plugged in (and the Pi can only provide a wimpy 50ma at 5v on pins, not enough to power a speaker). That's really it on the hardware department, the rest of the magic is software - namely Python. I've never worked with python, but the more languages you learn the easier new ones become (both spoken languages and programming). So let's bang something out and see what we can get it to do.

photo (1) photo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python
 
import time
import random
import os
import subprocess
 
random.seed()
command = ["mpg321", "/etc/Navi/Navi-WatchOut.mp3"]
print "Watch Out!"
with open(os.devnull, "w") as fnull:
	result = subprocess.call(command, stdout=fnull, stderr=fnull)
time.sleep(30)
 
while (True):
	command = ["mpg321", "/etc/Navi/Navi-Listen.mp3"]
	with open(os.devnull, "w") as fnull:
		result = subprocess.call(command, stdout=fnull, stderr=fnull)
	sleepTime = random.randrange(-15,15)
	time.sleep((30 + sleepTime) * 60)
	print "Hey! Listen"
	print "Sleeping for " + str(30 + sleepTime) , " minutes."

For those of you who can't decipher this what it does is play the "Hey Listen!" sound clip at random intervals between 15 and 45 minutes between each one. It's using the linux app mpg321 to play the audio files with most of the extra bits there to hide the output from mpg321 from spamming the console. Not really needed as the prank use will not have the Pi connected to a display but hey, why not.

To make sure that this script starts each time the PI is booted, we need to add this script to Init.d I must confess I'm not entirely sure what this is doing except at a high level; registering our python script as a service, and therefore runs even if you don't log-in.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#! /bin/sh
 
case "$1" in
  start)
    echo "Starting NAVI"
    # run application you want to start
    sudo amixer cset numid=1 90%
    python /etc/Navi/Navi.py &
    ;;
  stop)
    echo "Stopping NAVI"
    # kill application you want to stop
    killall python
    ;;
  *)
    echo "Usage: /etc/init.d/example{start|stop}"
    exit 1
    ;;
esac
 
 
exit 0

Save the scripts, chmod them if needed run update-rc.d and restart the Pi, you'll get a warning of "Lookout" and then you've got a minimum of 15 minutes to plant your annoyance bomb. Try not to get caught.

6Nov/11

Not Quite a Phoenix : Raising my MAME Machine From the Ashes.

I've been meaning to sit down and write this for some time now, but have always managed to come up with some sort of convenient excuse not to. Well now, coffee in hand, I'm going to make this happen.

I built a Mame arcade machine back in the summer of 2003 with my father. It was a ton of fun and I at least learned about the large whole of my knowledge and experience involving woodworking. However me being a student at the time, and now a graduate (arcade machines, while awesome, don't travel well or fit within a student's nomadic lifestyle), and my own parents having moved twice in that time, means that this little arcade machine has traveled many miles, and we unfortunately didn't design some aspects of the machine to handle the stresses of the average move.

About the third move was when things started to go south. This move was done by “professional” movers, and apparently the entire cabinet was dropped or something. The monitor yoke had fallen off the back of the monitor tube and smashed into the PC motherboard at the bottom of the cabinet. It looked worse than it actually was, and it didn't take too long to get it running again. Lucky for me there.

The next move happened while I was busy away at college, no idea what happened there, but I came home after college and the machine wouldn't boot up at all. After a few diagnostics, I decided that well, the parts were ancient when I built it, they must have finally given up the ghost, so I chucked the motherboard in the bin, and went about scrounging some new parts. This was the first step in legacy hell.

13Feb/09

Post-process glow in a GLSL shader.

As the render monkey for my final project team, I've been doing extensive research as to some interesting techniques with which to make our game pretty. I'm pretty proud of the effect I just finished, so I figured I'd share it with you.

This is the model for our scout unit, with his post-process glow effect turned on:

Very Tron, eh?  Well that's where this sort of effect came from, the Gamasutra article about the Real-Time glow effects used in Tron 2.0.  The Specifics as to how this effect was constructed is an article for another time, as it is pretty complex, and I want some time to refine the effect.

Tagged as: 3 Comments
14Jan/09

Piracy on the Nintendo DS

As sort of a counterpoint to Sailing the seven seas of Nintendo DS piracy, I'd like to write about my pesonal experiences about the subject.  I'm what you might call a 'budget gamer', I avoid paying full price for my games whenever possible.  There was a point in time when I could burn though all of my disposable income on things like games, but not so these days; now I haunt pre-owned games, and look forwared to the weekend deals through steam and similar to satisfy my gaming addiction.

I've mention my M3 card for my Nintendo DS before.  While I do use it to play homebrew software, such as Colors! and a fantastic NES and Genesis emulator, I make no attempts to sugar-coat the fact that I originally bought the thing to pirate games.  The story doesn't end therem however, the ability to try any DS game out of the whole library has led to me buying games I wouldn't normally buy, such as: