### Install luma.oled Library Source: https://luma-oled.readthedocs.io/en/latest/software.html Install or upgrade the luma.oled library within your virtual environment using pip. ```bash $ ~/luma-env/bin/python -m pip install --upgrade luma.oled ``` -------------------------------- ### Install Pillow via apt-get (Alternative 1) Source: https://luma-oled.readthedocs.io/en/latest/software.html Install the Pillow imaging library using apt-get if a pre-packaged version is available on your distribution. ```bash $ sudo apt-get install python3-imaging ``` -------------------------------- ### Install Pillow via apt-get (Alternative 2) Source: https://luma-oled.readthedocs.io/en/latest/software.html Install the Pillow imaging library using apt-get if a pre-packaged version is available on your distribution. ```bash $ sudo apt-get install python3-pil ``` -------------------------------- ### Install Dependencies on Raspberry Pi OS Source: https://luma-oled.readthedocs.io/en/latest/_sources/software.rst.txt Commands to install required development packages on Raspberry Pi OS using apt-get. ```bash $ sudo apt-get update $ sudo apt-get install python3 python3-pip python3-pil libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libopenjp2-7 libtiff5 -y ``` -------------------------------- ### Install i2c-tools and Add User to i2c Group Source: https://luma-oled.readthedocs.io/en/latest/_sources/hardware.rst.txt Installs the i2c-tools package and adds the current user to the 'i2c' group for device access. Logout and log back in for changes to take effect. ```bash $ sudo usermod -a -G i2c pi $ sudo apt-get install i2c-tools ``` -------------------------------- ### Initialize and Draw on CH1115 OLED Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Example of initializing a CH1115 OLED display via I2C and drawing text on it. Ensure the correct I2C port and address are used. ```python from luma.core.interface.serial import i2c from luma.core.render import canvas from luma.oled.device import ch1115 serial = i2c(port=1, address=0x3C) dev = ch1115(serial, width=128, height=64) with canvas(dev) as draw: draw.text((0, 0), "Hello CH1115", fill="white") ``` -------------------------------- ### Install Pillow Alternative Package Source: https://luma-oled.readthedocs.io/en/latest/_sources/software.rst.txt Install Pillow using apt-get if a pre-packaged version is available on your distribution. ```bash $ sudo apt-get install python3-imaging ``` ```bash $ sudo apt-get install python3-pil ``` -------------------------------- ### Install Dependencies on Raspberry Pi OS Source: https://luma-oled.readthedocs.io/en/latest/software.html Update package lists and install required development packages for luma.oled on Raspberry Pi OS. ```bash $ sudo apt-get update $ sudo apt-get install python3 python3-pip python3-pil libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libopenjp2-7 libtiff5 -y ``` -------------------------------- ### SSD1331 Initialization Sequence Source: https://luma-oled.readthedocs.io/en/latest/_modules/luma/oled/device.html This code snippet shows the initialization sequence for the SSD1331 display. It configures various display parameters like display off, remap, start line, offset, multiplexing, phase periods, clock divider, precharge speeds, and voltage. ```python self.command( 0xAE, # Display off 0xA0, 0x72, # Seg remap 0xA1, 0x00, # Set Display start line 0xA2, 0x00, # Set display offset 0xA4, # Normal display 0xA8, 0x3F, # Set multiplex 0xAD, 0x8E, # Master configure 0xB0, 0x0B, # Power save mode 0xB1, 0x74, # Phase12 period 0xB3, 0xD0, # Clock divider 0x8A, 0x80, # Set precharge speed A 0x8B, 0x80, # Set precharge speed B 0x8C, 0x80, # Set precharge speed C 0xBB, 0x3E, # Set pre-charge voltage 0xBE, 0x3E, # Set voltage 0x87, 0x0F) # Master current control ``` -------------------------------- ### show Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Sets the display mode ON, waking the device out of a prior low-power sleep mode. ```APIDOC ## `show` ### Description Sets the display mode ON, waking the device out of a prior low-power sleep mode. ``` -------------------------------- ### display(_image_) Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Takes a 1-bit PIL.Image and dumps it to the ws0010 OLED display. ```APIDOC display(_image_) Takes a 1-bit `PIL.Image` and dumps it to the ws0010 OLED display. ``` -------------------------------- ### Initialize ws0010 Display with Custom Font Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Demonstrates how to initialize a ws0010 OLED display using a parallel interface and a custom font. This snippet shows setting the text content for the display. ```python from luma.core.interface.serial import parallel from luma.oled.device import ws0010 p = parallel(RS=7, E=8, PINS=[25,24,23,18]) my_display = ws0010(p, selected_font='FT01') my_display.text = 'WS0010 Display\nFont FT01 5x8' ``` -------------------------------- ### Get Font Source: https://luma-oled.readthedocs.io/en/latest/_modules/luma/oled/device.html Loads and returns an embedded font from the device based on its index or name. ```APIDOC ## Get Font ### Description Loads one of the device's embedded fonts by its index value or name and returns it. ### Method get_font(ft) ### Parameters - **ft** (int or str) - Required - The index or the name of the font to return. ### Response - **font_data** (object) - The loaded font object. ### Code Example ```python # Assuming 'device' is an initialized OLED device object # font_index = 0 # font_name = "default" # loaded_font = device.get_font(font_index) # or device.get_font(font_name) ``` ``` -------------------------------- ### Dithered Color Drawing on Monochrome Display Source: https://luma-oled.readthedocs.io/en/latest/python-usage.html Shows how to use the `dither=True` option with the canvas to convert color drawings into a dithered monochrome effect on compatible displays. This example draws a white-outlined red rectangle. ```python with canvas(device, dither=True) as draw: draw.rectangle((10, 10, 30, 30), outline="white", fill="red") ``` -------------------------------- ### init_framebuffer(_framebuffer_) Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Initializes the framebuffer for the device. ```APIDOC ## init_framebuffer(_framebuffer_) ### Description Initializes the framebuffer for the device. ### Parameters #### Path Parameters - **framebuffer** (any) - Required - The framebuffer to initialize. ``` -------------------------------- ### Create Virtual Environment Source: https://luma-oled.readthedocs.io/en/latest/software.html Use this command to create a dedicated virtual environment for your project to manage dependencies. ```bash $ python3 -m venv ~/luma-env ``` -------------------------------- ### SSD1322 Set Position Command Source: https://luma-oled.readthedocs.io/en/latest/_modules/luma/oled/device.html Configures the display's column and row address for writing pixel data. It calculates the correct column start and end addresses based on the desired pixel range and offset. ```python self._column_offset = (480 - width) // 2 self.command(0x15, coladdr_start, coladdr_end) # set column addr self.command(0x75, top, bottom - 1) # Reset row addr self.command(0x5C) # Enable MCU to write data into RAM ``` -------------------------------- ### Configure I2C Baudrate in config.txt Source: https://luma-oled.readthedocs.io/en/latest/hardware.html To improve I2C performance, modify `/boot/config.txt` to set the I2C baudrate to 400KHz. This change requires a reboot to take effect. ```bash dtparam=i2c_arm=on,i2c_baudrate=400000 ``` -------------------------------- ### Detect I2C Device Address Source: https://luma-oled.readthedocs.io/en/latest/_sources/hardware.rst.txt Use the i2cdetect command to find the address of connected I2C devices. Use bus 0 for rev.1 boards, otherwise use bus 1. The example shows device address 0x3c. ```bash $ i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- ``` -------------------------------- ### clear Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Initializes the device memory with an empty (blank) image. ```APIDOC ## `clear` ### Description Initializes the device memory with an empty (blank) image. ``` -------------------------------- ### Device Initialization Source: https://luma-oled.readthedocs.io/en/latest/_modules/luma/oled/device.html Initializes the OLED display device, configuring it for graphics mode and turning it on. This method sets up the display to receive data. ```APIDOC ## Device Initialization ### Description Initializes the OLED display device, configuring it for graphics mode and turning it on. This method sets up the display to receive data. ### Method __init__ ### Parameters None explicitly documented for direct user invocation. ### Code Example ```python # Example of how the internal initialization might look (not directly callable by user) dl = 0x03 if self._bitmode == 8 else 0x02 self.command(0x00, 0x00, dl, self._const.FUNCTIONSET | (dl << 4)) self.command(self._const.DISPLAYOFF) # Set Display Off self.command(self._const.POWEROFF) self.command(self._const.ENTRY) # Set entry mode to direction right, no shift self.command(self._const.POWERON | self._const.GRAPHIC) # Turn internal power on and set into graphics mode self.command(self._const.DISPLAYON) # Turn Display back on ``` ``` -------------------------------- ### ws0010 Class Initialization Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Initializes a ws0010 OLED display instance. This class handles serial communication and display rendering for monochrome Winstar WS0010 OLED displays. ```APIDOC class luma.oled.device.ws0010(_serial_interface =None_, _width =100_, _height =16_, _undefined ='_'_, _font =None_, _selected_font =0_, _exec_time =4.9999999999999996e-05_, _rotate =0_, _framebuffer =None_, _const =_, _**kwargs_)[source] Bases: `parallel_device`, `character`, `__framebuffer_mixin` Serial interface to a monochrome Winstar WS0010 OLED display. This interface will work with most ws0010 powered devices including the weg010016. Parameters: * **serial_interface** – The serial interface (usually a `luma.core.interface.serial.parallel` instance) to delegate sending data and commands through. * **width** (_int_) – The number of pixels laid out horizontally. * **height** (_int_) – The number of pixels laid out vertically. * **undefined** (_str_) – The character to display if the font doesn’t contain the requested character * **font** (`PIL.ImageFont`) – Allows you to override the internal font by passing in an alternate * **selected_font** (_int_ _or_ _str_) – Select one of the ws0010’s embedded font tables (see note). Can be selected by number or name. Default is ‘FT00’ (English Japanese). * **exec_time** (_float_) – Time in seconds to wait for a command to complete. Default is 50 μs (1e-6 * 50) which is enough for all ws0010 commands. * **rotate** (_int_) – An integer value of 0 (default), 1, 2 or 3 only, where 0 is no rotation, 1 is rotate 90° clockwise, 2 is 180° rotation and 3 represents 270° rotation. * **framebuffer** (_str_) – Framebuffering strategy, currently values of `diff_to_previous` or `full_frame` are only supported. To place text on the display, simply assign the text to the ‘text’ instance variable: ``` p = parallel(RS=7, E=8, PINS=[25,24,23,18]) my_display = ws0010(p, selected_font='FT01') my_display.text = 'WS0010 Display\nFont FT01 5x8' ``` For more details on how to use the ‘text’ interface see `luma.core.virtual.character` Added in version 3.6.0. ``` -------------------------------- ### Add User to Hardware Access Groups Source: https://luma-oled.readthedocs.io/en/latest/software.html Add your user account to the spi, gpio, and i2c groups to grant access to hardware interfaces. Replace 'pi' with your actual username. ```bash $ sudo usermod -a -G spi,gpio,i2c pi ``` -------------------------------- ### CH1115 Device Initialization Sequence Source: https://luma-oled.readthedocs.io/en/latest/_modules/luma/oled/device.html The CH1115 class constructor includes a detailed initialization sequence using specific commands to configure the display, such as setting the display clock, multiplex ratio, and contrast. It also handles display mode validation. ```python self.command( 0xAE, # display off 0xD5, 0x80, # display clock divide / osc freq 0xA8, 0x3F, # multiplex ratio (1/64) 0xD3, 0x00, # display offset 0x40, # start line = 0 0xAD, 0x8B, # DC-DC control: internal DC-DC on (CH1115 specific) 0xA1, # segment remap 0xC8, # COM scan direction remapped 0xDA, 0x12, # COM pins hardware configuration 0x81, 0x7F, # contrast 0xD9, 0x22, # pre-charge period 0xDB, 0x20, # VCOMH deselect level 0xA4, # entire display ON follows RAM 0xA6 # normal (non-inverted) display ) ``` -------------------------------- ### display Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Takes a 1-bit PIL.Image and dumps it to the OLED display. ```APIDOC ## `display` ### Description Takes a 1-bit `PIL.Image` and dumps it to the OLED display. ### Parameters #### Path Parameters - **image** (PIL.Image) – Image to display. ``` -------------------------------- ### Enable I2C Baudrate in config.txt Source: https://luma-oled.readthedocs.io/en/latest/_sources/hardware.rst.txt Increase the I2C baudrate from 100KHz to 400KHz by adding this line to /boot/config.txt. Requires a reboot. ```bash dtparam=i2c_arm=on,i2c_baudrate=400000 ``` -------------------------------- ### luma.oled.device.ssd1322.init_framebuffer Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Initializes the framebuffer for the device. ```APIDOC ## `luma.oled.device.ssd1322.init_framebuffer` ### Description Initializes the framebuffer for the device. ### Parameters * **framebuffer** - The framebuffer to initialize. ``` -------------------------------- ### SSD1305 Initialization Source: https://luma-oled.readthedocs.io/en/latest/_modules/luma/oled/device.html Initializes the SSD1305 display with specific settings for width, height, and rotation. It configures multiplexing, display clock, and pin settings based on the display dimensions. Raises an error for unsupported display modes. ```python class ssd1305(ssd1306): """ Serial interface to a monochrome SSD1305 OLED display. On creation, an initialization sequence is pumped to the display to properly configure it. Further control commands can then be called to affect the brightness and other settings. The SSD1305 does not have an internal charge pump, so an external VCC supply must be provided. The column start offset for 128x32 mode is 4. :param serial_interface: The serial interface (usually a :py:class:`luma.core.interface.serial.i2c` instance) to delegate sending data and commands through. :param width: The number of horizontal pixels (optional, defaults to 128). :type width: int :param height: The number of vertical pixels (optional, defaults to 32). :type height: int :param rotate: An integer value of 0 (default), 1, 2 or 3 only, where 0 is no rotation, 1 is rotate 90° clockwise, 2 is 180° rotation and 3 represents 270° rotation. :type rotate: int .. versionadded:: 3.15.0 """ def __init__(self, serial_interface=None, width=128, height=32, rotate=0, **kwargs): super(ssd1306, self).__init__(luma.oled.const.ssd1306, serial_interface) self.capabilities(width, height, rotate) # Supported modes settings = { (128, 64): dict(multiplex=0x3F, displayclockdiv=0x80, compins=0x12, colstart=0), (128, 32): dict(multiplex=0x1F, displayclockdiv=0x80, compins=0x12, colstart=4), }.get((width, height)) if settings is None: raise luma.core.error.DeviceDisplayModeError( f"Unsupported display mode: {width} x {height}") self._pages = height // 8 self._mask = [1 << (i // width) % 8 for i in range(width * height)] self._offsets = [(width * (i // (width * 8))) + (i % width) for i in range(width * height)] self._colstart = settings['colstart'] self._colend = self._colstart + self._w self.command( self._const.DISPLAYOFF, self._const.SETDISPLAYCLOCKDIV, settings['displayclockdiv'], self._const.SETMULTIPLEX, settings['multiplex'], self._const.SETDISPLAYOFFSET, 0x00, self._const.SETSTARTLINE, self._const.CHARGEPUMP, 0x10, self._const.MEMORYMODE, 0x00, self._const.SETSEGMENTREMAP, self._const.COMSCANDEC, self._const.SETCOMPINS, settings['compins'], self._const.SETPRECHARGE, 0xF1, self._const.SETVCOMDETECT, 0x40, self._const.DISPLAYALLON_RESUME, self._const.NORMALDISPLAY) self.contrast(0xCF) self.clear() self.show() ``` -------------------------------- ### display(_image_) Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Takes a 1-bit monochrome or 24-bit RGB image and renders it to the greyscale OLED display. ```APIDOC ## display(_image_) ### Description Takes a 1-bit monochrome or 24-bit RGB image and renders it to the greyscale OLED display. RGB pixels are converted to 4-bit greyscale values using a simplified Luma calculation, based on _Y’=0.299R’+0.587G’+0.114B’_. ### Parameters #### Path Parameters - **image** (PIL.Image.Image) - Required - The image to render. ``` -------------------------------- ### SSD1362 Device Initialization Source: https://luma-oled.readthedocs.io/en/latest/_modules/luma/oled/device.html Initializes the SSD1362 device with specific configuration commands. This includes setting voltage, refresh rates, and display parameters. ```python def __init__(self, serial_interface=None, width=256, height=64, rotate=0, mode="RGB", framebuffer=None, **kwargs): super(ssd1362, self).__init__(luma.oled.const.ssd1362, serial_interface, width, height, rotate, mode, framebuffer, nibble_order=1, **kwargs) def _supported_dimensions(self): return [(256, 64)] def _init_sequence(self): self.command( 0xAB, # Set Vdd Mode 0x01, # ELW2106AA VCI = 3.0V 0xAD, 0x9E, # Set IREF selection 0x15, 0x00, 0x7F, # Set column address 0x75, 0x00, 0x3F, # Set row address 0xA0, 0x43, # Set Re-map 0xA1, 0x00, # Set display start line 0xA2, 0x00, # Set display offset 0xA4, # Set display mode 0xA8, 0x3F, # Set multiplex ratio 0xB1, 0x11, # Set Phase1,2 length 0xB3, 0xF0, # Set display clock divide ratio 0xB9, # Grey scale table 0xBC, 0x04, # Set pre-charge voltage 0xBE, 0x05) # Set VCOMH deselect level, 0.82 * Vcc def _set_position(self, top, right, bottom, left): self.command( 0x15, left >> 1, (right - 1) >> 1, # set column addr 0x75, top, bottom - 1) # set row addr ``` -------------------------------- ### init_framebuffer Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Initializes the framebuffer for the device. ```APIDOC ## `init_framebuffer` Initializes the framebuffer for the device. ``` -------------------------------- ### Initialize WS0010 Device Source: https://luma-oled.readthedocs.io/en/latest/_modules/luma/oled/device.html Initializes the WS0010 OLED display. This involves setting up the display mode, turning it off, configuring power and entry modes, and finally turning the display on in graphics mode. ```python dl = 0x03 if self._bitmode == 8 else 0x02 self.command(0x00, 0x00, dl, self._const.FUNCTIONSET | (dl << 4)) self.command(self._const.DISPLAYOFF) # Set Display Off self.command(self._const.POWEROFF) self.command(self._const.ENTRY) # Set entry mode to direction right, no shift self.command(self._const.POWERON | self._const.GRAPHIC) # Turn internal power on and set into graphics mode self.command(self._const.DISPLAYON) # Turn Display back on ``` -------------------------------- ### ssd1362 Methods Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Methods available for the ssd1362 driver. ```APIDOC ## ssd1362.capabilities() ### Description Retrieves the capabilities of the ssd1362 display. ### Method Not specified (assumed to be a method call) ### Endpoint Not applicable ### Parameters None specified ### Request Example ``` ssd1362.capabilities() ``` ### Response None specified ``` ```APIDOC ## ssd1362.cleanup() ### Description Cleans up resources for the ssd1362 display. ### Method Not specified (assumed to be a method call) ### Endpoint Not applicable ### Parameters None specified ### Request Example ``` ssd1362.cleanup() ``` ### Response None specified ``` ```APIDOC ## ssd1362.clear() ### Description Clears the ssd1362 display. ### Method Not specified (assumed to be a method call) ### Endpoint Not applicable ### Parameters None specified ### Request Example ``` ssd1362.clear() ``` ### Response None specified ``` ```APIDOC ## ssd1362.command() ### Description Sends a command to the ssd1362 display. ### Method Not specified (assumed to be a method call) ### Endpoint Not applicable ### Parameters None specified ### Request Example ``` ssd1362.command() ``` ### Response None specified ``` ```APIDOC ## ssd1362.contrast() ### Description Sets or gets the contrast for the ssd1362 display. ### Method Not specified (assumed to be a method call) ### Endpoint Not applicable ### Parameters None specified ### Request Example ``` ssd1362.contrast() ``` ### Response None specified ``` ```APIDOC ## ssd1362.data() ### Description Sends data to the ssd1362 display. ### Method Not specified (assumed to be a method call) ### Endpoint Not applicable ### Parameters None specified ### Request Example ``` ssd1362.data() ``` ### Response None specified ``` ```APIDOC ## ssd1362.display() ### Description Enables or disables the display for the ssd1362. ### Method Not specified (assumed to be a method call) ### Endpoint Not applicable ### Parameters None specified ### Request Example ``` ssd1362.display() ``` ### Response None specified ``` ```APIDOC ## ssd1362.hide() ### Description Hides the display content on the ssd1362. ### Method Not specified (assumed to be a method call) ### Endpoint Not applicable ### Parameters None specified ### Request Example ``` ssd1362.hide() ``` ### Response None specified ``` ```APIDOC ## ssd1362.init_framebuffer() ### Description Initializes the framebuffer for the ssd1362 display. ### Method Not specified (assumed to be a method call) ### Endpoint Not applicable ### Parameters None specified ### Request Example ``` ssd1362.init_framebuffer() ``` ### Response None specified ``` ```APIDOC ## ssd1362.preprocess() ### Description Preprocesses data for the ssd1362 display. ### Method Not specified (assumed to be a method call) ### Endpoint Not applicable ### Parameters None specified ### Request Example ``` ssd1362.preprocess() ``` ### Response None specified ``` ```APIDOC ## ssd1362.show() ### Description Shows data on the ssd1362 display. ### Method Not specified (assumed to be a method call) ### Endpoint Not applicable ### Parameters None specified ### Request Example ``` ssd1362.show() ``` ### Response None specified ``` -------------------------------- ### contrast() Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Switches the display contrast to the desired level, in the range of 0-255. Not suitable for fade-in/out animation. ```APIDOC ## contrast(_level_) ### Description Switches the display contrast to the desired level, in the range 0-255. Note that setting the level to a low (or zero) value will not necessarily dim the display to nearly off. In other words, this method is **NOT** suitable for fade-in/out animation. ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Method N/A (Function call) ### Parameters - **level** (int) - Desired contrast level in the range of 0-255. ``` -------------------------------- ### contrast(_level_) Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Switches the display contrast to the desired level. The level should be in the range of 0-255. Note that a low or zero value does not necessarily dim the display to off and is not suitable for fade animations. ```APIDOC contrast(_level_) Switches the display contrast to the desired level, in the range 0-255. Note that setting the level to a low (or zero) value will not necessarily dim the display to nearly off. In other words, this method is **NOT** suitable for fade-in/out animation. Parameters: **level** (_int_) – Desired contrast level in the range of 0-255. ``` -------------------------------- ### luma.oled.device.ssd1315 methods Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Methods available for the SSD1315 OLED display driver. ```APIDOC ## ssd1315.capabilities() ### Description Returns a dictionary of capabilities for the SSD1315 device. ### Method `ssd1315.capabilities()` ## ssd1315.cleanup() ### Description Cleans up resources used by the SSD1315 device. ### Method `ssd1315.cleanup()` ## ssd1315.clear() ### Description Clears the display buffer. ### Method `ssd1315.clear()` ## ssd1315.command(cmd, data=None) ### Description Sends a command to the SSD1315 device. ### Method `ssd1315.command(cmd, data=None)` ### Parameters #### Path Parameters - **cmd** (int) - Required - The command to send. - **data** (list[int]) - Optional - A list of data bytes to accompany the command. ## ssd1315.contrast(level) ### Description Sets the contrast level for the SSD1315 display. ### Method `ssd1315.contrast(level)` ### Parameters #### Path Parameters - **level** (int) - Required - The contrast level (0-255). ## ssd1315.data(data) ### Description Sends raw data to the SSD1315 device. ### Method `ssd1315.data(data)` ### Parameters #### Path Parameters - **data** (list[int]) - Required - A list of data bytes to send. ## ssd1315.display(image) ### Description Displays an image on the SSD1315 device. ### Method `ssd1315.display(image)` ### Parameters #### Path Parameters - **image** (PIL.Image.Image) - Required - The image to display. ## ssd1315.hide() ### Description Hides the display content (turns off pixels). ### Method `ssd1315.hide()` ## ssd1315.preprocess(data) ### Description Preprocesses data before sending it to the device. ### Method `ssd1315.preprocess(data)` ### Parameters #### Path Parameters - **data** (bytes) - Required - The raw data to preprocess. ## ssd1315.show() ### Description Shows the current display buffer content on the SSD1315 device. ### Method `ssd1315.show()` ``` -------------------------------- ### ssd1351 Methods Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Methods available for the ssd1351 driver. ```APIDOC ## ssd1351.preprocess() ### Description Preprocesses data for the ssd1351 display. ### Method Not specified (assumed to be a method call) ### Endpoint Not applicable ### Parameters None specified ### Request Example ``` ssd1351.preprocess() ``` ### Response None specified ``` ```APIDOC ## ssd1351.show() ### Description Displays data on the ssd1351 display. ### Method Not specified (assumed to be a method call) ### Endpoint Not applicable ### Parameters None specified ### Request Example ``` ssd1351.show() ``` ### Response None specified ``` -------------------------------- ### display Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Renders a 24-bit RGB image to the Color OLED display. ```APIDOC ## `display` Renders a 24-bit RGB image to the Color OLED display. Parameters: **image** (_PIL.Image.Image_) – The image to render. ``` -------------------------------- ### luma.oled.device.ssd1351 Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Initializes a SSD1351 OLED display. This class handles the low-level communication and configuration for the SSD1351 controller. ```APIDOC ## `luma.oled.device.ssd1351` Serial interface to the 16-bit color (5-6-5 RGB) SSD1351 OLED display. On creation, an initialization sequence is pumped to the display to properly configure it. Further control commands can then be called to affect the brightness and other settings. Parameters: * **serial_interface** – The serial interface (usually a `luma.core.interface.serial.spi` instance) to delegate sending data and commands through. * **width** (_int_) – The number of horizontal pixels (optional, defaults to 128). * **height** (_int_) – The number of vertical pixels (optional, defaults to 128). * **rotate** (_int_) – An integer value of 0 (default), 1, 2 or 3 only, where 0 is no rotation, 1 is rotate 90° clockwise, 2 is 180° rotation and 3 represents 270° rotation. * **framebuffer** (_str_) – Framebuffering strategy, currently instances of `diff_to_previous` or `full_frame` are only supported. * **bgr** (_bool_) – Set to `True` if device pixels are BGR order (rather than RGB). * **h_offset** (_int_) – Horizontal offset (in pixels) of screen to device memory (default: 0) * **v_offset** – Vertical offset (in pixels) of screen to device memory (default: 0) Added in version 2.3.0. ``` -------------------------------- ### SSD1306 Device Initialization and Display Source: https://luma-oled.readthedocs.io/en/latest/_modules/luma/oled/device.html This snippet outlines the initialization process for an SSD1306 OLED display and its `display` method. It supports various resolutions and rotation settings, configuring the display controller and then rendering a PIL Image onto the screen. ```APIDOC ## SSD1306 Device Initialization and Display ### Description Initializes the SSD1306 OLED display with support for multiple resolutions and rotation. The constructor configures the display controller based on the provided width, height, and rotation. The `display` method takes a 1-bit PIL Image, preprocesses it, and sends the pixel data to the display controller in pages. ### Method `__init__` (constructor), `display` ### Parameters for `__init__` * `serial_interface`: The serial interface (e.g., `luma.core.interface.serial.i2c`) for communication. * `width`: The width of the display in pixels (default: 128). * `height`: The height of the display in pixels (default: 64). * `rotate`: Rotation angle (0, 1, 2, or 3). ### Parameters for `display` * `image`: A 1-bit PIL.Image object to be displayed. ### Response for `display` None. The method updates the display directly. ### Example Usage (Conceptual) ```python from luma.oled.device import ssd1306 from PIL import Image # Assuming 'serial' is an initialized serial interface device = ssd1306(serial, width=128, height=64, rotate=0) image = Image.new('1', device.size, "black") # Draw on the image device.display(image) ``` ``` -------------------------------- ### luma.oled.device.ssd1305 methods Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Methods available for the SSD1305 OLED display driver. ```APIDOC ## ssd1305.capabilities() ### Description Returns a dictionary of capabilities for the SSD1305 device. ### Method `ssd1305.capabilities()` ## ssd1305.cleanup() ### Description Cleans up resources used by the SSD1305 device. ### Method `ssd1305.cleanup()` ## ssd1305.clear() ### Description Clears the display buffer. ### Method `ssd1305.clear()` ## ssd1305.command(cmd, data=None) ### Description Sends a command to the SSD1305 device. ### Method `ssd1305.command(cmd, data=None)` ### Parameters #### Path Parameters - **cmd** (int) - Required - The command to send. - **data** (list[int]) - Optional - A list of data bytes to accompany the command. ## ssd1305.contrast(level) ### Description Sets the contrast level for the SSD1305 display. ### Method `ssd1305.contrast(level)` ### Parameters #### Path Parameters - **level** (int) - Required - The contrast level (0-255). ## ssd1305.data(data) ### Description Sends raw data to the SSD1305 device. ### Method `ssd1305.data(data)` ### Parameters #### Path Parameters - **data** (list[int]) - Required - A list of data bytes to send. ## ssd1305.display(image) ### Description Displays an image on the SSD1305 device. ### Method `ssd1305.display(image)` ### Parameters #### Path Parameters - **image** (PIL.Image.Image) - Required - The image to display. ## ssd1305.hide() ### Description Hides the display content (turns off pixels). ### Method `ssd1305.hide()` ## ssd1305.preprocess(data) ### Description Preprocesses data before sending it to the device. ### Method `ssd1305.preprocess(data)` ### Parameters #### Path Parameters - **data** (bytes) - Required - The raw data to preprocess. ## ssd1305.show() ### Description Shows the current display buffer content on the SSD1305 device. ### Method `ssd1305.show()` ``` -------------------------------- ### Grant Hardware Access Permissions Source: https://luma-oled.readthedocs.io/en/latest/_sources/software.rst.txt Add your user account to groups that grant access to hardware interfaces like SPI, GPIO, and I2C. ```bash $ sudo usermod -a -G spi,gpio,i2c pi ``` -------------------------------- ### luma.oled.device.ssd1316 methods Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Methods available for the SSD1316 OLED display driver. ```APIDOC ## ssd1316.capabilities() ### Description Returns a dictionary of capabilities for the SSD1316 device. ### Method `ssd1316.capabilities()` ## ssd1316.cleanup() ### Description Cleans up resources used by the SSD1316 device. ### Method `ssd1316.cleanup()` ## ssd1316.clear() ### Description Clears the display buffer. ### Method `ssd1316.clear()` ## ssd1316.command(cmd, data=None) ### Description Sends a command to the SSD1316 device. ### Method `ssd1316.command(cmd, data=None)` ### Parameters #### Path Parameters - **cmd** (int) - Required - The command to send. - **data** (list[int]) - Optional - A list of data bytes to accompany the command. ## ssd1316.contrast(level) ### Description Sets the contrast level for the SSD1316 display. ### Method `ssd1316.contrast(level)` ### Parameters #### Path Parameters - **level** (int) - Required - The contrast level (0-255). ## ssd1316.data(data) ### Description Sends raw data to the SSD1316 device. ### Method `ssd1316.data(data)` ### Parameters #### Path Parameters - **data** (list[int]) - Required - A list of data bytes to send. ## ssd1316.display(image) ### Description Displays an image on the SSD1316 device. ### Method `ssd1316.display(image)` ### Parameters #### Path Parameters - **image** (PIL.Image.Image) - Required - The image to display. ## ssd1316.hide() ### Description Hides the display content (turns off pixels). ### Method `ssd1316.hide()` ## ssd1316.preprocess(data) ### Description Preprocesses data before sending it to the device. ### Method `ssd1316.preprocess(data)` ### Parameters #### Path Parameters - **data** (bytes) - Required - The raw data to preprocess. ## ssd1316.show() ### Description Shows the current display buffer content on the SSD1316 device. ### Method `ssd1316.show()` ``` -------------------------------- ### SSD1316 Initialization Source: https://luma-oled.readthedocs.io/en/latest/_modules/luma/oled/device.html Initializes the SSD1316 display, inheriting from ssd1306. This class is intended for monochrome SSD1316 OLED displays and supports standard initialization parameters. ```python class ssd1316(ssd1306): """ Serial interface to a monochrome SSD1316 OLED display. ``` -------------------------------- ### SSD1327 Initialization Sequence Source: https://luma-oled.readthedocs.io/en/latest/_modules/luma/oled/device.html This sequence initializes the SSD1327 greyscale OLED display. It configures display parameters, clock ratios, multiplexing, and greyscale settings. ```python self.command( 0xAE, # Display off (all pixels off) 0xA0, 0x53, # Segment remap (com split, com remap, nibble remap, column remap) 0xA1, 0x00, # Display start line 0xA2, 0x00, # Display offset 0xA4, # regular display 0xA8, 0x7F) # set multiplex ratio: 127 ``` ```python self.command( 0xB8, 0x01, 0x11, # Set greyscale table 0x22, 0x32, 0x43, # .. cont 0x54, 0x65, 0x76) # .. cont ``` ```python self.command( 0xB3, 0x00, # Front clock divider: 0, Fosc: 0 0xAB, 0x01, # Enable Internal Vdd 0xB1, 0xF1, # Set phase periods - 1: 1 clk, 2: 15 clks 0xBC, 0x08, # Pre-charge voltage: Vcomh 0xBE, 0x07, # COM deselect voltage level: 0.86 x Vcc 0xD5, 0x62, # Enable 2nd pre-charge 0xB6, 0x0F) # 2nd Pre-charge period: 15 clks ``` -------------------------------- ### luma.oled.device.ssd1327 methods Source: https://luma-oled.readthedocs.io/en/latest/api-documentation.html Methods available for the SSD1327 OLED display driver. ```APIDOC ## ssd1327.capabilities() ### Description Returns a dictionary of capabilities for the SSD1327 device. ### Method `ssd1327.capabilities()` ## ssd1327.cleanup() ### Description Cleans up resources used by the SSD1327 device. ### Method `ssd1327.cleanup()` ## ssd1327.clear() ### Description Clears the display buffer. ### Method `ssd1327.clear()` ## ssd1327.command(cmd, data=None) ### Description Sends a command to the SSD1327 device. ### Method `ssd1327.command(cmd, data=None)` ### Parameters #### Path Parameters - **cmd** (int) - Required - The command to send. - **data** (list[int]) - Optional - A list of data bytes to accompany the command. ## ssd1327.contrast(level) ### Description Sets the contrast level for the SSD1327 display. ### Method `ssd1327.contrast(level)` ### Parameters #### Path Parameters - **level** (int) - Required - The contrast level (0-255). ## ssd1327.data(data) ### Description Sends raw data to the SSD1327 device. ### Method `ssd1327.data(data)` ### Parameters #### Path Parameters - **data** (list[int]) - Required - A list of data bytes to send. ## ssd1327.display(image) ### Description Displays an image on the SSD1327 device. ### Method `ssd1327.display(image)` ### Parameters #### Path Parameters - **image** (PIL.Image.Image) - Required - The image to display. ## ssd1327.hide() ### Description Hides the display content (turns off pixels). ### Method `ssd1327.hide()` ## ssd1327.init_framebuffer() ### Description Initializes the framebuffer for the SSD1327 device. ### Method `ssd1327.init_framebuffer()` ## ssd1327.preprocess(data) ### Description Preprocesses data before sending it to the device. ### Method `ssd1327.preprocess(data)` ### Parameters #### Path Parameters - **data** (bytes) - Required - The raw data to preprocess. ## ssd1327.show() ### Description Shows the current display buffer content on the SSD1327 device. ### Method `ssd1327.show()` ``` -------------------------------- ### display Source: https://luma-oled.readthedocs.io/en/latest/_modules/luma/oled/device.html Takes a 1-bit monochrome or 24-bit RGB image and renders it to the greyscale OLED display. ```APIDOC ## display(image) ### Description Takes a 1-bit monochrome or 24-bit RGB image and renders it to the greyscale OLED display. RGB pixels are converted to 8-bit greyscale values using a simplified Luma calculation, based on *Y'=0.299R'+0.587G'+0.114B'*. ### Parameters - **image**: The image to render. - Type: PIL.Image.Image ``` -------------------------------- ### Check I2C Kernel Modules with dmesg Source: https://luma-oled.readthedocs.io/en/latest/hardware.html Use this command to check if the I2C driver is loaded and to view its initialization details. Look for output related to the BSC controller. ```bash $ dmesg | grep i2c [ 4.925554] bcm2708_i2c 20804000.i2c: BSC1 Controller at 0x20804000 (irq 79) (baudrate 100000) [ 4.929325] i2c /dev entries driver ```