code « My Site/Blog
Untitled Document

code

Leap and N64

I’ve been working on another silly project for the office that involves using a Leap Motion controller to replace the standard N64 one for certain games. The idea started with Mario Kart and using the roll and pitch of your hand to control the steering and acceleration. A simple google search turned up results for using an Arduino with a N64 controller, which provided instructions for using a N64 controller to control a N64 emulator running on your computer (also a fun project). This is done in two parts using an Arduino and Processing. The Arduino is first preloaded with code to parse the incoming controller data, which is transmitted in four byte chunks (you can google n64 protocol for more information on how the data is sent). The Arduino then passes the Processing script simple serial commands which it then turns into simulated key presses.

I decided to use the LeapMotionP5 library to integrate my controller . Once the leap is initialized, you can access most of the core functionality provided by the regular API. Initially I ran into a problem where the leap would stop sending tracking data if the Processing application was out of focus (I alt-tabbed to the emulator), which obviously didn’t help much. I emailed the creators of both libraries to see if their was a quick fix, and hear back from Cedric who worked on the P5 library who provided me with a one-line command flag enabling background frames. All I had to do then was map the left and right arrow key presses to left and right hand rolls. The same was done for acceleration and braking. Presto, use your hand to control the driving of your kart:

Right now the only buttons that are mapped are the acceleration/braking and left/right turns. It’s a little finicky and takes some getting used to but could definitely provide some additional amusement to classic games. All I have to do next is set processing to mirror the data it originally received from the Arduino, which will pipe it directly to a N64. I hope. Updates to come.

Leap Motion and JS Rubik’s Cube

I’ve had the chance to play with a Leap Motion over the past couple of days and started working on JavaScript and Websocket integration. I found a full HTML5/CSS3/JS Rubik’s cube simulator and decided it would be a nice way to familiarize myself with the orientation and gestures of the Leap.

Playing with the leap has been a lot of fun and there is definitely a lot of potential for embedded projects. The JS library and documentation was a little lacking and somewhat fragmented across several sites so it took me a while to get a handle on the API. I set up a stream to my new testing grounds where you can see what I’m currently working on. The cube currently uses the x/y position of one hand for orientation and gesture commands from the other to rotate the pieces. Check out the videos below for a quick demo:

It takes a while to get used to at first, however my code is far from perfect but adequately shows how responsive the leap can be. The cube orientation can be changed with an open hand while making a fist halts the tracking allowing you to easily interact with the cube faces with gestures. The mapping shown in the first video is merely a demo of preexisting moves and the final version will be changed to reflect more realistic interaction.

  • August 1st, 2013
  • posted in code
  • 1 comment

Chrome Extension Project

So one of the projects I’m currently working on is a Chrome extension. Whether or not the file will end up as a crx package or a standalone web app remains to be seen. The pending name of the project is Grammer Police, and would allow users browsing through websites to identify either grammatical or orthography based errors (possibly extended to content errors). Users will be able highlight letters, words, and sentences and type in whatever correction they think a certain area may need. Pages owners can mark a certain URL as their own to view all of the corrections for a website.

This project isn’t meant to be a revolutionary new browser app, just something silly and niche which hopefully some people will find useful. It is also my first large-scale js based project and thus makes for a great learning experience. Below you can find a screenshot of the app being tested (alternatively you can visit the URL yourself at www.cyamada.com/test which I will be using to host the app during development):

Screen Shot 2013-07-19 at 5.05.57 PMOnce the extension is enabled, it will pop up at the bottom of your screen whenever you highlight text. It display the text you’ve currently selected and also offers a text area and submit button where you can write your correction. After the submit button is clicked, the text you had selected for correction will highlight in yellow making it easy to see which areas of the text have been already modified.

All that’s left for me to do is figure out how to store the correction information so that it is available to anyone with the plugin.

  • July 21st, 2013
  • posted in code
  • no comments