About
In this tutorial, we will cover the deployment of a simple UWP app onto a Raspberry Pi 3 running Windows 10 IOT. All the app will do is display the current time. The deployment of the app will be done over the network.
Hardware Used
- #adAmazon LinkRaspberry Pi
- #adAmazon LinkLCD screen
Making the App
Start by creating a UWP app project in Visual Studio.
All the UI part consists of is a text block.
The UI in XAML code.
<Page x:Class="Windows10IOTTestApp.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:Windows10IOTTestApp" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <TextBlock x:Name="displayTextBlock" HorizontalAlignment="Left" Margin="66,63,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="945" Width="1779" FontSize="150"/> </Grid> </Page>
Next is the C# code for the functionality of the app. The code is pretty straight forward. There is a timer that triggers an event every second. That event then calls the getTime() method that gets the current time and displays it in the text block.
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; using Windows.Foundation.Collections; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 namespace Windows10IOTTestApp { /// <summary> /// An empty page that can be used on its own or navigated to within a Frame. /// </summary> public sealed partial class MainPage : Page { DispatcherTimer Timer; public MainPage() { this.InitializeComponent(); Timer = new DispatcherTimer(); Timer.Interval = TimeSpan.FromMilliseconds(1000); Timer.Tick += Timer_Tick; Timer.Start(); } private void Timer_Tick(object sender, object e) { getTime(); } private void getTime() { DateTime dt = DateTime.Now; displayTextBlock.Text = dt.ToString("HH:mm:ss"); } } }
Testing the App on PC
This is what our app is supposed to look like.
Deploying the App to the Raspberry Pi
Before deploying the app change the architecture from x86/64 to ARM.
For the device select Remote Machine.
Go to project properties.
Select Debug, under Start options choose remote machine for the target device, enter the IP of your windows IOT device and select Universal for authentication mode.
Now just click the green debug button or press F5 and your app will be deployed to your device. It might take quite a long time to deploy (1-2 minutes).