• Programming the Meggy Jr.

    I built my Meggy Jr. about a month or so back, and since I was having a pretty lazy weekend I figured I would mess around with programming it.

    The device comes with an “advanced” API that can manipulate the finer details of the device, and a simple wrapper API. The simple API is the one that 99% of people will use to program games and other applications, since it lets you do things like play sounds, turn the LEDs on and off while specifying their color, check for button presses, etc. Code is C/C++ written in whatever editor you want, and compiled and shipped to the device over a USB cable using the Java-based Arduino IDE. It’s a really neat little package and very easy to get started with.

    Here’s a picture of my Meggy hooked up via the USB adapter cable. The cable plugs in to the headers on the top right, and can be easily unplugged for taking the device with you.

    I wrote a basic program to test things out, and then decided to start on a library for a game (since I have been thinking about some kind of multi-colored Othello/Reversi that might be fun to figure out). However, as soon as I tried going from a monolithic one-file procedural application to something using classes, I started to get compiler errors about duplicate method implementations. Cracking open the code, I found out that the guys who wrote the Meggy API put all the simple API calls inline in a header file. As a result, whenever you want to include the header more than once, you end up with compiler errors for the duplicated object code.

    I posted a question to the forums about whether there were any specific reasons why this design approach had been chosen over a classic header/class file, but after taking a quick look at the code I couldn’t see any reason and decided to port the library to a header/class setup. If anybody is interested, the final code for the solution is posted on the Meggy forums. Also, if you want to download the library files you can get them here.

    I originally wanted to be a computer engineer in college, but chose software engineering instead since the market was so full of jobs at the time and I seemed to have some natural ability with it. My recent foray in to learning electronics has resulted in a keen interest in building devices and writing software for them, so apparently this passion for hardware has been laying dormant for over ten years. My original goal when I bought Make: Electronics was to get enough expertise to build an Arduinome, which looked really daunting at the time. Having assembled the Meggy last month, and having looked at the plans again in detail this weekend, building an Arduinome now looks like a walk in the park. To that end, I ordered an unsped Arduinome shield PCB from BatchPCB.com on Saturday, and will order the rest of the parts when the board goes off to China for fabrication.

    After that’s done, I’m going to get really ambitious and try to build an MB-6582. The project itself looks somewhat tougher from every angle (construction, case assembly, etc.), although by far the hardest part will be tracking down 8 SID chips. I’ve got one in my SIDStation, but that’s not going anywhere. There are plenty of C64s to be had on eBay, but when you only want the SID chip it’s a little hard to justify dropping $30+ 8 times. Luckily, the main board for the MB-6582 is set up to have as many or few SID chips as you have on hand, so I can start off with 2 and work my way up as my budget allows.

    Category: Uncategorized | Tags: