Tuesday, December 29, 2009

2D Engine/Game

This is sort of the highlight of my sad sad day, so I had to post this. I've been working on a 2D game, but at the same time, abstracting as much of the API specific code I could. For simplicity, I started out with SDL. Now I have OpenGL working, minus alpha blending. The best part is that the rendering engine can be switched by changing only one line of code(a few letters at that). I'm still fairly new to OpenGL, but I'm already glad I went that route, as the drawing is MUCH faster than SDL. 300FPS faster in the comparison above. Note that the tilesheet is being drawn 1 32x32 tile at a time.

Wednesday, December 23, 2009

C++ Code snippets

I said earlier that I would post some C++, so here we go.

Feel free to use my code in any way you see fit. I'd be curious to know if my code gets put to use, so leave a comment on here or something.

The following code is designed to run in a Win32 environment.

DataLogger.h / DataLogger.cpp - http://pastebin.com/f3a5eae52
Log to file - singleton class interface, various modes/levels of logging.

GameTimer.h / GameTimer.cpp - http://pastebin.com/fd99d76d
Timer - class interface

FontPrint.h / FontPrint.cpp - http://pastebin.com/f562ab8
On-screen debug output - drawing implemented using abstract drawing interface. Here's the 2-bit 8x8 font I use - http://farm3.static.flickr.com/2583/4209666632_c5da74397b_o.gif

And that's all I've got for now, the rest is still pretty well in active development.

Monday, December 14, 2009

Project list update



Been working on a lot of random stuff the past few weeks but had not posted anything to my blog, so here we go.

Still haven't worked out the kinks on my RGB Lighting project. I'm really not getting the results I want with Software based PWM, at this point, I'm getting ready to ditch the integrated IR receiver I had originally planned, in favor of actually finishing the project. I might be able to use some code posted on Lucas Eckels Blog, called IRMon. Check out his original post here. I haven't had a chance to test it yet, and some calls to delay will need to be changed to non-blocking routines, but there is a slim chance it will work for my purposes.

I've also started working on my 2D side-scroller once more. I'm working on making a Mario clone for right now, but the real purpose of this project is to develop some modular 2D framework. Nothing worth putting in pictures yet, but I will be posting bits of code later which I'm hoping others can make use of.

Monday, November 30, 2009

Light bar build log - Snag

Well things were going quite smoothly - I found some IR receiver code on the Arduino Forums written by PlastBox, mapped some buttons and had full functionality of the remote control, started hooking some LED's up to test when I ran into a bit of a problem. It turns out, the NEC IR code uses an internal timer on the Arduino for callback functions or something rather, which is very bad, as this disables the use of certain digital pins for PWM. I'm not certain which pins exactly, but none of that matters as I refuse to make the sort of sacrifice. I'm pondering my options currently.

The way I see, I have three options worth considering:
  1. Rewrite the remote control receiver code to not use timer - able to time receiver accurately enough?
  2. Use a PC serial-based IR receiver, arduino connected via USB - Would require additional circuit board, but would open more control options such as a color chooser running on my PC. Lose remote control functionality when PC is off.
  3. Write a software PWM controller for LED's - way less precise control.
Option # 1 would be best since the rest involve the loss of functionality, though I haven't really studied the IR code enough to know how it works. If anyone reading this could suggest something better I'd really appreciate it.

Monday, November 23, 2009

Light bar build log

Have been very very busy, finished a good bit of work and hadn't had a chance to update my log.

Finished with soldering until I program my Arduino LED driver software, at which point I'll be switching to an Arduino Pro Mini. Here's the most recent shot I took of the power supply stuff...

I got frustrated with solder trails, and since I had snipped the resistor legs, I decided to try with some small lengths of wire. I've since flipped the heat-sink on the regulator...apparently that's backwards up there ^. I decided to use 4 pin header connectors for connecting the LED's to the resistor board.
The mess of wires was making me nervous, so I have not done too much testing. Additionally, I screwed up the red diode on one light in the process of soldering without a heat-sink. I don't yet have the mounting for the LED's quite figured out, but I already have some new modules, so I don't believe a wall mounted test is too far away.

I ordered an IR receiver module and played around with it a bit. Time to get cracking away at some code.

Monday, November 16, 2009

RGB Light bar mod cont.

Parts from Futurlec haven't shown up and now I remember why I hate ordering from anywhere in Asia... Anyhow, I realized I screwed up and bought the transistors in the wrong package(TO-39 instead of TO-92 like I thought), so I went ahead and went up to "the shack"(LOL XD) and grabbed a pack of 15 for fairly cheap - PN 276-1617. Still a bit of soldering work to do, but I got my fair share of solder fumes for a few days. Remember to work in a well ventilated area, like I didn't! All that's left is the series of transistor emitter wires.

I mounted the DC wall plug and wired up some basic quick connects. Two standoff posts are screwed into each-other through the my main board, which is built onto one half of a Dual Mini Board from radioshack, PN 276-148. The board is then mounted with two screws through the front of the light bar.

Thursday, November 12, 2009

Detachable keyfob

It's hard to tell with the St. Louis weather, but the cold really is coming(it's nearly 60F out)

I've been looking for a way to make my key fob easily detachable so that I can lock my keys in the car while it's running in the morning.

I came up with this little abomination on my lunch break. It's not finished, as I don't really like how long it turned out - overall, it adds right around 3 inches between the key fob and keyring. Of course, this is all just a cheap circumvention to remote start anyhow. Maybe I'll come across something cheap that does what I'm looking for. I'm sure there's something out there - I'm just not much of a knickknack shopper.

On the topic of my car, it's getting older, and therefore harder to find parts for. My spoiler mount brake light is on the fritz, and apparently it's been rigged with makeshift wire brackets just to get it this far:

From what I can gather, they don't make this part anymore. I'm debating between another LED project and visiting a salvage yard at this point.

My headlights are another annoyance - when they burn out, I have to replace the entire lens assembly, as the bulb is sealed. I broke the seal and removed the bulb, and from what I can tell, I should be able to use a 9005 or 9006 style bulb as a direct replacement. I don't want to reseal the bulbs - which will allow some moisture to get in, so I may have to drill a couple small vent holes to alleviate this. Waiting for my paycheck to hit the bank, so this adds to my list of delayed projects...

Supplies supplies


My order from AllElectronics.com arrived today - got the wires I'll need, as well as a 12V 1 amp DC Power supply + panel mount 2.5mm power jack. Still waiting on my stuff from Futurlec(Asia) to arrive, but I should be able to get started on my internal power supply at this point. Turns out the wall wart IS voltage regulated, and that I only made more work for myself. Good news is that the power supply cable is in fact long enough, juuuuust barely.

Saturday, November 7, 2009

Light bar modification

I took apart and played with my light bar today, looks like I'll have even more room to work with than I thought - could fit an arduino pro mini long ways vertically and still have room to spare.

The sockets are attached to a mount, which is attached to the fixture by two screws.



I took two PCI slot covers and put an additional 90 degree bend on each to mount the LED Modules.


Need to run out for wiring supplies some time, but so far so good.

Friday, November 6, 2009

LED Fun


Started on my controller software, Arduino website is going slow as usual(an offline reference would be nice). powering LED's undercurrent - and they're still painful to look at - think I'd be blind[er] if not for the focuser on each module. The RGB Modules look brilliant even with a simple paper diffuser - tried plugging in color code from my background - looks better than that crappy cel phone pic I swear.

I've got some basic serial control through hyper terminal - need to make an RGB color chooser, as well as come up with various color effects. I'm starting to get a better feel for doing I/O w/ my Arduino - definitely giving me a brainstorm of idea's to tinker with.

Light bar modding is next, stay tuned.

Thursday, November 5, 2009

Getting settled in

This blog will now be my main spot to post my projects and such, tweets just weren't cutting it. I'll still try to post snippets and less relevant stuff @ http://twitter.com/skitchin

I've recently decided to try my hand at electrical engineering, so I went ahead and did the obvious and bought an Arduino. The first project I've decided to tackle is an RGB LED light bar, which I've wanted for some time now. There are already manufactured versions of these, but they're just not exactly what I want. For one, you only get to pick between 15 colors. Also, the IR sensor is mounted so that the light must face you to some degree, which won't work, since I want them shining on the ceiling and walls, not my retinas. Ofcourse, Arduino should let me do some pretty intense light shows.

I ordered two RGB LED modules from a local supplier, SuperBrightLEDs. I'm still waiting on my resistors and transistors to arrive from Futurlec.

When all is said and done, I plan on doing some sort of fit into a 120V lightbar I own. Two RGB LED modules, 6 diodes, which will be controlled individually via Pulse-Width modulation. Still need to figure out the IR receiver bit - as far as remote, this remote from ThinkGeek looks perfect.