Meadow.Foundation.ICs.IOExpanders.Is31fl3731
Is31fl3731 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Is31fl3731 iS31FL3731;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
iS31FL3731 = new Is31fl3731(Device.CreateI2cBus());
iS31FL3731.Initialize();
return base.Initialize();
}
public override Task Run()
{
iS31FL3731.ClearAllFrames();
iS31FL3731.SetFrame(frame: 0);
iS31FL3731.DisplayFrame(frame: 0);
//Turn on all LEDs in frame
for (byte i = 0; i <= 144; i++)
{
iS31FL3731.SetLedPwm(
frame: 0,
ledIndex: i,
brightness: 128);
Thread.Sleep(50);
}
return base.Run();
}
Sample project(s) available on GitHub
Wiring Example
To wire a Is31fl3731 to your Meadow board, connect the following:
Class Is31fl3731
Represents the IS31FL3731 IC The IS31FL3731 is a compact LED driver for 144 single LEDs
Assembly: Is31fl3731.dll
View Source
public class Is31fl3731 : II2cPeripheral
Implements:
Meadow.Hardware.II2cPeripheral
Properties
DefaultI2cAddress
The default I2C address for the peripheral
View Source
public byte DefaultI2cAddress { get; }
Frame
The current frame
View Source
public byte Frame { get; }
Fields
i2cComms
I2C Communication bus used to communicate with the peripheral
View Source
protected readonly II2cCommunications i2cComms
Methods
Initialize()
Initialize the IS31FL3731 by shutting it down, turning it back on and setting it to Picture mode.
View Source
public void Initialize()
SetLedState(bool)
Set the LED state for all LEDs in the current Frame
View Source
public virtual void SetLedState(bool on)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | on | true = on, false = off |
SetLedState(byte, bool)
Sets the state for all LEDs for the specified frame
View Source
public virtual void SetLedState(byte frame, bool on)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | frame | Frame number |
System.Boolean | on | true = on, false = off |
WriteRegister(byte, byte)
Write to the current frame register
View Source
protected virtual void WriteRegister(byte register, byte data)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | register | Register to write to |
System.Byte | data | The data value |
WriteRegister(byte, byte, byte)
Write a value to a register
View Source
protected virtual void WriteRegister(byte frame, byte register, byte data)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | frame | The frame |
System.Byte | register | Register to write to |
System.Byte | data | The data value |
ReadRegister(byte)
Read a value from a register
View Source
protected virtual byte ReadRegister(byte register)
Returns
System.Byte
: The data value read from the register
Parameters
Type | Name | Description |
---|---|---|
System.Byte | register | Register to read from |
SetBlinkMode(bool, byte)
Enable/disable blink mode
View Source
public virtual void SetBlinkMode(bool enabled, byte period)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | enabled | true = on, false = off |
System.Byte | period | The blink duration |
Clear()
Turn off all LEDs for the current frame
View Source
public virtual void Clear()
Clear(byte)
Turn off all LEDs for the specified frame
View Source
public virtual void Clear(byte frame)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | frame | The frame to clear |
ClearAllFrames()
Turn off all LEDs
View Source
public virtual void ClearAllFrames()
SetLedPwm(byte, byte)
Set the PWM value for the specified LED
View Source
public virtual void SetLedPwm(byte ledIndex, byte pwm)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | ledIndex | The LED number |
System.Byte | pwm | The PWM value (0-255) |
SetLedPwm(byte, byte, byte)
Set the PWM value for the specified LED
View Source
public virtual void SetLedPwm(byte frame, byte ledIndex, byte brightness)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | frame | Frame number (0-7) |
System.Byte | ledIndex | The LED number (0-144) |
System.Byte | brightness | The PWM value (0-255) |
GetLedPwm(byte, byte)
Get the PWM value for the specified LED
View Source
public virtual byte GetLedPwm(byte frame, byte ledIndex)
Returns
System.Byte
: The PWM value 0-255
Parameters
Type | Name | Description |
---|---|---|
System.Byte | frame | Frame number (0-7) |
System.Byte | ledIndex | The LED number (0-144) |
DisplayFrame(byte)
Display the specified frame
View Source
public virtual void DisplayFrame(byte frame)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | frame | The frame number (0-7) |
SetFrame(byte)
Sets the current frame.
View Source
public virtual void SetFrame(byte frame)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | frame | The frame number (0-7) |
SetBlinkFunctionOnAllLeds(bool)
Blink all LEDs for the current frame - blink Mode must be enabled
View Source
public virtual void SetBlinkFunctionOnAllLeds(bool on)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | on | true = on, false = off |
SetBlinkFunctionOnAllLeds(byte, bool)
Blink all the LEDs for the specified frame
View Source
public virtual void SetBlinkFunctionOnAllLeds(byte frame, bool on)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | frame | Frame number |
System.Boolean | on | true = on, false = off |
SelectPage(byte)
Select the page/frame
View Source
protected virtual void SelectPage(byte page)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | page | Page/frame number |
Implements
Meadow.Hardware.II2cPeripheral