We no longer sell products directly from the GHI Electronics website, click here for more details. Please find a Distributor to complete your online order. If you have any questions regarding this notice please contact us at support@ghielectronics.com.

FEZ Utility Developers' Guide

Last modified November 10, 2015

The FEZ Utility is a Raspberry Pi 2 Model B compatible hat with extenders for PWM, analog input, and additional GPIOs exposed through female headers. The original Raspberry Pi 2 pins are also exposed through an additional female header (with the exception of a single GPIO which is used internally).

To get started, make sure you are running Visual Studio 2015 on Windows 10. Create a new Universal application and make sure to add the Windows IoT Extension SDK. Then, add our FEZ Utility NuGet driver. The below example briefly shows the functionality on the board.

Do note that due to a requirement of the underlying hardware, every PWM pin must have the same frequency. Changing the frequency on one pin changes it on every other pin. Additionally, the frequency range is limited to 150Hz to 1500Hz. You have full independent control the duty cycle on every pin.

using System;
using Windows.Devices.Gpio;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using GIS = GHIElectronics.UWP.Shields;

namespace FEZUtilityDemo {
	public sealed partial class MainPage : Page {
		private GIS.FEZUtility utility;
		private DispatcherTimer timer;
		private bool next;

		public MainPage() {
			this.InitializeComponent();

			this.Setup();
		}

		private async void Setup() {
			this.utility = await GIS.FEZUtility.CreateAsync();
			this.utility.SetDigitalDriveMode(GIS.FEZUtility.DigitalPin.V00, GpioPinDriveMode.Output);

			this.timer = new DispatcherTimer();
			this.timer.Interval = TimeSpan.FromMilliseconds(100);
			this.timer.Tick += this.OnTick;
			this.timer.Start();
		}

		private void OnTick(object sender, object e) {
			this.LedsTextBox.Text = this.next.ToString();
			this.AnalogTextBox.Text = this.utility.ReadAnalog(GIS.FEZUtility.AnalogPin.A0).ToString("N2");

			this.utility.WriteDigital(GIS.FEZUtility.DigitalPin.V00, this.next);
			this.utility.SetPwmDutyCycle(GIS.FEZUtility.PwmPin.P0, this.next ? 1.0 : 0.0);
			this.utility.SetLedState(GIS.FEZUtility.Led.Led1, this.next);

			this.next = !this.next;
		}
	}
}
<Page x:Class="FEZUtilityDemo.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:App1" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
    <StackPanel Orientation="Horizontal" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <StackPanel Width="75">
            <TextBlock Text="Leds: " />
            <TextBlock Text="Analog: " />
        </StackPanel>
        <StackPanel>
            <TextBlock Name="LedsTextBox" />
            <TextBlock Name="AnalogTextBox" />
        </StackPanel>
    </StackPanel>
</Page>
Leave feedback about this document.
Let us know if the information presented here was accurate, helpful and if you have any suggestions.
Leave feedback about this document.
Let us know if the information presented here was accurate, helpful and if you have any suggestions.

* Indicates required fields.
This form is only for feedback not support.
Review our how to find information guide on locating helpful resources.