-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathweb-logic-analyzer.ino
791 lines (739 loc) · 21.7 KB
/
web-logic-analyzer.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
/*
* License: GNU GPL v3
*
* Author: Mustafa Kuru
* Created: 2022-09-11
*
* Description: Web Logic Analyzer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* This program is based on the work of yoursunny (2019-01-06)
*
*/
#define BAUDRATE 115200
#define WIFI_NAME "xxxxxxxx"
#define WIFI_PASS "xxxxxxxxxxxxxxxxxxx"
#define STATUS_LED LED_BUILTIN
static const int MAX_SAMPLE = 3000;
#ifdef ESP32 // ========================= ESP 32 =========================
#define PIN_START_NAME "GPIO22"
#define PIN_INTERRUPT_NAME "GPIO5"
#define PIN0_NAME "GPIO19"
#define PIN1_NAME "GPIO18"
#define PIN2_NAME "GPIO17"
#define PIN3_NAME "GPIO16"
static const int PIN_START = 22;
static const int PIN_INTERRUPT = 5;
static const int PIN0 = 19;
static const int PIN1 = 18;
static const int PIN2 = 17;
static const int PIN3 = 16;
#include "soc/rtc_wdt.h"
#include <WiFi.h>
#include <AsyncTCP.h>
#define RAW_READ() REG_READ(GPIO_IN_REG)
#define WTD_ENABLE(_) \
{ \
rtc_wdt_protect_on(); \
rtc_wdt_enable(); \
}
#define WTD_DISABLE(_) \
{ \
rtc_wdt_protect_off(); \
rtc_wdt_disable(); \
}
#define WTD_FEED(_) \
{ \
rtc_wdt_feed(); \
}
static_assert(PIN_START >= 0 && PIN_START < 29 && PIN0 != 20 && PIN0 != 24 && PIN0 != 28 && PIN0 != 29, "");
static_assert(PIN_INTERRUPT >= 0 && PIN_INTERRUPT <= 39, "");
static_assert(PIN0 >= 0 && PIN0 < 29 && PIN0 != 20 && PIN0 != 24 && PIN0 != 28 && PIN0 != 29, "");
static_assert(PIN1 >= 0 && PIN1 < 29 && PIN0 != 20 && PIN0 != 24 && PIN0 != 28 && PIN0 != 29, "");
static_assert(PIN2 >= 0 && PIN2 < 29 && PIN0 != 20 && PIN0 != 24 && PIN0 != 28 && PIN0 != 29, "");
static_assert(PIN3 >= 0 && PIN3 < 29 && PIN0 != 20 && PIN0 != 24 && PIN0 != 28 && PIN0 != 29, "");
#define L_LOW LOW
#define L_HIGH HIGH
#elif defined(ESP8266) // ==================== ESP 8266 ========================
#define PIN_START_NAME "D2"
#define PIN_INTERRUPT_NAME "D3"
#define PIN0_NAME "D5"
#define PIN1_NAME "D6"
#define PIN2_NAME "D7"
#define PIN3_NAME "S3"
static const int PIN_START = 15;
static const int PIN_INTERRUPT = 0;
static const int PIN0 = 14;
static const int PIN1 = 12;
static const int PIN2 = 13;
static const int PIN3 = 9;
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#define RAW_READ() (GPI)
#define WTD_ENABLE(_) \
{ \
ESP.wdtEnable(WDTO_8S); \
/* Hardware WDT ON */ \
(*((volatile uint32_t *)0x60000900) |= 1); \
}
#define WTD_DISABLE(_) \
{ \
ESP.wdtDisable(); \
/* Hardware WDT OFF*/ \
(*((volatile uint32_t *)0x60000900) &= ~(1)); \
}
#define WTD_FEED(_) \
{ \
ESP.wdtFeed(); \
}
static_assert(PIN_START >= 0 && PIN_START < 16, "");
static_assert(PIN_INTERRUPT >= 0 && PIN_INTERRUPT < 16, "");
static_assert(PIN0 >= 0 && PIN0 < 16, "");
static_assert(PIN1 >= 0 && PIN1 < 16, "");
static_assert(PIN2 >= 0 && PIN2 < 16, "");
static_assert(PIN3 >= 0 && PIN3 < 16, "");
#define L_LOW HIGH
#define L_HIGH LOW
#endif
#include <ESPAsyncWebServer.h>
// unused pins should be tied to the ground
AsyncWebServer server(80);
AsyncWebSocket ws("/ws");
static volatile bool stopListen = false;
static volatile bool start = false;
static volatile bool startRemote = false;
static unsigned long times[MAX_SAMPLE]; // when did change happen
static uint32_t values[MAX_SAMPLE]; // GPI value at time
static constexpr uint32_t MASK = (1 << PIN0) | (1 << PIN1) | (1 << PIN2) | (1 << PIN3);
static int collect_i_temp;
IRAM_ATTR void stopListening()
{
stopListen = true;
}
const char index_html[] PROGMEM = R"=="==(
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.9.1/chart.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-zoom/1.2.1/chartjs-plugin-zoom.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.0/FileSaver.min.js"></script>
<title>Web Logic Analyzer</title>
<style>
body {
background-color: #f5f5f5;
}
button {
margin: 2px 0px;
}
</style>
</head>
<body>
<div class="container-fluid" style="height: 70vh">
<h2 style="text-align: center">Web Logic Analyzer</h2>
<canvas id="chart"></canvas>
<div
class="row align-items-center justify-content-center justify-content-md-start"
>
<div class="col-md-auto">
<div>Start PIN: <span id="start">DX</span></div>
<div>Interrupt PIN: <span id="interrupt">DX</span></div>
</div>
<div class="col-md-auto">
<div>Sample Rate: 1.000.000 Hz</div>
<div style="display: flex">
Status:
<b><div id="status">Disconnected</div></b>
</div>
</div>
<div class="col-md-auto">
<button
type="button"
class="btn btn-primary btn-block"
onclick="handleStart()"
>
Start
</button>
</div>
<div class="col-md-auto">
<button
type="button"
class="btn btn-primary btn-block"
onclick="handleReset()"
>
Reset Table
</button>
</div>
<div class="col-md-auto">
<button
type="button"
class="btn btn-primary btn-block"
onclick="handleDownload()"
>
Download for PulseView (.CSV)
</button>
</div>
<div class="col-md-auto">
<button
type="button"
class="btn btn-primary btn-block"
onclick="handleDownloadRaw()"
>
Download for PulseView (RAW)
</button>
</div>
<div class="col-md-auto">
<div class="row align-items-center" style="flex-flow: nowrap">
<div class="col-auto">Auto download after captured:</div>
<div class="col">
<select
class="custom-select"
onchange="handleSelectAutoDownload(this.value)"
>
<option value="0" selected>None</option>
<option value="csv">PulseView (.CSV)</option>
<option value="raw">PulseView (RAW)</option>
</select>
</div>
</div>
</div>
</div>
</div>
<script>
function saveStringAsFile(text, raw = false) {
var blob = new Blob([text], {
type: !raw ? "text/plain;charset=utf-8" : "octet/stream",
});
const unixTime = Math.round(new Date().getTime() / 1000);
saveAs(blob, `pulseView_${unixTime}.${raw ? "raw" : "csv"}`);
}
function handleStart() {
websocket.send("S");
document.getElementById("status").innerHTML = "Capturing...";
}
function handleDownload() {
let data = `${chart.data.datasets[0].label},${chart.data.datasets[1].label},${chart.data.datasets[2].label},${chart.data.datasets[3].label}\n`;
let time = 0;
for (const [t, [p1, p2, p3, p4]] of dataTemp) {
if (!time) {
data += `${p1},${p2},${p3},${p4}\n`;
time = t;
} else {
while (time < t) {
data += `${p1},${p2},${p3},${p4}\n`;
time += 1;
}
}
}
saveStringAsFile(data);
}
let autoDownload = 0;
function handleSelectAutoDownload(value) {
autoDownload = value;
}
function handleDownloadRaw() {
let data = "";
let time = 0;
for (const [t, value] of dataTempRaw) {
if (!time) {
time = t;
data += String.fromCharCode(value);
} else {
while (time < t) {
data += String.fromCharCode(value);
time += 1;
}
}
}
saveStringAsFile(data, true);
}
function handleReset() {
window.chart.data.labels = [];
window.chart.data.datasets[0].data = [];
window.chart.data.datasets[1].data = [];
window.chart.data.datasets[2].data = [];
window.chart.data.datasets[3].data = [];
chart.update();
}
const decimation = {
enabled: false,
algorithm: "min-max",
};
const ctx = document.getElementById("chart").getContext("2d");
const chart = new Chart(ctx, {
type: "line",
data: {
labels: [] || fakeLabels,
datasets: [
{
label: "PIN 1",
data: [],
borderColor: "red",
backgroundColor: "red",
stepped: true,
yAxisID: "y4",
},
{
label: "PIN 2",
data: [],
borderColor: "blue",
backgroundColor: "blue",
stepped: true,
yAxisID: "y3",
},
{
label: "PIN 3",
data: [],
borderColor: "purple",
backgroundColor: "purple",
stepped: true,
yAxisID: "y2",
},
{
label: "PIN 4",
data: [],
borderColor: "green",
backgroundColor: "green",
stepped: true,
yAxisID: "y",
},
],
},
options: {
maintainAspectRatio: false,
animation: {
duration: 10,
},
hover: {
animationDuration: 10,
},
responsiveAnimationDuration: 10,
type: "line",
responsive: true,
interaction: {
intersect: true,
mode: "x",
axis: "x",
},
plugins: {
decimation: decimation,
zoom: {
zoom: {
wheel: {
enabled: true,
},
pinch: {
enabled: true,
},
mode: "x",
},
pan: {
enabled: true,
mode: "x",
},
},
},
scales: {
x: {
type: "linear",
beginAtZero: true,
offset: true,
min: 0,
},
y: {
type: "category",
labels: ["ON", "OFF"],
offset: true,
position: "left",
stack: "demo",
stackWeight: 1,
grid: {
borderColor: "green",
},
},
y2: {
type: "category",
labels: ["ON", "OFF"],
offset: true,
position: "left",
stack: "demo",
stackWeight: 1,
grid: {
borderColor: "purple",
},
},
y3: {
type: "category",
labels: ["ON", "OFF"],
offset: true,
position: "left",
stack: "demo",
stackWeight: 1,
grid: {
borderColor: "blue",
},
},
y4: {
type: "category",
labels: ["ON", "OFF"],
offset: true,
position: "left",
stack: "demo",
stackWeight: 1,
grid: {
borderColor: "red",
},
},
},
},
});
window.chart = chart;
var gateway = `ws://${window.location.hostname}/ws`;
if (
window.location.hostname === "localhost" ||
window.location.hostname === ""
) {
gateway = `ws://192.168.1.160/ws`;
}
var websocket;
function addData(time, [pin1, pin2, pin3, pin4]) {
window.chart.data.labels.push(time);
window.chart.data.datasets[0].data.push({ y: pin1, x: time });
window.chart.data.datasets[1].data.push({ y: pin2, x: time });
window.chart.data.datasets[2].data.push({ y: pin3, x: time });
window.chart.data.datasets[3].data.push({ y: pin4, x: time });
}
function initWebSocket() {
console.log("Trying to open a WebSocket connection...");
document.getElementById("status").innerHTML = "Reconnecting...";
websocket = new WebSocket(gateway);
websocket.onopen = onOpen;
websocket.onclose = onClose;
websocket.onmessage = onMessage; // <-- add this line
}
function onOpen(event) {
console.log("Connection opened");
document.getElementById("status").innerHTML = "Connected";
}
function onClose(event) {
console.log("Connection closed");
document.getElementById("status").innerHTML = "Closed";
setTimeout(initWebSocket, 2000);
}
let dataTemp = [];
let dataTempRaw = [];
function onMessage(event) {
if (event.data == "S" || event.data == "S-I") {
previousSignalData = 0;
currentTime = 0;
dataTemp = [];
dataTempRaw = [];
document.getElementById("status").innerHTML = `Receiving data ${
event.data === "S-I" ? " (Interrupt)" : ""
}...`;
handleReset();
} else if (event.data == "F") {
window.chart.resetZoom();
window.chart.update();
document.getElementById("status").innerHTML = "Capture Done!";
if (autoDownload === "csv") {
handleDownload();
} else if (autoDownload === "raw") {
handleDownloadRaw();
}
setTimeout(() => {
document.getElementById("status").innerHTML = "Connected";
}, 2000);
} else if (event.data.startsWith("H")) {
const payload = event.data.split("|")[1];
const [pin1, pin2, pin3, pin4, interrupt, start] = payload.split(":");
window.chart.data.datasets[0].label = `PIN 1 (${pin1})`;
window.chart.data.datasets[1].label = `PIN 2 (${pin2})`;
window.chart.data.datasets[2].label = `PIN 3 (${pin3})`;
window.chart.data.datasets[3].label = `PIN 4 (${pin4})`;
document.getElementById("interrupt").innerHTML = interrupt;
document.getElementById("start").innerHTML = start;
window.chart.update();
} else {
event.data.split("|").forEach((record) => {
handleSignalData(record);
});
}
}
let previousSignalData = null;
let currentTime = null;
function handleSignalData(data) {
const parts = data.split(":");
let signal = parseInt(parts[0]);
const micros = parseInt(parts[1]);
if (previousSignalData === null) {
previousSignalData = signal;
} else {
signal = signal - previousSignalData;
}
const pin1 = !!(signal & 0x01) ? 1 : 0;
const pin2 = !!(signal & 0x02) ? 1 : 0;
const pin3 = !!(signal & 0x04) ? 1 : 0;
const pin4 = !!(signal & 0x08) ? 1 : 0;
currentTime += micros;
dataTemp.push([currentTime, [pin1, pin2, pin3, pin4]]);
dataTempRaw.push([currentTime, signal]);
addData(currentTime, [
pin1 ? "ON" : "OFF",
pin2 ? "ON" : "OFF",
pin3 ? "ON" : "OFF",
pin4 ? "ON" : "OFF",
]);
}
function onLoad(event) {
initWebSocket();
}
window.addEventListener("load", onLoad);
</script>
</body>
</html>
)=="==";
void handleWebSocketMessage(void *arg, uint8_t *data, size_t len)
{
AwsFrameInfo *info = (AwsFrameInfo *)arg;
if (info->final && info->index == 0 && info->len == len && info->opcode == WS_TEXT)
{
data[len] = 0;
if (strcmp((char *)data, "S") == 0)
{
startRemote = true;
}
Serial.print("Received --> ");
Serial.println((char *)data);
}
}
void onEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len)
{
switch (type)
{
case WS_EVT_CONNECT:
Serial.printf("WebSocket client #%u connected from %s\n", client->id(), client->remoteIP().toString().c_str());
char msg[128];
sprintf(msg, "H|%s:%s:%s:%s:%s:%s", PIN0_NAME, PIN1_NAME, PIN2_NAME, PIN3_NAME, PIN_INTERRUPT_NAME, PIN_START_NAME);
ws.text(client->id(), msg);
break;
case WS_EVT_DISCONNECT:
Serial.printf("WebSocket client #%u disconnected\n", client->id());
break;
case WS_EVT_DATA:
handleWebSocketMessage(arg, data, len);
break;
case WS_EVT_PONG:
case WS_EVT_ERROR:
break;
}
}
void initWebSocket()
{
ws.onEvent(onEvent);
server.addHandler(&ws);
}
extern void IRAM_ATTR collect()
{
attachInterrupt(digitalPinToInterrupt(PIN_INTERRUPT), stopListening, CHANGE);
times[0] = micros();
values[0] = RAW_READ() & MASK;
stopListen = false;
collect_i_temp = MAX_SAMPLE;
for (int i = 1; i < MAX_SAMPLE; ++i)
{
uint32_t value;
do
{
value = RAW_READ() & MASK;
yield();
} while (value == values[i - 1] && !stopListen);
times[i] = micros();
values[i] = value;
if (stopListen)
{
collect_i_temp = i + 1;
break;
}
}
detachInterrupt(digitalPinToInterrupt(PIN_INTERRUPT));
}
int compactValue(uint32_t value)
{
int res = 0;
if ((value & (1 << PIN0)) != 0)
{
res |= (1 << 0);
}
if ((value & (1 << PIN1)) != 0)
{
res |= (1 << 1);
}
if ((value & (1 << PIN2)) != 0)
{
res |= (1 << 2);
}
if ((value & (1 << PIN3)) != 0)
{
res |= (1 << 3);
}
return res;
}
void report()
{
unsigned long elapsedTimeDueCapture = (micros() - times[0]);
Serial.printf("Total capture seconds: %lu\n", elapsedTimeDueCapture / 1000000);
bool isNeedWaitForWsReconnect = elapsedTimeDueCapture > 10 * 1000 * 1000;
if (isNeedWaitForWsReconnect)
{
digitalWrite(STATUS_LED, L_HIGH);
ws.closeAll();
for (int i = 0; i < 50; i++)
{
ws.cleanupClients();
if (i % 5 == 0)
{
digitalWrite(STATUS_LED, L_LOW);
}
else if ((i - 1) % 5 == 0)
{
digitalWrite(STATUS_LED, L_HIGH);
}
delay(100);
}
}
if (stopListen)
{
Serial.println("S-I");
ws.textAll("S-I");
}
else
{
Serial.println("S");
ws.textAll("S");
}
char msg0[32];
sprintf(msg0, "%d:%d", compactValue(values[0]), collect_i_temp - 1);
ws.textAll(msg0);
unsigned long previousTime = 0;
int chunk = 0;
String wsMsg = "";
Serial.printf("Total sample: %d", collect_i_temp);
for (int i = 1; i < collect_i_temp; ++i)
{
char msg[32];
int value = compactValue(values[i]);
unsigned long diff = times[i] - times[0] - previousTime;
sprintf(msg, "%i:%lu", value, diff);
while (!ws.availableForWriteAll())
{
WTD_FEED();
delay(1);
}
wsMsg += msg;
if (chunk > 30 || (chunk > 0 && i == collect_i_temp - 1))
{
ws.textAll(wsMsg);
Serial.println(wsMsg);
wsMsg = "";
chunk = 0;
}
else
{
wsMsg += "|";
}
previousTime += diff;
chunk++;
}
for (int i = 0; i < 3; i++)
{
digitalWrite(STATUS_LED, L_HIGH);
delay(100);
digitalWrite(STATUS_LED, L_LOW);
delay(200);
}
Serial.println("F");
ws.textAll("F");
}
void setup()
{
#ifdef ESP32
setCpuFrequencyMhz(240);
#endif
Serial.begin(BAUDRATE);
delay(1500);
pinMode(STATUS_LED, OUTPUT);
pinMode(PIN_START, INPUT);
pinMode(PIN0, INPUT_PULLUP);
pinMode(PIN1, INPUT_PULLUP);
pinMode(PIN2, INPUT_PULLUP);
pinMode(PIN3, INPUT_PULLUP);
for (int i = 0; i < 2; i++)
{
digitalWrite(STATUS_LED, L_HIGH);
delay(300);
digitalWrite(STATUS_LED, L_LOW);
delay(300);
}
WiFi.begin(WIFI_NAME, WIFI_PASS);
Serial.print("Connecting to WiFi..");
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.print("\nLocal IP: ");
Serial.println(WiFi.localIP());
for (int i = 0; i < 2; i++)
{
digitalWrite(STATUS_LED, L_HIGH);
delay(100);
digitalWrite(STATUS_LED, L_LOW);
delay(100);
}
initWebSocket();
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
{ request->send_P(200, "text/html", index_html); });
server.begin();
}
void loop()
{
ws.cleanupClients();
while (!start && !startRemote)
{
ws.cleanupClients();
start = digitalRead(PIN_START);
delay(1);
}
Serial.printf("Logic analyzer started. Button start: %d, Web Start: %d\n", start, startRemote);
start = false;
startRemote = false;
digitalWrite(STATUS_LED, L_HIGH);
WTD_DISABLE();
collect();
WTD_ENABLE();
digitalWrite(STATUS_LED, L_LOW);
report();
}