iWasHere Now Available On The App Store

iwashere

Augment your reality with iWasHere!

After a long wait my geo-locational social networking message board iPhone app iWasHere is finally available for purchase on the App Store.

iWasHere view page

iWasHere iPhone app

iWasHere is a geo-locational social networking message board. iWasHere allows you to create an augmented reality by enabling you to leave a message at a specific location which can then only be read at that location. You can write to a Public network that is readable and writable by everyone, or you can create your own private networks for just you and your friends.

Use iWasHere to leave a note for a friend at a bus stop, outside their work or in a park. Read or write reviews of stores and restaurants right outside their doors. Make a virtual community message board in your neighborhood. Hide directions to a secret party or a surprise proposal. Create a treasure hunt that uses virtual clues or do virtual geocaching. iWasHere can be whatever you want it to be. The only limit is your imagination!

marketing_badge

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • LinkedIn
  • RSS
  • Slashdot
  • Twitter
Posted in AR, app, iPhone | Leave a comment

PachubeMon Now Available On The App Store

pachubemonitorlogo

I am happy to announce that my Pachube feed organizer/viewer application PachubeMon is now available as a free download on the App Store. It was also announced on the Pachube blog on Monday.

PachubeMon iPhone app

PachubeMon iPhone app

Pachube is a web service available at pachube.com that enables you to connect, tag and share real time sensor data from objects, devices, buildings and environments around the world.

PachubeMon is a utility app for the iPhone that lets you manage and view your Pachube feeds all in one place. The main page allows you to add and remove feeds. By selecting a feed from the list you can view it. You can find feed IDs on the Pachube website here.

For a fascinating deeper look at Pachube and the concepts around it, check out the amazing article and interview here.

marketing_badge

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • LinkedIn
  • RSS
  • Slashdot
  • Twitter
Posted in app, arduino, iPhone, online, pachube, prototyping | Leave a comment

Field Recording: Thunder And Rain

Here is a field recording of thunder and rain recorded on my Zoom H2 in the late evening of July 23rd, 2009 in Nelson, BC, Canada. I love the phasing of the sound as it bounces off of the different mountain faces.

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • LinkedIn
  • RSS
  • Slashdot
  • Twitter
Posted in field recording, nature, sound | Leave a comment

How To Test For An Internet Connection On The iPhone

If you write an app that uses the internet then the Apple Human Interface Guidelines require that you check for a WiFi or Wireless Wide Area Network (cellular) connection and let the user know if they are not available.

nofunctionscreen

iTunes app with no WiFi

One reliable and easy way to test for this is to make use of the code in the Reachability sample project that Apple provides with XCode. Here is what you need to do:

  1. Add Reachability.h and Reachability.m from the sample project to your project
  2. Add the SystemConfiguration.framework to your project
  3. Use the following code in your project:
[[Reachability sharedReachability] setHostName:@"www.apple.com"];
NetworkStatus internetStatus = [[Reachability sharedReachability] remoteHostStatus];
if ((internetStatus != ReachableViaWiFiNetwork) && (internetStatus != ReachableViaCarrierDataNetwork)) {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Internet Connection"
        message:@"An internet connection via WiFi or cellular network is needed to use this app."
        delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    [alert show];
    [alert release];
} else {
    // do whatever your program does
}

In the first line you can set setHostName: to whatever you like. A simple page on your server that just returns True works just fine.

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • LinkedIn
  • RSS
  • Slashdot
  • Twitter
Posted in code, iPhone | 2 Comments

Pachube: The Internet Of Things

I just found out about Pachube over on the Make: Blog and am feeling really inspired. Pachube is just awesome! It is a service created by HAQUE design + research that “enables you to connect, tag and share real time sensor data from objects, devices, buildings and environments around the world. The key aim is to facilitate interaction between remote environments, both physical and virtual.”  Here is a video outlining the service:

I have already sent off a request for an invitation to the beta version and am watching my inbox with excitement. I can’t wait to use an arduino to start logging some data to share online. I would love to track the sun light in my garden or the energy usage in my house or use Pachube as part of a home automation system. Perhaps I will be able to monitor how much time I spend making music versus downsurfing on the interweb!

There is already a convenient way to follow peoples Pachube feeds on your iPhone but it might also be interesting to explore the API and create a handy Pachube iPhone app of my own.

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • LinkedIn
  • RSS
  • Slashdot
  • Twitter
Posted in arduino, energy, hack, iPhone, make, online, solar, ubiComp | Leave a comment

SSH Remote Access On Your iPhone

We are truly living in the future. Today while riding the bus to work I used my iPhone to log onto my web server using an SSH terminal app called TouchTerminal. As the bus made its way through the rain I was working at a command line logged on to a LAMP server implementing some PHP security measures that I had read about the night before. I was able to create and edit files with vi, move and copy files and folders, write and execute scripts and do anything that I could do logged onto my server from my computer at home. Did I mention this app is free?

SSH terminal on your iPhone

An SSH terminal on your iPhone

I’m not going to do a proper review of TouchTerminal except to say that it is a phenomenally cool free app for all network nerds. To be able to log onto a command line on my server from anywhere with cellular service is amazing. The makers of TouchTerminal also make a Pro version which implements all kinds of goodies to make doing network admin from your iPhone even easier if you are so inclined.

While I can’t really see myself using TouchTerminal all that much, the geek factor is just too much to resist, and for free you can’t go wrong. The only problem I can see is that now I have no excuse for not doing that WordPress upgrade I have been putting off. I’ll just have to do it on the bus.

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • LinkedIn
  • RSS
  • Slashdot
  • Twitter
Posted in command line, iPhone | Leave a comment

Create An Ad-Hoc Network For TouchOSC On Your Mac

After coding for iPhone for the last month and a half, I figured it was time I finally got one of the coveted devices for myself. This week I have been having fun setting it up, checking my email, and browsing the app store. They really are a marvel of technology and raise my expectaions in terms of elegance and functionality for all devices.

iPhone running TouchOSC

iPhone running TouchOSC

Today, in addition to working hard on my upcoming app release (which I am very excited about) I have been playing with the TouchOSC app from hexler.net. TouchOSC, available from the Apple App Store, provides several touchable interfaces including virtual faders, cross-faders, knobs, pads, keys, buttons, grids and x-y pads; all of which send OSC data over Wi-Fi using UDP. It is kind of  like a mini JazzMutant Lemur in your pocket.

The OSC data from TouchOSC can be used in software capable of receiving OSC messages, such as MaxMSP or Processing, or you can parse the OSC data to MIDI and then on to any MIDI controllable software such as Ableton Live. To translate the OSC to MIDI on a Mac I highly recommend you check out OSCulator. If you own Max you could build yourself a maxpat to do the same thing but OSCulator is prebuilt and there are some excellent presets available on the hexler.net website. Mac users will find instructions on using TouchOSC with Osculator and Ableton Live here. Windows users will find instructions to do something similar using a combination of Pure Data and MIDI Yoke here.

Setting up TouchOSC on your home wi-fi network is a piece of cake. All you have to do is open the TouchOSC Network settings and set the host and the  outgoing and incoming ports. The ports can be whatever you want to use; I use 8000 for outgoing and 9000 for the incoming port. The host should just be YOURCOMPUTENAME.local. This worked flawlessly for me the first time I tried it.

If however you are not at home, or are somewhere without wi-fi, and you want to use TouchOSC with your MacBook or MacBookPro, you need to create an ad-hoc wireless network. All an ad-hoc network is is a wireless network where the communciation between devices is direct, rather than through an access point or a router. Here are the steps to create an ad-hoc network and set up TouchOSC to communicate with your Mac:

1. Open up System Preferences->Network.

2. Click on the Network Name drop down and select  Create Network.

3. Give your network a name. A password is optional though probably a good idea.

4. Click on Advanced.

5. Click on the TCP/IP tab.

6. Click the Configure IPv4 drop down and select Manual.

7. Enter an IP and NetMask for your computer. I use 192.168.2.1 and 255.255.255.0.

8. Click OK and then Apply and close System Preferences.

9. On your iPhone open Settings->Wi-Fi and select the network you just created.

10. Click the arrow to the right of the network name.

11. Select Static for your IP type and enter your IP and NetMask for the iPhone. I use 192.168.2.2 for the IP. The NetMask must be the same as for the network which is 255.255.255.0.

12. Exit your iPhone settings and open TouchOSC.

13. Touch the field under the heading Network.

14. Enter the IP address you created for your Mac. In my case this is 192.168.2.1.

15. Make sure your ports are as you want them. Remember, the ports can be whatever you want to use, just make sure that they agree with whatever you are communicating with, ie OSCulator, MaxMSP, Processing etc. I use 8000 for the outgoing port and 9000 for the incoming port.

16. Touch the done button and then once you are at the mainscreen of TouchOSC, select your Layout and touch done again.

It sometimes takes a few seconds to connect to the network and open the TouchOSC Layout but once it opens you should be able to communicate with your Mac over the ad-hoc wireless network. To test out the ad-hoc network try using OSCulator or one of the Max patches provided on hexler.net. This is what worked for me; hopefully you will find that these instructions get you up and running TouchOSC over an ad-hoc network too. If you have any problems please leave a comment and I will do my best to help you.

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • LinkedIn
  • RSS
  • Slashdot
  • Twitter
Posted in MIDI, OSC, OSX, iPhone | 6 Comments

Getting Started With iPhone Development

I was recently inspired to write some apps for Apple’s iPhone. It is just way too fun a platform to resist. Having never done any development for Mac I had a lot to learn. Fortunately, as they do everything, Apple provides excellent documentation. The getting started documents at the iPhone Dev Center  are a good read and the guides found in the iPhone Reference Library provide more in depth information. Apple also has guides to using XCode and Interface Builder as well as other aspects of Mac development. If you are new to Objective-C like I was, then I would suggest looking at the Introduction to The Objective-C 2.0 Programming Language guide. If you are new to object oriented programming languages then the Object Oriented Programming with Objective-C document will be helpful to you as well.

Though Apple’s documentation is great, I find that getting several different takes on the same topic helps me to learn quickly. I also find that books with examples are useful learning tools. This led me to purchase two introductory offerings on iPhone development: iPhone in Action published by Manning and written by Christopher Allen and Shannon Appelcline and Beginning iPhone Development published by APress and written by Dave Mark and Jeff LaMarche.

iPhone in Action

iPhone in Action

The great thing about iPhone in Action is that it covers both native and web programming for the iPhone (about a third of the book). It does not assume pre-knowledge of Objective-C and even has a very brief overview of the C programming language that may be useful for someone coming from a non-C background. This is certainly not the book for someone who has no programming experience In fact, neither of these two books are aimed at people completely new to programming, but it does provide an adequate intro for Objective-C is you already know C.

iPhone in Action contains many helpful examples and covers topics not found in the APress book such as customizing web pages to be viewed on the iPhone and how to POST to a web server. On the downside I sometimes found the explanations for creating the examples in the book to be unclear. For some example apps the authors’ have included lists of steps to accomplish a task but they are inconsistant about flushing those steps out. In some places I needed to sift through the text to find the one tidbit that I was missing; something that could easily have been included in the step-by-step lists. Overall though it is a useful book to have in your library and will probably serve as a good reference for your iPhone projects for some time to come.

Beginning iPhone Development

Beginning iPhone Development

Beginning iPhone Development provides a great introduction to native iPhone development. Though this book does not cover web programming for the iPhone, and though it assumes knowledge of Objective-C programming, it does cover native development in greater depth than the Manning title. The explanations of the example apps that you build in this book are very clearly written. My personal preference in an introductory programming book is for a fun read that holds your hand a bit through the examples. Beginning iPhone Development definitely does this better than iPhone in Action, and does so without being patronizing.

At the end of the day either book will give you a good start developing apps for the iPhone. Whereas iPhone in Action gives a little broader treatment by including web programming and an introduction to Objective-C, Beginning iPhone Development covers more of the iPhone SDK and in greater depth. I personally think that these two books work great as companions, both filling in the missing bits in the other.

Finally I will reccomend the forums at iPhone Dev SDK as a great place to have your questions answered as you start developing your first apps. Happy coding!

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • LinkedIn
  • RSS
  • Slashdot
  • Twitter
Posted in OSX, iPhone | Leave a comment

Improved Arrow Key Key-bindings For OSX Terminal

When using Terminal it is sometimes useful to have your Page-Up, Page-Down, Home and End keys (the four arrow keys on Mac keyboards) function as you would expect. This is especially useful when using more or less to view text files or man pages. Unfortunately the default key-bindings for Terminal do not provide this. Here is a quick fix that works for me on OSX 10.5.6.

Setting key-bindings for Terminal

Setting the Page-Up key-binding in Terminal

Open Terminal then go to Terminal -> Preferences -> Settings -> Keyboard. Scroll down to find the key that you want to change and highlight it. Click the edit button at the bottom of the window. A new window will open like the one pictured above. Set everything as shown and replace the string to send to the shell with the appropriate one from the following list:

Key        Escape Sequence
End        \033[4~
Home       \033[1~
Page-Down  \033[6~
Page-Up    \033[5~

Enjoy.

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • LinkedIn
  • RSS
  • Slashdot
  • Twitter
Posted in OSX, hack | Leave a comment

Software Debouncing Multiple Latching Switches With Arduino

This last week I have been working on making the operation of my MIDI controller prototype more robust. One of my tasks has been to debounce and latch the states of my pushbutton toggle switches. Though you could use hardware for debouncing and latching I chose to do it with software. Doing it this way is cheaper, requires less space on a PCB and is fairly easily accomplished with todays microcontrollers.

A lone pushbutton switch

A lone pushbutton switch

Before setting out to debounce my pushbuttons I did some searching on Google and discovered an excellent article on debouncing called simply, A Guide To Debouncing. It covers multiple techniques for both hardware and software debouncing.

After reading the article, I decided to go with a software counting algorithm. I did some more research but I wasn’t happy with the examples that I found. All of them involved debouncing a single switch. I wanted to debounce an entire port of switches. To do this you could just repeat the debouncing code for each switch but I decided to write a single piece of code to handle an entire port.

Below is my solution using PORTB on an Arduino. PORTB is a six pin port. This could easily be ported to be used on any AVR microcontroller or indeed any other microcontroller that can be programmed in C.

Arduino NG

My Arduino NG

All the pushbuttons in my example are active high with pull down resistors. The code could easily be adapted for active low. (Note that my prototype actually only has two buttons connected to it. I set up wires with pull downs to act as switches for the remaining pins)

First we define the number of switches on our port (in this case six), then the debounce depth. Debounce depth is the number of consecutive times that a switch must be read to have a certain value (HIGH or LOW, 1 or 0) before a press of that switch is validated.

#define numButtons 6
#define debounceDepth 10

Next we set up the variables we will need. The first one is used to read the PORTB value into. The second is to keep a memory of the last debounceDepth number of reads. The next keeps tabs on whether the pushbutton switch has been released after pressing. This variable provides a form of hysterisis so that we don’t get multiple toggles on one button press. The buttonPressFilter is a bitwise ANDed sum of all of the debounceDepth number of memories. The result in the buttonPressFilter is what determines if a pushbutton switch has been validly pressed.

char buttonRead;
char buttonMemory[debounceDepth] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int buttonHasReleased[numButtons] = {true,true,true,true,true,true};
char buttonPressFilter = 0xFF;
int buttonState[numButtons] = {0,0,0,0,0,0};

So that is the end of initialization. Now onto the code that you would put in your loop. The buttonPressFilter is an 8-bit variable with each of the lower 6 bits representing the state of a pushbutton switch, pressed or not-pressed. (Remember, PORTB on Arduino only has 6 pins) Each time we loop through here, we reset the buttonPressFilter to start as all 1′s. As it is bitwise ANDed with the previous button memories, any button read of a zero value will fall through as a zero, the rest will be left as 1′s. It basically ‘filters’ out any button presses that are not yet stable.

buttonPressFilter = 0xFF;

Here we shift all the memory by one, dumping the oldest reading to make room for the new reading. Then we AND all the old memories together.

for(i=(debounceDepth-1); i>0; i--) {
    buttonMemory[i] = buttonMemory[i-1];
    buttonPressFilter &= buttonMemory[i];
}

Here we read the current status of the switches on PORTB.

buttonRead = PINB;

Now for each pushbutton switch we check if the current read indicates a press. If it does, then we set its memory bit, otherwise we clear it.

for(i=0; i<numButtons; i++) {
    if((buttonRead & bitMask[i]) != 0) { // if current read shows button is pressed
        buttonMemory[0] |= bitMask[i];     // set the memory bit for that button
    } else {
        buttonMemory[0] &= ~(bitMask[i]); // otherwise clear the memory bit for that button
    }
}

Take account of the newest read into memory.

buttonPressFilter &= buttonMemory[0]; // AND the final memory bits into the buttonPressFilter

Now the buttonPressFilter contains the current pressed or non-pressed state of the switches. If any switch has had a consistent value for debounceDepth number of times, then toggle the state in the buttonState array and do whatever it is you want your button to do.

for(i=0; i<numButtons; i++) {
    if((buttonPressFilter & bitMask[i]) != 0) {
        if(buttonHasReleased[i] == true) {
            if(buttonState[i] == 0) {
                // ENTER CODE HERE FOR WHAT YOU WANT TO HAPPEN WHEN BUTTON IS ON
                buttonState[i] = 1;
            } else {
                // ENTER CODE HERE FOR WHAT YOU WANT TO HAPPEN WHEN BUTTON IS OFF
                buttonState[i] = 0;
            }
        }
        buttonHasReleased[i] = false;
    } else {
        buttonHasReleased[i] = true;
    }
}

One final thing to mention is that the debounceDepth value is something that you need to experiment with for the specific switches in your project. Currently with my cheap pushbuttons sitting in a cardboard chassis and wired to a breadboard, I need a value of 10 to get stable results. Using better switches, a stable chassis and a PCB I expect this number to drop.

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Technorati
  • LinkedIn
  • RSS
  • Slashdot
  • Twitter
Posted in MIDI, arduino, code, make, prototyping | 3 Comments