Remarks
NesClassicController | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
NesClassicController nesController;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2cBus = Device.CreateI2cBus(NesClassicController.DefaultI2cSpeed);
nesController = new NesClassicController(i2cBus: i2cBus);
//onetime update - could be used in a game loop
nesController.Update();
//check the state of a button
Resolver.Log.Info("X Button is " + (nesController.AButton.State == true ? "pressed" : "not pressed"));
//.NET events
nesController.AButton.Clicked += (s, e) => Resolver.Log.Info("A button clicked");
nesController.BButton.Clicked += (s, e) => Resolver.Log.Info("B button clicked");
nesController.StartButton.Clicked += (s, e) => Resolver.Log.Info("+ button clicked");
nesController.SelectButton.Clicked += (s, e) => Resolver.Log.Info("- button clicked");
nesController.DPad.Updated += (s, e) => Resolver.Log.Info($"DPad {e.New}");
return Task.CompletedTask;
}
public override Task Run()
{
nesController.StartUpdating(TimeSpan.FromMilliseconds(200));
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
To wire a NesClassicController to your Meadow board, connect the following:
NesClassicController | Meadow Pin |
---|---|
GND | GND |
SCL | D08 (SCL) |
SDA | D07 (SDA) |
VCC | 3V3 |
Syntax
public class NesClassicController : WiiClassicControllerBase, II2cPeripheral
Constructors
NesClassicController(II2cBus)
Creates a NES Classic Mini Controller object
Declaration
public NesClassicController(II2cBus i2cBus)
Parameters
Type | Name | Description |
---|---|---|
II2cBus | i2cBus | the I2C bus connected to controller |
Remarks
NesClassicController | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
NesClassicController nesController;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2cBus = Device.CreateI2cBus(NesClassicController.DefaultI2cSpeed);
nesController = new NesClassicController(i2cBus: i2cBus);
//onetime update - could be used in a game loop
nesController.Update();
//check the state of a button
Resolver.Log.Info("X Button is " + (nesController.AButton.State == true ? "pressed" : "not pressed"));
//.NET events
nesController.AButton.Clicked += (s, e) => Resolver.Log.Info("A button clicked");
nesController.BButton.Clicked += (s, e) => Resolver.Log.Info("B button clicked");
nesController.StartButton.Clicked += (s, e) => Resolver.Log.Info("+ button clicked");
nesController.SelectButton.Clicked += (s, e) => Resolver.Log.Info("- button clicked");
nesController.DPad.Updated += (s, e) => Resolver.Log.Info($"DPad {e.New}");
return Task.CompletedTask;
}
public override Task Run()
{
nesController.StartUpdating(TimeSpan.FromMilliseconds(200));
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
To wire a NesClassicController to your Meadow board, connect the following:
NesClassicController | Meadow Pin |
---|---|
GND | GND |
SCL | D08 (SCL) |
SDA | D07 (SDA) |
VCC | 3V3 |
Properties
AButton
A Button
Declaration
public IButton AButton { get; }
Property Value
Type | Description |
---|---|
IButton |
Remarks
NesClassicController | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
NesClassicController nesController;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2cBus = Device.CreateI2cBus(NesClassicController.DefaultI2cSpeed);
nesController = new NesClassicController(i2cBus: i2cBus);
//onetime update - could be used in a game loop
nesController.Update();
//check the state of a button
Resolver.Log.Info("X Button is " + (nesController.AButton.State == true ? "pressed" : "not pressed"));
//.NET events
nesController.AButton.Clicked += (s, e) => Resolver.Log.Info("A button clicked");
nesController.BButton.Clicked += (s, e) => Resolver.Log.Info("B button clicked");
nesController.StartButton.Clicked += (s, e) => Resolver.Log.Info("+ button clicked");
nesController.SelectButton.Clicked += (s, e) => Resolver.Log.Info("- button clicked");
nesController.DPad.Updated += (s, e) => Resolver.Log.Info($"DPad {e.New}");
return Task.CompletedTask;
}
public override Task Run()
{
nesController.StartUpdating(TimeSpan.FromMilliseconds(200));
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
To wire a NesClassicController to your Meadow board, connect the following:
NesClassicController | Meadow Pin |
---|---|
GND | GND |
SCL | D08 (SCL) |
SDA | D07 (SDA) |
VCC | 3V3 |
BButton
B Button
Declaration
public IButton BButton { get; }
Property Value
Type | Description |
---|---|
IButton |
Remarks
NesClassicController | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
NesClassicController nesController;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2cBus = Device.CreateI2cBus(NesClassicController.DefaultI2cSpeed);
nesController = new NesClassicController(i2cBus: i2cBus);
//onetime update - could be used in a game loop
nesController.Update();
//check the state of a button
Resolver.Log.Info("X Button is " + (nesController.AButton.State == true ? "pressed" : "not pressed"));
//.NET events
nesController.AButton.Clicked += (s, e) => Resolver.Log.Info("A button clicked");
nesController.BButton.Clicked += (s, e) => Resolver.Log.Info("B button clicked");
nesController.StartButton.Clicked += (s, e) => Resolver.Log.Info("+ button clicked");
nesController.SelectButton.Clicked += (s, e) => Resolver.Log.Info("- button clicked");
nesController.DPad.Updated += (s, e) => Resolver.Log.Info($"DPad {e.New}");
return Task.CompletedTask;
}
public override Task Run()
{
nesController.StartUpdating(TimeSpan.FromMilliseconds(200));
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
To wire a NesClassicController to your Meadow board, connect the following:
NesClassicController | Meadow Pin |
---|---|
GND | GND |
SCL | D08 (SCL) |
SDA | D07 (SDA) |
VCC | 3V3 |
DPad
D-pad
Declaration
public IDigitalJoystick DPad { get; }
Property Value
Type | Description |
---|---|
IDigitalJoystick |
Remarks
NesClassicController | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
NesClassicController nesController;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2cBus = Device.CreateI2cBus(NesClassicController.DefaultI2cSpeed);
nesController = new NesClassicController(i2cBus: i2cBus);
//onetime update - could be used in a game loop
nesController.Update();
//check the state of a button
Resolver.Log.Info("X Button is " + (nesController.AButton.State == true ? "pressed" : "not pressed"));
//.NET events
nesController.AButton.Clicked += (s, e) => Resolver.Log.Info("A button clicked");
nesController.BButton.Clicked += (s, e) => Resolver.Log.Info("B button clicked");
nesController.StartButton.Clicked += (s, e) => Resolver.Log.Info("+ button clicked");
nesController.SelectButton.Clicked += (s, e) => Resolver.Log.Info("- button clicked");
nesController.DPad.Updated += (s, e) => Resolver.Log.Info($"DPad {e.New}");
return Task.CompletedTask;
}
public override Task Run()
{
nesController.StartUpdating(TimeSpan.FromMilliseconds(200));
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
To wire a NesClassicController to your Meadow board, connect the following:
NesClassicController | Meadow Pin |
---|---|
GND | GND |
SCL | D08 (SCL) |
SDA | D07 (SDA) |
VCC | 3V3 |
SelectButton
- Button
Declaration
public IButton SelectButton { get; }
Property Value
Type | Description |
---|---|
IButton |
Remarks
NesClassicController | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
NesClassicController nesController;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2cBus = Device.CreateI2cBus(NesClassicController.DefaultI2cSpeed);
nesController = new NesClassicController(i2cBus: i2cBus);
//onetime update - could be used in a game loop
nesController.Update();
//check the state of a button
Resolver.Log.Info("X Button is " + (nesController.AButton.State == true ? "pressed" : "not pressed"));
//.NET events
nesController.AButton.Clicked += (s, e) => Resolver.Log.Info("A button clicked");
nesController.BButton.Clicked += (s, e) => Resolver.Log.Info("B button clicked");
nesController.StartButton.Clicked += (s, e) => Resolver.Log.Info("+ button clicked");
nesController.SelectButton.Clicked += (s, e) => Resolver.Log.Info("- button clicked");
nesController.DPad.Updated += (s, e) => Resolver.Log.Info($"DPad {e.New}");
return Task.CompletedTask;
}
public override Task Run()
{
nesController.StartUpdating(TimeSpan.FromMilliseconds(200));
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
To wire a NesClassicController to your Meadow board, connect the following:
NesClassicController | Meadow Pin |
---|---|
GND | GND |
SCL | D08 (SCL) |
SDA | D07 (SDA) |
VCC | 3V3 |
StartButton
- Button
Declaration
public IButton StartButton { get; }
Property Value
Type | Description |
---|---|
IButton |
Remarks
NesClassicController | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
NesClassicController nesController;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2cBus = Device.CreateI2cBus(NesClassicController.DefaultI2cSpeed);
nesController = new NesClassicController(i2cBus: i2cBus);
//onetime update - could be used in a game loop
nesController.Update();
//check the state of a button
Resolver.Log.Info("X Button is " + (nesController.AButton.State == true ? "pressed" : "not pressed"));
//.NET events
nesController.AButton.Clicked += (s, e) => Resolver.Log.Info("A button clicked");
nesController.BButton.Clicked += (s, e) => Resolver.Log.Info("B button clicked");
nesController.StartButton.Clicked += (s, e) => Resolver.Log.Info("+ button clicked");
nesController.SelectButton.Clicked += (s, e) => Resolver.Log.Info("- button clicked");
nesController.DPad.Updated += (s, e) => Resolver.Log.Info($"DPad {e.New}");
return Task.CompletedTask;
}
public override Task Run()
{
nesController.StartUpdating(TimeSpan.FromMilliseconds(200));
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
To wire a NesClassicController to your Meadow board, connect the following:
NesClassicController | 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
NesClassicController | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
NesClassicController nesController;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var i2cBus = Device.CreateI2cBus(NesClassicController.DefaultI2cSpeed);
nesController = new NesClassicController(i2cBus: i2cBus);
//onetime update - could be used in a game loop
nesController.Update();
//check the state of a button
Resolver.Log.Info("X Button is " + (nesController.AButton.State == true ? "pressed" : "not pressed"));
//.NET events
nesController.AButton.Clicked += (s, e) => Resolver.Log.Info("A button clicked");
nesController.BButton.Clicked += (s, e) => Resolver.Log.Info("B button clicked");
nesController.StartButton.Clicked += (s, e) => Resolver.Log.Info("+ button clicked");
nesController.SelectButton.Clicked += (s, e) => Resolver.Log.Info("- button clicked");
nesController.DPad.Updated += (s, e) => Resolver.Log.Info($"DPad {e.New}");
return Task.CompletedTask;
}
public override Task Run()
{
nesController.StartUpdating(TimeSpan.FromMilliseconds(200));
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Wiring Example
To wire a NesClassicController to your Meadow board, connect the following:
NesClassicController | Meadow Pin |
---|---|
GND | GND |
SCL | D08 (SCL) |
SDA | D07 (SDA) |
VCC | 3V3 |