Skip to content

Commit

Permalink
Merge branch 'mega' into touchwake
Browse files Browse the repository at this point in the history
  • Loading branch information
chromoxdor authored Dec 11, 2024
2 parents dab591f + 30e4197 commit 140e6f5
Show file tree
Hide file tree
Showing 74 changed files with 3,178 additions and 860 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
Loading

0 comments on commit 140e6f5

Please sign in to comment.