Dew Drop – November 21, 2012 (#1,447)

Top Links

 

Web Development

 

XAML

 

Miscellaneous .NET

 

Design / Methodology / Testing

 

Other Mobile Platforms

 

Podcasts / Screencasts / Videos

 

Community / Events

 

Database

 

Miscellaneous

 

More Link Collections

 

The Geek Shelf

 

The Dew Review – Intel Next Generation Ultrabook™ with Windows 8: A Final Look

You can read my first two reviews of the Next Gen Ultrabook from Intel here:

  1. The Dew Review – Intel Next Generation Ultrabook™ with Windows 8: Initial Impressions
  2. The Dew Review – Intel Next Generation Ultrabook™ with Windows 8: Playing with Sensors

Intro

This is my third and final review of the Intel Ultrabook. I am happy to say it is not the end of my use of the machine. It has become my primary device for development and all other regular use outside of work. My wife and kids also love using it.

Family Time

I have three daughters. The six-year-old, Luci, likes to practice words and numbers on Mr. Anker Tests. It’s got a variety of Flash-based activities for pre-K and grade school kids. Luci really likes that she can use either the touchpad or the screen to interact with the site. Whenever she sees Windows apps on a non-touch-enabled device, she tends to reach for the screen first. This was not something that happened after using an iPod Touch, iPad or Kindle Fire. I think it’s seeing the same Windows UI that triggers it.

More Windows 8 Development

I have continued to look at the sensor APIs available in WinRT since my last review. I have created a couple other simple proof-of-concept type apps that just reference all the sensors and display and log the output. One of them is similar to my first C#/XAML SensorFun app, but I wrote it in HTML/JavaScript to see how things are different in that type of app. I found that outside of syntax, it’s pretty much the same. That app is called SensorFunJS, and here is a snippet of the JavaScript code.

(function () {
    "use strict";

    WinJS.Binding.optimizeBindingReferences = true;

    var orientationSensor;
    var app = WinJS.Application;

    function id(elementId) {
        return document.getElementById(elementId);
    }

    function onOrientationChanged(e) {
        switch (e.orientation) {
            case Windows.Devices.Sensors.SimpleOrientation.notRotated:
                id('orientationElement').innerHTML = "Not Rotated";
                break;
            case Windows.Devices.Sensors.SimpleOrientation.rotated90DegreesCounterclockwise:
                id('orientationElement').innerHTML = "Rotated 90 degrees";
                break;
            case Windows.Devices.Sensors.SimpleOrientation.rotated180DegreesCounterclockwise:
                id('orientationElement').innerHTML = "Rotated 180 degrees";
                break;
            case Windows.Devices.Sensors.SimpleOrientation.rotated270DegreesCounterclockwise:
                id('orientationElement').innerHTML = "Rotated 270 degrees";
                break;
            case Windows.Devices.Sensors.SimpleOrientation.faceup:
                id('orientationElement').innerHTML = "Face Up";
                break;
            case Windows.Devices.Sensors.SimpleOrientation.facedown:
                id('orientationElement').innerHTML = "Face Down";
                break;
            default:
                id('orientationElement').innerHTML = "Unknown orientation: " + e.orientation;
                break;
        }
    }

    app.onactivated = function (activationArgs) {
        if (activationArgs.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
            
            orientationSensor = Windows.Devices.Sensors.SimpleOrientationSensor.getDefault();
            orientationSensor.addEventListener("orientationchanged", onOrientationChanged);
            
            WinJS.UI.processAll();
        }
    };
    
    app.start();
})();

Next, I found an article on Code Project with a Windows 8 WinForm app referencing the WinRT libraries and using the Sensor API. This same C# code could be used behind a WPF desktop application on WIndows 8. I plan on taking the ideas in this project to create my own library that can be shared across Windows 8 desktop applications. Here’s a sample of the code from Yvan’s article.

private void SensorListener()
{
    // Monitor accelerometer events.
    if (_accelerometer != null)
    {
        _accelerometer.ReportInterval = 0; // default
        _accelerometer.ReadingChanged += AccelerometerOnReadingChanged;
        _accelerometer.Shaken += (s, a) => _shaken++;
        Log("Shake activity will be monitored.");
    }

    // Monitor compass events.
     if(_compass != null)
    {
        _compass.ReportInterval = 0; // default
        _compass.ReadingChanged += CompassOnReadingChanged;
    }

    // Monitor gyro events.
    if(_gyrometer != null)
    {
        _gyrometer.ReportInterval = 0; // default
        _gyrometer.ReadingChanged += GyrometerOnReadingChanged;
    }

    // Monitor light sensor events.
    if (_light != null)
    {
        _light.ReportInterval = 0; // default
        _light.ReadingChanged += LightOnReadingChanged;
    }

    // Monitor position sensor events.
    if (_geolocator != null)
    {
        _geolocator.ReportInterval = 1000;
        _geolocator.MovementThreshold = 1;
        _geolocator.DesiredAccuracy = PositionAccuracy.High;
        _geolocator.StatusChanged += GeolocatorOnStatusChanged;
        _geolocator.PositionChanged += GeolocatorOnPositionChanged;
    }

     // Monitor NFC proximity events.
     if (_proximity != null)
    {
        _proximity.DeviceArrived += ProximityDeviceArrived;
        _proximity.DeviceDeparted += ProximityDeviceDeparted;
    }
            
    // The sensor loop.
    while (true)
    {
        if (_stopping)
            return;
        Thread.Sleep(0); // Defer to other threads that need cycles.
    }
}

As you can see, the code is no different than that of a WinRT app.

Intel has a really good article titled “Using Windows 8 WinRT API from desktop applications.” I highly recommend checking that out if you are developing desktop applications for Windows 8. There are a lot of great (and simple to use) APIs in WinRT. Having the ability to leverage them in our desktop apps is really exciting.

Sensors in the Real World

As far as the usefulness of sensors in real world applications, I think the biggest opportunity lies in game development. There could also be some simulator and health care related applications for some of these apps as well.

I am in the early stages of creating an app called Steady Hands Challenge. You can read my overview of the app on Code Project. Basically, you hold the Ultrabook on the palms of your hands, and the app will use charts on the screen to instruct the user which way to tilt the Ultrabook. The closer you keep the actual X/Y/Z lines to the target lines, the higher your score. Any shaking detected by the accelerometer will result in a penalty. Although I originally envisioned this WPF app as a sort of game, I could see how something similar could be used to gamify physical therapy. As long as your not worried about patients dropping your Ultrabook.  Smile

A Final Wrap Up

As I have repeatedly stated, I really have enjoyed developing on this machine. I truly believe that Ultrabooks with Windows 8 are the perfect developer machine today. They provide the power and speed needed to run multiple instances of Visual Studio or any other IDE. The touch screen and sensors also eliminate the need to have a separate tablet for testing your apps. I can write apps that use complex gestures and test with a simple F5. This saves time, money and headaches.

My name is Alvin Ashcraft, and I approve this Ultrabook.

 

Disclosure of Material Connection: I received one or more of the products or services mentioned above for free in the hope that I would mention it on my blog. Regardless, I only recommend products or services I use personally and believe my readers will enjoy. I am disclosing this in accordance with the Federal Trade Commission’s 16 CFR, Part 255: “Guides Concerning the Use of Endorsements and Testimonials in Advertising.”

 

Dew Drop – November 20, 2012 (#1,446)

Top Links

 

Web Development

 

XAML

 

Miscellaneous .NET

 

Design / Methodology / Testing

 

Other Mobile Platforms

 

Podcasts / Screencasts / Videos

 

Community / Events

 

Database

 

SharePoint

 

Miscellaneous

 

More Link Collections

 

The Geek Shelf