Skip to content

Commit

Permalink
Merge branch 'mega' into feature/P045-add-all-axis-option-for-measure…
Browse files Browse the repository at this point in the history
…ments
  • Loading branch information
TD-er authored Dec 9, 2024
2 parents 872c846 + 1cdfec5 commit e5b574c
Show file tree
Hide file tree
Showing 24 changed files with 654 additions and 34 deletions.
68 changes: 64 additions & 4 deletions docs/source/Participate/PlatformIO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PlatformIO
ESP easy can be built using the Arduino IDE or PlatformIO (PIO).
Arduino IDE is not being used during development, so it may take some more effort to get it setup for building ESPeasy.

We advice to use PlatformIO as build environment.
We *strongly* advise to use PlatformIO as build environment.

PlatformIO is just the build, test and upload environment for many micro controllers like the ESP8266 and ESP32 we use.

Expand Down Expand Up @@ -68,6 +68,7 @@ For development of ESPEasy, a number of extensions has to be installed in VS-Cod

* PlatformIO IDE (by PlatformIO)
* C/C++ IntelliSense (by Microsoft)
* C/C++ Extension Pack (by Microsoft)
* Uncrustify (by Zachary Flower, originally by Laurent Tréguier)

Optional, but highly recommended:
Expand All @@ -81,6 +82,7 @@ Optional, but highly recommended:
* reStructuredText Syntax highlighting (by Trond Snekvik)
* Extension pack for reStructuredText (by LeXtudio Inc.)
* Markdown All in One (by Yu Zhang)
* WSL (by Microsoft) (when using WSL2 as documented below)


Uncrustify
Expand All @@ -92,6 +94,8 @@ For new code contributions, it is highly appreciated if the code is formatted us

NB: Uncrustify has to be installed separately, as it is not included in the plugin! Download `Uncrustify from Sourceforge.net <https://sourceforge.net/projects/uncrustify/>`_

When using a Linux OS, f.e. WSL with Ubuntu, uncrustify can be installed via the regular package manager (shown below). It is strongly advised to use version 0.78 or newer, as older versions seem to have some bugs, causing document formatting to fail.

To do so:

* Right click mouse in editor
Expand Down Expand Up @@ -176,10 +180,66 @@ All these mainly apply to the latest ESP32-xx builds using ESP-IDF5.x.
On a beefy desktop PC, like an AMD Ryzen9 with 12 CPU cores, building a ``MAX`` build for ESP32-S3 takes about 10 - 15 minutes on Windows.
The same build when using WSL2 via VS-Code takes only 2 minutes to build.

When using VS-Code with WSL2, the VS-Code editor application runs on Windows, and, via the WSL plugin, communicates with a VS-Code server component on a Linux instance, running on WSL, that has the source code repository available, and where the build process is executed.


Installing WSL2
---------------

For installing WSL2 the following steps are needed. Assumption here is that the default Linux distribution for WSL is used, currently Ubuntu (24.04 LTS), using apt-get as the package manager. Other Linux distributions may use a different package manager, like dnf, zypper or yum, using somewhat different commands. Those commands are not documented here.

Install WSL2 - The Windows part
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* Open a Windows Command prompt, preferrably Powershell, with Administrator privileges (Press the Windows key and start typing ``powershell``, then select Run as administrator)

* Type the command ``wsl --install`` and press <Enter>, this will start the installation procedure, ask for permissions via User Account Control where needed (that must be confirmed), and download and install what's required.

* Once this part of the installation is complete, the computer must be restarted. This will install any additional Windows components that weren't installed yet.

* After logging in to Windows, the installation procedure will be further completed, and you will be asked to enter a username and password for your day-to-day Linux user. This password will be needed later, f.e. when starting the WSL Linux instance, so best practice is to store it in a password safe of some sort (or write it on a Post-It note and stick that under your keyboard ;-))

Install WSL2 - The Linux part
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Now that Linux is installed, it's strongly advised to get it up to date with the latest patches, similar to Windows Update. This should be repeated on a regular basis to keep your installation up to date:

.. highlight::sh
.. code-block::
sudo apt-get update
sudo apt-get upgrade
NB: The ``sudo`` command will ask for your current account password once, (and maybe later again after some time has passed). When asked for confirmation, confirm the installation of any needed updates, or add the ``-y`` parameter to the ``upgrade`` command to continue without questions.

Additionally some tools need to be installed so PlatformIO can be properly installed later, and we can use the Uncrustify plugin in VS-Code to format the code nicely:

.. highlight::sh
.. code-block::
sudo apt-get install python3-venv python3-pip uncrustify
NB: When running an older release of Ubuntu, like 2022.04 LTS, then uncrustify needs to be install/updated manually with a newer version, as the distributed version isn't working correctly. Or your Ubuntu install could be upgraded to 2024.04 (or newer) to correct this issue.

Once this is completed, you can get the ESPEasy code in your WSL Linux file system. By default your Linux instance has access to the same internet connection as the host-computer that's running WSL, so the commands are the same as below for cloning a repository (**Clone your forked repositoryto your computer**)

Start VS-Code from Linux
^^^^^^^^^^^^^^^^^^^^^^^^

Now that the repository is available locally, you can start VS-Code from the root folder of this repository:

.. highlight::sh
.. code-block::
cd ESPEasy
code .
This will install, or update, the VS-Code server component in Linux and then open the VS-Code IDE in your Windows environment, assuming you have installed the suggested WSL plugin in VS-Code.



Linking USB serial adapter to WSL2
----------------------------------
Expand All @@ -190,7 +250,7 @@ After the USB device is 'bound' (shared), it must be attached to a specific wsl
N.B. this must be repeated after a device was unplugged and replugged.

The required steps are described `here <https://learn.microsoft.com/en-us/windows/wsl/connect-usb#attach-a-usb-device>`_
However since this is rather tedious and error prone, it is strongly adviced to use a GUI tool like `WSL USB Manager <https://gitlab.com/alelec/wsl-usb-gui>`_ to perform these steps.
However since this is rather tedious and error prone, it is strongly advised to use a GUI tool like `WSL USB Manager <https://gitlab.com/alelec/wsl-usb-gui>`_ to perform these steps.

After attaching an USB device to a WSL instance, it is best to check whether it was found using `dmesg` via the command line on WSL2.

Expand All @@ -201,7 +261,7 @@ If only an USB device was detected but no `/dev/ttyUSBxx` was assigned, then a m
* ``sudo modprobe cp210x`` - For FTDI CP210x USB to serial chips (small square form factor)
* ``sudo modprobe ftdi_sio`` - For FTDI USB to serial chips with multiple serial ports like the FTDI4232H which has 4 serial ports.

After calling these 'modprobe' commands, the result can be verified using ``lsmod`` and rechecking ``dmesg`` to see which ``/dev/ttyUSBxx`` ports were assigned.
After calling these 'modprobe' commands, the result can be verified using ``lsmod`` and re-checking ``dmesg`` to see which ``/dev/ttyUSBxx`` ports were assigned.

The ownerchip and permissions of these ``/dev/ttyUSBxx`` are probably set like this:

Expand Down Expand Up @@ -455,7 +515,7 @@ Writing documentation

Updating, or adding if it does not yet exist, the documentation is a useful activity that should be part of changing or adding to the ESPEasy code. Some of the optional VSCode extensions are specifically aimed at that task.

The documentation is created in the reStructuredText format, using mostly a ``.rst`` extension, and can be built locally by installing the sphinx tool. This can be installed manually by opening a Terminal window in VSCode (an already open Terminal can also be used) and issuing these commands:
The documentation is created in the reStructuredText format, using mostly a ``.rst`` extension, and can be built locally by installing the sphinx tool. This can be installed manually by opening a PlatformIO Terminal window in VSCode (an already open PIO Terminal can also be used, when using WSL2 a PlatformIO Terminal is *required* to execute in the correct Python Virtual Environment (venv)) and issuing these commands:

.. code-block::
Expand Down
7 changes: 7 additions & 0 deletions docs/source/Plugin/MCP23017_rev_d.repl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. note:: Due to technical reasons, the **MCP23017 rev. D** chip no longer has (official) Input capability on the ``GPA7`` and ``GPB7`` pins!

Following `this news article <https://hackaday.com/2023/02/03/mcp23017-went-through-shortage-hell-lost-two-inputs/>`_, the MCP23017 I2C chip, since **revision D** released around 2022, might possibly no longer accept signals reliably for Input on the ``GPA7`` and ``GPB7`` pins. Other sources (links no longer available) suggest these pins have had issues taking input signals since at least 2014, so your milage may vary! (Output is still working as usual on these pins.)

This may have impact on the use of this board/chip with this plugin when using a MCP23017 rev. D.

Possible alternatives are using an older revision of this chip, or switching to a different chip, like PCF8574 (8 I/O pins), PCF8575 (16 I/O pins, external pull-up), 74HC165 (Input only), 74HC595 (Output only).
2 changes: 2 additions & 0 deletions docs/source/Plugin/P009.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Supported hardware

The chip can be used on specifically designed hardware, or a generic module can be used. These are available from several sources.

.. include:: MCP23017_rev_d.repl

|P009_usedby|

Configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/source/Plugin/P020.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ When selecting the **Event processing** options *Generic* or *RFLink*, after sub
* *(Unchecked)* -> ``Serial``
* *HW Serial0* -> ``serial0``
* *HW Serial0 swap* -> ``serial0``
* *HW Serial0 swap* -> ``serial0swap``
* *HW Serial1* -> ``serial1``
* *HW Serial2* -> ``serial2``
* *SW Serial* -> ``serialsw``
Expand Down
6 changes: 3 additions & 3 deletions docs/source/Plugin/P022_commands.repl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

``[<taskname>].pwm,<pcagpio>,<value>[,<duration>]``

pcagpio: 0 ... 255
pcagpio: 0 ... 15

value: 0 ... 4096

Expand All @@ -25,7 +25,7 @@
"
``[<taskname>].gpio,<pcagpio>,<value>``

pcagpio: 0 ... 255/all
pcagpio: 0 ... 15/all

value: 0/1
","
Expand All @@ -36,7 +36,7 @@
"
``[<taskname>].pulse,<pcagpio>,<value>,<duration>[,<resettimeout>|auto]``

pcagpio: 0 ... 255
pcagpio: 0 ... 15

value: 0/1

Expand Down
19 changes: 14 additions & 5 deletions docs/source/Plugin/P049.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,29 @@ Used libraries: |P049_usedlibraries|
Supported hardware
------------------

|P049_usedby|
.. ..|P049_usedby|
MH-Z19B,
MH-Z19C,
MH-Z19D,
MH-Z19E

Sensor
^^^^^^

See: :ref:`SerialHelper_page`


**TODO**: Complete this documentation...
Commands available
^^^^^^^^^^^^^^^^^^

.. include:: P049_commands.repl

.. Commands available
.. ^^^^^^^^^^^^^^^^^^
Additional infos can be found here: https://emariete.com/en/sensor-co2-mh-z19b/

.. .. include:: P049_commands.repl


**TODO**: Complete this documentation...

.. Events
.. ~~~~~~
Expand Down
24 changes: 24 additions & 0 deletions docs/source/Plugin/P049_commands.repl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.. csv-table::
:header: "Command", "Explanation"
:widths: 20, 30

"
``MHZCalibrateZero``

``MHZReset``

``MHZABCEnable``

``MHZABCDisable``

","
Sets the zero point of the sensor (in this case 400ppm)

Reset to factory defaults

Enables automatic baseline calibration

Disables automatic baseline calibration
"


2 changes: 2 additions & 0 deletions docs/source/Plugin/P061.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ Often used matrix keypads, in 16 and 12 key configuration:

(Image sourced from Aliexpress)

.. include:: MCP23017_rev_d.repl

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

Expand Down
4 changes: 2 additions & 2 deletions docs/source/Plugin/_plugin_substitutions_p04x.repl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
.. |P041_type| replace:: :cyan:`Output`
.. |P041_typename| replace:: :cyan:`Output - NeoPixel (Word Clock)`
.. |P041_porttype| replace:: `.`
.. |P041_status| replace:: :green:`NORMAL` :yellow:`NEOPIXEL`
.. |P041_status| replace:: :yellow:`NEOPIXEL`
.. |P041_github| replace:: P041_NeoClock.ino
.. _P041_github: https://github.com/letscontrolit/ESPEasy/blob/mega/src/_P041_NeoClock.ino
.. |P041_usedby| replace:: `.`
Expand All @@ -28,7 +28,7 @@
.. |P042_type| replace:: :cyan:`Output`
.. |P042_typename| replace:: :cyan:`Output - NeoPixel (Candle)`
.. |P042_porttype| replace:: `.`
.. |P042_status| replace:: :green:`NORMAL` :yellow:`NEOPIXEL`
.. |P042_status| replace:: :yellow:`NEOPIXEL`
.. |P042_github| replace:: P042_Candle.ino
.. _P042_github: https://github.com/letscontrolit/ESPEasy/blob/mega/src/_P042_Candle.ino
.. |P042_usedby| replace:: `.`
Expand Down
6 changes: 3 additions & 3 deletions docs/source/Reference/Command.rst
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,10 @@ P048 :ref:`P048_page`
.. include:: ../Plugin/P048_commands.repl


.. P049 :ref:`P049_page`
.. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
P049 :ref:`P049_page`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. .. include:: ../Plugin/P049_commands.repl
.. include:: ../Plugin/P049_commands.repl


.. P050 :ref:`P050_page`
Expand Down
2 changes: 1 addition & 1 deletion src/_C002.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ bool CPlugin_002(CPlugin::Function function, struct EventStruct *event, String&
switch (Settings.getPluginID_for_task(x).value) {
case 1: // temp solution, if input switch, update state
{
action = strformat(F("gpio,%d,%d"), x, static_cast<int>(nvalue));
action = strformat(F("gpio,%d,%d"), Settings.TaskDevicePin1[x], static_cast<int>(nvalue));
break;
}
case 29: // temp solution, if plugin 029, set gpio
Expand Down
8 changes: 8 additions & 0 deletions src/_P082_GPS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,14 @@ boolean Plugin_082(uint8_t function, struct EventStruct *event, String& string)
# endif // ifndef BUILD_NO_DEBUG
success = true;
}

if (P082_data->gps->course.isUpdated()) {
P082_setOutputValue(event, static_cast<uint8_t>(P082_query::P082_QUERY_COURSE), P082_data->gps->course.deg());
# ifndef BUILD_NO_DEBUG
addLog(LOG_LEVEL_DEBUG, F("GPS: Course update."));
# endif // ifndef BUILD_NO_DEBUG
success = true;
}
}
P082_setOutputValue(event, static_cast<uint8_t>(P082_query::P082_QUERY_SATVIS), P082_data->gps->satellitesStats.nrSatsVisible());
P082_setOutputValue(event, static_cast<uint8_t>(P082_query::P082_QUERY_SATUSE), P082_data->gps->satellitesStats.nrSatsTracked());
Expand Down
10 changes: 5 additions & 5 deletions src/src/CustomBuild/define_plugin_sets.h
Original file line number Diff line number Diff line change
Expand Up @@ -2748,10 +2748,10 @@ To create/register a plugin, you have to :
#define FEATURE_SETTINGS_ARCHIVE 0

#ifndef PLUGIN_BUILD_CUSTOM
#ifdef FEATURE_SERVO
#undef FEATURE_SERVO
#endif
#define FEATURE_SERVO 0
// #ifdef FEATURE_SERVO
// #undef FEATURE_SERVO
// #endif
// #define FEATURE_SERVO 0
#endif
#ifdef FEATURE_RTTTL
#undef FEATURE_RTTTL
Expand Down Expand Up @@ -3210,7 +3210,7 @@ To create/register a plugin, you have to :
#endif

#ifndef FEATURE_SERVO
#define FEATURE_SERVO 0
#define FEATURE_SERVO 1
#endif

#ifndef FEATURE_SETTINGS_ARCHIVE
Expand Down
2 changes: 1 addition & 1 deletion src/src/Helpers/Hardware_GPIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ bool getGpioInfo(int gpio, int& pinnr, bool& input, bool& output, bool& warning)
output = false;
}

if ((gpio >= 6) && (gpio <= 11)) {
if (isFlashInterfacePin_ESPEasy(gpio)) {
// Connected to the integrated SPI flash.
input = false;
output = false;
Expand Down
37 changes: 37 additions & 0 deletions src/src/Helpers/Hardware_device_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,43 @@ int32_t getPartitionInfo(ESP8266_partition_type ptype, uint32_t& address, int32_
bool isFlashInterfacePin_ESPEasy(int gpio) {
#if CONFIG_IDF_TARGET_ESP32

if (getChipFeatures().embeddedFlash ||
getChipFeatures().embeddedPSRAM) {

// See page 20: https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf
if (getChipFeatures().embeddedFlash) {
// ESP32-U4WDH In-Package Flash (4 MB)
// SD_DATA_1 IO0/DI (GPIO-8)
// GPIO17 IO1/DO (GPIO-17)
// SD_DATA_0 IO2/WP# (GPIO-7)
// SD_CMD IO3/HOLD# (GPIO-11)
// SD_CLK CLK (GPIO-6)
// GPIO16 CS# (GPIO-16)
// GND VSS
// VDD_SDIO1 VDD

if (gpio >= 6 && gpio <= 8) return true;
if (gpio == 17 || gpio == 11 || gpio == 16) return true;
}

if (getChipFeatures().embeddedPSRAM) {
// ESP32-D0WDR2-V3 In-Package PSRAM (2 MB)
// SD_DATA_1 SIO0/SI (GPIO-8)
// SD_DATA_0 SIO1/SO (GPIO-7)
// SD_DATA_3 SIO2 (GPIO-10)
// SD_DATA_2 SIO3 (GPIO-9)
// SD_CLK SCLK (GPIO-6)
// GPIO16 CE# (GPIO-16)
// GND VSS
// VDD_SDIO1 VDD
if (gpio >= 6 && gpio <= 10) return true;
if (gpio == 16) return true;

}
return false;
}


// GPIO-6 ... 11: SPI flash and PSRAM
// GPIO-16 & 17: CS for PSRAM, thus only unuable when PSRAM is present
return (gpio) >= 6 && (gpio) <= 11;
Expand Down
Loading

0 comments on commit e5b574c

Please sign in to comment.