Meadow.Foundation.Grove.Sensors.Hid.ThumbJoystick
ThumbJoystick | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
ThumbJoystick joystick;
public override Task Initialize()
{
Resolver.Log.Info("Initializing hardware...");
joystick = new ThumbJoystick(
Device.CreateAnalogInputPort(Device.Pins.A01, 1, TimeSpan.FromMilliseconds(10), new Voltage(3.3)),
Device.CreateAnalogInputPort(Device.Pins.A02, 1, TimeSpan.FromMilliseconds(10), new Voltage(3.3)),
null);
joystick.Updated += JoystickUpdated;
return Task.CompletedTask;
}
public override async Task Run()
{
await joystick.SetCenterPosition();
joystick.StartUpdating(TimeSpan.FromMilliseconds(20));
}
private void JoystickUpdated(object sender, IChangeResult<AnalogJoystickPosition> e)
{
Resolver.Log.Info($"Horizontal: {e.New.Horizontal:n2}, Vertical: {e.New.Vertical:n2}");
Resolver.Log.Info($"Digital position: {joystick.DigitalPosition}");
}
Sample project(s) available on GitHub
Wiring Example
ThumbJoystick | Meadow Pin |
---|---|
GND | GND |
VCC | 3.3V |
RX | D01 |
TX | D00 |
Class ThumbJoystick
Represents a ThumbJoystick
Assembly: ThumbJoystick.dll
View Source
public class ThumbJoystick : AnalogJoystick, IObservable<IChangeResult<AnalogJoystickPosition>>, ISamplingSensor<AnalogJoystickPosition>, ISensor<AnalogJoystickPosition>, ISensor, ISamplingSensor, IAnalogJoystick, IDisposable
Inheritance: System.Object
-> Meadow.Foundation.ObservableBase<Meadow.Peripherals.Sensors.Hid.AnalogJoystickPosition>
-> Meadow.Foundation.SamplingSensorBase<Meadow.Peripherals.Sensors.Hid.AnalogJoystickPosition>
-> Meadow.Foundation.Sensors.Hid.AnalogJoystick
Implements:
System.IObservable<Meadow.IChangeResult<Meadow.Peripherals.Sensors.Hid.AnalogJoystickPosition>>
, Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Peripherals.Sensors.Hid.AnalogJoystickPosition>
, Meadow.Peripherals.Sensors.ISensor<Meadow.Peripherals.Sensors.Hid.AnalogJoystickPosition>
, Meadow.Peripherals.Sensors.ISensor
, Meadow.Peripherals.Sensors.ISamplingSensor
, Meadow.Peripherals.Sensors.Hid.IAnalogJoystick
, System.IDisposable
Implements
System.IObservable<Meadow.IChangeResult<Meadow.Peripherals.Sensors.Hid.AnalogJoystickPosition>>
Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Peripherals.Sensors.Hid.AnalogJoystickPosition>
Meadow.Peripherals.Sensors.ISensor<Meadow.Peripherals.Sensors.Hid.AnalogJoystickPosition>
Meadow.Peripherals.Sensors.ISensor
Meadow.Peripherals.Sensors.ISamplingSensor
Meadow.Peripherals.Sensors.Hid.IAnalogJoystick
System.IDisposable