Remarks

As5013
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Hid.As5013

Code Example

As5013 joystick;

public override Task Initialize()
{
    Console.WriteLine("Initializing ...");

    var joystick = new As5013(Device.CreateI2cBus());

    joystick.Updated += As5013_Updated;

    return Task.CompletedTask;
}

public override Task Run()
{
    joystick.StartUpdating(TimeSpan.FromMilliseconds(100));

    return Task.CompletedTask;
}

private void As5013_Updated(object sender, IChangeResult<Meadow.Peripherals.Sensors.Hid.AnalogJoystickPosition> e)
{
    Console.WriteLine($"{e.New.Horizontal}, {e.New.Vertical}");
}

Sample project(s) available on GitHub

Wiring Example

To wire a As5013 to your Meadow board, connect the following:

As5013 Meadow Pin
GND GND
SCL D08 (SCL)
SDA D07 (SDA)
VCC 3V3
Characteristic Locus
Inheritance System.Object ObservableBase<AnalogJoystickPosition> SensorBase<AnalogJoystickPosition> > As5013
Implements IAnalogJoystick
Inherited Members SensorBase<AnalogJoystickPosition>.Updated SensorBase<AnalogJoystickPosition>.samplingLock SensorBase<AnalogJoystickPosition>.SamplingTokenSource SensorBase<AnalogJoystickPosition>.Conditions SensorBase<AnalogJoystickPosition>.IsSampling SensorBase<AnalogJoystickPosition>.UpdateInterval SensorBase<AnalogJoystickPosition>.RaiseEventsAndNotify(IChangeResult<>) SensorBase<AnalogJoystickPosition>.Read() ObservableBase<AnalogJoystickPosition>.observers ObservableBase<AnalogJoystickPosition>.NotifyObservers(IChangeResult<>) Meadow.Foundation.ObservableBase<AnalogJoystickPosition>.Subscribe(IObserver<>) Meadow.Foundation.ObservableBase<AnalogJoystickPosition>.CreateObserver(Action<>, System.Nullable<Predicate<IChangeResult<UNIT>>>)
Namespace Meadow.Foundation.Sensors.Hid
Assembly As5013.dll

Syntax

public class As5013 : SensorBase<AnalogJoystickPosition>, IAnalogJoystick

Constructors

As5013(II2cBus, Byte, IDigitalInterruptPort)

Create a new As5013 object

Declaration
public As5013(II2cBus i2cBus, byte address = null, IDigitalInterruptPort interruptPort = null)

Parameters

Type Name Description
II2cBus i2cBus

the I2C bus

System.Byte address

the device I2C address

IDigitalInterruptPort interruptPort

port connected to the interrupt pin

Properties

DefaultSpeed

Default I2C bus speed

Declaration
public I2cBusSpeed DefaultSpeed { get; }

Property Value

Type Description
I2cBusSpeed

DigitalPosition

The digital joystick position

Declaration
public DigitalJoystickPosition? DigitalPosition { get; }

Property Value

Type Description
System.Nullable<DigitalJoystickPosition>

IsHorizontalInverted

Is the horizontal analog value inverted

Declaration
public bool IsHorizontalInverted { get; set; }

Property Value

Type Description
System.Boolean

IsVerticalHorizonalSwapped

Swap horizonal and vertical

Declaration
public bool IsVerticalHorizonalSwapped { get; set; }

Property Value

Type Description
System.Boolean

IsVerticalInverted

Is the vertical analog value inverted

Declaration
public bool IsVerticalInverted { get; set; }

Property Value

Type Description
System.Boolean

Position

The joystick position

Declaration
public AnalogJoystickPosition? Position { get; }

Property Value

Type Description
System.Nullable<AnalogJoystickPosition>

Methods

DisableInterrupt()

Disable the interrupt pin

Declaration
public void DisableInterrupt()

EnableInterrupt()

enable the interrupt pin

Declaration
public void EnableInterrupt()

InvertSpinning()

Invert the channel voltage function

Declaration
public void InvertSpinning()

ReadSensor()

Convenience method to get the current temperature. For frequent reads, use StartSampling() and StopSampling() in conjunction with the SampleBuffer.

Declaration
protected override Task<AnalogJoystickPosition> ReadSensor()

Returns

Type Description
Task<AnalogJoystickPosition>

Overrides

Meadow.Foundation.SensorBase<AnalogJoystickPosition>.ReadSensor()

SetDefaultConfiguration()

Set the default configuration

Declaration
public void SetDefaultConfiguration()

SetLowPowerMode(Byte)

Set the device into low power mode

Declaration
public void SetLowPowerMode(byte timing)

Parameters

Type Name Description
System.Byte timing

timing between reads

SetScalingFactor(Byte)

Set the data scaling factor from the hall sensor (see datasheet)

Declaration
public void SetScalingFactor(byte scalingFactor)

Parameters

Type Name Description
System.Byte scalingFactor

SoftReset()

Soft reset the IC

Declaration
public void SoftReset()

StartUpdating(Nullable<TimeSpan>)

Declaration
public void StartUpdating(TimeSpan? updateInterval)

Parameters

Type Name Description
System.Nullable<TimeSpan> updateInterval

StopUpdating()

Stops sampling the joystick position.

Declaration
public void StopUpdating()

Events

Interrupt

Event if interrupt port is provided for interrupt pin

Declaration
public event EventHandler Interrupt

Event Type

Type Description
EventHandler