HIDeous Arcade: its not that ugly, is it?

It all started a few years ago when I discovered the book Project Arcade: Build your own Arcade Machine! I have always been a closet old-skool gamer and so I bought the book. As soon as I had devoured its information, I began designing my own.

It flopped. Quickly. I never got out of the planning stages for the machine. There was no room at home, and it would end up costing too much. But I did order enough buttons for a two player panel, and the extremely expensive (but high quality) iPac encoder. I ended up drilling a few holes with a spade bit and plonking it all on a piece of wood that I sat between two boxes. That thing was hideous.

Jump forward 6 months, and a new workshop room had been constructed at BGS. I now had access to a multitude of machining tools: CNC, drill press, laithe, it was all there. I decided to dismantle my mess of buttons and start from scratch on a more aesthetically appealing box. My first stop was Morningside Plastics where I bought some dangerous looking [carcinogenic when wet] glue and lots of transparent perspex. After measuring up everything, I went into the workshop and started to bend and drill my perspex into shape. My presence piqued the interest of one of the teachers who runs classes in the room. He asked me what I was building, and I told him that I was building an arcade control panel. Suffice to say the teacher was also loved classic games and I offered to show it to him when I had completed it. I was really pleased with the end result, and after showing it to a few people, I realised how much demand there was for such a device.

Grade 11s at BGS were starting a new subject: Technology Studies. New projects for them to build were needed. The teacher I had showed the panel to approached me and asked if I would tell him what I did to construct it. I gave him the names of the suppliers that I used and although it would have been a great project, the cost of the encoders was far too much. Enter plex.

Everyone has a genius-type friend; my genius-type friend is plex. He has answered every question about electronics that I have not been able to answer myself and as a result I have learned an immeasurable amount about building things from him. He was the guy who got me into AVRs! When I told him about my arcade panel, I found that he too was into old-skool games (is everyone secretly into them?). One thing led to another, and he agreed to help out with the project: he was going to build an encoder for far less than the ones that were sold in shops.

Plex constructed the first encoder on a piece of veroboard. It was called Facade and sent keypresses via the ps/2 port. It had too many issues with line noise however, so he moved onto creating a USB edition. This was given the name HIDeous Arcade (see picture above). The ‘HID’ part comes from the fact that it shows up as a HID joystick in the USB subsystem. The major advantage of this is that a large number of panels can be connected to one computer and no reconfiguring of keys is needed. I made a minor tweak to the code, reprogrammed the micro and then showed the teacher. After a good session of gaming, he decided to include it in the curriculum!

The parts came in soon after. PCBs were ordered and boxes of components began rolling in. At the risk of sounding weird, my favourite part of this whole process was standing in front of about a cubic metre of arcade buttons. A short script combined with three hours of switching chips in and out of the ZIF socket daughterboard on my STK500, and students were ready to build their panels.

The students are currently constructing their controllers. Hopefully I will be able to snap a picture or two of the finished ones and put them up here. It was a great project to be involved in, and it was also an invalueable learning experience. At some point the encoders will be on sale, so watch this space!

Getting some practice in

I recently discovered Project Euler in one of my trawls through Stumbleupon. If you have ever done work with complex numbers, you will know all about Euler. True to its name, it is a website that lists a series of algorithm design problems, often with bit of math thrown in. You are given a description of the problem and a box to enter your result in. So far, it has proved to be an invaueable resource for refining my skills.

The website is great because it fosters an environment in which people can choose to be competitive or not. Users are ranked by their skill, but this ranking is never displayed unless you go looking for it. My favourite thing is that the problems can be completed in your own time. I enjoy a good programming puzzle, but I generally have very little time to spare. Having a high score on Project Euler could also look good on a CV/resume.

It was difficult for the first few sets as, in my case, I had never really done these kinds of problems. However, once you get a small cache of reusable functions going (checking for primality, etc) the problems transform from intimidating mind-benders to simple programming exercises. I will definitely be attempting more problems over the next few years, hopefully I can make it all the way to 100%!

I heartily recommend that everyone who is interested in programming gives it a go.

Merry Christmas: jComix kinda does CBZ

First of all, thanks to everyone who is currrently using jComix! It’s great to see people actually use your software. Another note: please read this whole post before trying the new jComix. Continue reading ‘Merry Christmas: jComix kinda does CBZ’

jComix now in Installer.app

So, I received a few emails (thanks guys!) about difficulty installing jComix. Thats not a problem anymore; I have just created an Installer.app repository with jComix in it. Incidentally, if anyone is trying to create zip files for distribution through Installer.app, WinRAR zips do not work (that one cost me a few hours of tinkering).

To get jComix running: Continue reading ‘jComix now in Installer.app’

jComix: Native Edition!

Although I thought jComix was useful, I got sick and tired of only reading comics when I was in range of my own WiFi. So I sat down with my Python Reference Manual and ported the entire application to Python; the reason being that, unlike Ruby, the Python build for the iTouch is not broken. Now before you download this, a warning is in order:

This took me all of 3 hours to make. There are probably better ways of doing it. There are probably faster ways of doing it. I did the best I could inside my limited timeframe. Nonetheless, there may be bugs, both benign and malignant. I take absolutely no responsibility for anything that breaks or ceases to function as expected. Again, this application is released under the GNU GPL v2 (http://www.fsf.org/licensing/licenses/info/GPLv2.html).

Now that the yucky legalese is over, lets have some download: Download jComix Native Edition here.

I don’t have time right now to write a full install tutorial, so here are the basics:

  1. Install Python from Installer.app
  2. Download the archive (linked above)
  3. Extract the contents to a folder
  4. Copy that folder to your iPod/iPhone
  5. Make the install script executable
  6. Run the install script
  7. Delete the install folder
  8. Run this line in a shell:
    1. python /var/root/jcomix/jComix.py
  9. Head to http://127.0.0.1:8080/ in Safari and you should see your comic (after a little wait)
  10. If you want jComix to run on startup, save this file to /System/Library/LaunchDaemons.

If you notice anything wrong (or right ;) ), drop me a comment here or send an email to jeremy DAHT 006 AHT gmail DAHT com.

UPDATE: Check here for an Installer.app version.

ARRR-duino

ArduinoSo I finally bit the bullet and bought myself an ARRR-duino (arduino.cc) from a nice little shop called Little Bird Electronics, which by the way has a really cool design in comparison to other webshops. Even though I already have an AVR development platform (the wonderful STK500), it will be nice to have a simple, no extras needed dev kit with USB support. I know USB is complex and all, but dev kit makers, you are still living in the dark ages. My recent computer breakdown decision to upgrade meant it was time for a QuadCore processor. For this, I needed a motherboard upgrade as well. Props to Murphy’s Law, because my new motherboard has no COM ports.

I’m also pleased that this thing gets its power over USB. There is no need to lug a chunky power brick wherever you take it. So I can make little projects and just plug it into my iPod charger (which I take with me anyway) to power it up. Brilliant.

Now I just have to work out how to program it from my iPod Touch…

Picture copyright Pip 2007

Tengu Time!

The Tengu is simply a small LED matrix hooked up to a microcontroller and a electret microphone. The cool part comes in when playing music; the Tengu appears to be lip-syncing. After seeing just what it can do, I knew I needed to have one. But why buy one when you can make it yourself?

It was actually surprisingly easy to drive the LED matrix. The ‘faces’ are stored as eight chars; one for each line of the matrix. Basic code follows:

  1. /* This file assumes that the NPN-transistors are hooked up to PORTB and the cathodes are connected to PORTD */
  2. #include <avr/io.h>
  3. void output_matrix (unsigned char matrix[8]);
  4. unsigned char mouth_closed[] =          {0×00, 0×66, 0×66, 0×00, 0×7E, 0×00, 0×00, 0×00};
  5. unsigned char mouth_pursed[] =          {0×00, 0×66, 0×66, 0×00, 0×7E, 0×7E, 0×00, 0×00};
  6. unsigned char mouth_open[] =            {0×00, 0×66, 0×66, 0×00, 0×7E, 0×81, 0×7E, 0×00};
  7. unsigned char mouth_large[] =           {0×00, 0×66, 0×66, 0×00, 0×7E, 0×81, 0×81, 0×7E};
  8. unsigned char mouth_big_smile[] =       {0×00, 0×66, 0×66, 0×00, 0×7E, 0×42, 0×42, 0×3C};
  9. unsigned char mouth_smile[] =           {0×00, 0×66, 0×66, 0×00, 0×42, 0×42, 0×3C, 0×00};
  10. unsigned char mouth_surprise[] =        {0×00, 0×66, 0×66, 0×00, 0×7E, 0×42, 0×42, 0×7E};
  11.  
  12. int main (void)
  13. {
  14.  DDRB = 0xFF;
  15.  DDRD = 0xFF; /* Ports are all output */
  16. while (1)
  17.  {
  18.         output_matrix(mouth_open); /* Forever print the face */
  19.  }
  20. return 0;
  21. }
  22.  
  23. void output_matrix (unsigned char matrix[8])
  24. {
  25.  int x; /* Loop control variable */
  26. for (x = 0; x < 8; x++) { /* For each LED in the array */
  27.         PORTB = (1 << x); /* Turn on the NPN connected to the ‘x’ row */
  28.         PORTD = matrix[x]; /* Output data */
  29.  }
  30. }

I haven’t yet been able to test it with a microphone because my new motherboard does not have any COM ports, so I can’t program any of my AVRs on my STK500. But cables are coming in from eBay soon, so I should have it running sometime in the near future (maybe even make some PCBs!).

Reading comic books on the iPhone/iPod Touch

Note: There is a new native version of jComix here. This page is depreciated.
So I mentioned it before, and I’ve finally got around to releasing a beta version of jComix. Jump on the page here or just click the jComix tab at the top of this blog!

LaTeX + LyX = super mathematical fun-ness

A few days ago, I set out to write the all the definitions required for my physics exam in one location. I didn’t want to do them by hand (so I could share it with other people), but Word the usual suspect pretty much sucks at equations. At first, I discovered the intuitive Tomboy Notes program for Linux. It was great, and there was a LaTeX (TeX is a typesetting language; LaTeX is an extension of it) plugin for it too. Alas though, it was very crashy, and the equations could not be exported as images. So I rang up my super internets friend (google) and found LyX.

LyX is a TeX editor for someone who just wants to get their work done and not faff around in the niceties of TeX. Don’t get me wrong, TeX is powerful and all, but it really is overcomplicated for something this small. It runs on Windows, Linux and MacOSX and exports to PDF, so using it was a win-win situation!

I hate to say it, but the language is actually intuative. Want to square root 3? \sqrt{3} in LaTeX will do that. Need to use greek letters like rho and delta? No problem, \rho and \delta should do the trick. The best part of the language is fractions. Simply typing \frac{1}{2} will give you a fraction of 1/2 (perhaps I should get TeX going in wordpress…).

Well, my physics sheet turned out just fine. If anyone wants to see it (it has information on circular and simple harmonic motion, large scale gravitation and impulse/momentum) you can find it here.

The Magic of WEBrick

Recently, I purchased an iPod Touch. I was looking around for development docs, but it turns out that Apple are only letting people make webapps that run through Safari. I searched around for the best way to make apps from scratch with a webserver built in, and my searching returned me to my favourite scripting language: Ruby. Ruby has a library called WEBrick built in that is specifically tailored to serving HTTP requests.

My first venture into the world of WEBrick was to write an iTunes control program. It turned out quite nicely, but it was definitely lacking in features. Instead of continuing down the path that others had already gone and adding more features, I took a new one. I wanted to be able to read my comics on my iTouch and I could not find a solution anywhere else on the interwebs, so I decided to write my own CBR reader. CBR files are comic books compressed in a RAR archive; each image represents one page. With some Ruby and some regular expression magic, I can now read Tintin while lying on the couch!

The code is surprisingly simple. All of the webrick-handling code is less then 25 lines:

  1. # jcomix.rb
  2. require ‘webrick’
  3. include WEBrick # So we dont need the WEBrick:: namespace
  4. require ‘config’
  5. require ‘ComixServlet’
  6.  
  7. def start_webrick(config = {})
  8.   # always listen on port 8081
  9.   config.update(:Port => $gPort)
  10.   server = HTTPServer.new(config)
  11.   yield server if block_given?
  12.   [‘INT’, ‘TERM’].each {|signal|
  13.         trap(signal) {server.shutdown}
  14.   }
  15.   server.start
  16. end
  17.  
  18. start_webrick {|server|
  19.         server.mount("/comics", HTTPServlet::FileHandler, $gPath, {:FancyIndexing=>true})
  20.         server.mount(‘/’, ComixServlet)
  21. }

The servlet code is also very simple, the basic framework for usage is:

  1. class ComixServlet < HTTPServlet::AbstractServlet # Comix Servlet
  2. def do_GET(req, resp)
  3. # Parse req for the GET variable (eg req.query['id'] gives the value of ?id= in the url)
  4. resp.body = ‘Hello World’ # Send ‘Hello World’ to the browser
  5. end
  6. end

Add a bit more code and you have a webapp ready to roll! I will shortly be providing a link to my finished jComix application if anyone is interested.