Remarks
Pca9685 | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
public class MeadowApp : App<F7Micro, MeadowApp>
{
Pca9685 pca9685;
public MeadowApp()
{
Initialize();
Run();
}
void Initialize()
{
Console.WriteLine("Initialize hardware...");
var i2CBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus);
pca9685 = new Pca9685(i2CBus, 0x40, 50);
pca9685.Initialize();
}
public void Run()
{
var port0 = pca9685.CreatePwmPort(0, 0.05f);
var port7 = pca9685.CreatePwmPort(7);
port0.Start();
port7.Start();
}
}
Characteristic | Locus |
---|---|
Inheritance | System.Object > Pca9685 |
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 | PCA9685.dll |
Syntax
public class Pca9685
Constructors
Pca9685(II2cBus, Byte, Int32)
Declaration
public Pca9685(II2cBus i2cBus, byte address, int frequency = 100)
Parameters
Type | Name | Description |
---|---|---|
II2cBus | i2cBus | |
System.Byte | address | |
System.Int32 | frequency |
Fields
allCall
Declaration
protected const byte allCall = 1
Field Value
Type | Description |
---|---|
System.Byte |
AllLedOffH
Declaration
protected const byte AllLedOffH = 253
Field Value
Type | Description |
---|---|
System.Byte |
AllLedOffL
Declaration
protected const byte AllLedOffL = 252
Field Value
Type | Description |
---|---|
System.Byte |
AllLedOnH
Declaration
protected const byte AllLedOnH = 251
Field Value
Type | Description |
---|---|
System.Byte |
AllLedOnL
Declaration
protected const byte AllLedOnL = 250
Field Value
Type | Description |
---|---|
System.Byte |
invert
Declaration
protected const byte invert = 16
Field Value
Type | Description |
---|---|
System.Byte |
Led0OffH
Declaration
protected const byte Led0OffH = 9
Field Value
Type | Description |
---|---|
System.Byte |
Led0OffL
Declaration
protected const byte Led0OffL = 8
Field Value
Type | Description |
---|---|
System.Byte |
Led0OnH
Declaration
protected const byte Led0OnH = 7
Field Value
Type | Description |
---|---|
System.Byte |
Led0OnL
Declaration
protected const byte Led0OnL = 6
Field Value
Type | Description |
---|---|
System.Byte |
Mode1
Declaration
protected const byte Mode1 = 0
Field Value
Type | Description |
---|---|
System.Byte |
mode1AI
Declaration
protected const byte mode1AI = 33
Field Value
Type | Description |
---|---|
System.Byte |
Mode2
Declaration
protected const byte Mode2 = 1
Field Value
Type | Description |
---|---|
System.Byte |
outDrv
Declaration
protected const byte outDrv = 4
Field Value
Type | Description |
---|---|
System.Byte |
PreScale
Declaration
protected const byte PreScale = 254
Field Value
Type | Description |
---|---|
System.Byte |
restart
Declaration
protected const byte restart = 128
Field Value
Type | Description |
---|---|
System.Byte |
sleep
Declaration
protected const byte sleep = 16
Field Value
Type | Description |
---|---|
System.Byte |
SubAdr1
Declaration
protected const byte SubAdr1 = 2
Field Value
Type | Description |
---|---|
System.Byte |
SubAdr2
Declaration
protected const byte SubAdr2 = 3
Field Value
Type | Description |
---|---|
System.Byte |
SubAdr3
Declaration
protected const byte SubAdr3 = 4
Field Value
Type | Description |
---|---|
System.Byte |
Properties
Address
Declaration
public byte Address { get; protected set; }
Property Value
Type | Description |
---|---|
System.Byte |
i2CBus
Declaration
public II2cBus i2CBus { get; protected set; }
Property Value
Type | Description |
---|---|
II2cBus |
Methods
CreatePwmPort(Byte, Single)
Create a IPwmPort on the specified pin
Declaration
public virtual IPwmPort CreatePwmPort(byte portNumber, float dutyCycle = 0.5F)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | portNumber | The port number (0-15) |
System.Single | dutyCycle | The duty cycle for that port |
Returns
Type | Description |
---|---|
IPwmPort | IPwmPort |
Initialize()
Initializes the PCA9685 IC
Declaration
public virtual void Initialize()
SetFrequency(Int32)
Declaration
protected virtual void SetFrequency(int frequency)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | frequency |
SetPin(Byte, Boolean)
Turns the specified pin On or Off
Declaration
public virtual void SetPin(byte pin, bool on)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | pin | The pin to set |
System.Boolean | on | true is on, false if off |
SetPwm(Byte, Int32, Int32)
Declaration
public virtual void SetPwm(byte pin, int on, int off)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | pin | |
System.Int32 | on | |
System.Int32 | off |
Write(Byte, Byte)
Declaration
protected virtual void Write(byte register, byte value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | register | |
System.Byte | value |
Write(Byte, Byte, Byte, Byte, Byte)
Declaration
protected virtual void Write(byte register, byte ledXOnL, byte ledXOnH, byte ledXOffL, byte ledXOffH)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | register | |
System.Byte | ledXOnL | |
System.Byte | ledXOnH | |
System.Byte | ledXOffL | |
System.Byte | ledXOffH |