Skip to content

Commit 6254efd

Browse files
authored
Merge pull request #29 from luc-github/refactoring
Refactoring for better maintenance and improve reliability
2 parents 09fb609 + 2c3374b commit 6254efd

73 files changed

Lines changed: 7105 additions & 3076 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version: "20"
17+
cache: npm
18+
- run: npm ci
19+
- run: npm run validate:config
20+
- run: npm run build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules
33
.vscode
44
build/*.map
55
tmp/
6+

API.md

Lines changed: 447 additions & 52 deletions
Large diffs are not rendered by default.

CONTRIBUTING.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Contributing to ESP3D-Configurator
2+
3+
Thank you for helping improve the configurator. This guide covers local development; the configuration schema is documented in [API.md](API.md).
4+
5+
## Getting started
6+
7+
### Requirements
8+
9+
- Node.js **20+**
10+
- npm
11+
12+
### Setup
13+
14+
```bash
15+
git clone https://github.com/luc-github/ESP3D-Configurator.git
16+
cd ESP3D-Configurator
17+
npm ci
18+
npm run dev
19+
```
20+
21+
The `dev` script runs the webpack dev server and the small Express server in `config/server.js`. Use the URL from the terminal output.
22+
23+
Production build (static site, e.g. GitHub Pages):
24+
25+
```bash
26+
npm run build
27+
```
28+
29+
Output is under `build/` (mainly `index.html` and bundled assets).
30+
31+
## Scripts
32+
33+
| Command | When to use |
34+
|---------|-------------|
35+
| `npm run dev` | Day-to-day UI work |
36+
| `npm run build` | Before PR; verify production bundle |
37+
| `npm run validate:config` | After editing any `src/configuration/tabs/*.json` or `boardPresets.json` |
38+
| `npm run sync:pin-roles` | After editing `pinUsageRoles.json` (writes `pinRole` into tab JSON) |
39+
| `npm run check:esp3d` | Optional: compare camera models to a local ESP3D clone in `tmp/esp3d` |
40+
41+
## Pull request checklist
42+
43+
- [ ] `npm run validate:config` passes
44+
- [ ] `npm run build` passes (same as CI)
45+
- [ ] New field ids are **unique** across all tab JSON files
46+
- [ ] New UI strings added to `src/translations/en.json`
47+
- [ ] Manually tested: affected wizard tab(s), Download preview, import/preset if touched
48+
- [ ] [API.md](API.md) updated if you change schema, export format, presets, or tooling
49+
50+
CI (`.github/workflows/ci.yml`) runs `validate:config` + `build` on pushes and PRs to `main` / `master`.
51+
52+
## Common change types
53+
54+
### New firmware option (define)
55+
56+
1. Add control in the right `src/configuration/tabs/<section>.json`.
57+
2. Set `define`, `type`, `setting`, `depend` as needed.
58+
3. Confirm the macro exists in [ESP3D](https://github.com/luc-github/ESP3D) firmware.
59+
4. See **Quick checklist: new feature flag** in [API.md](API.md).
60+
61+
### New board preset
62+
63+
1. Edit `src/configuration/boardPresets.json`.
64+
2. `npm run validate:config`
65+
3. Test on Features → preset dropdown.
66+
67+
### Pin / GPIO behaviour
68+
69+
- Lists: `src/tabs/step/pins.json`, `ports.json`
70+
- MCU rules: `pinCapabilities.js`, `mcuPinDefaults.js`, `psramReservedPins.js`
71+
- Roles: `pinUsageRoles.json` + `npm run sync:pin-roles`
72+
73+
Details: [API.md — Pin and port allocation](API.md#pin-and-port-allocation).
74+
75+
### Import / snapshot format
76+
77+
Logic: `src/configuration/configurationSnapshot.js`. Do not break markers `ESP3D_CONFIG_SNAPSHOT_BEGIN` / `END` without a version bump and migration note in API.md.
78+
79+
## Optional: ESP3D reference tree
80+
81+
To run `npm run check:esp3d`:
82+
83+
```text
84+
tmp/
85+
esp3d/ # clone of ESP3D repo
86+
platformio.ini # optional reference copy
87+
```
88+
89+
## Code style
90+
91+
- Match existing patterns in the file you edit (Preact, Spectre CSS, JSON-driven config).
92+
- Prefer small, focused diffs; avoid unrelated refactors in the same PR.
93+
- Comments only for non-obvious behaviour (see project conventions in existing modules).
94+
95+
## Questions
96+
97+
Open a [GitHub issue](https://github.com/luc-github/ESP3D-Configurator/issues) for bugs or feature discussion. For schema questions, cite [API.md](API.md) and the relevant `tabs/*.json` path.

README.md

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,67 @@
33
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)
44
<!-- ALL-CONTRIBUTORS-BADGE:END -->
55

6-
Project of Web Configurator to generate ESP3D configuration file.
6+
Web configurator to build **ESP3D 3.x** firmware settings: wizard UI → `configuration.h` and `platformio.ini`.
77

8-
Using github-action / issues form bring too many constraints with not really great user experience, so I went for
9-
a standalone html file instead, and it is hosted in github static page area
10-
It use same element as ESP3D-WebUI to save development time (yeah I am super lazy...):
8+
**Live demo:** [luc-github.github.io](https://luc-github.github.io/)
119

12-
- nodejs
13-
- webpack
14-
- spectre.css
15-
- Preact
10+
## Features (overview)
1611

17-
It should be something similar to https://www.repetier.com/firmware/v100/index.php but in one static page so it should work online hosted by github or offline on user PC
12+
- Step-by-step wizard (Features, Network, Filesystems, Devices, …)
13+
- Board **presets** and **import** of a previous `configuration.h` (JSON snapshot at end of file)
14+
- Pin conflict detection before download
15+
- Light / dark UI theme
1816

19-
> [!WARNING]
20-
>### Disclaimer
21-
> The software is provided 'as is,' without any warranty of any kind, expressed or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.
22-
>It is essential that you carefully read and understand this disclaimer before using this software and its components. If you do not agree with any part of this disclaimer, please refrain from using the software.
17+
## Documentation
18+
19+
| Doc | Description |
20+
|-----|-------------|
21+
| [API.md](API.md) | Configuration schema, tabs, pins, export/import, presets, planned work |
22+
| [CONTRIBUTING.md](CONTRIBUTING.md) | Development setup, npm scripts, PR checklist, CI |
23+
24+
## Development
25+
26+
**Requirements:** Node.js 20+, npm.
27+
28+
```bash
29+
npm ci
30+
npm run dev # local development
31+
npm run build # production bundle in build/
32+
```
33+
34+
**Quality checks (run before a PR):**
35+
36+
```bash
37+
npm run validate:config
38+
npm run build
39+
```
40+
41+
CI runs the same steps on GitHub Actions (see `.github/workflows/ci.yml`).
42+
43+
### Stack
2344

24-
The configurator is available [here](https://luc-github.github.io/)
45+
- Node.js, webpack
46+
- [Preact](https://preactjs.com/)
47+
- [Spectre.css](https://picturepan2.github.io/spectre/)
48+
49+
The UI reuses patterns from ESP3D-WebUI to keep maintenance aligned across projects.
50+
51+
## Using the configurator (makers)
52+
53+
1. Walk the wizard tabs and set your board (MCU, flash, WiFi, pins, …).
54+
2. On **Download**, resolve any **pin conflicts**, then download `configuration.h` and `platformio.ini`.
55+
3. To restore settings later: **Features****Import configuration.h** (file must have been generated by this tool so the JSON snapshot is present).
56+
57+
See [API.md — Configuration snapshot](API.md#configuration-snapshot-in-configurationh-only) for technical details.
58+
59+
## Project history
60+
61+
GitHub issue forms were dropped in favour of a **single static page** (works hosted on GitHub Pages or offline), similar in spirit to [Repetier’s firmware configurator](https://www.repetier.com/firmware/v100/index.php).
62+
63+
> [!WARNING]
64+
> ### Disclaimer
65+
> The software is provided "as is," without any warranty of any kind, expressed or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.
66+
> It is essential that you carefully read and understand this disclaimer before using this software and its components. If you do not agree with any part of this disclaimer, please refrain from using the software.
2567
2668
## Contributors ✨
2769

@@ -43,4 +85,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
4385

4486
<!-- ALL-CONTRIBUTORS-LIST:END -->
4587

46-
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
88+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome — see [CONTRIBUTING.md](CONTRIBUTING.md).

build/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/esp3d-camera-custom-pins.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# ESP3D — Camera CUSTOM pins and configurator
2+
3+
When **Camera type = Custom**, the configurator emits camera GPIO overrides in `configuration.h`:
4+
5+
```c
6+
#define CAMERA_DEVICE CAMERA_MODEL_CUSTOM
7+
#define PWDN_GPIO_NUM 32
8+
#define XCLK_GPIO_NUM 0
9+
// ...
10+
```
11+
12+
ESP3D loads `configuration.h` before `esp3d_pins.h`. The firmware **CUSTOM** pin block must use `#ifndef` / `#define` / `#endif` so these values take effect (see ESP3D `esp3d/src/include/esp3d_pins.h`).
13+
14+
Predefined models use fixed maps in firmware; the configurator shows those pins read-only from `src/configuration/cameraPinMaps.json`.

info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "1.0.34"
2+
"version": "1.1.0"
33
}

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"front": "webpack serve --config config/webpack.dev.js ",
99
"server": "nodemon config/server.js",
1010
"dev": "concurrently \"npm run server\" \"npm run front\"",
11-
"build": "webpack --config config/webpack.prod.js"
11+
"build": "webpack --config config/webpack.prod.js",
12+
"validate:config": "node tools/validate_configuration.js",
13+
"sync:pin-roles": "node tools/sync_pin_roles.js",
14+
"check:esp3d": "node tools/check_esp3d_reference.js"
1215
},
1316
"author": "",
1417
"license": "ISC",

src/components/App/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818
import { h } from "preact"
19-
export const Version = "1.0.34"
19+
export const Version = "1.1.0"

0 commit comments

Comments
 (0)