Recent Updates RSS Hide threads | Keyboard Shortcuts

  • Develop for Android on your Mac

    Ellen 12:53 on January 19, 2012 | 0 Permalink | Reply
    Tags: ADT Plugin, android, Eclipse

    Here is a short tutorial on how to install all you need for Android development on a Mac.

    1. Download Eclipse 3.2, 3.3 (Europa) for your Mac on:
    http://www.eclipse.org/downloads/

    2. Download the Android SDK from here:
    http://developer.android.com/sdk/index.html

    2. Once you installed the SDK you can get the latest update from this command-line command by
    executing:

    tools/android update sdk

    3. Install the ADT plugin
    - Start Eclipse, then select Help ]]> Install New Software…
    - Click on add and the window below will appear. Input the URL https://dl-ssl.google.com/android/eclipse/. Use http if https does not work. Name it “ADT Plugin”.

    android_adt_plugin

    - Click on Next, and then Next agian and accept the license agreements. Click on Finish.
    - Restart Eclipse

    4. Create an AVD Manager
    - In order to run our Android app on the Mac we need to set up an Android Virtual Device in Eclipse.
    Window > AVD Manager
    - Create a new AVD by clicking on new
    - Type in the name of your avd, in my case my_avd
    - Choose a target.
    The target is the platform (that is, the version of the Android SDK, such as 2.3.3) you want to run on the emulator. I chose the latest one I got.
    - Click create!
    android_virtual_device_manager

    5. Now you are up and running!
    Why not start with a simple Hello World:
    http://developer.android.com/resources/tutorials/hello-world.html

  • Small Ehternet access just got smaller

    Ellen 22:08 on January 12, 2012 | 0 Permalink | Reply
    Tags: , arduino shield, , ethernet, freetronics

    ethernet

    The Arduino Ethernet shield has been around for some time now. It’s a great solution for cutting out the middle man of the computer when check things online from the Arduino. In order to build smaller cases I stumbled upon EtherTen from Freetronics. It’s a fully Arduino-compatible board that runs Arduino code AND connects to internet with Ethernet.

    Lets make a list of the pros:
    - Smaller than Arduino board with Ethernet shield on top
    - Runs Arduino Ethernet library
    - Power of Ethernet, no power supply needed (!!!!)
    - Micro SD card holder
    - And sexy round corners (rounder than the Ethernet Shield)
    - Neat mini USB socket

    When it arrived I simply ran the TwitterClient file by Tom Igoe in Ethernet examples of the Arduino IDE and it was up and running. To call my custom php file was a bit harder though. Example code to be posted on my Arduino Circuit Blog shortly.

  • Xmas Installation based on node-js and Hydna

    Ellen 14:35 on December 22, 2011 | 0 Permalink | Reply
    Tags: , nodejs

    At Society 46 we celebrated the Xmas by hooking up to loads of Xmas lights to the node-js module Hydna. People can switch on and off 11 220 V sockets in real-time. Try it out on http://www.society46.com/xmas and turn on the lights of Society 46 Xmas Crib.

    site

  • AppleScript in Objective-C

    Ellen 11:22 on December 5, 2011 | 0 Permalink | Reply
    Tags: applescript, objectve-c,

    I am working on a project where the good old Apple Script is need to do some magic on a Mac computer. Even though it is very semantic it can do some powerful stuff. The result will be posted as soon as it is finished.

    Here is a simle Hello World example just to get it up and running in Xcode. The example is used in a Mac OS X application.

    #import "S46AppDelegate.h"

    @implementation S46AppDelegate

    @synthesize window;

    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
    {
        // Insert code here to initialize your application
        NSDictionary* errorDict;
        NSAppleEventDescriptor* returnDescriptor = NULL;
       
        NSAppleScript* scriptObject = [[NSAppleScriptalloc] initWithSource:
        @"display dialog \"Hello World\" buttons \"OK\" default button \"OK\""
                                       ];
       
       
       
        returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
        [scriptObject release];
       
        if (returnDescriptor != NULL)
        {
            // successful execution
            if (kAENullEvent != [returnDescriptor descriptorType])
            {
                // script returned an AppleScript result
                if (cAEList == [returnDescriptor descriptorType])
                {
                    // result is a list of other descriptors
                }
                else
                {
                    // coerce the result to the appropriate ObjC type
                }
            }
        }
        else
        {
            // no script result, handle error here
        }
    }

    @end

  • Tracking technology meets iPhone

    Ellen 10:49 on November 2, 2011 | 0 Permalink | Reply
    Tags: , , tracab

    Today Society46 is launching the Pepsi Refresh project together with Åkestam Holst. The project involves the Tracab tracking stystem, UDP streams, iPhone sensors and FMOD for iOS. Code will follow.


  • My Arduino circuit blog

    Ellen 11:45 on October 31, 2011 | 4 Permalink | Reply
    Tags: , curcuits,

    Whenever I make a circuit I try to document it and take photos. With the Fritzing software it gets even better. To share code and circuits I gathered my Arduino circuits on this new blog: Ellen Sundh’s Arduino Circuit Blog

    Untitled-1

  • Using iPhone sensors with real-time server

    Ellen 11:35 on October 12, 2011 | 0 Permalink | Reply
    Tags: , , real-time server, , society46, webapp

    The latest work from Society46 where the iPhones turns into a tool to paint together with other, in real time with the help of Hydna real-time server.

    CO:CREATE from Society 46 on Vimeo.

  • Geek Girl Arduino Workshop

    Ellen 11:15 on October 12, 2011 | 0 Permalink | Reply
    Tags: , ,

    During the Arduino Workshop with Geek Girls Meetup we went through a number of sensors. A full list will be posted here soon. Here are some images from the workshop:
    @ellensundh visarVisning av motståndsappen

  • The dirty robot

    Ellen 17:55 on October 1, 2011 | 0 Permalink | Reply
    Tags: , robot, sound

    Some robots only reacts on very dirty words. It’s a struggle but what could you do. This robot reacts on Swedish dirty words (genitals and poo related words).

  • Stabalize compass of iPhone with gyroscope

    Ellen 18:50 on September 18, 2011 | 11 Permalink | Reply
    Tags: compass, gyroscope, , , yaw

    How is it possible to detect the rotation of an iPhone that lies on a table like the compass but is showing a more accurate rotation? I tried to use the compass with the magnetic heading of the iPhone but it appears to be quite unreliable and jumps unexpectedly. The gyroscope can be used but the original reference point drifts with the gyroscope over time. This example combines the compass and the gyroscope using the compass as a reference as long as it is stable and using the fast update of the gyroscope between the times the compass is unstable.

    In the app below there are 3 rotating graphics:

    • Yellow is magnetic heading.
    • Blue is a compass offset (always following the magnetic heading with a decided offset)
    • Black is the gyroscope (reset every time the compass is stable)

    The application uses the CLLocationManager to access the magnetic heading of the compass and CMMotionManager to access the gyroscope. The values I use are newHeading.magneticHeading and motion.attitude.yaw. The magnetic heading gives a value of 360 degrees. The yaw value gives a value between -180 and 180.

    Compass from Location Manager

    First we initialize the location manager. This will only work on the device and not in the simulator.

    locationManager=[[CLLocationManager alloc] init];
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    locationManager.delegate=self;
           
    if([CLLocationManager headingAvailable] == YES){
            NSLog(@"Heading is available");
    } else {
            NSLog(@"Heading isn’t available");
    }
    [locationManager startUpdatingHeading];

    As shown in the code above we delegate the listener to RotationViewController. The following code is needed to listen to updates for the compass:

    #import <UIKit/UIKit.h>
    #import <math.h>
    #import <CoreMotion/CoreMotion.h> // For the gyroscope
    #import <CoreLocation/CoreLocation.h> // For the compass

    @interface RotationViewController : UIViewController <CLLocationManagerDelegate> {

    Yaw data from gyroscope

    Next step is to listen to updates from the gyroscope. We do that by listening to motionManager’s CMAttitude updates. We use the yaw which is retrieved in radians and we convert it to degrees.

    motionManager = [[CMMotionManageralloc]  init];
     motionManager.deviceMotionUpdateInterval = 1.0/60.0;
     opQ = [[NSOperationQueuecurrentQueue] retain];
       
     if(motionManager.isDeviceMotionAvailable) {
        motionHandler = ^ (CMDeviceMotion *motion, NSError *error) {
            CMAttitude *currentAttitude = motion.attitude;
            float yawValue = currentAttitude.yaw;
            float yawDegrees = CC_RADIANS_TO_DEGREES(yawValue);
        };
    } else {

        [motionManager release];
    }

    [motionManagerstartDeviceMotionUpdatesToQueue:opQwithHandler:motionHandler];

    We now have the compass and the gyroscope. In this example I wanted to offset the magnetic heading so it always points at a certain direction. I decide on that direction when I press the “Calibrate”-button I set my offset from the magnetic heading. updatedHeading is the latest magnetic heading I got from the locationManager. northOffset becomes my reference to where I want the gyroscope to always origin from.

    - (IBAction)calibrate:(id)sender
    {  
        northOffest = updatedHeading - 0;
    }

    Compensating for compass inaccuracies

    Now that we have the northOffset we want to use it together with the gyroscope. Since the compass is jumping sometimes we want to only use the compass value when it is stable. A timer is created with the updater method that checks if the value of the magnetic heading has changed. The interval is called every other second. If the magnetic heading hasn’t changed from last time it is considered a stable value. The stable value is added to newCompassTarget which is use for the gyroscope to get a new reference.

    - (void)updater:(NSTimer *)timer
    {
        // Om inte compassen rört sig på ett tag kalibrera gyron efter det
        if(updatedHeading == oldHeading) {
           NSLog(@"Update gyro");
           newCompassTarget = (0 - updatedHeading) + northOffest;
           offsetG = currentYaw;
            updateCompass = 1;
        } else {
            updateCompass = 0;
        }
       
        oldHeading = updatedHeading;
    }

    newCompassTarget is used in the code below so that the gyroscope always strive to go to the new reference of the compass but with the offset we use in the variable offsetG which is the difference between where the gyroscope was with the old and compared to the new heading.

    motionHandler = ^ (CMDeviceMotion *motion, NSError *error) {
                CMAttitude *currentAttitude = motion.attitude;
                float yawValue = currentAttitude.yaw;
                float yawDegrees = CC_RADIANS_TO_DEGREES(yawValue);
                currentYaw = yawDegrees;
               
                yawDegrees = newCompassTarget + (yawDegrees - offsetG);
               
                if(yawDegrees < 0) {
                    yawDegrees = yawDegrees + 360;
                }
           
                compassDif.text = [NSString stringWithFormat:@"Gyro: %f",yawDegrees];
               
                float gyroDegrees = (yawDegrees*radianConst);
               
                if(updateCompass) {
                    [UIView beginAnimations:nil context:NULL];
                    [UIView setAnimationDuration:0.25];
                    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                    [rotateImg setTransform:CGAffineTransformMakeRotation(gyroDegrees)];
                    [UIView commitAnimations];
                   
                    updateCompass = 0;

                } else {
                    rotateImg.transform = CGAffineTransformMakeRotation(gyroDegrees);
                }
            };

    Download project source code here.

    • Lars Mahnkopf 11:37 on September 23, 2011 Permalink

      Hi,

      one question about the code above: the radianConst just converts degrees into radians or am i wrong? when will you post your example code? ( I can´t wait to see it ;) )

      best regards

      Lars

    • HC 18:49 on September 26, 2011 Permalink

      is the source code available for this project yet?

    • Michael 08:19 on September 28, 2011 Permalink

      when will you post your source code?

      Michael.

    • Ellen 06:33 on September 29, 2011 Permalink

      The source code will be posted here in a day or 2.

    • Ellen 06:34 on September 29, 2011 Permalink

      @Lars Here is the conversion for radianConst:
      radianConst M_PI/180.0

    • Jack 07:48 on September 29, 2011 Permalink

      Dear Ellen:

      There are 2 questions
      1. Where is the CC_RADIANS_TO_DEGREES function?
      2. opQ = [[NSOperationQueuecurrentQueue] retain];
      is NSOperationQueuecurrentQueue the normal object in iOS ?

      Waiting for your whole project too… ^^

      Thanks,
      Jack

    • Ellen 08:02 on September 29, 2011 Permalink

      The project is available for download in the post now.

    • Jack 08:20 on September 29, 2011 Permalink

      Thanks~ Ellen~

    • Michael 09:34 on September 30, 2011 Permalink

      Thanks :)

    • HC 15:19 on October 3, 2011 Permalink

      quick note:

      this has been causing a crash for me on a 3G device

      } else {
      NSLog(@”No Device Motion on device.”);
      [motionManager release];
      }

      when I remove the motionManager release it works fine.

      thanks.

    • Ellen 13:25 on October 4, 2011 Permalink

      @HC The motionManager will only work on iPhone 4 since 3G and 3GS doesn’t have the gyroscope.

c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
esc
cancel