Remarks

As1115
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.ICs.IOExpanders.As1115

Code Example

As1115 as1115;
MicroGraphics graphics;

public override Task Initialize()
{
    Console.WriteLine("Initialize...");
    as1115 = new As1115(Device, Device.CreateI2cBus(), Device.Pins.D03);

    //general key scan events - will raise for all buttons
    as1115.KeyScanPressStarted += KeyScanPressStarted;

    //or access buttons as IButtons individually
    as1115.KeyScanButtons[KeyScanButtonType.Button1].LongClickedThreshold = TimeSpan.FromSeconds(1);
    as1115.KeyScanButtons[KeyScanButtonType.Button1].Clicked += Button1_Clicked;
    as1115.KeyScanButtons[KeyScanButtonType.Button1].LongClicked += Button1_LongClicked; ;

    graphics = new MicroGraphics(as1115);

    return base.Initialize();
}

private void Button1_LongClicked(object sender, EventArgs e)
{
    Console.WriteLine("Button 1 long press");
}

private void Button1_Clicked(object sender, EventArgs e)
{
    Console.WriteLine("Button 1 clicked");
}

private void KeyScanPressStarted(object sender, KeyScanEventArgs e)
{
    Console.WriteLine($"{e.Button} pressed");
}

public override Task Run()
{
    graphics.Clear();
    graphics.DrawLine(0, 0, 7, 7, true);
    graphics.DrawLine(0, 7, 7, 0, true);

    graphics.Show();

    return base.Run();
}

Sample project(s) available on GitHub

Wiring Example

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

Ads1115 Meadow Pin
GND GND
VCC 3V3
SCL D08 (SCL Pin)
SDA D07 (SDA Pin)
Characteristic Locus
Inheritance System.Object > As1115
Implements IGraphicsDisplay IDisposable
Namespace Meadow.Foundation.ICs.IOExpanders
Assembly As1115.dll

Syntax

public class As1115 : object, IGraphicsDisplay, IDisposable

Constructors

As1115(IMeadowDevice, II2cBus, IPin, Byte)

Create a new AS1115 object using the default parameters for

Declaration
public As1115(IMeadowDevice device, II2cBus i2cBus, IPin buttonInterruptPin, byte address = null)

Parameters

Type Name Description
IMeadowDevice device

Meadow device object

II2cBus i2cBus

I2cBus connected to display

IPin buttonInterruptPin

Interrupt pin

System.Byte address

Address of the bus on the I2C display.

Fields

i2cPeripheral

As1115 I2C driver

Declaration
protected II2cPeripheral i2cPeripheral

Field Value

Type Description
II2cPeripheral

Properties

ColorMode

The display color mode (1 bit per pixel)

Declaration
public ColorType ColorMode { get; }

Property Value

Type Description
ColorType

DecodeMode

The display decode mode BCD character / Hex character / Pixel

Declaration
public As1115.DecodeType DecodeMode { get; }

Property Value

Type Description
As1115.DecodeType

Height

Display height in pixels for 8x8 matrix displays

Declaration
public int Height { get; }

Property Value

Type Description
System.Int32

IsDisposed

Is the peripheral disposed

Declaration
public bool IsDisposed { get; }

Property Value

Type Description
System.Boolean

KeyScanButtons

Readonly collection that contains all 16 key scan button objects

Declaration
public ReadOnlyDictionary<As1115.KeyScanButtonType, KeyScanButton> KeyScanButtons { get; protected set; }

Property Value

Type Description
ReadOnlyDictionary<As1115.KeyScanButtonType, KeyScanButton>

PixelBuffer

The buffer that holds the pixel data for 8x8 matrix displays

Declaration
public IPixelBuffer PixelBuffer { get; }

Property Value

Type Description
IPixelBuffer

Width

Display width in pixels for 8x8 matrix displays

Declaration
public int Width { get; }

Property Value

Type Description
System.Int32

Methods

Clear(Boolean)

Clear the display buffer

Declaration
public void Clear(bool updateDisplay = false)

Parameters

Type Name Description
System.Boolean updateDisplay

If true, update the display

Dispose()

Dispose Peripheral

Declaration
public void Dispose()

Dispose(Boolean)

Dispose peripheral

Declaration
protected virtual void Dispose(bool disposing)

Parameters

Type Name Description
System.Boolean disposing

DrawPixel(Int32, Int32, Color)

Draw a pixel at a given location

Declaration
public void DrawPixel(int x, int y, Color color)

Parameters

Type Name Description
System.Int32 x

X postion in pixels

System.Int32 y

Y position in pixels

Color color

Color to draw - Black will turn pixels off, any color will turn pixels on

DrawPixel(Int32, Int32, Boolean)

Draw a pixel at a given location

Declaration
public void DrawPixel(int x, int y, bool enabled)

Parameters

Type Name Description
System.Int32 x

X postion in pixels

System.Int32 y

Y position in pixels

System.Boolean enabled

If true, turn led on at location

Enable or disable display blinking

Declaration
public void EnableBlink(bool isEnabled, bool fastBlink = true)

Parameters

Type Name Description
System.Boolean isEnabled

Display will blink if true

System.Boolean fastBlink

True for fast blink (period of 1s), False for slow blink (period of 2s)

Fill(Color, Boolean)

Fill the display buffer with a color Black will clear the display, any other color will turn on all leds

Declaration
public void Fill(Color fillColor, bool updateDisplay = false)

Parameters

Type Name Description
Color fillColor

The color to fill

System.Boolean updateDisplay

Update the display

Fill(Int32, Int32, Int32, Int32, Color)

Fill a region of the display buffer with a color Black will clear the display, any other color will turn on all leds

Declaration
public void Fill(int x, int y, int width, int height, Color fillColor)

Parameters

Type Name Description
System.Int32 x

X postion in pixels

System.Int32 y

Y position in pixels

System.Int32 width

Width in pixels

System.Int32 height

Height in pixels

Color fillColor

Color to fill - Black will turn pixels off, any color will turn pixels on

GetButton(As1115.KeyScanButtonType)

Helper method to get IButton object references for keyscan buttons

Declaration
public IButton GetButton(As1115.KeyScanButtonType buttonType)

Parameters

Type Name Description
As1115.KeyScanButtonType buttonType

The button type

Returns

Type Description
IButton

The button object reference

InvertPixel(Int32, Int32)

Invert pixel at location (switch on/off)

Declaration
public void InvertPixel(int x, int y)

Parameters

Type Name Description
System.Int32 x

X postion in pixels

System.Int32 y

Y position in pixels

SetCharacter(As1115.BcdCharacterType, Int32, Boolean)

Set a single character

Declaration
public void SetCharacter(As1115.BcdCharacterType character, int digit, bool showDecimal = false)

Parameters

Type Name Description
As1115.BcdCharacterType character

the chracter to display

System.Int32 digit

the digit index starting from the left

System.Boolean showDecimal

show the decimal with the character

SetCharacter(As1115.HexCharacterType, Int32, Boolean)

Set a single character

Declaration
public void SetCharacter(As1115.HexCharacterType character, int digit, bool showDecimal = false)

Parameters

Type Name Description
As1115.HexCharacterType character

the chracter to display

System.Int32 digit

the digit index starting from the left

System.Boolean showDecimal

show the decimal with the character

SetIntensity(Byte)

Set display intensity (0-15)

Declaration
public void SetIntensity(byte intensity)

Parameters

Type Name Description
System.Byte intensity

Instensity from 0-15 (clamps above 15)

SetNumber(Int32)

Set number to display (left aligned)

Declaration
public void SetNumber(int value)

Parameters

Type Name Description
System.Int32 value

the number to display

Show()

Update the display

Declaration
public void Show()

Show(Int32, Int32, Int32, Int32)

Update the display from the display buffer

Declaration
public void Show(int left, int top, int right, int bottom)

Parameters

Type Name Description
System.Int32 left
System.Int32 top
System.Int32 right
System.Int32 bottom

TestMode(Boolean)

Enable/disable test mode

Declaration
public void TestMode(bool testOn)

Parameters

Type Name Description
System.Boolean testOn

True to enable, false to disable

WriteBuffer(Int32, Int32, IPixelBuffer)

Write a pixel buffer to the display buffer

Declaration
public void WriteBuffer(int x, int y, IPixelBuffer displayBuffer)

Parameters

Type Name Description
System.Int32 x

X postion in pixels

System.Int32 y

Y position in pixels

IPixelBuffer displayBuffer

Display buffer to write

Events

KeyScanPressEnded

Event raised when any key scan button is released

Declaration
public event EventHandler<KeyScanEventArgs> KeyScanPressEnded

Event Type

Type Description
EventHandler<KeyScanEventArgs>

KeyScanPressStarted

Event raised when any key scan button is pressed

Declaration
public event EventHandler<KeyScanEventArgs> KeyScanPressStarted

Event Type

Type Description
EventHandler<KeyScanEventArgs>