Remarks
KeyboardWing | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
KeyboardWing keyboardWing;
MicroGraphics graphics;
string lastKeyPress;
public override Task Initialize()
{
Console.WriteLine("Initializing ...");
var i2cBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
var spiBus = Device.CreateSpiBus(new Meadow.Units.Frequency(48000, Meadow.Units.Frequency.UnitType.Kilohertz));
keyboardWing = new KeyboardWing(
spiBus: spiBus,
i2cBus: i2cBus,
keyboardPin: Device.Pins.D10,
displayChipSelectPin: Device.Pins.D11,
displayDcPin: Device.Pins.D12,
lightSensorPin: Device.Pins.A05);
keyboardWing.TouchScreen.Rotation = RotationType._90Degrees;
graphics = new MicroGraphics(keyboardWing.Display)
{
Rotation = RotationType._90Degrees,
CurrentFont = new Font12x16()
};
keyboardWing.Keyboard.OnKeyEvent += Keyboard_OnKeyEvent;
return Task.CompletedTask;
}
public override Task Run()
{
graphics.Clear(true);
keyboardWing.LightSensor.StartUpdating(new TimeSpan(0, 0, 30));
return Task.CompletedTask;
}
private void Keyboard_OnKeyEvent(object sender, Meadow.Foundation.Sensors.Hid.BBQ10Keyboard.KeyEvent e)
{
if (e.KeyState == BBQ10Keyboard.KeyState.StatePress)
{
Console.WriteLine($"OnKeyEvent ASCII value: {(byte)e.AsciiValue}");
lastKeyPress = (byte)e.AsciiValue switch
{
(byte)ButtonType._5WayUp => "5-way up",
(byte)ButtonType._5WayDown => "5-way down",
(byte)ButtonType._5WayLeft => "5-way left",
(byte)ButtonType._5WayRight => "5-way right",
(byte)ButtonType._5WayCenter => "5-way center",
(byte)ButtonType.Button1 => "Button 1",
(byte)ButtonType.Button2 => "Button 2",
(byte)ButtonType.Button3 => "Button 3",
(byte)ButtonType.Button4 => "Button 4",
_ => e.AsciiValue.ToString()
};
}
UpdateDisplay();
}
void UpdateDisplay()
{
graphics.Clear();
graphics.DrawText(0, 0, $"Last pressed: {lastKeyPress}");
graphics.DrawText(0, 16, $"Luminance: {keyboardWing.LightSensor.Illuminance.Value.Lux}");
graphics.Show();
}
Sample project(s) available on GitHub
Characteristic | Locus |
---|---|
Inheritance | object > KeyboardWing |
Inherited Members | object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString() |
Namespace | Meadow.Foundation.FeatherWings |
Assembly | KeyboardWing.dll |
Syntax
public class KeyboardWing
Constructors
KeyboardWing(ISpiBus, II2cBus, IPin, IPin, IPin, IPin)
Creates a KeyboardWing driver
Declaration
public KeyboardWing(ISpiBus spiBus, II2cBus i2cBus, IPin keyboardPin, IPin displayChipSelectPin, IPin displayDcPin, IPin lightSensorPin)
Parameters
Type | Name | Description |
---|---|---|
ISpiBus | spiBus | The SPI bus used for the display |
II2cBus | i2cBus | The I2C bus connected to the device |
IPin | keyboardPin | The pin used to interrupt the keyboard |
IPin | displayChipSelectPin | The chip select pin |
IPin | displayDcPin | The DC pin |
IPin | lightSensorPin | The light sensor pin |
Remarks
KeyboardWing | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
KeyboardWing keyboardWing;
MicroGraphics graphics;
string lastKeyPress;
public override Task Initialize()
{
Console.WriteLine("Initializing ...");
var i2cBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
var spiBus = Device.CreateSpiBus(new Meadow.Units.Frequency(48000, Meadow.Units.Frequency.UnitType.Kilohertz));
keyboardWing = new KeyboardWing(
spiBus: spiBus,
i2cBus: i2cBus,
keyboardPin: Device.Pins.D10,
displayChipSelectPin: Device.Pins.D11,
displayDcPin: Device.Pins.D12,
lightSensorPin: Device.Pins.A05);
keyboardWing.TouchScreen.Rotation = RotationType._90Degrees;
graphics = new MicroGraphics(keyboardWing.Display)
{
Rotation = RotationType._90Degrees,
CurrentFont = new Font12x16()
};
keyboardWing.Keyboard.OnKeyEvent += Keyboard_OnKeyEvent;
return Task.CompletedTask;
}
public override Task Run()
{
graphics.Clear(true);
keyboardWing.LightSensor.StartUpdating(new TimeSpan(0, 0, 30));
return Task.CompletedTask;
}
private void Keyboard_OnKeyEvent(object sender, Meadow.Foundation.Sensors.Hid.BBQ10Keyboard.KeyEvent e)
{
if (e.KeyState == BBQ10Keyboard.KeyState.StatePress)
{
Console.WriteLine($"OnKeyEvent ASCII value: {(byte)e.AsciiValue}");
lastKeyPress = (byte)e.AsciiValue switch
{
(byte)ButtonType._5WayUp => "5-way up",
(byte)ButtonType._5WayDown => "5-way down",
(byte)ButtonType._5WayLeft => "5-way left",
(byte)ButtonType._5WayRight => "5-way right",
(byte)ButtonType._5WayCenter => "5-way center",
(byte)ButtonType.Button1 => "Button 1",
(byte)ButtonType.Button2 => "Button 2",
(byte)ButtonType.Button3 => "Button 3",
(byte)ButtonType.Button4 => "Button 4",
_ => e.AsciiValue.ToString()
};
}
UpdateDisplay();
}
void UpdateDisplay()
{
graphics.Clear();
graphics.DrawText(0, 0, $"Last pressed: {lastKeyPress}");
graphics.DrawText(0, 16, $"Luminance: {keyboardWing.LightSensor.Illuminance.Value.Lux}");
graphics.Show();
}
Properties
Display
Returns the Ili9341 driver
Declaration
public Ili9341 Display { get; protected set; }
Property Value
Type | Description |
---|---|
Ili9341 |
Remarks
KeyboardWing | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
KeyboardWing keyboardWing;
MicroGraphics graphics;
string lastKeyPress;
public override Task Initialize()
{
Console.WriteLine("Initializing ...");
var i2cBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
var spiBus = Device.CreateSpiBus(new Meadow.Units.Frequency(48000, Meadow.Units.Frequency.UnitType.Kilohertz));
keyboardWing = new KeyboardWing(
spiBus: spiBus,
i2cBus: i2cBus,
keyboardPin: Device.Pins.D10,
displayChipSelectPin: Device.Pins.D11,
displayDcPin: Device.Pins.D12,
lightSensorPin: Device.Pins.A05);
keyboardWing.TouchScreen.Rotation = RotationType._90Degrees;
graphics = new MicroGraphics(keyboardWing.Display)
{
Rotation = RotationType._90Degrees,
CurrentFont = new Font12x16()
};
keyboardWing.Keyboard.OnKeyEvent += Keyboard_OnKeyEvent;
return Task.CompletedTask;
}
public override Task Run()
{
graphics.Clear(true);
keyboardWing.LightSensor.StartUpdating(new TimeSpan(0, 0, 30));
return Task.CompletedTask;
}
private void Keyboard_OnKeyEvent(object sender, Meadow.Foundation.Sensors.Hid.BBQ10Keyboard.KeyEvent e)
{
if (e.KeyState == BBQ10Keyboard.KeyState.StatePress)
{
Console.WriteLine($"OnKeyEvent ASCII value: {(byte)e.AsciiValue}");
lastKeyPress = (byte)e.AsciiValue switch
{
(byte)ButtonType._5WayUp => "5-way up",
(byte)ButtonType._5WayDown => "5-way down",
(byte)ButtonType._5WayLeft => "5-way left",
(byte)ButtonType._5WayRight => "5-way right",
(byte)ButtonType._5WayCenter => "5-way center",
(byte)ButtonType.Button1 => "Button 1",
(byte)ButtonType.Button2 => "Button 2",
(byte)ButtonType.Button3 => "Button 3",
(byte)ButtonType.Button4 => "Button 4",
_ => e.AsciiValue.ToString()
};
}
UpdateDisplay();
}
void UpdateDisplay()
{
graphics.Clear();
graphics.DrawText(0, 0, $"Last pressed: {lastKeyPress}");
graphics.DrawText(0, 16, $"Luminance: {keyboardWing.LightSensor.Illuminance.Value.Lux}");
graphics.Show();
}
Keyboard
Returns the BBQ10Keyboard driver
Declaration
public BBQ10Keyboard Keyboard { get; protected set; }
Property Value
Type | Description |
---|---|
BBQ10Keyboard |
Remarks
KeyboardWing | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
KeyboardWing keyboardWing;
MicroGraphics graphics;
string lastKeyPress;
public override Task Initialize()
{
Console.WriteLine("Initializing ...");
var i2cBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
var spiBus = Device.CreateSpiBus(new Meadow.Units.Frequency(48000, Meadow.Units.Frequency.UnitType.Kilohertz));
keyboardWing = new KeyboardWing(
spiBus: spiBus,
i2cBus: i2cBus,
keyboardPin: Device.Pins.D10,
displayChipSelectPin: Device.Pins.D11,
displayDcPin: Device.Pins.D12,
lightSensorPin: Device.Pins.A05);
keyboardWing.TouchScreen.Rotation = RotationType._90Degrees;
graphics = new MicroGraphics(keyboardWing.Display)
{
Rotation = RotationType._90Degrees,
CurrentFont = new Font12x16()
};
keyboardWing.Keyboard.OnKeyEvent += Keyboard_OnKeyEvent;
return Task.CompletedTask;
}
public override Task Run()
{
graphics.Clear(true);
keyboardWing.LightSensor.StartUpdating(new TimeSpan(0, 0, 30));
return Task.CompletedTask;
}
private void Keyboard_OnKeyEvent(object sender, Meadow.Foundation.Sensors.Hid.BBQ10Keyboard.KeyEvent e)
{
if (e.KeyState == BBQ10Keyboard.KeyState.StatePress)
{
Console.WriteLine($"OnKeyEvent ASCII value: {(byte)e.AsciiValue}");
lastKeyPress = (byte)e.AsciiValue switch
{
(byte)ButtonType._5WayUp => "5-way up",
(byte)ButtonType._5WayDown => "5-way down",
(byte)ButtonType._5WayLeft => "5-way left",
(byte)ButtonType._5WayRight => "5-way right",
(byte)ButtonType._5WayCenter => "5-way center",
(byte)ButtonType.Button1 => "Button 1",
(byte)ButtonType.Button2 => "Button 2",
(byte)ButtonType.Button3 => "Button 3",
(byte)ButtonType.Button4 => "Button 4",
_ => e.AsciiValue.ToString()
};
}
UpdateDisplay();
}
void UpdateDisplay()
{
graphics.Clear();
graphics.DrawText(0, 0, $"Last pressed: {lastKeyPress}");
graphics.DrawText(0, 16, $"Luminance: {keyboardWing.LightSensor.Illuminance.Value.Lux}");
graphics.Show();
}
LightSensor
Returns the LightSensor driver
Declaration
public AnalogLightSensor LightSensor { get; protected set; }
Property Value
Type | Description |
---|---|
AnalogLightSensor |
Remarks
KeyboardWing | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
KeyboardWing keyboardWing;
MicroGraphics graphics;
string lastKeyPress;
public override Task Initialize()
{
Console.WriteLine("Initializing ...");
var i2cBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
var spiBus = Device.CreateSpiBus(new Meadow.Units.Frequency(48000, Meadow.Units.Frequency.UnitType.Kilohertz));
keyboardWing = new KeyboardWing(
spiBus: spiBus,
i2cBus: i2cBus,
keyboardPin: Device.Pins.D10,
displayChipSelectPin: Device.Pins.D11,
displayDcPin: Device.Pins.D12,
lightSensorPin: Device.Pins.A05);
keyboardWing.TouchScreen.Rotation = RotationType._90Degrees;
graphics = new MicroGraphics(keyboardWing.Display)
{
Rotation = RotationType._90Degrees,
CurrentFont = new Font12x16()
};
keyboardWing.Keyboard.OnKeyEvent += Keyboard_OnKeyEvent;
return Task.CompletedTask;
}
public override Task Run()
{
graphics.Clear(true);
keyboardWing.LightSensor.StartUpdating(new TimeSpan(0, 0, 30));
return Task.CompletedTask;
}
private void Keyboard_OnKeyEvent(object sender, Meadow.Foundation.Sensors.Hid.BBQ10Keyboard.KeyEvent e)
{
if (e.KeyState == BBQ10Keyboard.KeyState.StatePress)
{
Console.WriteLine($"OnKeyEvent ASCII value: {(byte)e.AsciiValue}");
lastKeyPress = (byte)e.AsciiValue switch
{
(byte)ButtonType._5WayUp => "5-way up",
(byte)ButtonType._5WayDown => "5-way down",
(byte)ButtonType._5WayLeft => "5-way left",
(byte)ButtonType._5WayRight => "5-way right",
(byte)ButtonType._5WayCenter => "5-way center",
(byte)ButtonType.Button1 => "Button 1",
(byte)ButtonType.Button2 => "Button 2",
(byte)ButtonType.Button3 => "Button 3",
(byte)ButtonType.Button4 => "Button 4",
_ => e.AsciiValue.ToString()
};
}
UpdateDisplay();
}
void UpdateDisplay()
{
graphics.Clear();
graphics.DrawText(0, 0, $"Last pressed: {lastKeyPress}");
graphics.DrawText(0, 16, $"Luminance: {keyboardWing.LightSensor.Illuminance.Value.Lux}");
graphics.Show();
}
TouchScreen
Returns the Tsc2004 driver
Declaration
public Tsc2004 TouchScreen { get; protected set; }
Property Value
Type | Description |
---|---|
Tsc2004 |
Remarks
KeyboardWing | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
KeyboardWing keyboardWing;
MicroGraphics graphics;
string lastKeyPress;
public override Task Initialize()
{
Console.WriteLine("Initializing ...");
var i2cBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
var spiBus = Device.CreateSpiBus(new Meadow.Units.Frequency(48000, Meadow.Units.Frequency.UnitType.Kilohertz));
keyboardWing = new KeyboardWing(
spiBus: spiBus,
i2cBus: i2cBus,
keyboardPin: Device.Pins.D10,
displayChipSelectPin: Device.Pins.D11,
displayDcPin: Device.Pins.D12,
lightSensorPin: Device.Pins.A05);
keyboardWing.TouchScreen.Rotation = RotationType._90Degrees;
graphics = new MicroGraphics(keyboardWing.Display)
{
Rotation = RotationType._90Degrees,
CurrentFont = new Font12x16()
};
keyboardWing.Keyboard.OnKeyEvent += Keyboard_OnKeyEvent;
return Task.CompletedTask;
}
public override Task Run()
{
graphics.Clear(true);
keyboardWing.LightSensor.StartUpdating(new TimeSpan(0, 0, 30));
return Task.CompletedTask;
}
private void Keyboard_OnKeyEvent(object sender, Meadow.Foundation.Sensors.Hid.BBQ10Keyboard.KeyEvent e)
{
if (e.KeyState == BBQ10Keyboard.KeyState.StatePress)
{
Console.WriteLine($"OnKeyEvent ASCII value: {(byte)e.AsciiValue}");
lastKeyPress = (byte)e.AsciiValue switch
{
(byte)ButtonType._5WayUp => "5-way up",
(byte)ButtonType._5WayDown => "5-way down",
(byte)ButtonType._5WayLeft => "5-way left",
(byte)ButtonType._5WayRight => "5-way right",
(byte)ButtonType._5WayCenter => "5-way center",
(byte)ButtonType.Button1 => "Button 1",
(byte)ButtonType.Button2 => "Button 2",
(byte)ButtonType.Button3 => "Button 3",
(byte)ButtonType.Button4 => "Button 4",
_ => e.AsciiValue.ToString()
};
}
UpdateDisplay();
}
void UpdateDisplay()
{
graphics.Clear();
graphics.DrawText(0, 0, $"Last pressed: {lastKeyPress}");
graphics.DrawText(0, 16, $"Luminance: {keyboardWing.LightSensor.Illuminance.Value.Lux}");
graphics.Show();
}