luma.oled
Platypush documentation
luma.oled
- 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: Optional[int] = None, font: Optional[str] = None, font_size: int = 10, **kwargs)[source]
Bases:
Plugin
Plugin to interact with small OLED-based RaspberryPi displays through the luma.oled driver.
Requires:
luma.oled (
pip install git+https://github.com/rm-hull/luma.oled
)
- __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: Optional[int] = None, font: Optional[str] = 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). :param 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: Optional[Union[Tuple[int], List[int]]] = None, fill: Optional[str] = None, outline: Optional[str] = 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: Optional[Union[Tuple[int], List[int]]] = None, fill: Optional[str] = None, outline: Optional[str] = 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: Optional[Union[Tuple[int], List[int]]] = None, fill: Optional[str] = None, outline: Optional[str] = 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: Optional[Union[Tuple[int], List[int]]] = None, fill: Optional[str] = None, outline: Optional[str] = None, width: int = 1, curve: bool = False, clear: bool = False)[source]
Draw a line on the canvas.
- Parameters:
xy – Sequence of either 2-tuples like [(x, y), (x, y), …] or numeric values like [x, y, x, y, …].
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: Optional[Union[Tuple[int], List[int]]] = None, fill: Optional[str] = None, outline: Optional[str] = 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: Optional[Union[Tuple[int], List[int]]] = None, fill: Optional[str] = None, clear: bool = False)[source]
Draw one or more points on the canvas.
- Parameters:
xy – Sequence of either 2-tuples like [(x, y), (x, y), …] or numeric values like [x, y, x, y, …].
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: Optional[Union[Tuple[int], List[int]]] = None, fill: Optional[str] = None, outline: Optional[str] = None, clear: bool = False)[source]
Draw a polygon on the canvas.
- Parameters:
xy – Sequence of either 2-tuples like [(x, y), (x, y), …] or numeric values like [x, y, x, y, …].
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: Optional[Union[Tuple[int], List[int]]] = None, fill: Optional[str] = None, outline: Optional[str] = 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: Union[Tuple[int], List[int]] = (0, 0), fill: str = 'white', font: Optional[str] = None, font_size: Optional[int] = 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).