[DOC] Update README.md (#15)
Reviewed-on: #15
This commit was merged in pull request #15.
This commit is contained in:
1 parent
c3e8893ea5
commit
261e7c146a
1 file changed
+72
-9
@@ -8,9 +8,10 @@
|
||||
6. [MuteDeck integration](#user-content-mutedeck-integration)
|
||||
7. [Electronic parts](#user-content-electronic-parts)
|
||||
8. [Firmware installation](#user-content-firmware-installation)
|
||||
9. [3D files - Enclosure](#user-content-3d-files---enclosure)
|
||||
10. [Wiring / Soldering](#user-content-wiring--soldering)
|
||||
11. [Tools & libs](#user-content-tools--libs)
|
||||
9. [Building the precompiled files (.mpy)](#user-content-building-the-precompiled-files-mpy)
|
||||
10. [3D files - Enclosure](#user-content-3d-files---enclosure)
|
||||
11. [Wiring / Soldering](#user-content-wiring--soldering)
|
||||
12. [Tools & libs](#user-content-tools--libs)
|
||||
|
||||
# What's this project?
|
||||
|
||||
@@ -30,7 +31,7 @@ It comes with a with a simplistic but neat **Web UI** and a simple (but hopefull
|
||||
|
||||
# Web UI
|
||||
|
||||
A very simplistic but neat UI is available on port `80` (thanks @nicolaeser).
|
||||
A very simplistic but neat UI is available on port `80` (thanks [@nicolaeser](https://github.com/nicolaeser)).
|
||||
Default hostname is `igox-busylight`.
|
||||
|
||||
You can try to reach the web UI @ <http://igox-busylight.local>.
|
||||
@@ -211,14 +212,76 @@ It will automatically switch to the BusyLight in:
|
||||
|
||||

|
||||
|
||||
> 💡 **Memory tip:** the application code lives in `busylight.py`. To save RAM at boot, precompile it and copy `busylight.mpy` to the ESP32 instead of `busylight.py` (if both are present, MicroPython loads the `.py` one, so delete `busylight.py` from the device):
|
||||
> ```sh
|
||||
> pip install "mpy-cross>=1.24,<1.25"
|
||||
> mpy-cross -march=xtensawin ESP32/busylight.py
|
||||
> ```
|
||||
> 💡 **Memory tip:** the application code lives in `busylight.py`. To save RAM at boot, copy the precompiled `busylight.mpy` to the ESP32 instead of `busylight.py` (if both are present, MicroPython loads the `.py` one, so delete `busylight.py` from the device). See [Building the precompiled files (.mpy)](#user-content-building-the-precompiled-files-mpy) to rebuild it after modifying `busylight.py`.
|
||||
|
||||
**Done!**
|
||||
|
||||
# Building the precompiled files (.mpy)
|
||||
|
||||
`busylight.mpy` is generated from `busylight.py` using `mpy-cross`, the MicroPython cross-compiler. It must be rebuilt every time `busylight.py` is modified, otherwise the ESP32 keeps running the previous code.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- **Python 3.8+** with `pip` on your computer (check with `python3 --version`).
|
||||
- **`mpy-cross` matching the firmware version**: the `.mpy` format is tied to the MicroPython version. With MicroPython **v1.24.x** on the ESP32, use `mpy-cross` **v1.24.x** (`.mpy` format v6.3). A mismatched version produces `ValueError: incompatible .mpy file` when importing on the device.
|
||||
|
||||
## Install `mpy-cross`
|
||||
|
||||
Using a dedicated virtual environment is recommended, to avoid conflicts with other Python packages.
|
||||
|
||||
macOS / Linux:
|
||||
|
||||
```sh
|
||||
python3 -m venv ~/.venvs/mpy-cross
|
||||
source ~/.venvs/mpy-cross/bin/activate
|
||||
pip install "mpy-cross>=1.24,<1.25"
|
||||
mpy-cross --version
|
||||
```
|
||||
|
||||
Windows (PowerShell):
|
||||
|
||||
```powershell
|
||||
py -3 -m venv $HOME\.venvs\mpy-cross
|
||||
& $HOME\.venvs\mpy-cross\Scripts\Activate.ps1
|
||||
pip install "mpy-cross>=1.24,<1.25"
|
||||
mpy-cross --version
|
||||
```
|
||||
|
||||
`mpy-cross --version` must print something like `MicroPython v1.24.1 ... mpy-cross emitting mpy v6.3`.
|
||||
|
||||
## Build `busylight.mpy`
|
||||
|
||||
From the root of this repository (with the virtual environment activated):
|
||||
|
||||
```sh
|
||||
mpy-cross -march=xtensawin ESP32/busylight.py
|
||||
```
|
||||
|
||||
This creates (or overwrites) `ESP32/busylight.mpy`. No output means success; syntax errors in `busylight.py` are reported with their line number.
|
||||
|
||||
- `-march=xtensawin` targets the ESP32 CPU architecture (Xtensa). Use `-march=rv32imc` instead for RISC-V based boards (ESP32-C3 / C6).
|
||||
- Use `-o <path>` to choose another output file, e.g. `mpy-cross -march=xtensawin -o /tmp/busylight.mpy ESP32/busylight.py`.
|
||||
|
||||
## Deploy and check
|
||||
|
||||
1. Copy `ESP32/busylight.mpy` to the root of the ESP32 file system (e.g. with Thonny).
|
||||
2. Make sure `busylight.py` is **not** present on the ESP32.
|
||||
3. Reset the ESP32. At startup, the console should print a line like `Memory: python heap free ... B, IDF heap free ... B`.
|
||||
|
||||
To confirm the precompiled module is the one being loaded, run in the ESP32 REPL: `import busylight; print(busylight.__file__)` (it must end with `.mpy`).
|
||||
|
||||
## Rebuilding Microdot (optional)
|
||||
|
||||
The precompiled Microdot files in [ESP32/lib/microdot](ESP32/lib/microdot) only need to be rebuilt when changing the Microdot version:
|
||||
|
||||
```sh
|
||||
pip download microdot==2.0.6 --no-deps -d /tmp/microdot
|
||||
unzip -o /tmp/microdot/microdot-2.0.6-py3-none-any.whl -d /tmp/microdot/src
|
||||
for f in __init__ microdot helpers websocket; do
|
||||
mpy-cross -march=xtensawin -o ESP32/lib/microdot/$f.mpy /tmp/microdot/src/microdot/$f.py
|
||||
done
|
||||
```
|
||||
|
||||
# 3D files - Enclosure
|
||||
|
||||
All the required 3D files (STLs and f3d project) to 3D print the enclosure are available in the [3D-files-to-print](3D-files-to-print) folder.
|
||||
|
||||
Reference in new issue
Block a user