Skip to content

Serial multiplexed display #4880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions components/display/serial_multiplexed_display.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
Serial Shift Register Multiplexed Displays
==========================================

.. seo::
:description: Instructions for setting up a serial shift register based display.
:image: serial_multiplexed_display.jpg

The ``serial_multiplexed_display`` display platform allows you to use (for now) two different kinds of serial shift registers to drive segment displays with ESPHome.

.. figure:: images/serial_multiplexed_display.jpg
:align: center
:width: 75.0%

SN74HC595 Serial Shift Register.

These devices normally require three GPIO inputs, clock, data, and latch. These pins can be configured for the component like below.


.. code-block:: yaml

# Example configuration entry
display:
- platform: serial_multiplexed_display
model: sn74hc595
latch_pin: GPIO35
clk_pin: GPIO34
data_pin: GPIO33
common_cathode: True
reversed: True
lambda: |-
it.printf("%s", "1234");

Configuration variables:
------------------------

- **model** (**Required**, string): The model of the shift register, one of ``sn74hc595``, or ``ct1642``.
- **data_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The pin for serial data.
- **clk_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The pin for the serial clock.
- **latch_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The pin for the latch signal.
- **length** (*Optional*, int): The number of segment displays connected to the shift registers. (defaults to 4, must be between 1 and 8)
- **lambda** (*Optional*, :ref:`lambda <config-lambda>`): The lambda to use for rendering the content on the TM1621.
See :ref:`display-serial_multiplexed_display_lambda` for more information.
- **common_cathode** (*Optional*, boolean): True if the displays are configured as common cathode.
- **reversed** (*Optional*, boolean): True to reverse the display order of the segment displays.
- **update_interval** (*Optional*, :ref:`config-time`): The interval to re-draw the screen. Defaults to ``1s``.
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.

.. _display-serial_multiplexed_display_lambda:

Rendering Lambda
----------------

This component has a similar API to the fully fledged :ref:`display-engine`, but it's only a subset as it's intended to
be used with segment displays (such as 7 segments) and does not have a concept of individual pixels.
In the lambda you're passed a variable called ``it`` as with all other displays. In this case however, ``it`` is a SerialMultiplexedDisplay
instance (see API Reference).

The most basic operation is writing a simple number to the screen as in the configuration example
at the top of this page. But even though you're passing in a string (here ``"1234"``), ESPHome converts it
into a representation that the connected segments can understand.

This component does not support the decimal point on displays, yet.

.. code-block:: yaml

display:
- platform: serial_multiplexed_display
# ...
lambda: |-
it.printf("%d", id(my_sensor1).state);


Please see :ref:`display-printf` for a quick introduction into the ``printf`` formatting rules.

See Also
--------

- :doc:`index`
- :ghedit:`Edit`
Binary file added components/images/serial_multiplexed_display.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions components/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ Display Hardware Platforms
PVVX MiThermometer, components/display/pvvx_mithermometer, xiaomi_lywsd03mmc.jpg
Quad SPI Displays, components/display/qspi_dbi, t4-s3.jpg
RPI_DPI_RGB, components/display/rpi_dpi_rgb, waveshare_touch-s3.jpg
Serial Multiplexed Displays, components/display/serial_multiplexed_display, serial_multiplexed_display.jpg
SSD1306, components/display/ssd1306, ssd1306.jpg
SSD1322, components/display/ssd1322, ssd1322.jpg
SSD1325, components/display/ssd1325, ssd1325.jpg
Expand Down
Binary file added images/serial_multiplexed_display.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading