pyupm_pca9685 module¶
-
class
pyupm_pca9685.PCA9685(bus, address=96, raw=False)[source]¶ Bases:
objectAPI for the PCA9685 16-channel, 12-bit PWM LED Controller.
ID: pca9685
Name: I2C 16-channel 12-bit PWM LED Controller
Category: led motor
Manufacturer: adafruit
Link:http://www.adafruit.com/products/815
Connection: i2c This controller is also used on the Adafruit* Motor Shield v2.3 board to control up to 4 DC motors, 2 stepper motors, and 2 servo motors.
This module was tested with the Adafruit Motor Shield v2.3
C++ includes: pca9685.hpp
-
MODE1_AI= 32¶
-
MODE1_ALL_CALL= 1¶
-
MODE1_EXTCLK= 64¶
-
MODE1_RESTART= 128¶
-
MODE1_SLEEP= 16¶
-
MODE1_SUB1= 8¶
-
MODE1_SUB2= 4¶
-
MODE1_SUB3= 2¶
-
MODE2_INVRT= 16¶
-
MODE2_OCH= 8¶
-
MODE2_OUTDRV= 4¶
-
MODE2_OUTNE= 2¶
-
MODE2_OUTNE0= 1¶
-
MODE2_RESERVE0= 32¶
-
MODE2_RESERVE1= 64¶
-
MODE2_RESERVE2= 128¶
-
REG_ALLCALL= 5¶
-
REG_ALL_LED_OFF_H= 253¶
-
REG_ALL_LED_OFF_L= 252¶
-
REG_ALL_LED_ON_H= 251¶
-
REG_ALL_LED_ON_L= 250¶
-
REG_I2C_SA1= 2¶
-
REG_I2C_SA2= 3¶
-
REG_I2C_SA3= 4¶
-
REG_LED0_OFF_H= 9¶
-
REG_LED0_OFF_L= 8¶
-
REG_LED0_ON_H= 7¶
-
REG_LED0_ON_L= 6¶
-
REG_LED10_OFF_H= 49¶
-
REG_LED10_OFF_L= 48¶
-
REG_LED10_ON_H= 47¶
-
REG_LED10_ON_L= 46¶
-
REG_LED11_OFF_H= 53¶
-
REG_LED11_OFF_L= 52¶
-
REG_LED11_ON_H= 51¶
-
REG_LED11_ON_L= 50¶
-
REG_LED12_OFF_H= 57¶
-
REG_LED12_OFF_L= 56¶
-
REG_LED12_ON_H= 55¶
-
REG_LED12_ON_L= 54¶
-
REG_LED13_OFF_H= 61¶
-
REG_LED13_OFF_L= 60¶
-
REG_LED13_ON_H= 59¶
-
REG_LED13_ON_L= 58¶
-
REG_LED14_OFF_H= 65¶
-
REG_LED14_OFF_L= 64¶
-
REG_LED14_ON_H= 63¶
-
REG_LED14_ON_L= 62¶
-
REG_LED15_OFF_H= 69¶
-
REG_LED15_OFF_L= 68¶
-
REG_LED15_ON_H= 67¶
-
REG_LED15_ON_L= 66¶
-
REG_LED1_OFF_H= 13¶
-
REG_LED1_OFF_L= 12¶
-
REG_LED1_ON_H= 11¶
-
REG_LED1_ON_L= 10¶
-
REG_LED2_OFF_H= 17¶
-
REG_LED2_OFF_L= 16¶
-
REG_LED2_ON_H= 15¶
-
REG_LED2_ON_L= 14¶
-
REG_LED3_OFF_H= 21¶
-
REG_LED3_OFF_L= 20¶
-
REG_LED3_ON_H= 19¶
-
REG_LED3_ON_L= 18¶
-
REG_LED4_OFF_H= 25¶
-
REG_LED4_OFF_L= 24¶
-
REG_LED4_ON_H= 23¶
-
REG_LED4_ON_L= 22¶
-
REG_LED5_OFF_H= 29¶
-
REG_LED5_OFF_L= 28¶
-
REG_LED5_ON_H= 27¶
-
REG_LED5_ON_L= 26¶
-
REG_LED6_OFF_H= 33¶
-
REG_LED6_OFF_L= 32¶
-
REG_LED6_ON_H= 31¶
-
REG_LED6_ON_L= 30¶
-
REG_LED7_OFF_H= 37¶
-
REG_LED7_OFF_L= 36¶
-
REG_LED7_ON_H= 35¶
-
REG_LED7_ON_L= 34¶
-
REG_LED8_OFF_H= 41¶
-
REG_LED8_OFF_L= 40¶
-
REG_LED8_ON_H= 39¶
-
REG_LED8_ON_L= 38¶
-
REG_LED9_OFF_H= 45¶
-
REG_LED9_OFF_L= 44¶
-
REG_LED9_ON_H= 43¶
-
REG_LED9_ON_L= 42¶
-
REG_MODE1= 0¶
-
REG_MODE2= 1¶
-
REG_PRESCALE= 254¶
-
REG_TESTMODE= 255¶
-
enableRestart(enabled)[source]¶ void enableRestart(bool enabled)
Enables or disables the restart capability of the controller
enabled: True to enable, false to disable It is enabled by default.
-
ledFullOff(led, val)[source]¶ bool ledFullOff(uint8_t led, bool val)
Sets or clears the FULL OFF bit for a given LED. If the FULL ON bit is also set, FULL OFF has precedence.
led: LED number; valid values are 0-15, PCA9685_ALL_LED
val: True to set the bit, false to clear it
True if successful
-
ledFullOn(led, val)[source]¶ bool ledFullOn(uint8_t led, bool val)
Sets or clears the FULL ON bit for a given LED
led: LED number; valid values are 0-15, PCA9685_ALL_LED
val: True to set the bit, false to clear it
True if successful
-
ledOffTime(led, time)[source]¶ bool ledOffTime(uint8_t led, uint16_t time)
Sets the ‘LED off’ time (0-4,095). See the PCA9685 datasheet for details.
led: LED number; valid values are 0-15, PCA9685_ALL_LED
time: 12-bit value at which point the LED turns off
True if successful
-
ledOnTime(led, time)[source]¶ bool ledOnTime(uint8_t led, uint16_t time)
Sets the ‘LED on’ time (0-4,095). See the PCA9685 datasheet for details.
led: LED number; valid values are 0-15, PCA9685_ALL_LED
time: 12-bit value at which point the LED turns on
True if successful
-
readByte(reg)[source]¶ uint8_t readByte(uint8_t reg)
Reads a byte value from a register
reg: Register location to read from
Value in a specified register
-
readWord(reg)[source]¶ uint16_t readWord(uint8_t reg)
Reads a word value from a register. Note: the device must have the auto-increment bit set in the MODE1 register to work.
reg: Register location to read from
Value in a specified register
-
setModeSleep(sleep)[source]¶ bool setModeSleep(bool sleep)
Puts the device in or out of the sleep mode. The device is always in the sleep mode upon power-up.
sleep: True to put the device in the sleep mode, false to put out
True if successful
-
setPrescale(prescale)[source]¶ bool setPrescale(uint8_t prescale)
Sets the prescale value. See the PCA9685 datasheet for details. The prescale can only be set when the device is in the sleep mode.
prescale: Prescale value
True if successful
-
setPrescaleFromHz(hz, oscFreq=25000000.0)[source]¶ bool setPrescaleFromHz(float hz, float oscFreq=PCA9685_INTERNAL_OSC)
Sets the prescale value based on a desired frequency in Hz. The prescale can only be set when the device is in the sleep mode.
hz: Desired frequency in Hz
oscFreq: Oscillator frequency; default is 25 MHz
True if successful
-