# This file was automatically generated by SWIG (http://www.swig.org).
# Version 3.0.8
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info
if version_info >= (2, 6, 0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_pyupm_pca9685', [dirname(__file__)])
except ImportError:
import _pyupm_pca9685
return _pyupm_pca9685
if fp is not None:
try:
_mod = imp.load_module('_pyupm_pca9685', fp, pathname, description)
finally:
fp.close()
return _mod
_pyupm_pca9685 = swig_import_helper()
del swig_import_helper
else:
import _pyupm_pca9685
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
if (name == "thisown"):
return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name, None)
if method:
return method(self, value)
if (not static):
if _newclass:
object.__setattr__(self, name, value)
else:
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self, class_type, name, value):
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
def _swig_getattr_nondynamic(self, class_type, name, static=1):
if (name == "thisown"):
return self.this.own()
method = class_type.__swig_getmethods__.get(name, None)
if method:
return method(self)
if (not static):
return object.__getattr__(self, name)
else:
raise AttributeError(name)
def _swig_getattr(self, class_type, name):
return _swig_getattr_nondynamic(self, class_type, name, 0)
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except AttributeError:
class _object:
pass
_newclass = 0
def getVersion():
return _pyupm_pca9685.getVersion()
getVersion = _pyupm_pca9685.getVersion
_pyupm_pca9685.PCA9685_I2C_BUS_swigconstant(_pyupm_pca9685)
PCA9685_I2C_BUS = _pyupm_pca9685.PCA9685_I2C_BUS
_pyupm_pca9685.PCA9685_DEFAULT_I2C_ADDR_swigconstant(_pyupm_pca9685)
PCA9685_DEFAULT_I2C_ADDR = _pyupm_pca9685.PCA9685_DEFAULT_I2C_ADDR
_pyupm_pca9685.PCA9685_INTERNAL_OSC_swigconstant(_pyupm_pca9685)
PCA9685_INTERNAL_OSC = _pyupm_pca9685.PCA9685_INTERNAL_OSC
_pyupm_pca9685.PCA9685_ALL_LED_swigconstant(_pyupm_pca9685)
PCA9685_ALL_LED = _pyupm_pca9685.PCA9685_ALL_LED
[docs]class PCA9685(_object):
"""
API 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
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, PCA9685, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, PCA9685, name)
__repr__ = _swig_repr
REG_MODE1 = _pyupm_pca9685.PCA9685_REG_MODE1
REG_MODE2 = _pyupm_pca9685.PCA9685_REG_MODE2
REG_I2C_SA1 = _pyupm_pca9685.PCA9685_REG_I2C_SA1
REG_I2C_SA2 = _pyupm_pca9685.PCA9685_REG_I2C_SA2
REG_I2C_SA3 = _pyupm_pca9685.PCA9685_REG_I2C_SA3
REG_ALLCALL = _pyupm_pca9685.PCA9685_REG_ALLCALL
REG_LED0_ON_L = _pyupm_pca9685.PCA9685_REG_LED0_ON_L
REG_LED0_ON_H = _pyupm_pca9685.PCA9685_REG_LED0_ON_H
REG_LED0_OFF_L = _pyupm_pca9685.PCA9685_REG_LED0_OFF_L
REG_LED0_OFF_H = _pyupm_pca9685.PCA9685_REG_LED0_OFF_H
REG_LED1_ON_L = _pyupm_pca9685.PCA9685_REG_LED1_ON_L
REG_LED1_ON_H = _pyupm_pca9685.PCA9685_REG_LED1_ON_H
REG_LED1_OFF_L = _pyupm_pca9685.PCA9685_REG_LED1_OFF_L
REG_LED1_OFF_H = _pyupm_pca9685.PCA9685_REG_LED1_OFF_H
REG_LED2_ON_L = _pyupm_pca9685.PCA9685_REG_LED2_ON_L
REG_LED2_ON_H = _pyupm_pca9685.PCA9685_REG_LED2_ON_H
REG_LED2_OFF_L = _pyupm_pca9685.PCA9685_REG_LED2_OFF_L
REG_LED2_OFF_H = _pyupm_pca9685.PCA9685_REG_LED2_OFF_H
REG_LED3_ON_L = _pyupm_pca9685.PCA9685_REG_LED3_ON_L
REG_LED3_ON_H = _pyupm_pca9685.PCA9685_REG_LED3_ON_H
REG_LED3_OFF_L = _pyupm_pca9685.PCA9685_REG_LED3_OFF_L
REG_LED3_OFF_H = _pyupm_pca9685.PCA9685_REG_LED3_OFF_H
REG_LED4_ON_L = _pyupm_pca9685.PCA9685_REG_LED4_ON_L
REG_LED4_ON_H = _pyupm_pca9685.PCA9685_REG_LED4_ON_H
REG_LED4_OFF_L = _pyupm_pca9685.PCA9685_REG_LED4_OFF_L
REG_LED4_OFF_H = _pyupm_pca9685.PCA9685_REG_LED4_OFF_H
REG_LED5_ON_L = _pyupm_pca9685.PCA9685_REG_LED5_ON_L
REG_LED5_ON_H = _pyupm_pca9685.PCA9685_REG_LED5_ON_H
REG_LED5_OFF_L = _pyupm_pca9685.PCA9685_REG_LED5_OFF_L
REG_LED5_OFF_H = _pyupm_pca9685.PCA9685_REG_LED5_OFF_H
REG_LED6_ON_L = _pyupm_pca9685.PCA9685_REG_LED6_ON_L
REG_LED6_ON_H = _pyupm_pca9685.PCA9685_REG_LED6_ON_H
REG_LED6_OFF_L = _pyupm_pca9685.PCA9685_REG_LED6_OFF_L
REG_LED6_OFF_H = _pyupm_pca9685.PCA9685_REG_LED6_OFF_H
REG_LED7_ON_L = _pyupm_pca9685.PCA9685_REG_LED7_ON_L
REG_LED7_ON_H = _pyupm_pca9685.PCA9685_REG_LED7_ON_H
REG_LED7_OFF_L = _pyupm_pca9685.PCA9685_REG_LED7_OFF_L
REG_LED7_OFF_H = _pyupm_pca9685.PCA9685_REG_LED7_OFF_H
REG_LED8_ON_L = _pyupm_pca9685.PCA9685_REG_LED8_ON_L
REG_LED8_ON_H = _pyupm_pca9685.PCA9685_REG_LED8_ON_H
REG_LED8_OFF_L = _pyupm_pca9685.PCA9685_REG_LED8_OFF_L
REG_LED8_OFF_H = _pyupm_pca9685.PCA9685_REG_LED8_OFF_H
REG_LED9_ON_L = _pyupm_pca9685.PCA9685_REG_LED9_ON_L
REG_LED9_ON_H = _pyupm_pca9685.PCA9685_REG_LED9_ON_H
REG_LED9_OFF_L = _pyupm_pca9685.PCA9685_REG_LED9_OFF_L
REG_LED9_OFF_H = _pyupm_pca9685.PCA9685_REG_LED9_OFF_H
REG_LED10_ON_L = _pyupm_pca9685.PCA9685_REG_LED10_ON_L
REG_LED10_ON_H = _pyupm_pca9685.PCA9685_REG_LED10_ON_H
REG_LED10_OFF_L = _pyupm_pca9685.PCA9685_REG_LED10_OFF_L
REG_LED10_OFF_H = _pyupm_pca9685.PCA9685_REG_LED10_OFF_H
REG_LED11_ON_L = _pyupm_pca9685.PCA9685_REG_LED11_ON_L
REG_LED11_ON_H = _pyupm_pca9685.PCA9685_REG_LED11_ON_H
REG_LED11_OFF_L = _pyupm_pca9685.PCA9685_REG_LED11_OFF_L
REG_LED11_OFF_H = _pyupm_pca9685.PCA9685_REG_LED11_OFF_H
REG_LED12_ON_L = _pyupm_pca9685.PCA9685_REG_LED12_ON_L
REG_LED12_ON_H = _pyupm_pca9685.PCA9685_REG_LED12_ON_H
REG_LED12_OFF_L = _pyupm_pca9685.PCA9685_REG_LED12_OFF_L
REG_LED12_OFF_H = _pyupm_pca9685.PCA9685_REG_LED12_OFF_H
REG_LED13_ON_L = _pyupm_pca9685.PCA9685_REG_LED13_ON_L
REG_LED13_ON_H = _pyupm_pca9685.PCA9685_REG_LED13_ON_H
REG_LED13_OFF_L = _pyupm_pca9685.PCA9685_REG_LED13_OFF_L
REG_LED13_OFF_H = _pyupm_pca9685.PCA9685_REG_LED13_OFF_H
REG_LED14_ON_L = _pyupm_pca9685.PCA9685_REG_LED14_ON_L
REG_LED14_ON_H = _pyupm_pca9685.PCA9685_REG_LED14_ON_H
REG_LED14_OFF_L = _pyupm_pca9685.PCA9685_REG_LED14_OFF_L
REG_LED14_OFF_H = _pyupm_pca9685.PCA9685_REG_LED14_OFF_H
REG_LED15_ON_L = _pyupm_pca9685.PCA9685_REG_LED15_ON_L
REG_LED15_ON_H = _pyupm_pca9685.PCA9685_REG_LED15_ON_H
REG_LED15_OFF_L = _pyupm_pca9685.PCA9685_REG_LED15_OFF_L
REG_LED15_OFF_H = _pyupm_pca9685.PCA9685_REG_LED15_OFF_H
REG_ALL_LED_ON_L = _pyupm_pca9685.PCA9685_REG_ALL_LED_ON_L
REG_ALL_LED_ON_H = _pyupm_pca9685.PCA9685_REG_ALL_LED_ON_H
REG_ALL_LED_OFF_L = _pyupm_pca9685.PCA9685_REG_ALL_LED_OFF_L
REG_ALL_LED_OFF_H = _pyupm_pca9685.PCA9685_REG_ALL_LED_OFF_H
REG_PRESCALE = _pyupm_pca9685.PCA9685_REG_PRESCALE
REG_TESTMODE = _pyupm_pca9685.PCA9685_REG_TESTMODE
MODE1_ALL_CALL = _pyupm_pca9685.PCA9685_MODE1_ALL_CALL
MODE1_SUB3 = _pyupm_pca9685.PCA9685_MODE1_SUB3
MODE1_SUB2 = _pyupm_pca9685.PCA9685_MODE1_SUB2
MODE1_SUB1 = _pyupm_pca9685.PCA9685_MODE1_SUB1
MODE1_SLEEP = _pyupm_pca9685.PCA9685_MODE1_SLEEP
MODE1_AI = _pyupm_pca9685.PCA9685_MODE1_AI
MODE1_EXTCLK = _pyupm_pca9685.PCA9685_MODE1_EXTCLK
MODE1_RESTART = _pyupm_pca9685.PCA9685_MODE1_RESTART
MODE2_OUTNE0 = _pyupm_pca9685.PCA9685_MODE2_OUTNE0
MODE2_OUTNE = _pyupm_pca9685.PCA9685_MODE2_OUTNE
MODE2_OUTDRV = _pyupm_pca9685.PCA9685_MODE2_OUTDRV
MODE2_OCH = _pyupm_pca9685.PCA9685_MODE2_OCH
MODE2_INVRT = _pyupm_pca9685.PCA9685_MODE2_INVRT
MODE2_RESERVE0 = _pyupm_pca9685.PCA9685_MODE2_RESERVE0
MODE2_RESERVE1 = _pyupm_pca9685.PCA9685_MODE2_RESERVE1
MODE2_RESERVE2 = _pyupm_pca9685.PCA9685_MODE2_RESERVE2
def __init__(self, bus, address=0x60, raw=False):
"""
PCA9685(int bus,
uint8_t address=PCA9685_DEFAULT_I2C_ADDR, bool raw=false)
PCA9685 constructor
Parameters:
-----------
bus: I2C bus to use
address: Address for this device
"""
this = _pyupm_pca9685.new_PCA9685(bus, address, raw)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _pyupm_pca9685.delete_PCA9685
__del__ = lambda self: None
[docs] def writeByte(self, reg, byte):
"""
bool
writeByte(uint8_t reg, uint8_t byte)
Writes a byte value into a register
Parameters:
-----------
reg: Register location to write into
byte: Byte to write
True if successful
"""
return _pyupm_pca9685.PCA9685_writeByte(self, reg, byte)
[docs] def writeWord(self, reg, word):
"""
bool
writeWord(uint8_t reg, uint16_t word)
Writes a word value into a register. Note: the device must have the
auto-increment bit set in the MODE1 register to work.
Parameters:
-----------
reg: Register location to write into
word: Word to write
True if successful
"""
return _pyupm_pca9685.PCA9685_writeWord(self, reg, word)
[docs] def readByte(self, reg):
"""
uint8_t
readByte(uint8_t reg)
Reads a byte value from a register
Parameters:
-----------
reg: Register location to read from
Value in a specified register
"""
return _pyupm_pca9685.PCA9685_readByte(self, reg)
[docs] def readWord(self, reg):
"""
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.
Parameters:
-----------
reg: Register location to read from
Value in a specified register
"""
return _pyupm_pca9685.PCA9685_readWord(self, reg)
[docs] def setModeSleep(self, sleep):
"""
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.
Parameters:
-----------
sleep: True to put the device in the sleep mode, false to put out
True if successful
"""
return _pyupm_pca9685.PCA9685_setModeSleep(self, sleep)
[docs] def ledFullOn(self, led, val):
"""
bool
ledFullOn(uint8_t led, bool val)
Sets or clears the FULL ON bit for a given LED
Parameters:
-----------
led: LED number; valid values are 0-15, PCA9685_ALL_LED
val: True to set the bit, false to clear it
True if successful
"""
return _pyupm_pca9685.PCA9685_ledFullOn(self, led, val)
[docs] def ledFullOff(self, led, val):
"""
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.
Parameters:
-----------
led: LED number; valid values are 0-15, PCA9685_ALL_LED
val: True to set the bit, false to clear it
True if successful
"""
return _pyupm_pca9685.PCA9685_ledFullOff(self, led, val)
[docs] def ledOnTime(self, led, time):
"""
bool
ledOnTime(uint8_t led, uint16_t time)
Sets the 'LED on' time (0-4,095). See the PCA9685 datasheet for
details.
Parameters:
-----------
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
"""
return _pyupm_pca9685.PCA9685_ledOnTime(self, led, time)
[docs] def ledOffTime(self, led, time):
"""
bool
ledOffTime(uint8_t led, uint16_t time)
Sets the 'LED off' time (0-4,095). See the PCA9685 datasheet for
details.
Parameters:
-----------
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
"""
return _pyupm_pca9685.PCA9685_ledOffTime(self, led, time)
[docs] def setPrescale(self, prescale):
"""
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.
Parameters:
-----------
prescale: Prescale value
True if successful
"""
return _pyupm_pca9685.PCA9685_setPrescale(self, prescale)
[docs] def setPrescaleFromHz(self, hz, oscFreq=25000000.0):
"""
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.
Parameters:
-----------
hz: Desired frequency in Hz
oscFreq: Oscillator frequency; default is 25 MHz
True if successful
"""
return _pyupm_pca9685.PCA9685_setPrescaleFromHz(self, hz, oscFreq)
[docs] def enableRestart(self, enabled):
"""
void
enableRestart(bool enabled)
Enables or disables the restart capability of the controller
Parameters:
-----------
enabled: True to enable, false to disable It is enabled by default.
"""
return _pyupm_pca9685.PCA9685_enableRestart(self, enabled)
PCA9685_swigregister = _pyupm_pca9685.PCA9685_swigregister
PCA9685_swigregister(PCA9685)
# This file is compatible with both classic and new-style classes.