From 4437927bdcc75ef9720bf7cb138cac50daadde73 Mon Sep 17 00:00:00 2001 From: luckydizzier <134082331+luckydizzier@users.noreply.github.com> Date: Thu, 19 Jun 2025 04:58:11 +0200 Subject: [PATCH] Add ESP web UI and configuration docs --- README.md | 5 + docs/README.md | 1 + docs/configuration/ota.md | 10 ++ docs/configuration/pins.md | 24 ++++ docs/impl/commands.md | 3 + docs/impl/esp8266.md | 2 + docs/impl/hardware_connection_map.md | 2 + docs/impl/ota_update.md | 1 + ...06-19_04-55-19_docs_agent_configuration.md | 6 + .../2025-06-19_04-55-19_ui_agent_web_ui.md | 6 + firmware/esp/main.ino | 111 +++++++++++++++--- firmware/esp/web_ui/index.html | 44 +++++++ 12 files changed, 201 insertions(+), 14 deletions(-) create mode 100644 docs/configuration/ota.md create mode 100644 docs/configuration/pins.md create mode 100644 docs/progress/2025-06-19_04-55-19_docs_agent_configuration.md create mode 100644 docs/progress/2025-06-19_04-55-19_ui_agent_web_ui.md create mode 100644 firmware/esp/web_ui/index.html diff --git a/README.md b/README.md index cbbe3b1..70de6b3 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,11 @@ The project is fully documented in `docs/` and follows the architecture describe - Configuration stored in 24LC256 EEPROM - Cross-platform CLI and experimental GUI tools +Pin assignments and OTA usage are documented in +[`docs/configuration/pins.md`](docs/configuration/pins.md) and +[`docs/configuration/ota.md`](docs/configuration/ota.md). All peripherals, +except the LCD shield, must use Arduino pins 20 and above. + ## Directory Overview - `firmware/` – Arduino Due and ESP8266 source code diff --git a/docs/README.md b/docs/README.md index 39e14b8..637cc5d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -3,3 +3,4 @@ This folder contains design notes, implementation guides and progress logs for DDS-Controller. Each subfolder focuses on a specific area of the project. ESP8266-01 support and configuration details are documented under `docs/impl/esp8266.md`. +Pin mapping and OTA instructions can be found in `docs/configuration/`. diff --git a/docs/configuration/ota.md b/docs/configuration/ota.md new file mode 100644 index 0000000..34a5df2 --- /dev/null +++ b/docs/configuration/ota.md @@ -0,0 +1,10 @@ +# OTA Update Instructions + +OTA updates rely on the ESP8266-01 bootloader pin **GPIO0**. When `USE_ESP_OTA` is set, keep this pin free from other hardware so the module can enter boot mode. Toggle the pin low only during firmware upload. + +1. Enable `USE_ESP=1` and `USE_ESP_OTA=1` in `config/pins.conf`. +2. Connect the ESP8266-01 to your WiFi network. +3. Upload new firmware through the web interface or `espota.py`. +4. After a successful upload the module restarts automatically. + +For a detailed walkthrough see `docs/guides/ota_esp8266.md`. diff --git a/docs/configuration/pins.md b/docs/configuration/pins.md new file mode 100644 index 0000000..ad6f0d0 --- /dev/null +++ b/docs/configuration/pins.md @@ -0,0 +1,24 @@ +# Pin Assignments + +This table lists all recommended connections for the DDS-Controller hardware. The ESP8266-01 module works at **3.3V** logic levels only. All peripherals except the LCD shield must be connected on Arduino pins **20** and above. + +| Arduino Pin | Peripheral | Function | +|-------------|-------------|-------------------| +| 8,9,4,5,6,7 | LCD Shield | RS,E,D4,D5,D6,D7 | +| A0 | LCD Shield | Buttons ADC | +| 10 | AD9850 | WCLK | +| 11 | AD9850 | FQUD | +| 12 | AD9850 | DATA | +| 13 | AD9850 | RESET | +| 20 | ESP8266-01 | RX (from Due TX) | +| 21 | ESP8266-01 | TX (to Due RX) | +| 24 | ESP8266-01 | GPIO2 status LED | +| 25 | DDS Output | Control line | +| 26 | ESP8266-01 | GPIO0 (OTA) | + +``` +D20..D53 -> custom peripherals +< D20 -> reserved for shield and internal functions +``` + +See `docs/hardware/pinmap.md` for an expanded diagram. diff --git a/docs/impl/commands.md b/docs/impl/commands.md index 3bf11f9..182f3f6 100644 --- a/docs/impl/commands.md +++ b/docs/impl/commands.md @@ -16,3 +16,6 @@ implemented constants and their meaning. Commands for saving or loading presets continue to use the words `SAVE` and `LOAD`. The constants keep request strings short while responses still use the human-readable tokens documented in `command_spec.md`. + +Hardware pin names referenced here match the tables in +[`docs/configuration/pins.md`](../configuration/pins.md). diff --git a/docs/impl/esp8266.md b/docs/impl/esp8266.md index 4e9f01f..62b0bf2 100644 --- a/docs/impl/esp8266.md +++ b/docs/impl/esp8266.md @@ -65,5 +65,7 @@ Ensure the `ota_mode` setting in your ESP firmware matches this wiring. ## See Also - `docs/hardware/pinmap.md` – authoritative wiring table +- `docs/configuration/pins.md` – quick reference pin list - `docs/guides/ota_esp8266.md` – step‑by‑step OTA procedure +- `docs/configuration/ota.md` – summary of OTA mode behaviour diff --git a/docs/impl/hardware_connection_map.md b/docs/impl/hardware_connection_map.md index ae36bc6..141fae6 100644 --- a/docs/impl/hardware_connection_map.md +++ b/docs/impl/hardware_connection_map.md @@ -4,7 +4,9 @@ This file lists the recommended wiring between the Arduino Due, AD9850, and ESP8 See also: - `docs/config/pins.conf` – editable pin assignments +- `docs/configuration/pins.md` – reference table - `docs/impl/ota_update.md` – OTA flashing procedure +- `docs/configuration/ota.md` – brief OTA notes | Peripheral | Signal | Due Pin | |------------|-------|--------| diff --git a/docs/impl/ota_update.md b/docs/impl/ota_update.md index c3e4089..2bb18f1 100644 --- a/docs/impl/ota_update.md +++ b/docs/impl/ota_update.md @@ -9,3 +9,4 @@ Steps: 4. The Arduino Due should avoid toggling GPIO0 during the upload. See also `docs/guides/ota_esp8266.md` for a walkthrough. +Quick reference: [`docs/configuration/ota.md`](../configuration/ota.md) diff --git a/docs/progress/2025-06-19_04-55-19_docs_agent_configuration.md b/docs/progress/2025-06-19_04-55-19_docs_agent_configuration.md new file mode 100644 index 0000000..e6a8769 --- /dev/null +++ b/docs/progress/2025-06-19_04-55-19_docs_agent_configuration.md @@ -0,0 +1,6 @@ +# docs_agent Progress Log +Date: 2025-06-19 04:55:19 CEST + +- Created `docs/configuration/pins.md` with full pin map and 3.3V notice. +- Created `docs/configuration/ota.md` summarising OTA update steps. +- Linked new docs from README and implementation guides. diff --git a/docs/progress/2025-06-19_04-55-19_ui_agent_web_ui.md b/docs/progress/2025-06-19_04-55-19_ui_agent_web_ui.md new file mode 100644 index 0000000..93ef864 --- /dev/null +++ b/docs/progress/2025-06-19_04-55-19_ui_agent_web_ui.md @@ -0,0 +1,6 @@ +# ui_agent Progress Log +Date: 2025-06-19 04:55:19 CEST + +- Added minimal Web UI HTML page under `firmware/esp/web_ui/index.html`. +- Implemented ESP8266 web server with JSON endpoints for pin states and config. +- Web UI allows editing pin assignments and toggling output lines. diff --git a/firmware/esp/main.ino b/firmware/esp/main.ino index cf1b447..1f6883f 100644 --- a/firmware/esp/main.ino +++ b/firmware/esp/main.ino @@ -1,19 +1,102 @@ +#include +#include +#include "../shared/config/config.h" +#include "../shared/config/pins.h" + +struct ConfigState { + bool use_esp = USE_ESP; + bool use_esp_ota = USE_ESP_OTA; + int pin_dds_wclk = PIN_DDS_WCLK; + int pin_dds_fqud = PIN_DDS_FQUD; + int pin_dds_data = PIN_DDS_DATA; + int pin_dds_reset = PIN_DDS_RESET; + int pin_esp_rx = PIN_ESP_RX; + int pin_esp_tx = PIN_ESP_TX; + int pin_esp_led = PIN_ESP_LED; + int pin_output_control = PIN_OUTPUT_CONTROL; + int pin_esp_gpio0 = PIN_ESP_GPIO0; +} cfg; + +ESP8266WebServer server(80); + +const char index_html[] PROGMEM = R"rawliteral( +#include "web_ui/index.html" +)rawliteral"; + +void handle_root() { + server.send_P(200, "text/html", index_html); +} + +void handle_get_config() { + String json = "{"; + json += "\"USE_ESP\":" + String(cfg.use_esp ? 1 : 0) + ","; + json += "\"USE_ESP_OTA\":" + String(cfg.use_esp_ota ? 1 : 0) + ","; + json += "\"PIN_ESP_RX\":" + String(cfg.pin_esp_rx) + ","; + json += "\"PIN_ESP_TX\":" + String(cfg.pin_esp_tx) + ","; + json += "\"PIN_ESP_LED\":" + String(cfg.pin_esp_led) + ","; + json += "\"PIN_OUTPUT_CONTROL\":" + String(cfg.pin_output_control) + ","; + json += "\"PIN_ESP_GPIO0\":" + String(cfg.pin_esp_gpio0); + json += "}"; + server.send(200, "application/json", json); +} + +void handle_get_pins() { + String json = "{"; + json += "\"LED\":" + String(digitalRead(cfg.pin_esp_led)) + ","; + json += "\"OUT\":" + String(digitalRead(cfg.pin_output_control)); + json += "}"; + server.send(200, "application/json", json); +} + +void handle_set_pins() { + String body = server.arg("plain"); + if (body.indexOf("\"LED\":1") != -1) { + digitalWrite(cfg.pin_esp_led, HIGH); + } else if (body.indexOf("\"LED\":0") != -1) { + digitalWrite(cfg.pin_esp_led, LOW); + } + if (body.indexOf("\"OUT\":1") != -1) { + digitalWrite(cfg.pin_output_control, HIGH); + } else if (body.indexOf("\"OUT\":0") != -1) { + digitalWrite(cfg.pin_output_control, LOW); + } + handle_get_pins(); +} + +void handle_status() { + String json = "{"; + json += "\"wifi\":" + String(WiFi.status() == WL_CONNECTED ? 1 : 0) + ","; + json += "\"ota\":" + String(cfg.use_esp_ota ? 1 : 0); + json += "}"; + server.send(200, "application/json", json); +} + void setup() { - Serial.begin(115200); // debug console - Serial1.begin(115200); // link to Arduino Due - Serial.println("ESP bridge ready"); + Serial.begin(115200); + Serial1.begin(ESP_BAUD_RATE); + pinMode(cfg.pin_esp_led, OUTPUT); + pinMode(cfg.pin_output_control, OUTPUT); + + WiFi.mode(WIFI_STA); + WiFi.begin("DDS", "password"); + + server.on("/", handle_root); + server.on("/api/config", HTTP_GET, handle_get_config); + server.on("/api/pins", HTTP_GET, handle_get_pins); + server.on("/api/pins", HTTP_POST, handle_set_pins); + server.on("/api/status", HTTP_GET, handle_status); + server.begin(); + Serial.println("ESP web server ready"); } void loop() { - if (Serial.available()) { - String line = Serial.readStringUntil('\n'); - Serial1.println(line); // forward to Due - Serial.print("TX: "); - Serial.println(line); - } - if (Serial1.available()) { - String line = Serial1.readStringUntil('\n'); - Serial.print("RX: "); - Serial.println(line); - } + server.handleClient(); + if (Serial.available()) { + String line = Serial.readStringUntil('\n'); + Serial1.println(line); + } + if (Serial1.available()) { + String line = Serial1.readStringUntil('\n'); + Serial.println(line); + } } diff --git a/firmware/esp/web_ui/index.html b/firmware/esp/web_ui/index.html new file mode 100644 index 0000000..e8e0fff --- /dev/null +++ b/firmware/esp/web_ui/index.html @@ -0,0 +1,44 @@ + + + + + + DDS Vezérlő + + + +

DDS WiFi vezérlés

+
Állapot lekérése...
+
+ + + +