devices subpackage
devices.DebugLedDev module
- class uun_iot_libledstrip.devices.DebugLedDev.DebugLedDev(n: int, colored: bool = True)
Bases:
LedDevVirtual debugging LED device.
This can be used to debug applications without hardware LED devices at hand.
- Parameters
n – number of LEDs
colored – attempt to use colored output in console (requires package colored to be installed), default to True. For Windows, import package colorama and run colorama.init() before working with this package.
- show()
devices.GPIODev module
- class uun_iot_libledstrip.devices.GPIODev.GPIODev(pins: List[int], pin_mode: str)
Bases:
LedDevCreate a pin-based light strip. Each pin controls exactly one light pixel.
- Parameters
pins – list of pin numbers to be contained in the strip
pin_mode – either “BCM” for RPi.GPIO.BCM or “BOARD” for RPi.GPIO.BOARD
- Raises
ValueError – if pin_mode is none of the above
- show()
devices.I2CPixelDev module
- exception uun_iot_libledstrip.devices.I2CPixelDev.ChipError
Bases:
Exception
- class uun_iot_libledstrip.devices.I2CPixelDev.I2CPixelDev(n: int, addr: int = 32, i2c_bus: int = 1)
Bases:
LedDevA pixel-based LED device operated via I2C IO Expander.
This module is customized to communicate with MCP20316 GPIO expander, but might be easily extended to other GPIO expanders.
This module was developed with idea of a hardware setup consisting of the microcontroller (Raspberry Pi) connected to GPIO expander over I2C which in turn controls individial LEDs. The GPIO expander is present in case of high power consumption of LEDs.
- Parameters
n – number of LEDs
addr – I2C address of the chip, default
0x20i2c_bus – ID of I2C bus on Raspberry, defaults to 1
- Raises
ValueError – If n is bigger than max_n supported by underlying chip; max_n=16
- show()
- class uun_iot_libledstrip.devices.I2CPixelDev.mcp23016(addr=32, active: str = 'HIGH', block1_direction: int = 0, block2_direction: int = 0, i2c_bus=1)
Bases:
objectHelper class for interfacing with MCP23016 GPIO expander over I2C. Beware, commands sent in quick succession might cause the chip to error and ignore some instructions (important when rapidly blinking for example).
- close()
- pinAllOff()
- pinOff(group, pin)
- pinOn(group, pin)
Set pin active.
This and the following function take parameters:
- Parameters
group – ID of group (0 or 1)
pin – pin ID in group (0-7)
- pinRead(group, pin)
- readINTCAP()
- resetGP(group, pin)
- resetIPOL(group, pin)
- setGP(group, bitmask)
Set whole group of pins using bitmask.
Warning: Set pins as output (using block_direction in constructor, IODIR0/1) first!
- Parameters
group – ID of group (0, 1)
bitmask – 8 bits - 0 bit on i-th position means turn off i-th pin, similarly with bit 1
- setIPOL(group, pin)
- setOLAT(group, bitmask)
Set whole group of pins using bitmask.
Warning: Set pins as output (using block_direction in constructor, IODIR0/1) first!
- Parameters
group – ID of group (0, 1)
bitmask – 8 bits - 0 bit on i-th position means turn off i-th pin, similarly with bit 1
devices.LedDev module
- class uun_iot_libledstrip.devices.LedDev.LedDev(*args, **kwargs)
Bases:
ABCAbstract class interface for the underlying hardware implementation of LED strip.
Pixel colors are written in RGB tuple format directly into derived objects using list index syntax. Call
show()to propagate the written values. Some derived class accept parameterautoshowto control automatic show-after-write behaviour.Example
ledd = DebugLedDev(16) ledd[0] = (100, 200, 255) print(ledd[0])
>>> (100,200,255)
- abstract show()
devices.NeopixelDev module
- class uun_iot_libledstrip.devices.NeopixelDev.NeopixelDev(*args, **kwargs)
Bases:
NeoPixel,LedDevSee Adafruit NeoPixel.
autowriteis alwaysFalse, set it instead at level ofLedStrip