# 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_apa102', [dirname(__file__)])
except ImportError:
import _pyupm_apa102
return _pyupm_apa102
if fp is not None:
try:
_mod = imp.load_module('_pyupm_apa102', fp, pathname, description)
finally:
fp.close()
return _mod
_pyupm_apa102 = swig_import_helper()
del swig_import_helper
else:
import _pyupm_apa102
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_apa102.getVersion()
getVersion = _pyupm_apa102.getVersion
_pyupm_apa102.HIGH_swigconstant(_pyupm_apa102)
HIGH = _pyupm_apa102.HIGH
_pyupm_apa102.LOW_swigconstant(_pyupm_apa102)
LOW = _pyupm_apa102.LOW
[docs]class APA102(_object):
"""
API for controlling APA102/DotStar RGB LED Strips.
ID: apa102
Name: LED Strip
Category: led
Manufacturer: adafruit
Connection: spi
Link:https://www.adafruit.com/product/2343 APA102 LED Strips provide
individually controllable LEDs through a SPI interface. For each LED,
brightness (0-31) and RGB (0-255) values can be set.
C++ includes: apa102.hpp
"""
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, APA102, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, APA102, name)
__repr__ = _swig_repr
def __init__(self, ledCount, spiBus, batchMode=False, csn=-1):
"""
APA102(uint16_t ledCount,
uint8_t spiBus, bool batchMode=false, int8_t csn=-1)
Instantiates a new APA102 LED Strip
Parameters:
-----------
ledCount: Number of APA102 leds in the strip
spiBus: SPI Bus number
batchMode: (optional) Immediately write to SPI (false, default) or
wait for a pushState call (true)
csn: (optional) Chip Select Pin
"""
this = _pyupm_apa102.new_APA102(ledCount, spiBus, batchMode, csn)
try:
self.this.append(this)
except Exception:
self.this = this
__swig_destroy__ = _pyupm_apa102.delete_APA102
__del__ = lambda self: None
[docs] def setLed(self, ledIdx, brightness, r, g, b):
"""
void setLed(uint16_t
ledIdx, uint8_t brightness, uint8_t r, uint8_t g, uint8_t b)
Change the color and brightness for a single led
Parameters:
-----------
ledIdx: Index of the LED in the strip (0 based)
brightness: Brightness value (0-31)
r: Red component (0-255)
g: Green component (0-255)
b: Blue component (0-255)
"""
return _pyupm_apa102.APA102_setLed(self, ledIdx, brightness, r, g, b)
[docs] def setLedBrightness(self, ledIdx, brightness):
"""
void
setLedBrightness(uint16_t ledIdx, uint8_t brightness)
Change the brightness for a single led
Parameters:
-----------
ledIdx: Index of the LED in the strip (0 based)
brightness: Brightness value (0-31)
"""
return _pyupm_apa102.APA102_setLedBrightness(self, ledIdx, brightness)
[docs] def setAllLeds(self, brightness, r, g, b):
"""
void
setAllLeds(uint8_t brightness, uint8_t r, uint8_t g, uint8_t b)
Change the color and brightness for all leds
Parameters:
-----------
brightness: Brightness value (0-31)
r: Red component (0-255)
g: Green component (0-255)
b: Blue component (0-255)
"""
return _pyupm_apa102.APA102_setAllLeds(self, brightness, r, g, b)
[docs] def setLedsBrightness(self, startIdx, endIdx, brightness):
"""
void
setLedsBrightness(uint16_t startIdx, uint16_t endIdx, uint8_t
brightness)
Change the brightness for a range of leds
Parameters:
-----------
startIdx: Start index of the range of LEDs in the strip (0 based)
endIdx: End index of the range of LEDs in the strip (0 based)
brightness: Brightness value (0-31)
"""
return _pyupm_apa102.APA102_setLedsBrightness(self, startIdx, endIdx, brightness)
[docs] def setLeds(self, *args):
"""
void setLeds(uint16_t
startIdx, uint16_t endIdx, uint8_t *colors)
(Advanced) Manually control the colors and brightness of a range of
LEDS Best used to maximize performance
Parameters:
-----------
startIdx: Start index of the range of LEDs to update (0 based)
endIdx: End index of the range of LEDs to update (0 based)
colors: Pointer to an array of bytes. Each color is described as the
following: B1: Brightness (224-255) B2: Blue (0-255) B3: Green (0-255)
B4: Red (0-255) No check done on the boundaries
"""
return _pyupm_apa102.APA102_setLeds(self, *args)
[docs] def setBusSpeed(self, hz):
"""
void setBusSpeed(int
hz)
Change the speed/frequency of the SPI bus Note: Slower speeds will
allow driving longer strips without having to condition the clock
signal with extra hardware
Parameters:
-----------
hz: Desired bus speed in Hz
"""
return _pyupm_apa102.APA102_setBusSpeed(self, hz)
[docs] def pushState(self):
"""
void pushState()
Outputs the current LED data to the SPI bus Note: Only required if
batch mode is set to TRUE
"""
return _pyupm_apa102.APA102_pushState(self)
APA102_swigregister = _pyupm_apa102.APA102_swigregister
APA102_swigregister(APA102)
# This file is compatible with both classic and new-style classes.