.NET Micro Framework: Getting Started With Agent SmartWatch Apps
Today, we are going to discuss the .NET Micro Framework, SmartWatch apps, and we will also develop, run and deploy the apps to emulator. We can build the our wearable smartwatch apps using .NET Micro Framework. We require the prerequisite Software Agent SmartWatch SDK, .NET Micro Framework SDK and Visual Studio 2015.
What is .NET Micro Framework?
.NET Micro Framework (formerly know as SPOT) is a powerful and flexible platform for rapidly creating embedded device firmware with Microsoft Visual Studio. SPOT is called Smart Personal Object Technology and its support smallest device, SPOT Watches, GPS navigation devices, and Windows Vista Sideshow displays.
http://san2debug.net/image.axd?picture=/2016/02/MicroFramworkArchitecture.jpg
Image source: msdn.microsoft
Prerequisites
- Visual Studio 2015
- Agent SDK v0.3
- Microsoft .NET Micro Framework SDK v4.3
First, we need to set up the environment
- Microsoft .NET Micro Framework SDK v4.3
- Agent SDK v0.3
Agent SDK
**Steps 1: **Double click “agentsdk”.
The AGENT SDK v0.3 Setup will open and then select checkbox license terms and click **Install **button.
http://san2debug.net/image.axd?picture=%2f2016%2f02%2fAgentSDK1.png
Getting started with setup initializing process for the Agent SDK setup.
http://san2debug.net/image.axd?picture=%2f2016%2f02%2fAgentSDK2.png
After it is successfully installed in Agent SDK, you can see the following screen and click **Close **button.
http://san2debug.net/image.axd?picture=%2f2016%2f02%2fAgentSDK3.png
Microsoft .NET Micro Framework SDK
**Steps 2: **Double Click “MicroFrameworkSDK”
The Microsoft .NET Micro Framework SDK 4.3 Setup will open and click Next button.
http://san2debug.net/image.axd?picture=%2f2016%2f02%2fMicroFrameworkSDK1.png
The Microsoft .NET Micro Framework SDK 4.3 setup wizard is open now. Select checkbox for license terms and click **Next **button.
http://san2debug.net/image.axd?picture=%2f2016%2f02%2fMicroFrameworkSDK2.png
The Microsoft .NET Micro Framework SDK 4.3 setup wizard is open now. Select checkbox **Typical **and click **Next **button.
http://san2debug.net/image.axd?picture=%2f2016%2f02%2fMicroFrameworkSDK3.png
The Microsoft .NET Micro Framework SDK 4.3 setup wizard is open and click **Install **button
http://san2debug.net/image.axd?picture=%2f2016%2f02%2fMicroFrameworkSDK4.png
Getting started with setup installation process for the .NET Micro Framework SDK setup.
http://san2debug.net/image.axd?picture=%2f2016%2f02%2fMicroFrameworkSDK5.png
After it is successfully installed in .NET Micro Framework SDK, you can see the following screen and click **Finish **button.
http://san2debug.net/image.axd?picture=%2f2016%2f02%2fMicroFrameworkSDK6.png
Steps 3:
Create a sample application using .NET Micro Framework and deploy the emulator.
Open Visual Studio 2015 and go to File menu and point New and then click New Project, where you can see the section** Visual C#** Template. Click Micro Framework, then select Window Application and type Project Name AgentSmartWatchApps. Choose the project Location path and then click OK button.
http://san2debug.net/image.axd?picture=%2f2016%2f02%2fAgentSmartWatchApps1.png
You can see AgentSmartWatchApps project structure as in the following screenshot:
http://san2debug.net/image.axd?picture=%2f2016%2f02%2fAgentSmartWatchApps2.png
Go to Solution Explorer, right click the project name and select an Application option. Select a target framework “.NET Micro Framework 4.3”.
http://san2debug.net/image.axd?picture=%2f2016%2f02%2fAgentSmartWatchApps3.png
Next select .NET Micro Framework option, then a device “AGENT Emulator”.
http://san2debug.net/image.axd?picture=%2f2016%2f02%2fAgentSmartWatchApps4.png
using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Input;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
namespace AgentSmartWatchApps
{
public class Program : Microsoft.SPOT.Application
{
public static void Main()
{
Program myApplication = new Program();
Window mainWindow = myApplication.CreateWindow();
// Create the object that configures the GPIO pins to buttons.
GPIOButtonInputProvider inputProvider = new GPIOButtonInputProvider(null);
// Start the application
myApplication.Run(mainWindow);
}
private Window mainWindow;
public Window CreateWindow()
{
// Create a window object and set its size to the
// size of the display.
mainWindow = new Window();
mainWindow.Height = SystemMetrics.ScreenHeight;
mainWindow.Width = SystemMetrics.ScreenWidth;
// Create a single text control.
Text text = new Text();
text.Font = Resources.GetFont(Resources.FontResources.small);
text.TextContent = Resources.GetString(Resources.StringResources.String1);
text.HorizontalAlignment = Microsoft.SPOT.Presentation.HorizontalAlignment.Center;
text.VerticalAlignment = Microsoft.SPOT.Presentation.VerticalAlignment.Center;
// Add the text control to the window.
mainWindow.Child = text;
// Connect the button handler to all of the buttons.
mainWindow.AddHandler(Buttons.ButtonUpEvent, new RoutedEventHandler(OnButtonUp), false);
// Set the window visibility to visible.
mainWindow.Visibility = Visibility.Visible;
// Attach the button focus to the window.
Buttons.Focus(mainWindow);
return mainWindow;
}
private void OnButtonUp(object sender, RoutedEventArgs evt)
{
ButtonEventArgs e = (ButtonEventArgs)evt;
// Print the button code to the Visual Studio output window.
Debug.Print(e.Button.ToString());
}
}
}
Run and test the Agent Smartwatch “Hello World” apps
http://san2debug.net/image.axd?picture=%2f2016%2f02%2fAGENTSmartwatchAppHelloWorld.png
Conclusion
This article helps you to understand .NET Micro Framework and AGENT SDK with Agent Smartwatch apps using Visual Studio 2015.