Cleanup pins

This commit is contained in:
2026-06-16 19:04:50 +10:00
parent 1706186727
commit f0cd430eb9
3 changed files with 25 additions and 10 deletions
+11
View File
@@ -242,6 +242,8 @@
<option value="921600">921600</option>
</select>
</div>
<button class="danger" onclick="doReset()" title="Pulse the target reset line">Reset</button>
<button onclick="doButton()" title="Pulse the target button / wake line">Button</button>
<button onclick="clearTerminal()">Clear</button>
<button onclick="reconnect()">Reconnect</button>
<button id="logBtn" onclick="toggleLog()">Log: --</button>
@@ -591,6 +593,15 @@
return (bytes / 1024 / 1024).toFixed(1) + ' MB';
}
// ---- Target control lines (reset / button) ----
function pulseLine(path, label) {
fetch(path + '?ms=200').then(r => r.text())
.then(t => term.writeln(`\r\n\x1b[33m[${label}] ${t.trim()}\x1b[0m`))
.catch(() => term.writeln(`\r\n\x1b[31m[${label} failed]\x1b[0m`));
}
function doReset() { pulseLine('/api/reset', 'reset'); }
function doButton() { pulseLine('/api/button', 'button'); }
// ---- SD logging controls ----
let logOn = false;
function toggleLog() {
+5 -3
View File
@@ -83,9 +83,11 @@ build_flags =
; --- target UART bridge (wire to the sensor's debug UART) ---
-DTARGET_RX_PIN=44 ; CONFIRM: dongle RX <- sensor TX
-DTARGET_TX_PIN=43 ; CONFIRM: dongle TX -> sensor RX
; --- GPIO control lines to the target (reset / wake) ---
-DGPIO_RESET_PIN=2 ; CONFIRM: -> sensor RST
-DGPIO_WAKE_PIN=1 ; CONFIRM: -> sensor control/wake pin
; --- GPIO control lines to the target (reset out / button out) ---
; GPIO4 + GPIO12 are free, broken-out pins on the T3-S3. (Earlier 2/1 were
; wrong: GPIO2 is the SD MISO and GPIO1 is the battery-ADC pin.)
-DGPIO_RESET_PIN=4 ; -> sensor RST (active-low pulse)
-DGPIO_WAKE_PIN=12 ; -> sensor button/wake (active-low pulse)
-DGPIO_CTRL_ACTIVE_LOW=1
; --- microSD on FSPI/SPI2 (separate bus from LoRa, which uses HSPI/SPI3) ---
-DT3S3_SD_SCK=14
+9 -7
View File
@@ -364,7 +364,7 @@ void handleCommand(const char* line, Stream* reply) {
const char* args = line[n] ? line + n + 1 : line + n;
if (!strcmp(verb, "help")) {
reply->print("[help] ~status ~reset [ms] ~wake [ms] ~baud <n> "
reply->print("[help] ~status ~reset [ms] ~button [ms] ~baud <n> "
"~port <int|usb|ext> ~log on|off ~gpio <pin> <0|1>\r\n"
" ~mesh [on|off] ~psk <base64key> ~chan <name> <base64key> ~msg <text>\r\n"
" (any non-~ line is sent to the target UART)\r\n");
@@ -372,8 +372,8 @@ void handleCommand(const char* line, Stream* reply) {
printStatus(reply);
} else if (!strcmp(verb, "reset")) {
gpioPulse(GPIO_RESET_PIN, (uint32_t)strtoul(args, nullptr, 10), reply, "reset");
} else if (!strcmp(verb, "wake")) {
gpioPulse(GPIO_WAKE_PIN, (uint32_t)strtoul(args, nullptr, 10), reply, "wake");
} else if (!strcmp(verb, "wake") || !strcmp(verb, "button")) {
gpioPulse(GPIO_WAKE_PIN, (uint32_t)strtoul(args, nullptr, 10), reply, "button");
} else if (!strcmp(verb, "baud")) {
uint32_t b = strtoul(args, nullptr, 10);
if (b) { setBaudRate(b); reply->printf("[ctrl] baud=%lu\r\n", (unsigned long)b); }
@@ -563,11 +563,13 @@ void setupWebServer() {
gpioPulse(GPIO_RESET_PIN, ms, nullptr, "reset");
req->send(200, "text/plain", "reset pulsed\n");
});
server.on("/api/wake", HTTP_GET, [](AsyncWebServerRequest* req) {
auto pulseButton = [](AsyncWebServerRequest* req) {
uint32_t ms = req->hasParam("ms") ? req->getParam("ms")->value().toInt() : 0;
gpioPulse(GPIO_WAKE_PIN, ms, nullptr, "wake");
req->send(200, "text/plain", "wake pulsed\n");
});
gpioPulse(GPIO_WAKE_PIN, ms, nullptr, "button");
req->send(200, "text/plain", "button pulsed\n");
};
server.on("/api/button", HTTP_GET, pulseButton);
server.on("/api/wake", HTTP_GET, pulseButton); // back-compat alias
server.on("/api/baud", HTTP_GET, [](AsyncWebServerRequest* req) {
if (req->hasParam("baud")) setBaudRate(req->getParam("baud")->value().toInt());
req->send(200, "application/json", statusJson());