Skip to main content

Meadow.Foundation.Grove.Sensors.Hid.ThumbJoystick

ThumbJoystick
StatusStatus badge: working
Source codeGitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Grove.Sensors.Hid.ThumbJoystick

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

ThumbJoystickMeadow Pin
GNDGND
VCC3.3V
RXD01
TXD00

Class ThumbJoystick

Represents a ThumbJoystick

Assembly: ThumbJoystick.dll
View Source
Declaration
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