luma.oled
#
Description#
Plugin to interact with small OLED-based RaspberryPi displays through the luma.oled driver.
Configuration#
luma.oled:
# [Required]
# Serial interface the display is connected to (``spi``
# or ``i2c``).
interface: # type=str
# [Required]
# Display chipset type (supported: ssd1306 ssd1309,
# ssd1322, ssd1325, ssd1327, ssd1331, ssd1351, ssd1362, sh1106).
device: # type=str
# [Optional]
# Device port (usually 0 or 1).
# port: 0 # type=int
# [Optional]
# Device slot (0 for back, 1 for front).
# slot: 0 # type=int
# [Optional]
# Display width.
# width: 128 # type=int
# [Optional]
# Display height.
# height: 64 # type=int
# [Optional]
# Display rotation (0 for no rotation, 1 for 90 degrees, 2
# for 180 degrees, 3 for 270 degrees).
# rotate: 0 # type=int
# [Optional]
# [SPI only] GPIO PIN used for data (default: 24).
# gpio_DC: 24 # type=int
# [Optional]
# [SPI only] GPIO PIN used for RST (default: 25).
# gpio_RST: 25 # type=int
# [Optional]
# [SPI only] Bus speed in Hz (default: 8 MHz).
# bus_speed_hz: 8000000 # type=int
# [Optional]
# [I2C only] Device address (default: 0x3c).
# address: 60 # type=int
# [Optional]
# [SPI only] Set to True if the SPI chip select is high.
# cs_high: False # type=bool
# [Optional]
# [SPI only] Maximum amount of bytes to transfer in
# one go (default: 4096).
# transfer_size: 4096 # type=int
# [Optional]
# [SPI only] SPI mode as two bit pattern of clock
# polarity and phase [CPOL|CPHA], 0-3 (default:None).
# spi_mode: # type=Optional[int]
# [Optional]
# Path to a default TTF font used to display the text.
# font: # type=Optional[str]
# [Optional]
# Font size - it only applies if ``font`` is set.
# font_size: 10 # type=int
Dependencies#
pip
pip install luma.oled
Actions#
Module reference#
- class platypush.plugins.luma.oled.DeviceInterface(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
Enum
- class platypush.plugins.luma.oled.DeviceRotation(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
IntEnum
- __init__(*args, **kwds)#
- as_integer_ratio()#
Return a pair of integers, whose ratio is equal to the original int.
The ratio is in lowest terms and has a positive denominator.
>>> (10).as_integer_ratio() (10, 1) >>> (-10).as_integer_ratio() (-10, 1) >>> (0).as_integer_ratio() (0, 1)
- bit_count()#
Number of ones in the binary representation of the absolute value of self.
Also known as the population count.
>>> bin(13) '0b1101' >>> (13).bit_count() 3
- bit_length()#
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()#
Returns self, the complex conjugate of any int.
- denominator#
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)#
Return the integer represented by the given array of bytes.
- bytes
Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Indicates whether two’s complement is used to represent the integer.
- imag#
the imaginary part of a complex number
- is_integer()#
Returns True. Exists for duck type compatibility with float.is_integer.
- numerator#
the numerator of a rational number in lowest terms
- real#
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)#
Return an array of bytes representing an integer.
- length
Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
- class platypush.plugins.luma.oled.DeviceSlot(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
IntEnum
- __init__(*args, **kwds)#
- as_integer_ratio()#
Return a pair of integers, whose ratio is equal to the original int.
The ratio is in lowest terms and has a positive denominator.
>>> (10).as_integer_ratio() (10, 1) >>> (-10).as_integer_ratio() (-10, 1) >>> (0).as_integer_ratio() (0, 1)
- bit_count()#
Number of ones in the binary representation of the absolute value of self.
Also known as the population count.
>>> bin(13) '0b1101' >>> (13).bit_count() 3
- bit_length()#
Number of bits necessary to represent self in binary.
>>> bin(37) '0b100101' >>> (37).bit_length() 6
- conjugate()#
Returns self, the complex conjugate of any int.
- denominator#
the denominator of a rational number in lowest terms
- from_bytes(byteorder='big', *, signed=False)#
Return the integer represented by the given array of bytes.
- bytes
Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Indicates whether two’s complement is used to represent the integer.
- imag#
the imaginary part of a complex number
- is_integer()#
Returns True. Exists for duck type compatibility with float.is_integer.
- numerator#
the numerator of a rational number in lowest terms
- real#
the real part of a complex number
- to_bytes(length=1, byteorder='big', *, signed=False)#
Return an array of bytes representing an integer.
- length
Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.
- byteorder
The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.
- signed
Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
- class platypush.plugins.luma.oled.LumaOledPlugin(interface: str, device: str, port: int = 0, slot: int = 0, width: int = 128, height: int = 64, rotate: int = 0, gpio_DC: int = 24, gpio_RST: int = 25, bus_speed_hz: int = 8000000, address: int = 60, cs_high: bool = False, transfer_size: int = 4096, spi_mode: int | None = None, font: str | None = None, font_size: int = 10, **kwargs)[source]#
Bases:
Plugin
Plugin to interact with small OLED-based RaspberryPi displays through the luma.oled driver.
- __init__(interface: str, device: str, port: int = 0, slot: int = 0, width: int = 128, height: int = 64, rotate: int = 0, gpio_DC: int = 24, gpio_RST: int = 25, bus_speed_hz: int = 8000000, address: int = 60, cs_high: bool = False, transfer_size: int = 4096, spi_mode: int | None = None, font: str | None = None, font_size: int = 10, **kwargs)[source]#
- Parameters:
interface – Serial interface the display is connected to (
spi
ori2c
).device – Display chipset type (supported: ssd1306 ssd1309, ssd1322, ssd1325, ssd1327, ssd1331, ssd1351, ssd1362, sh1106).
port – Device port (usually 0 or 1).
slot – Device slot (0 for back, 1 for front).
width – Display width.
height – Display height.
rotate – Display rotation (0 for no rotation, 1 for 90 degrees, 2 for 180 degrees, 3 for 270 degrees).
gpio_DC – [SPI only] GPIO PIN used for data (default: 24).
gpio_RST – [SPI only] GPIO PIN used for RST (default: 25).
bus_speed_hz – [SPI only] Bus speed in Hz (default: 8 MHz).
address – [I2C only] Device address (default: 0x3c).
cs_high – [SPI only] Set to True if the SPI chip select is high.
transfer_size – [SPI only] Maximum amount of bytes to transfer in one go (default: 4096).
spi_mode – [SPI only] SPI mode as two bit pattern of clock polarity and phase [CPOL|CPHA], 0-3 (default:None).
font – Path to a default TTF font used to display the text.
font_size – Font size - it only applies if
font
is set.
- arc(start: int, end: int, xy: Tuple[int] | List[int] | None = None, fill: str | None = None, outline: str | None = None, width: int = 1, clear: bool = False)[source]#
Draw an arc on the canvas.
- Parameters:
start – Starting angle, in degrees (measured from 3 o’ clock and increasing clockwise).
end – Ending angle, in degrees (measured from 3 o’ clock and increasing clockwise).
xy – Two points defining the bounding box, either as
[(x0, y0), (x1, y1)]
or[x0, y0, x1, y1]
. Default: bounding box of the device.fill – Fill color - can be
black
orwhite
.outline – Outline color - can be
black
orwhite
.width – Figure width in pixels (default: 1).
clear – Set to True if you want to clear the canvas before writing the text (default: False).
- chord(start: int, end: int, xy: Tuple[int] | List[int] | None = None, fill: str | None = None, outline: str | None = None, width: int = 1, clear: bool = False)[source]#
Same as
arc
, but it connects the end points with a straight line.- Parameters:
start – Starting angle, in degrees (measured from 3 o’ clock and increasing clockwise).
end – Ending angle, in degrees (measured from 3 o’ clock and increasing clockwise).
xy – Two points defining the bounding box, either as
[(x0, y0), (x1, y1)]
or[x0, y0, x1, y1]
. Default: bounding box of the device.fill – Fill color - can be
black
orwhite
.outline – Outline color - can be
black
orwhite
.width – Figure width in pixels (default: 1).
clear – Set to True if you want to clear the canvas before writing the text (default: False).
- ellipse(xy: Tuple[int] | List[int] | None = None, fill: str | None = None, outline: str | None = None, width: int = 1, clear: bool = False)[source]#
Draw an ellipse on the canvas.
- Parameters:
xy – Two points defining the bounding box, either as
[(x0, y0), (x1, y1)]
or[x0, y0, x1, y1]
. Default: bounding box of the device.fill – Fill color - can be
black
orwhite
.outline – Outline color - can be
black
orwhite
.width – Figure width in pixels (default: 1).
clear – Set to True if you want to clear the canvas before writing the text (default: False).
- image(image: str)[source]#
Draws an image to the canvas (this will clear the existing canvas).
- Parameters:
image – Image path.
- line(xy: Tuple[int] | List[int] | None = None, fill: str | None = None, outline: str | None = None, width: int = 1, curve: bool = False, clear: bool = False)[source]#
Draw a line on the canvas.
- Parameters:
xy – Two points defining the bounding box, either as
[(x0, y0), (x1, y1)]
or[x0, y0, x1, y1]
. Default: bounding box of the device.fill – Fill color - can be
black
orwhite
.outline – Outline color - can be
black
orwhite
.width – Figure width in pixels (default: 1).
curve – Set to True for rounded edges (default: False).
clear – Set to True if you want to clear the canvas before writing the text (default: False).
- pieslice(start: int, end: int, xy: Tuple[int] | List[int] | None = None, fill: str | None = None, outline: str | None = None, width: int = 1, clear: bool = False)[source]#
Same as
arc
, but it also draws straight lines between the end points and the center of the bounding box.- Parameters:
start – Starting angle, in degrees (measured from 3 o’ clock and increasing clockwise).
end – Ending angle, in degrees (measured from 3 o’ clock and increasing clockwise).
xy – Two points defining the bounding box, either as
[(x0, y0), (x1, y1)]
or[x0, y0, x1, y1]
. Default: bounding box of the device.fill – Fill color - can be
black
orwhite
.outline – Outline color - can be
black
orwhite
.width – Figure width in pixels (default: 1).
clear – Set to True if you want to clear the canvas before writing the text (default: False).
- point(xy: Tuple[int] | List[int] | None = None, fill: str | None = None, clear: bool = False)[source]#
Draw one or more points on the canvas.
- Parameters:
xy – Two points defining the bounding box, either as
[(x0, y0), (x1, y1)]
or[x0, y0, x1, y1]
. Default: bounding box of the device.fill – Fill color - can be
black
orwhite
.clear – Set to True if you want to clear the canvas before writing the text (default: False).
- polygon(xy: Tuple[int] | List[int] | None = None, fill: str | None = None, outline: str | None = None, clear: bool = False)[source]#
Draw a polygon on the canvas.
- Parameters:
xy – Two points defining the bounding box, either as
[(x0, y0), (x1, y1)]
or[x0, y0, x1, y1]
. Default: bounding box of the device.fill – Fill color - can be
black
orwhite
.outline – Outline color - can be
black
orwhite
.clear – Set to True if you want to clear the canvas before writing the text (default: False).
- rectangle(xy: Tuple[int] | List[int] | None = None, fill: str | None = None, outline: str | None = None, width: int = 1, clear: bool = False)[source]#
Draw a rectangle on the canvas.
- Parameters:
xy – Two points defining the bounding box, either as
[(x0, y0), (x1, y1)]
or[x0, y0, x1, y1]
. Default: bounding box of the device.fill – Fill color - can be
black
orwhite
.outline – Outline color - can be
black
orwhite
.width – Figure width in pixels (default: 1).
clear – Set to True if you want to clear the canvas before writing the text (default: False).
- text(text: str, pos: Tuple[int] | List[int] = (0, 0), fill: str = 'white', font: str | None = None, font_size: int | None = None, clear: bool = False)[source]#
Draw text on the canvas.
- Parameters:
text – Text to be drawn.
pos – Position of the text.
fill – Text color (default:
white
).font –
font
type override.font_size –
font_size
override.clear – Set to True if you want to clear the canvas before writing the text (default: False).