Skip to main content

Class AnalogJoystick

2-axis analog joystick

Assembly: Meadow.Foundation.dll
View Source
Declaration
public class AnalogJoystick : SamplingSensorBase<AnalogJoystickPosition>, IObservable<IChangeResult<AnalogJoystickPosition>>, ISamplingSensor<AnalogJoystickPosition>, ISensor<AnalogJoystickPosition>, ISensor, ISamplingSensor, IAnalogJoystick, IDisposable

Inheritance: System.Object -> Meadow.Foundation.ObservableBase<UNIT>

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

Properties

HorizontalInputPort

Analog port connected to horizontal joystick pin

View Source
Declaration
protected IAnalogInputPort HorizontalInputPort { get; set; }

VerticalInputPort

Analog port connected to vertical joystick pin

View Source
Declaration
protected IAnalogInputPort VerticalInputPort { get; set; }

IsHorizontalInverted

Is the horizontal / x-axis inverted

View Source
Declaration
public bool IsHorizontalInverted { get; set; }

IsVerticalInverted

Is the vertical / y-axis inverted

View Source
Declaration
public bool IsVerticalInverted { get; set; }

Position

Current position of analog joystick

View Source
Declaration
public AnalogJoystickPosition? Position { get; protected set; }

DigitalPosition

Digital position of joystick

View Source
Declaration
public DigitalJoystickPosition? DigitalPosition { get; }

Calibration

Calibration for 2-axis analog joystick

View Source
Declaration
public AnalogJoystick.JoystickCalibration Calibration { get; protected set; }

IsDisposed

Is the object disposed

View Source
Declaration
public bool IsDisposed { get; }

Fields

sampleCount

Number of samples used to calculate position

View Source
Declaration
protected int sampleCount

sampleIntervalMs

Interval between samples

View Source
Declaration
protected int sampleIntervalMs

Methods

SetCenterPosition()

sets the current position as the center position and saves to the calibration.

View Source
Declaration
public Task SetCenterPosition()
Returns

System.Threading.Tasks.Task

GetDigitalJoystickPosition()

Translates an analog position into a digital position, taking into account the calibration information.

View Source
Declaration
protected DigitalJoystickPosition GetDigitalJoystickPosition()
Returns

Meadow.Peripherals.Sensors.Hid.DigitalJoystickPosition: The digital joystick position as DigitalJoystickPosition### ReadSensor() Convenience method to get the current temperature. For frequent reads, use StartSampling() and StopSampling() in conjunction with the SampleBuffer.

View Source
Declaration
protected override Task<AnalogJoystickPosition> ReadSensor()
Returns

System.Threading.Tasks.Task<Meadow.Peripherals.Sensors.Hid.AnalogJoystickPosition>

StartUpdating(TimeSpan?)

Starts continuously sampling the sensor.

This method also starts raising Changed events and IObservable subscribers getting notified. Use the readIntervalDuration parameter to specify how often events and notifications are raised/sent.

View Source
Declaration
public override void StartUpdating(TimeSpan? updateInterval)
Parameters
TypeNameDescription
System.Nullable<System.TimeSpan>updateIntervalA TimeSpan that specifies how long to
 wait between readings. This value influences how often `*Updated`
events are raised and `IObservable` consumers are notified.
The default is 5 seconds. |

StopUpdating()

Stops sampling the joystick position

View Source
Declaration
public override void StopUpdating()

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

View Source
Declaration
public void Dispose()

Dispose(bool)

Dispose of the object

View Source
Declaration
protected virtual void Dispose(bool disposing)
Parameters
TypeNameDescription
System.BooleandisposingIs disposing

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