Remarks

WiiNunchuck
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Hid.WiiExtensionControllers

Code Example

WiiNunchuck nunchuck;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");

    nunchuck = new WiiNunchuck(Device.CreateI2cBus(WiiNunchuck.DefaultI2cSpeed));

    nunchuck.GetIdentification();

    Resolver.Log.Info("Update");

    //onetime update - could be used in a game loop
    nunchuck.Update();

    //check the state of a button
    Resolver.Log.Info("C Button is " + (nunchuck.CButton.State == true ? "pressed" : "not pressed"));

    //.NET events
    nunchuck.CButton.Clicked += (s, e) => Resolver.Log.Info("C button clicked");
    nunchuck.ZButton.Clicked += (s, e) => Resolver.Log.Info("Z button clicked");

    nunchuck.AnalogStick.Updated += (s, e) => Resolver.Log.Info($"Analog Stick {e.New.Horizontal}, {e.New.Vertical}");

    return Task.CompletedTask;
}

public override Task Run()
{
    nunchuck.StartUpdating(TimeSpan.FromMilliseconds(200));
    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a WiiNunchuck to your Meadow board, connect the following:

WiiNunchuck Meadow Pin
GND GND
SCL D08 (SCL)
SDA D07 (SDA)
VCC 3V3
Characteristic Locus
Inheritance object WiiExtensionControllerBase > WiiNunchuck
Implements II2cPeripheral
Inherited Members WiiExtensionControllerBase.DefaultI2cAddress WiiExtensionControllerBase.DefaultI2cSpeed WiiExtensionControllerBase.i2cComms WiiExtensionControllerBase.ReadBuffer WiiExtensionControllerBase.samplingLock WiiExtensionControllerBase.SamplingTokenSource WiiExtensionControllerBase.IsSampling WiiExtensionControllerBase.Initialize() WiiExtensionControllerBase.GetIdentification() WiiExtensionControllerBase.StartUpdating(TimeSpan) WiiExtensionControllerBase.StopUpdating() object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.Sensors.Hid
Assembly WiiExtensionControllers.dll

Syntax

public class WiiNunchuck : WiiExtensionControllerBase, II2cPeripheral

Constructors

WiiNunchuck(II2cBus)

Creates a Wii Nunchuck object

Declaration
public WiiNunchuck(II2cBus i2cBus)

Parameters

Type Name Description
II2cBus i2cBus

the I2C bus connected to controller

Remarks

WiiNunchuck
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Hid.WiiExtensionControllers

Code Example

WiiNunchuck nunchuck;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");

    nunchuck = new WiiNunchuck(Device.CreateI2cBus(WiiNunchuck.DefaultI2cSpeed));

    nunchuck.GetIdentification();

    Resolver.Log.Info("Update");

    //onetime update - could be used in a game loop
    nunchuck.Update();

    //check the state of a button
    Resolver.Log.Info("C Button is " + (nunchuck.CButton.State == true ? "pressed" : "not pressed"));

    //.NET events
    nunchuck.CButton.Clicked += (s, e) => Resolver.Log.Info("C button clicked");
    nunchuck.ZButton.Clicked += (s, e) => Resolver.Log.Info("Z button clicked");

    nunchuck.AnalogStick.Updated += (s, e) => Resolver.Log.Info($"Analog Stick {e.New.Horizontal}, {e.New.Vertical}");

    return Task.CompletedTask;
}

public override Task Run()
{
    nunchuck.StartUpdating(TimeSpan.FromMilliseconds(200));
    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a WiiNunchuck to your Meadow board, connect the following:

WiiNunchuck Meadow Pin
GND GND
SCL D08 (SCL)
SDA D07 (SDA)
VCC 3V3

Properties

Acceleration3D

Acceleration data from accelerometer

Declaration
public Acceleration3D? Acceleration3D { get; protected set; }

Property Value

Type Description
Acceleration3D?

Remarks

WiiNunchuck
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Hid.WiiExtensionControllers

Code Example

WiiNunchuck nunchuck;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");

    nunchuck = new WiiNunchuck(Device.CreateI2cBus(WiiNunchuck.DefaultI2cSpeed));

    nunchuck.GetIdentification();

    Resolver.Log.Info("Update");

    //onetime update - could be used in a game loop
    nunchuck.Update();

    //check the state of a button
    Resolver.Log.Info("C Button is " + (nunchuck.CButton.State == true ? "pressed" : "not pressed"));

    //.NET events
    nunchuck.CButton.Clicked += (s, e) => Resolver.Log.Info("C button clicked");
    nunchuck.ZButton.Clicked += (s, e) => Resolver.Log.Info("Z button clicked");

    nunchuck.AnalogStick.Updated += (s, e) => Resolver.Log.Info($"Analog Stick {e.New.Horizontal}, {e.New.Vertical}");

    return Task.CompletedTask;
}

public override Task Run()
{
    nunchuck.StartUpdating(TimeSpan.FromMilliseconds(200));
    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a WiiNunchuck to your Meadow board, connect the following:

WiiNunchuck Meadow Pin
GND GND
SCL D08 (SCL)
SDA D07 (SDA)
VCC 3V3

AnalogStick

Analog joystick (8 bits of precision)

Declaration
public IAnalogJoystick AnalogStick { get; }

Property Value

Type Description
IAnalogJoystick

Remarks

WiiNunchuck
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Hid.WiiExtensionControllers

Code Example

WiiNunchuck nunchuck;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");

    nunchuck = new WiiNunchuck(Device.CreateI2cBus(WiiNunchuck.DefaultI2cSpeed));

    nunchuck.GetIdentification();

    Resolver.Log.Info("Update");

    //onetime update - could be used in a game loop
    nunchuck.Update();

    //check the state of a button
    Resolver.Log.Info("C Button is " + (nunchuck.CButton.State == true ? "pressed" : "not pressed"));

    //.NET events
    nunchuck.CButton.Clicked += (s, e) => Resolver.Log.Info("C button clicked");
    nunchuck.ZButton.Clicked += (s, e) => Resolver.Log.Info("Z button clicked");

    nunchuck.AnalogStick.Updated += (s, e) => Resolver.Log.Info($"Analog Stick {e.New.Horizontal}, {e.New.Vertical}");

    return Task.CompletedTask;
}

public override Task Run()
{
    nunchuck.StartUpdating(TimeSpan.FromMilliseconds(200));
    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a WiiNunchuck to your Meadow board, connect the following:

WiiNunchuck Meadow Pin
GND GND
SCL D08 (SCL)
SDA D07 (SDA)
VCC 3V3

CButton

C Button

Declaration
public IButton CButton { get; }

Property Value

Type Description
IButton

Remarks

WiiNunchuck
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Hid.WiiExtensionControllers

Code Example

WiiNunchuck nunchuck;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");

    nunchuck = new WiiNunchuck(Device.CreateI2cBus(WiiNunchuck.DefaultI2cSpeed));

    nunchuck.GetIdentification();

    Resolver.Log.Info("Update");

    //onetime update - could be used in a game loop
    nunchuck.Update();

    //check the state of a button
    Resolver.Log.Info("C Button is " + (nunchuck.CButton.State == true ? "pressed" : "not pressed"));

    //.NET events
    nunchuck.CButton.Clicked += (s, e) => Resolver.Log.Info("C button clicked");
    nunchuck.ZButton.Clicked += (s, e) => Resolver.Log.Info("Z button clicked");

    nunchuck.AnalogStick.Updated += (s, e) => Resolver.Log.Info($"Analog Stick {e.New.Horizontal}, {e.New.Vertical}");

    return Task.CompletedTask;
}

public override Task Run()
{
    nunchuck.StartUpdating(TimeSpan.FromMilliseconds(200));
    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a WiiNunchuck to your Meadow board, connect the following:

WiiNunchuck Meadow Pin
GND GND
SCL D08 (SCL)
SDA D07 (SDA)
VCC 3V3

ZButton

Z Button

Declaration
public IButton ZButton { get; }

Property Value

Type Description
IButton

Remarks

WiiNunchuck
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Hid.WiiExtensionControllers

Code Example

WiiNunchuck nunchuck;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");

    nunchuck = new WiiNunchuck(Device.CreateI2cBus(WiiNunchuck.DefaultI2cSpeed));

    nunchuck.GetIdentification();

    Resolver.Log.Info("Update");

    //onetime update - could be used in a game loop
    nunchuck.Update();

    //check the state of a button
    Resolver.Log.Info("C Button is " + (nunchuck.CButton.State == true ? "pressed" : "not pressed"));

    //.NET events
    nunchuck.CButton.Clicked += (s, e) => Resolver.Log.Info("C button clicked");
    nunchuck.ZButton.Clicked += (s, e) => Resolver.Log.Info("Z button clicked");

    nunchuck.AnalogStick.Updated += (s, e) => Resolver.Log.Info($"Analog Stick {e.New.Horizontal}, {e.New.Vertical}");

    return Task.CompletedTask;
}

public override Task Run()
{
    nunchuck.StartUpdating(TimeSpan.FromMilliseconds(200));
    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a WiiNunchuck to your Meadow board, connect the following:

WiiNunchuck Meadow Pin
GND GND
SCL D08 (SCL)
SDA D07 (SDA)
VCC 3V3

Methods

Update()

Get the latest sensor data from the device

Declaration
public override void Update()

Overrides

Remarks

WiiNunchuck
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Hid.WiiExtensionControllers

Code Example

WiiNunchuck nunchuck;

public override Task Initialize()
{
    Resolver.Log.Info("Initialize...");

    nunchuck = new WiiNunchuck(Device.CreateI2cBus(WiiNunchuck.DefaultI2cSpeed));

    nunchuck.GetIdentification();

    Resolver.Log.Info("Update");

    //onetime update - could be used in a game loop
    nunchuck.Update();

    //check the state of a button
    Resolver.Log.Info("C Button is " + (nunchuck.CButton.State == true ? "pressed" : "not pressed"));

    //.NET events
    nunchuck.CButton.Clicked += (s, e) => Resolver.Log.Info("C button clicked");
    nunchuck.ZButton.Clicked += (s, e) => Resolver.Log.Info("Z button clicked");

    nunchuck.AnalogStick.Updated += (s, e) => Resolver.Log.Info($"Analog Stick {e.New.Horizontal}, {e.New.Vertical}");

    return Task.CompletedTask;
}

public override Task Run()
{
    nunchuck.StartUpdating(TimeSpan.FromMilliseconds(200));
    return Task.CompletedTask;
}

Sample project(s) available on GitHub

Wiring Example

To wire a WiiNunchuck to your Meadow board, connect the following:

WiiNunchuck Meadow Pin
GND GND
SCL D08 (SCL)
SDA D07 (SDA)
VCC 3V3