Skip to content
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

[P139] Add support for AXP2101 Powermanagement #4977

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
652566b
[P139] Add support for AXP2101 Powermanagement
tonhuisman Feb 16, 2024
82d0164
[P139] Exclude AXP2101 from ESP8266 builds
tonhuisman Feb 16, 2024
9c205a7
Cherry pick: [IPv6] Reduce events to keep webserver alive
tonhuisman Feb 17, 2024
f82c0e7
[P139] Add AXP2101 to I2C Scanner
tonhuisman Feb 17, 2024
b1decb9
[P139] Add chargeled and batcharge options, Code cleanup
tonhuisman Feb 17, 2024
9ce252a
Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into …
tonhuisman Feb 18, 2024
6638222
[P139] Add generate events option, chargestate and battery detect, fi…
tonhuisman Feb 19, 2024
934d2d4
Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into …
tonhuisman Feb 21, 2024
c7ab9a4
[P139] Add chipid and chargingdetail support
tonhuisman Feb 21, 2024
d94b904
[String] Add `FsP` macro to convert Flash string to String.c_str() po…
tonhuisman Feb 25, 2024
4e64e06
[P139] Add I2C-enabled check, implement FsP macro
tonhuisman Feb 25, 2024
838d65d
Merge branch 'mega' into feature/P139-add-support-for-axp2101-powerma…
TD-er May 29, 2024
5204f4a
Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into …
tonhuisman Jun 14, 2024
0a2895d
Merge branch 'mega' into feature/P139-add-support-for-axp2101-powerma…
TD-er Jul 3, 2024
9d57884
Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into …
tonhuisman Jul 28, 2024
373a561
Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into …
tonhuisman Sep 27, 2024
dbe7d61
Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into …
tonhuisman Oct 1, 2024
3228353
Merge branch 'mega' into feature/P139-add-support-for-axp2101-powerma…
TD-er Oct 2, 2024
b71f851
Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into …
tonhuisman Oct 3, 2024
bebcf9a
Merge branch 'mega' into feature/P139-add-support-for-axp2101-powerma…
TD-er Oct 7, 2024
c1e4424
Merge branch 'feature/P139-add-support-for-axp2101-powermanagement' o…
tonhuisman Oct 7, 2024
ce55930
Merge branch 'mega' into feature/P139-add-support-for-axp2101-powerma…
tonhuisman Dec 20, 2024
1dcb2ce
Merge branch 'feature/P139-add-support-for-axp2101-powermanagement' o…
tonhuisman Dec 21, 2024
3a5b02b
Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into …
tonhuisman Dec 21, 2024
1828376
Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into …
tonhuisman Jan 18, 2025
a4ae2cb
[P139] Apply some code optimizations
tonhuisman Jan 18, 2025
5433d5a
[P139] Fix silly typos
tonhuisman Jan 18, 2025
655e638
[Libs] AXP2101 corrections
tonhuisman Jan 18, 2025
21c7c37
[P139] Enable writing to AXP2101 chip
tonhuisman Jan 18, 2025
8d02956
[P139] Add documentation
tonhuisman Jan 19, 2025
56e9bf2
[Docs] Priority task updated layout
tonhuisman Jan 19, 2025
678f61c
[P139] Add capturing ADC inputs
TD-er Jan 20, 2025
5ad7b41
[P139] Documentation updates, updated TTGO T-Pcie configuration defaults
tonhuisman Jan 20, 2025
ae33161
[P139] Fix configuration constructor typo
tonhuisman Jan 20, 2025
5b12750
[P139] Add charger settings
TD-er Jan 21, 2025
015ead3
[P139] Split AXP2101_settings to separate file
TD-er Jan 21, 2025
20297f3
[P139] Add charger settings to webform load/save
TD-er Jan 21, 2025
df6e39f
[P139] Move webform_load and _save to P139_data_struct class
TD-er Jan 21, 2025
5485373
[P139] Add functions to apply settings to AXP2101
TD-er Jan 21, 2025
9017809
[P139] Apply setttings to device
TD-er Jan 23, 2025
8f05a54
[P139] Fix build ESP8266
TD-er Jan 23, 2025
c57cdea
[P139] Fix setting defaults for charger settings
TD-er Jan 23, 2025
a2bc54a
[Cleanup] Add FormSelector class to simplify P139 charge options
TD-er Jan 24, 2025
0a684b0
[Cleanup] Convert other charging related settings to use FormSelector
TD-er Jan 24, 2025
65320c8
[P139] Fix ESP8266 build + show device state
TD-er Jan 24, 2025
b85f19d
[P139] Clarify charging state
TD-er Jan 24, 2025
cca1a26
[Cleanup] Simplify addSelector calls
TD-er Jan 24, 2025
b60a6ad
[Cleanup] Change addFormSelector calls to use new class
TD-er Jan 24, 2025
13a0be9
Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into …
tonhuisman Jan 25, 2025
d0540dd
[P139] Uncrustify formatting
tonhuisman Jan 25, 2025
f0ce5f2
[P139] Fix saving settings & predefined, also when task is not enabled
tonhuisman Jan 25, 2025
6301cbe
[P139] Updated TTGO T-Pcie configuration defaults
tonhuisman Jan 25, 2025
3bc83be
[Cleanup] Show reload icon next to selection box triggering page reload
TD-er Jan 25, 2025
a28eccc
[Cleanup] Move more code to use new FormSelectorOptions class
TD-er Jan 25, 2025
bcea8ef
[Cleanup] Convert more code to use new FormSelectorOptions class
TD-er Jan 25, 2025
ec5d0e3
[Cleanup] Move more plugin code to use FormSelectorOptions class
TD-er Jan 25, 2025
8ee4fa8
[P139] Remove PMIC plugins from IRext builds
TD-er Jan 25, 2025
944d314
[Cleanup] Fix build issue on ESP8266
TD-er Jan 25, 2025
f2d004a
[Cleanup] Use new addSelector function of FormSelectorOptions class
TD-er Jan 26, 2025
ec9172e
[Cleanup] Remove no longer used markup functions
TD-er Jan 26, 2025
314fa17
[Cleanup] Add "reloadOnChange" icon for all occasions change will reload
TD-er Jan 26, 2025
2b1e793
[Cleanup] Move duplicate 'tooltip' code to separate function
TD-er Jan 26, 2025
4801202
[Cleanup] Add tooltip about ReloadOnChange icon
TD-er Jan 26, 2025
e1b7fbc
[Cleanup] Reduce build size when using empty class name on FormSelector
TD-er Jan 26, 2025
7b7c2b8
[Cleanup] Reduce bin size using FormSelectOptions class
TD-er Jan 27, 2025
0cb87d0
[Build] Reduce bin size by reducing nr. arguments in addTextBox
TD-er Jan 27, 2025
1148a0d
[Build] Fix build errors on ESP8266
TD-er Jan 27, 2025
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
2 changes: 1 addition & 1 deletion docs/source/Plugin/P137.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Hardware outputs AXP192

* *LilyGO T-Beam* Settings for the LilyGO T-Beam series of GPS/LoRa devices with optional OLed display.

* *User defined* To be able to configure are available output pins the User defined option is available, f.e. when using a custom designed, or not yet supported, hardware setup.
* *User defined* To be able to configure all available output pins the User defined option is available, f.e. when using a custom designed, or not yet supported, hardware setup.

When available, new predefined devices will be added. The User defined option will stay the last option.

Expand Down
198 changes: 198 additions & 0 deletions docs/source/Plugin/P139.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
.. include:: ../Plugin/_plugin_substitutions_p13x.repl
.. _P139_page:

|P139_typename|
==================================================

|P139_shortinfo|

Plugin details
--------------

Type: |P139_type|

Name: |P139_name|

Status: |P139_status|

GitHub: |P139_github|_

Maintainer: |P139_maintainer|

Used libraries: |P139_usedlibraries|

Description
-----------

I2C Power management controller. As found in some ESP32 models of M5Stack and TTGO.

Plugin is only available in ESP32 builds, as the library uses some software constructs that aren't available for ESP8266, and this controller is currently only found to be used with ESP32 boards.

Configuration
--------------

.. image:: P139_DeviceConfiguration.png
:alt: Device configuration

* **Name** A unique name should be entered here.

* **Enabled** The device can be disabled or enabled. When not enabled the device should not use any resources.

.. include:: PriorityTask.rst

I2C Options
^^^^^^^^^^^^

The available settings here depend on the build used. At least the **Force Slow I2C speed** option is available, but selections for the I2C Multiplexer can also be shown. For details see the :ref:`Hardware_page`

Device Settings
^^^^^^^^^^^^^^^^

* **Charge LED**: Select the working of the Charge LED (if that's available on your device). Available options:

.. image:: P139_ChargeLEDOptions.png

* *Off*: Do not turn the LED on during charging.

* *Flash 1Hz*: The LED will flash in a slow 1Hz tempo during charging.

* *Flash 4Hz*: The LED will flash in a somewhat faster 4Hz rate during charging.

* *Steady On*: The LED will be on during charging.

..

* **Generate events**: Generate events when the charging state changes. There are 2 event values for this event: ``<taskname>#ChargingState=<NewState>,<OldState>``.

Hardware ports AXP2101
^^^^^^^^^^^^^^^^^^^^^^

* **Predefined device configuration** The plugin provides presets for some specific devices:

.. image:: P139_PredefinedDeviceOptions.png

* *Select an option to set default values*: This option will always be selected when opening the page.

* *M5Stack Core2 v1.1*: Settings for the M5Stack Core2 v1.1, and some derived special models, hardware (not for v1.0 hardware).

* *M5Stack Core S3*: Settings for the M5Stack S3 hardware.

* *LilyGO T-Beam v1.2*: Settings for the LilyGO T-Beam v1.2 series of GPS/LoRa devices with optional OLed display (not for v1.0 or v1.1 models).

* *LilyGO T-Beam S3 v3*: Settings for the LilyGO T-Beam S3 v3 series hardware.

* *LilyGO T-Pcie v1.2*: Settings for the LilyGO T-Pcie v1.2 series hardware.

* *User defined*: To be able to configure all available ports the User defined option is added, f.e. when using a custom designed, or not yet supported, hardware setup.

When available, new predefined devices will be added. The User defined option will stay the last option.

Depending on the selected configuration, the ports of the AXP2101 can be set at a predefined value. When setting a value below the minimum value (shown next to the voltage selector), the port will be turned off. Above the maximum voltage is not supported/allowed. Stepsize/resolution depends on the port, and can be found in the technical documentation of the AXP2101.

.. warning:: Check board documentation for what each port is actually connected to, and the allowed voltage range for that port.

For the available ports, the initial state can be selected. The available options are:

.. image:: P139_InitialStateOptions.png

* *Off*: Sets the state to off level (0 V).

* *On*: Sets the state to on (high) level.

* *Default*: Doesn't set the state of the port.

If the column shows ``[Protected]`` or ``[Disabled]``, that port is not available for use in the current configuration or in the commands (see below).

Output Configuration
^^^^^^^^^^^^^^^^^^^^

* **Number Output Values**: Select the number of values that have to be available. The default is set to *Quad*, as there are far more than 4 values available for display.

Available options: *Single* (1), *Dual* (2), *Triple* (3) and *Quad* (4).

* **Value 1..4**: Select the desired value to be available in the Values fields. The name of the Values will be set to a matching default automatically, but can be changed afterward.

.. image:: P139_ValueOptions.png

.. image:: P139_ValueOptionsB.png

Available options:

* *None*: To leave the value empty/0.00

* *DCDC1* .. *CPULDOS*: The voltage of the port.

* *ChargeLed*: The state of the Charge LED, 0 = Off, 1 = Flash 1Hz, 2 = Flash 4Hz, 3 = Steady On.

* *BatCharge*: The charge state percentage of the battery.

* *ChargingState*: The state of charging, -1 = discharging, 0 = standby, 1 = charging.

* *BatPresent*: Is a battery present (1) or disconnected (0).

* *ChipID*: The ID set in the chip, 0 = not found, 71 = AXP2101.

* *ChargingDetail*: The detailed state of charging.

* 0: ``tri-charge``
* 1: ``pre-charge``
* 2: ``constant charge (CC)``
* 3: ``constant voltage (CV)``
* 4: ``charge done``
* 5: ``not charging``

* *BatVoltage*: The battery voltage.

* *BatTemp*: The temperature of the battery, (if a battery-temperature sensor is installed).

* *BusVoltage*: The bus-voltage.

* *SysVoltage*: The system-voltage.

* *ChipTemp*: The internal temperature of the chip.


.. note:: Not all options hold usable values for all boards, some may even be not connected. Check the board documentation for available values.

Data Acquisition
^^^^^^^^^^^^^^^^

This group of settings, **Single event with all values**, **Send to Controller** and **Interval** settings are standard available configuration items. Send to Controller is only visible when one or more Controllers are configured.

* **Interval** By default, Interval will be set to 0 sec. as it is optional. When set > 0 it is the frequency used to read sensor values and send these to any Controllers configured for this device.

Values
^^^^^^

The measured values are available in variables, where the initial names are determined by the selected **Value 1..4** settings. A formula can be set to recalculate. The number of decimals can be set as desired, and defaults to 2.

In selected builds, per Value **Stats** options are available, that when enabled, will gather the measured data and present most recent data in a graph, as described here: :ref:`Task Value Statistics: <Task Value Statistics>`

Commands
~~~~~~~~

.. include:: P139_commands.repl


Extra values
~~~~~~~~~~~~

As this plugin has more values available than can be set in the regular Values fields, all values are also available from the Get Config feature.

.. include:: P139_values.repl


Extra events
~~~~~~~~~~~~

Besides the regular events, of ``<taskname>#<valuename>=<value>`` or ``<taskname>#All=<value1>,..<valueN>`` when the **Interval** is set, there can be an extra event generated:

.. include:: P139_events.repl


Change log
----------

.. versionchanged:: 2.0

|added| 2025-01-19 Initially added.
Binary file added docs/source/Plugin/P139_ChargeLEDOptions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/Plugin/P139_DeviceConfiguration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/Plugin/P139_InitialStateOptions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/Plugin/P139_ValueOptions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/Plugin/P139_ValueOptionsB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions docs/source/Plugin/P139_commands.repl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
.. csv-table::
:header: "Command Syntax", "Extra information"
:widths: 20, 30

"
| Commands to control the AXP2101 port voltages & states.
","
| **Attention**: Commands will fail if the selected port is 'Protected' or 'Disabled' according to the selected Predefined device configuration.
"
"
| ``axp,readchip``

","
| List the current values as configured in the chip. The logging level must be set to ``INFO``. This data can be used to configure additional predefined devices.
"
"
| ``axp,voltage,<port>,<voltage>``

| ``port`` one of the available ports.
| ``voltage`` range: 0..<max_port_voltage> mV.
","
| Set selected port to the specified voltage. When set to 0 mV the port will be turned off.
| Ports of the AXP2101: ``DCDC1`` .. ``DCDC4``, ``ALDO1`` .. ``ALDO4``, ``BLDO1``, ``BLDO2``, ``DLDO1``, ``DLDO2`` or ``CPULDOS``.

| The max port voltage depends on the selected port, and is available in the technical documentation of the AXP2101.
"
"
| ``axp,on,<port>``

| ``port`` one of the available ports.
","
| Set the selected AXP2101 port ON.
| Ports of the AXP2101: ``DCDC1`` .. ``DCDC4``, ``ALDO1`` .. ``ALDO4``, ``BLDO1``, ``BLDO2``, ``DLDO1``, ``DLDO2`` or ``CPULDOS``.
"
"
| ``axp,off,<port>``

| ``port`` one of the available ports.
","
| Set the selected AXP2101 port OFF.
| Ports of the AXP2101: ``DCDC1`` .. ``DCDC4``, ``ALDO1`` .. ``ALDO4``, ``BLDO1``, ``BLDO2``, ``DLDO1``, ``DLDO2`` or ``CPULDOS``.
"
"
| ``axp,percentage,<port>,<percentage>``

| ``port`` one of the available Ports.
| ``percentage``: 0 (off/low) or 1..100%
","
| Set the selected port to Off for 0%, or On in range <min_range>..<max_range> for 1..100%.
| Ports of the AXP2101: ``DCDC1`` .. ``DCDC4``, ``ALDO1`` .. ``ALDO4``, ``BLDO1``, ``BLDO2``, ``DLDO1``, ``DLDO2`` or ``CPULDOS``.

| The min and max port voltages depend on the selected port, and are available in the technical documentation of the AXP2101.
"
12 changes: 12 additions & 0 deletions docs/source/Plugin/P139_events.repl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. csv-table::
:header: "Event", "Extra information"
:widths: 20, 30

"
| ``<taskname>#ChargingState=<old_state>,<new_state>``

| ``new_state`` / ``old_state``: ``-1`` (Discharging), ``0`` (Standby) or ``1`` (Charging).

","
| Event generated when the **Generate events** checkbox is enabled.
"
79 changes: 79 additions & 0 deletions docs/source/Plugin/P139_values.repl
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
.. csv-table::
:escape: ^
:widths: 20, 30

"
Most value options can be appended with ``.status`` (or ``.state`` for ``BatCharge`` and any of the ports)
","
| ``.status``: A text representation of the value will be returned, where applicable.
| ``.state``: A numeric representation of the value will be returned (usually the same as if the plain value name was used.)

| Example: ``[<taskname>#ChargingDetail.status]`` will return ``constant charge (CC)`` for ``ChargingDetail`` = 2.
"
"
``[<taskname>#<port>]``
","
| Ports of the AXP2101: ``DCDC1`` .. ``DCDC4``, ``ALDO1`` .. ``ALDO4``, ``BLDO1``, ``BLDO2``, ``DLDO1``, ``DLDO2`` or ``CPULDOS``.
"
"
``[<taskname>#ChargeLed]``
","
| The state of the Charge LED, 0 = ``Off``, 1 = ``Flash 1Hz``, 2 = ``Flash 4Hz``, 3 = ``Steady On``.
"
"
``[<taskname>#BatCharge]``
","
| The charge state percentage of the battery.
"
"
``[<taskname>#ChargingState]``
","
| The state of charging, -1 = ``Discharging``, 0 = ``Standby``, 1 = ``Charging``.
"
"
``[<taskname>#BatPresent]``
","
| Is a battery present (1) or disconnected (0). (no ``.status`` value available)
"
"
``[<taskname>#ChipID]``
","
| The ID set in the chip, 71 = ``AXP2101`` or any numeric value found, returning an empty value for the ``.status`` command-suffix.
"
"
``[<taskname>#ChargingDet]``
","
| The detailed state of charging.

* 0: ``tri-charge``
* 1: ``pre-charge``
* 2: ``constant charge (CC)``
* 3: ``constant voltage (CV)``
* 4: ``charge done``
* 5: ``not charging``
"
"
``[<taskname>#BatVoltage]``
","
| The current voltage of the battery.
"
"
``[<taskname>#BatTemp]``
","
| The temperature of the battery, (if a battery-temperature sensor is installed).
"
"
``[<taskname>#VBus]``
","
| The bus-voltage.
"
"
``[<taskname>#VSys]``
","
| The charge state percentage of the battery.
"
"
``[<taskname>#ChipTemp]``
","
| The internal temperature of the chip.
"
Loading