Documentation for CH422G I/O Expander (#4210)

This commit is contained in:
Andrzej Skowroński 2024-09-02 03:57:36 +02:00 committed by GitHub
parent 31f188f262
commit 397a225f7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 69 additions and 0 deletions

67
components/ch422g.rst Normal file
View File

@ -0,0 +1,67 @@
CH422G I/O Expander
====================
.. seo::
:description: Instructions for setting up CH422G digital port expanders in ESPHome.
:image: ch422g.svg
The CH422G component allows you to use the **CH422G** I/O expander in ESPHome.
It uses an :ref:`I²C Bus <i2c>` for communication.
Once configured, you can use any of the 8 available GPIO pins for your projects.
Within ESPHome they can be used in place of internal GPIO pins in many of ESPHome's components such as the GPIO Binary Sensor or GPIO Switch. They are not usable for PWM or other situations requiring an internal GPIO pin.
.. note::
This I/O Expander chip is used in the *Waveshare ESP32-S3-Touch-LCD-4.3*
.. code-block:: yaml
# Example configuration entry
ch422g:
- id: ch422g_hub
address: 0x24
# Individual outputs
switch:
- platform: gpio
name: CH422G Pin 0
pin:
ch422g: ch422g_hub
number: 0
mode:
output: true
inverted: false
Configuration variables:
************************
- **id** (**Required**, :ref:`config-id`): The id to use for this ``ch422g`` component.
- **address** (*Optional*, int): The I²C address of the driver.
Defaults to ``0x24``.
- **restore_value** (*Optional*, boolean): Writes default flags on setup, overriding values from chips cache.
Defaults to ``false``.
Pin configuration variables:
****************************
- **ch422g** (**Required**, :ref:`config-id`): The id of the ``ch422g`` component of the pin.
- **number** (**Required**, int): The pin number. Valid numbers are 0-7.
- **inverted** (*Optional*, boolean): If all read and written values
should be treated as inverted. Defaults to ``false``.
- **mode** (*Optional*, string): A pin mode to set the pin at. One of ``INPUT`` or ``OUTPUT``.
See Also
--------
- :ref:`i2c`
- :doc:`switch/gpio`
- :doc:`binary_sensor/gpio`
- `CH422G datasheet <https://www.wch-ic.com/downloads/file/315.html?time=2024-07-29%2002:02:32&code=Fxex1sTRHysGLS6ALgh7PTOOZnAACY6KTQx05vzD>`__
- :apiref:`ch422g/ch422g.h`
- :ghedit:`Edit`

1
images/ch422g.svg Normal file
View File

@ -0,0 +1 @@
<svg viewBox="0 0 120 25" id="svg5" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"><defs id="defs9"/><path d="M5 0H115a5 5 0 015 5v15a5 5 0 01-5 5H5a5 5 0 01-5-5V5a5 5 0 015-5z" style="fill:#000" id="path2"/><g aria-label="CH422G" id="component-text" style="font-weight:900;font-size:25px;font-family:Montserrat;letter-spacing:1.1px;fill:#fffffc"><path d="m15.475 21.4q-2.1.0-3.9-.65-1.775-.675-3.1-1.9-1.3-1.225-2.025-2.9-.725-1.675-.725-3.7t.725-3.7q.725-1.675 2.025-2.9 1.325-1.225 3.1-1.875 1.8-.675 3.9-.675 2.575.0 4.55.9 2 .9 3.3 2.6L19.6 9.925q-.775-.975-1.725-1.5-.925-.55-2.1-.55-.925.0-1.675.3t-1.3.875q-.525.575-.825 1.4-.3.8-.3 1.8t.3 1.825q.3.8.825 1.375.55.575 1.3.875t1.675.3q1.175.0 2.1-.525.95-.55 1.725-1.525l3.725 3.325q-1.3 1.675-3.3 2.6-1.975.9-4.55.9z" id="path11"/><path d="m37.474987 3.5h5.9V21h-5.9zm-5.45 17.5h-5.9V3.5h5.9zm5.85-6.45h-6.25V9.7h6.25z" id="path13"/><path d="m46.475009 18v-3.75l7.425-10.75h6.05l-7.15 10.75-2.75-.825h13.55V18zm9.075 3v-3l.175-4.575V10.75h5.55V21z" id="path15"/><path d="m65.500007 21v-3.625l6.325-5.85q.6-.575.875-1 .3-.425.4-.75.1-.35.1-.65.0-.65-.425-1-.425-.375-1.275-.375-.775.0-1.475.425-.7.4-1.1 1.2l-4.45-2.225q.95-1.8 2.85-2.925 1.9-1.125 4.725-1.125 2.075.0 3.675.675t2.5 1.9q.9 1.225.9 2.9.0.85-.225 1.7-.2.85-.85 1.8-.65.925-1.925 2.075l-4.75 4.325-.925-2.05h9.075V21z" id="path17"/><path d="m81.799998 21v-3.625l6.325-5.85q.6-.575.875-1 .3-.425.4-.75.1-.35.1-.65.0-.65-.425-1-.425-.375-1.275-.375-.775.0-1.475.425-.7.4-1.1 1.2l-4.45-2.225q.95-1.8 2.85-2.925 1.9-1.125 4.725-1.125 2.075.0 3.675.675t2.5 1.9q.9 1.225.9 2.9.0.85-.225 1.7-.2.85-.85 1.8-.65.925-1.925 2.075l-4.75 4.325-.925-2.05h9.075V21z" id="path19"/><path d="m107.89999 21.4q-2.125.0-3.925-.65-1.775-.675-3.1-1.9-1.299996-1.225-2.024996-2.9-.725-1.675-.725-3.7t.725-3.7q.725-1.675 2.049996-2.9 1.325-1.225 3.125-1.875 1.825-.675 4-.675 2.6.0 4.625.875 2.05.875 3.375 2.5l-3.775 3.325q-.825-.95-1.8-1.425-.95-.5-2.125-.5-.975.0-1.775.3-.775.3-1.325.875t-.85 1.375-.3 1.825q0 .975.3 1.8.3.8.85 1.375t1.3.9q.775.3 1.725.3 1 0 1.95-.325.95-.35 2.025-1.175l3.3 4.05q-1.6 1.075-3.65 1.65-2.05.575-3.975.575zm2.5-2.975v-6.65h5.125v7.4z" id="path21"/></g></svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -267,6 +267,7 @@ I/O Expanders/Multiplexers
.. imgtable::
CH422G, components/ch422g, ch422g.svg
MAX6956 - I²C Bus, components/max6956, max6956.jpg
MCP230XX - I²C Bus, components/mcp230xx, mcp230xx.svg
MCP23SXX - SPI Bus, components/mcp23Sxx, mcp230xx.svg