Remarks

ThumbJoystick
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

ThumbJoystick Meadow Pin
GND GND
VCC 3.3V
RX D01
TX D00
Characteristic Locus
Inheritance object ObservableBase<AnalogJoystickPosition> SamplingSensorBase<AnalogJoystickPosition> AnalogJoystick > ThumbJoystick
Implements IObservable<IChangeResult<AnalogJoystickPosition>> ISamplingSensor<AnalogJoystickPosition> ISensor<AnalogJoystickPosition> IAnalogJoystick IDisposable
Inherited Members AnalogJoystick.sampleCount AnalogJoystick.sampleIntervalMs AnalogJoystick.SetCenterPosition() AnalogJoystick.GetDigitalJoystickPosition() AnalogJoystick.ReadSensor() AnalogJoystick.StartUpdating(TimeSpan?) AnalogJoystick.StopUpdating() AnalogJoystick.Dispose() AnalogJoystick.Dispose(bool) AnalogJoystick.HorizontalInputPort AnalogJoystick.VerticalInputPort AnalogJoystick.IsHorizontalInverted AnalogJoystick.IsVerticalInverted AnalogJoystick.Position AnalogJoystick.DigitalPosition AnalogJoystick.Calibration AnalogJoystick.IsDisposed SamplingSensorBase<AnalogJoystickPosition>.samplingLock SamplingSensorBase<AnalogJoystickPosition>.RaiseEventsAndNotify(IChangeResult<AnalogJoystickPosition>) SamplingSensorBase<AnalogJoystickPosition>.Read() SamplingSensorBase<AnalogJoystickPosition>.SamplingTokenSource SamplingSensorBase<AnalogJoystickPosition>.Conditions SamplingSensorBase<AnalogJoystickPosition>.IsSampling SamplingSensorBase<AnalogJoystickPosition>.UpdateInterval SamplingSensorBase<AnalogJoystickPosition>.Updated ObservableBase<AnalogJoystickPosition>.NotifyObservers(IChangeResult<AnalogJoystickPosition>) ObservableBase<AnalogJoystickPosition>.Subscribe(IObserver<IChangeResult<AnalogJoystickPosition>>) ObservableBase<AnalogJoystickPosition>.CreateObserver(Action<IChangeResult<AnalogJoystickPosition>>, Predicate<IChangeResult<AnalogJoystickPosition>>) ObservableBase<AnalogJoystickPosition>.observers object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.Grove.Sensors.Hid
Assembly ThumbJoystick.dll

Syntax

public class ThumbJoystick : AnalogJoystick, IObservable<IChangeResult<AnalogJoystickPosition>>, ISamplingSensor<AnalogJoystickPosition>, ISensor<AnalogJoystickPosition>, IAnalogJoystick, IDisposable

Constructors

ThumbJoystick(IAnalogInputPort, IAnalogInputPort, JoystickCalibration)

Creates a ThumbJoystick driver

Declaration
public ThumbJoystick(IAnalogInputPort horizontalInputPort, IAnalogInputPort verticalInputPort, AnalogJoystick.JoystickCalibration calibration = null)

Parameters

Type Name Description
IAnalogInputPort horizontalInputPort
IAnalogInputPort verticalInputPort
AnalogJoystick.JoystickCalibration calibration

Remarks

ThumbJoystick
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

ThumbJoystick Meadow Pin
GND GND
VCC 3.3V
RX D01
TX D00

ThumbJoystick(IPin, IPin, JoystickCalibration)

Creates a ThumbJoystick driver

Declaration
public ThumbJoystick(IPin horizontalPin, IPin verticalPin, AnalogJoystick.JoystickCalibration calibration = null)

Parameters

Type Name Description
IPin horizontalPin
IPin verticalPin
AnalogJoystick.JoystickCalibration calibration

Calibration for the joystick.

Remarks

ThumbJoystick
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

ThumbJoystick Meadow Pin
GND GND
VCC 3.3V
RX D01
TX D00

ThumbJoystick(IPin, IPin, JoystickCalibration, int, TimeSpan)

Creates a ThumbJoystick driver

Declaration
public ThumbJoystick(IPin horizontalPin, IPin verticalPin, AnalogJoystick.JoystickCalibration calibration, int sampleCount, TimeSpan sampleInterval)

Parameters

Type Name Description
IPin horizontalPin
IPin verticalPin
AnalogJoystick.JoystickCalibration calibration

Calibration for the joystick.

int sampleCount

How many samples to take during a given reading. These are automatically averaged to reduce noise.

TimeSpan sampleInterval

The time, in milliseconds, to wait in between samples during a reading.

Remarks

ThumbJoystick
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

ThumbJoystick Meadow Pin
GND GND
VCC 3.3V
RX D01
TX D00