Welcome to Pete Brown's 10rem.net

First time here? If you are a developer or are interested in Microsoft tools and technology, please consider subscribing to the latest posts.

You may also be interested in my blog archives, the articles section, or some of my lab projects such as the C64 emulator written in Silverlight.

(hide this)

Get an AGENT Smart watch and help them get to 1MM

Pete Brown - 15 June 2013

If you're a Windows Phone (or iOS or Android) user and want a smart watch which you can program using .NET, then get into the AGENT watch kickstarter before it ends in just 4 days.

image

You may know Secret Labs from their most popular NETMF product, the Netduino. I've always been a huge fan of their stuff.

image

Community

Secret labs has always made community a core part of their products. In this case, they've already helped people figure out how to create watch faces using straight NETMF, even before the SDK and community site are ready (both coming after the funding period is over).

The community is hard at work, even without prototype hardware, developing cool watch faces. Here are a few of my favorites community creations, snagged from the comment thread.

image image image image image image image

image image

Those don't even include the ones that Secret Labs and House of Horology will deliver with the phone. Also, once people get the devices and have access to the on-board accelerometers, the weather data, bluetooth connections, and more, you can expect some pretty amazing watch faces and apps.

Coding your own watch faces

You can create all sorts of apps for the watch. To do this, you use the same tools you use for Windows Phone and Windows apps. You use Visual Studio, including the free version, and C# along with the Apache-licensed open source NETMF 4.3 runtime and the AGENT SDK.

One class of app is a watch face, like those shown above. Here's an example of what the watch face code might look like (source "Jeroen" via pastebin). This example has a background bitmap and some text over it.

If you're already a Windows, Windows Phone, ASP.NET, or NETMF developer, you'll find the code extremely easy to create. You'll be able to load the apps on to the watch using bluetooth and even create companion apps for your phone.

using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Media;
using System.Threading;

namespace WPWatchface
{
public class Program
{
const int SCREEN_WIDTH = 128;
const int SCREEN_HEIGHT = 128;

// set the following to true for 24-hour time (00-23 instead of 1-12)
const bool DISPLAY_24_HOUR_TIME = true;
// set the following to true to outline screen in emulator
const bool DISPLAY_BORDER_BOX = false;

static Bitmap _bitmap;
static Bitmap _background;

static Font _fontLarge;
static Font _fontMedium;
static Font _fontSmall;
static Font _fontExtraSmall;

static Timer _updateClockTimer;

static object _updateTimeLock = new object();

static DateTime _startTime = new DateTime(2013, 01, 01, 09, 00, 00);

public static void Main()
{
_bitmap = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);
_background = new Bitmap(Resources.GetBytes(Resources.BinaryResources.wp_logo), Bitmap.BitmapImageType.Gif);

_fontExtraSmall = Resources.GetFont(Resources.FontResources.WeblySleek_12);
_fontSmall = Resources.GetFont(Resources.FontResources.WeblySleek_14);
_fontMedium = Resources.GetFont(Resources.FontResources.WeblySleek_24);
_fontLarge = Resources.GetFont(Resources.FontResources.WeblySleek_32);

// optionally set time; comment out the following line to use the current system time
//Microsoft.SPOT.Hardware.Utility.SetLocalTime(_startTime);

// display the time immediately
UpdateTime(null);

// set up timer to refresh time every minute
DateTime currentTime = DateTime.Now;
TimeSpan dueTime = new TimeSpan(0, 0, 0, 59 - currentTime.Second, 1000 - currentTime.Millisecond); // beginning of next minute
TimeSpan period = new TimeSpan(0, 0, 1, 0, 0); // update time every minute
_updateClockTimer = new Timer(UpdateTime, null, dueTime, period); // start our minute timer

// go to sleep; time updates will happen automatically every minute
Thread.Sleep(Timeout.Infinite);
}

static void UpdateTime(object state)
{
string hour = "";
string minute = "";

// clear our display buffer
_bitmap.Clear();

// set background
_bitmap.DrawImage(0, 0, _background, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);

// grab the current time
DateTime currentTime = DateTime.Now;

// set our hour and minute based on 12/24 hour settinsg
if (DISPLAY_24_HOUR_TIME)
{
hour = currentTime.Hour.ToString();
}
else
{
hour = (currentTime.Hour % 12).ToString();
if ((currentTime.Hour % 12) == 0) hour = "12";
}
minute = currentTime.Minute.ToString();

// draw hours
int w = _fontLarge.CharWidth(hour[0]);
if (hour.Length > 1)
{
w += _fontLarge.CharWidth(hour[1]);
}
else
{
hour = "0" + minute;
w += _fontLarge.CharWidth(hour[0]);
}
_bitmap.DrawText(hour, _fontLarge, Color.Black, (90 - (w / 2)), 5);

// draw minutes
w = _fontSmall.CharWidth(minute[0]);
if (minute.Length > 1)
{
w += _fontLarge.CharWidth(minute[1]);
}
else
{
minute = "0" + minute;
w += _fontLarge.CharWidth(minute[0]);
}
_bitmap.DrawText(minute, _fontLarge, Color.Black, (84 - (w / 2)), 62);

// draw current weekday
string weekday = DateTime.Now.ToString("ddd");
w = 0;
for (int i = 0; i < weekday.Length; i++)
w += _fontExtraSmall.CharWidth(weekday[i]);
_bitmap.DrawText(weekday.ToLower(), _fontExtraSmall, Color.Black, (27 - (w / 2)), 28);

// draw current date
string date = currentTime.Day + "-" + currentTime.Month;
w = 0;
for (int i = 0; i < date.Length; i++)
w += _fontExtraSmall.CharWidth(date[i]);
_bitmap.DrawText(date, _fontExtraSmall, Color.Black, (26 - (w / 2)), 76);

// draw a border around the screen, if desired.
if (DISPLAY_BORDER_BOX)
{
_bitmap.DrawRectangle(Color.White, 1, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, Color.White, 0, 0, Color.White, 0, 0, 0);
}

// flush the display buffer to the display
_bitmap.Flush();
}
}
}

 

The project is a go, having met the goal a long time ago. However, at 1MM, we might see an app store for the watch apps. I'd love to see this happen and would also love to see more of you out there coding for NETMF devices you can wear on your wrist. Join us!

Join the kickstarter project and get a great watch.

         
posted by Pete Brown on Saturday, June 15, 2013
filed under:          

3 comments for “Get an AGENT Smart watch and help them get to 1MM”

  1. G. Andrew Duthiesays:
    Just pledged...was waiting until after we got through our refi so I had some idea of what the cash flow would look like. Looking forward to SPOT v2.0. Or maybe should call it 3.0, given how far advanced it is over the original smart watch. ;-)

Comment on this Post

Remember me