Wednesday, August 21, 2013

Moving Right Along

I have made some progress.

On the software side, I have been working on a MVC design for the dart game engine, which will allow for easy plug-in capability.  No more real code has been written, though.  Looking at the following examples for guidance:
http://learn.adafruit.com/boarduino-kits/usb-boarduino-assembly
http://stackoverflow.com/questions/7249388/python-duck-typing-for-mvc-event-handling-in-pygame

On the hardware side, I got me a desk and set up my mackerspace and assembled the boarduino.  I started out soldering the socket to the board with a 40W iron, which was probably too hot.  It's been awhile since I've soldered, and I've never soldered much, so i was worried about ruining the boarduino. I went pretty quickly on most of the pins, so hopefully i didn't do any damage.  For the header pins, I went to a 25W iron which worked just as well and made me less nervous about a meltdown.

This here is what I did:
http://learn.adafruit.com/boarduino-kits/usb-boarduino-assembly

I loaded up the Arduino IDE hooked the boarduino to the laptop with a mini USB cable and loaded on the Blink sketch, the "hello world" of Arduinos.  Of course, I picked the wrong board in the IDE, so the first few attempts to upload the code failed and made me think I destroyed the board or let it sit in the closet for too many years.  Finally picked the correct board and had it blinking in no time.

My next step will be to get familiar with the shift registers and writing sketches.  Will probably start with controlling 8 LEDs since there are examples on the web I can reference if I get stuck.

Not much exciting here to anyone but me... getting the boarduino built was my big first step in making progress on the dartboard project.

Thursday, August 8, 2013

Setting Up My Google Project and git in Windows

I decided to use Google Code Project Hosting for my source code repository and git as the Source Control Manager (SCM).

Why?

Well, I'm doing this Blogger thing in Google, so might as well put the code on Google, too.


git was one of a few choices for SCM on Google Code Project Hosting.  SubVersion was another, and I have used SubVersion before... am familiar with it, yet I picked git.  I just did.


The thing about git, is it is really a unix/linux thingy, and I am developing on a Windows machine right now.    Seems that when you install the git client, it installs a bash terminal, so you kind of end up using whateverNIX anyway.  Might end up on Linux since Raspberry Pi is in my Dartboard Hack design.  No big deal for me since I've been on a whateverNIX system a few times before.


So, after you create a new project and repository, you need to create a local repository on your development machine.  Here's partly what I did and partly what I should have did if i had did it right the first time.


On Google Code, I created my new project named  "no-arms-darts," selected git as the SCM and went to the "Source" tab.


On my development (windows) system, I created a "git" folder in my Documents folder.  Then I installed the git client for windows and ran the git bash app from the link conveniently created in the start menu by the installer.  I changed the directory to my new git folder:


$ cd ~/Documents/git


Then I set git up to connect to my repository on Google code.  Looking back to my project source page on Google code, it gives the following option to do this:


Option 2: Stay authenticated with .netrc:
Add the following to your .netrc.
machine code.google.com login [Me@Gmail.com] password [generated googlecode.com password]

To use .netrc, make sure the clone URL doesn't contain your username:
git clone https://code.google.com/p/no-arms-darts/


To do this on windows, .netrc is actually _netrc.  So I clicked the link to generate my googlecode.com password and copied it to my clipboard.  Then I opened a command prompt in windows and:


C:\Users\Me> echo machine code.google.com login [Me@Gmail.com] password [generated password] > %HOMEPATH%\_netrc


Where [Me@Gmail.com] is my Gmail account and [generated password] is the password generated by the link on my Source code page under Option 2 shown above.


Then I went back to the git bash and executed the clone command, also shown above under option 2:


$ clone https://code.google.com/p/no-arms-darts


You would substitute your project name in place of no-arms-darts to clone your project... (or you can execute this for my project to clone all of my crappy code onto your development system).  This should create a new folder with the same name as your project under the git folder.


Since I already had some code for my project elsewhere on my system under a folder named "Python", I went to Windows explorer and copied the Python folder to the clipboard, then pasted it into C:\Users\Me\Documents\git\no-arms-darts.

Most of the time when you are developing with source control, there are files and directories used for developing, testing, debugging, etc that you don't want to be saved in the shared repository.  git has several ways to handle this ...like per repository, or globally.  I added a .gitignore file that I found on github among many prefab ignore files for specific development platforms.  This will effectively exclude the pycache folders, compiled scripts and so forth.


I just browsed my project and think I put the ignore file in the wrong place... looks like it is working out in its current location, but maybe should be at the root or master folder of the repository.


The next thing to do was copy all the files to my google code repository which took 6ish steps: add the Pyhton folder and its files to the local repository, set my email address and user name for the git config, commit the changes, set the default push mode, push the changes.... all done in the git bash, from the no-arms-darts folder:


$ cd no-arms-darts

$ git add Python



$ git config --global user.email "Me@Gmail.com"


$ git config --global user.name "Me"


$ git commit

git config --global push.default simple
$ git push


Now, the commit command opens up a whateverNIX text editor which I know as vi, and it prepopulates a commit document with comments detailing the files being committed, adds, mods, deletes... and requests that you add a version comment, and I think if you don't, it cancels the commit.  If you don't know how to use vi, you might want to try a git GUI or learn some vi commands. Quick and dirty:  press i to insert the comment, type the comment, press Esc to exit insert mode, then :wq to write your changes to the file and quit vi.

Oh, ok.  I actually read some of the git documentation and you can avoid the whole text editor thing by using the -m switch on the commit command like:

$ git commit -m "fixed another stupid mistake (rtfm)"


As I implied earlier, I didn't do this right the first time through... so I became acquainted with a few more git commands along the way: status and reset.  These are all explained very well in the git documentation.


After pushing the code to google, I went back to my source browser and the code was there.  If you are reading this and decide to look at this code, it's probably not the highest quality Python code... hopefully I will clean it up so it's actually worth looking at.  Maybe I'll run through this all again and take some screen shots and rewrite this post to make it more like a tutorial than a memoir.

Monday, August 5, 2013

Dartboard Hack - Software Design Ideas

The Dartboard Hack (or Mack?) will require several pieces of software:


  • Arduino sketch running on boarduino to read dartboard and send data to the game engine
  • Game engine - python/pygame running on RPi
  • Android app to remote control game over bluetooth
I have a bit of programming experience, but none of it falls within any of the 3 realms listed above.
The game engine will be the meat of the system, so I started learning python and pygame.

I spent a weekend writing an intro animation.  It could use some refactoring... like using an actual game engine structure with some FPS BS... but that's not really important to me at the moment.  I will create the proper game engine structure when I get into the dart game engine and maybe retrofit the intro later.

The intro pays homage to the classic game Jumpman.  I borrowed some sounds and sprites from another project,so I think I'll make sure it's ok to use them before putting them on here.

Sunday, August 4, 2013

Dartboard Hack - Intro

I've been looking for a project to get me going in my new hobby, and this is it.  The dartboard hack. 

Why do I want to do it?  Well, I came up with my own stupid dart games and wanted to code a web or android version.  Then I looked at my electronic dartboard and wondered if I could hook it up to my laptop or something to have it play my games.

I found that it's been done (or attempted) before:
http://forum.arcadecontrols.com/index.php?topic=34866.0
http://web.archive.org/web/20021017065130/http://ice.fas.harvard.edu/~sander/dip/
http://amqsoftware.com/~yocom/projects/darts.php
http://www.martinpersson.org/wordpress/category/dart/

After researching these projects and similar projects, here is my initial design idea:



Perhaps an ambitious first macker project, perhaps not.  I ordered the shift registers and sockets and a soldering fume filter fan thing.  I still have a little work to get my mackerspace set up, but the first step in hardware will be assembling the boarduino

I have already taken the first step in software and jumped into pygame.  I'll make that a new post.