Remarks
Is31fl3731 | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
public class MeadowApp : App<F7Micro, MeadowApp>
{
II2cBus _i2cBus;
Is31fl3731 _iS31FL3731;
public MeadowApp()
{
Initialize();
Thread.Sleep(1000);
Brightness();
Thread.Sleep(1000);
_iS31FL3731.Clear();
RunExplicit();
Thread.Sleep(1000);
_iS31FL3731.Clear();
RunImplicit();
Thread.Sleep(5000);
_iS31FL3731.Clear();
}
void Initialize()
{
Console.WriteLine("Initialize hardware...");
_i2cBus= Device.CreateI2cBus();
_iS31FL3731 = new Is31fl3731(_i2cBus, 0x74);
_iS31FL3731.Initialize();
Console.WriteLine("Clear all frames...");
for (byte i = 0; i <= 7; i++)
{
_iS31FL3731.SetLedState(i,true);
_iS31FL3731.Clear(i);
}
_iS31FL3731.SetFrame(0);
_iS31FL3731.DisplayFrame(0);
}
void Brightness()
{
byte brightness = 0;
byte led = 0;
for (byte y = 0; y < 144; y++)
{
if (brightness >= 255)
brightness = 0;
_iS31FL3731.SetLedPwm(led, brightness);
led++;
brightness += 2;
Thread.Sleep(100);
}
}
/// <summary>
/// Set the LEDs explicitly for each function call.
/// </summary>
void RunExplicit()
{
Console.WriteLine("Run...");
Console.WriteLine("Display frame 0");
_iS31FL3731.DisplayFrame(0);
_iS31FL3731.SetLedPwm(0, 1, 128);
_iS31FL3731.SetLedPwm(1, 2, 128);
_iS31FL3731.SetLedPwm(2, 3, 128);
Thread.Sleep(1000);
Console.WriteLine("Display frame 1");
_iS31FL3731.DisplayFrame(1);
Thread.Sleep(1000);
Console.WriteLine("Display frame 2");
_iS31FL3731.DisplayFrame(2);
Thread.Sleep(1000);
Console.WriteLine("Display frame 0");
_iS31FL3731.DisplayFrame(0);
//Turn on All the LED
for(byte i = 0; i <= 144; i++)
{
_iS31FL3731.SetLedPwm(0, i, 128);
_iS31FL3731.SetLedPwm(1, i, 70);
Thread.Sleep(50);
}
Console.WriteLine("Frame switching blinking");
//Switch between Frame 0 and 1. Blinking them
for (byte i = 0; i < 10; i++)
{
Thread.Sleep(1000);
_iS31FL3731.DisplayFrame(1);
Thread.Sleep(1000);
_iS31FL3731.DisplayFrame(0);
}
//Switch between Frame 0 and 1. Blinking them
Thread.Sleep(1000);
Console.WriteLine("Frame 0 blink mode on");
_iS31FL3731.SetBlinkMode(true, 0x05);
_iS31FL3731.SetBlinkFunctionOnAllLeds(0, true);
Thread.Sleep(10000);
Console.WriteLine("Turn off blink mode");
_iS31FL3731.SetBlinkFunctionOnAllLeds(0, false);
_iS31FL3731.SetBlinkMode(false, 0x05);
_iS31FL3731.Clear(0);
}
/// <summary>
/// Set the LEDs implicitly for each function call.
/// </summary>
void RunImplicit()
{
Console.WriteLine("Run implicit...");
Console.WriteLine("Display frame 0");
_iS31FL3731.DisplayFrame(0);
_iS31FL3731.SetFrame(0);
_iS31FL3731.SetLedPwm(1, 128);
_iS31FL3731.SetFrame(1);
_iS31FL3731.SetLedPwm(1, 2, 128);
_iS31FL3731.SetFrame(2);
_iS31FL3731.SetLedPwm(2, 3, 128);
Thread.Sleep(1000);
Console.WriteLine("Display frame 1");
_iS31FL3731.DisplayFrame(1);
Thread.Sleep(1000);
Console.WriteLine("Display frame 2");
_iS31FL3731.DisplayFrame(2);
Thread.Sleep(1000);
Console.WriteLine("Display frame 0");
_iS31FL3731.DisplayFrame(0);
//Turn on All the LED
for (byte i = 0; i <= 144; i++)
{
_iS31FL3731.SetFrame(0);
_iS31FL3731.SetLedPwm(i, 128);
_iS31FL3731.SetFrame(1);
_iS31FL3731.SetLedPwm(1, i, 70);
Thread.Sleep(50);
}
Console.WriteLine("Frame switching blinking");
//Switch between Frame 0 and 1. Blinking them
for (byte i = 0; i < 10; i++)
{
Thread.Sleep(1000);
_iS31FL3731.DisplayFrame(1);
Thread.Sleep(1000);
_iS31FL3731.DisplayFrame(0);
}
//Switch between Frame 0 and 1. Blinking them
Thread.Sleep(1000);
_iS31FL3731.SetFrame(0);
Console.WriteLine("Frame 0 blink mode on");
_iS31FL3731.SetBlinkMode(true, 0x05);
_iS31FL3731.SetBlinkFunctionOnAllLeds(true);
Thread.Sleep(10000);
Console.WriteLine("Turn off blink mode");
_iS31FL3731.SetBlinkFunctionOnAllLeds(false);
_iS31FL3731.SetBlinkMode(false, 0x05);
_iS31FL3731.Clear();
}
}
Characteristic | Locus |
---|---|
Inheritance | System.Object > Is31fl3731 |
Inherited Members | System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone() |
Namespace | Meadow.Foundation.ICs.IOExpanders |
Assembly | IS31FL3731.dll |
Syntax
public class Is31fl3731
Constructors
Is31fl3731(II2cBus, Byte)
Declaration
public Is31fl3731(II2cBus i2cBus, byte address)
Parameters
Type | Name | Description |
---|---|---|
II2cBus | i2cBus | |
System.Byte | address |
Fields
CommandFunctionReg
Declaration
protected const byte CommandFunctionReg = 11
Field Value
Type | Description |
---|---|
System.Byte |
CommandRegister
Declaration
protected const byte CommandRegister = 253
Field Value
Type | Description |
---|---|
System.Byte |
ConfAudioMode
Declaration
protected const byte ConfAudioMode = 8
Field Value
Type | Description |
---|---|
System.Byte |
ConfAutoFrameMode
Declaration
protected const byte ConfAutoFrameMode = 4
Field Value
Type | Description |
---|---|
System.Byte |
ConfPictureMode
Declaration
protected const byte ConfPictureMode = 0
Field Value
Type | Description |
---|---|
System.Byte |
DisplayOptionRegister
Declaration
protected const byte DisplayOptionRegister = 5
Field Value
Type | Description |
---|---|
System.Byte |
i2cPeripheral
Declaration
protected readonly II2cPeripheral i2cPeripheral
Field Value
Type | Description |
---|---|
II2cPeripheral |
PictureFrameReg
Declaration
protected const byte PictureFrameReg = 1
Field Value
Type | Description |
---|---|
System.Byte |
RegAudioSync
Declaration
protected const byte RegAudioSync = 6
Field Value
Type | Description |
---|---|
System.Byte |
RegConfig
Declaration
protected const byte RegConfig = 0
Field Value
Type | Description |
---|---|
System.Byte |
RegConfigAudioPlayMode
Declaration
protected const byte RegConfigAudioPlayMode = 24
Field Value
Type | Description |
---|---|
System.Byte |
RegConfigAutoPlayMode
Declaration
protected const byte RegConfigAutoPlayMode = 8
Field Value
Type | Description |
---|---|
System.Byte |
RegConfigPictureMode
Declaration
protected const byte RegConfigPictureMode = 0
Field Value
Type | Description |
---|---|
System.Byte |
RegShutdown
Declaration
protected const byte RegShutdown = 10
Field Value
Type | Description |
---|---|
System.Byte |
Properties
Frame
Declaration
public byte Frame { get; }
Property Value
Type | Description |
---|---|
System.Byte |
Methods
Clear()
Turn off all LEDs for the specified frame
Declaration
public virtual void Clear()
Clear(Byte)
Turn off all LEDs for the specified frame
Declaration
public virtual void Clear(byte frame)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | frame | the frame to clear |
DisplayFrame(Byte)
Display the specified frame
Declaration
public virtual void DisplayFrame(byte frame)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | frame | The frame number. 0-7 |
Initialize()
Initialize the IS31FL3731 by shutting it down, turning it back on and setting it to Picture mode.
Declaration
public void Initialize()
SelectPage(Byte)
Select the page/frame
Declaration
protected virtual void SelectPage(byte page)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | page | page/frame # |
SetBlinkFunctionOnAllLeds(Boolean)
Blink all LEDs for the current frame. Blink Mode muse be enabled
Declaration
public virtual void SetBlinkFunctionOnAllLeds(bool on)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | on | true = on, false = off |
SetBlinkFunctionOnAllLeds(Byte, Boolean)
Blink all the LEDs for the specified frame
Declaration
public virtual void SetBlinkFunctionOnAllLeds(byte frame, bool on)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | frame | frame # |
System.Boolean | on | true = on, false = off |
SetBlinkMode(Boolean, Byte)
Enable/disable blink mode
Declaration
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 |
SetFrame(Byte)
Sets the current frame.
Declaration
public virtual void SetFrame(byte frame)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | frame | The frame number. 0-7 |
SetLedPwm(Byte, Byte)
Set the PWM value for the specified LED
Declaration
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
Declaration
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 |
SetLedState(Boolean)
Set the LED state for all LED's in the current Frame
Declaration
public virtual void SetLedState(bool on)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | on | true = on, false = off |
SetLedState(Byte, Boolean)
Sets the state for all LEDs for the specified frame
Declaration
public virtual void SetLedState(byte frame, bool on)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | frame | |
System.Boolean | on | true = on, false = off |
WriteRegister(Byte, Byte)
Write to the current frame register
Declaration
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)
Declaration
protected virtual void WriteRegister(byte frame, byte reg, byte data)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | frame | |
System.Byte | reg | |
System.Byte | data |