Skip to content

Commit 3c31fb9

Browse files
committed
fix compile errors for esp32 v 6.13.0
1 parent 8a2a825 commit 3c31fb9

15 files changed

Lines changed: 108 additions & 122 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ extras/tests/pc_based/ramp_helper
4141
.claude
4242
AGENTS.md
4343
extras/tests/pc_based/AGENTS.md
44+
extras/Esp32StepperDemo/lib/FastAccelStepper/src

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
pre-0.34.1:
1+
pre-1.0.0:
22
- add memory report script
33
- rename old pmf/PMF to log2/LOG2 representation and define type `log2_value_t`
44
- add timing plot `to extras/tests/simavr_based`
5+
- major refactoring of the code
6+
- esp32: new platformio project in extras/Esp32StepperDemo for esp32 stepper configuration
7+
- esp32-idf5: implement I2S-module in DIRECT mode to drive one stepper up to 200 kHz (1-3 modules depending on esp32 variant)
8+
- esp32-idf5: use I2S-module in MUX mode (16bit/stereo) to drive up to 32 steppers (or less if direction/enable on mux) (#338)
9+
ATTENTION: WORK IN PROGRESS - DIR/ENABLE not yet functional. using Esp32StepperDemo manual dir/enable setting is possible
510

611
0.34.0:
712
- Major internal refactoring: reorganize code into subdirectories

examples/StepperDemo/StepperDemo.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,9 @@ bool process_cmd(char* cmd) {
12531253
uint16_t s = *cmd++;
12541254
char* endptr;
12551255
int8_t res;
1256+
#if !defined(__AVR_ATmega32U4__)
12561257
int8_t gv;
1258+
#endif
12571259
switch (MODE(mode, s)) {
12581260
case MODE(normal, 'M'):
12591261
case MODE(test, 'M'):
@@ -1490,6 +1492,7 @@ bool process_cmd(char* cmd) {
14901492
return true;
14911493
}
14921494
break;
1495+
#if !defined(__AVR_ATmega32U4__)
14931496
case MODE(config, 'd'):
14941497
if (strcmp(cmd, "c") == 0) {
14951498
output_msg(MSG_DISABLED);
@@ -1531,6 +1534,7 @@ bool process_cmd(char* cmd) {
15311534
break;
15321535
}
15331536
break;
1537+
#endif
15341538
case MODE(normal, 'N'):
15351539
if (*cmd == 0) {
15361540
output_msg(MSG_OUTPUT_DRIVER_ON);

extras/Esp32StepperDemo/src/web/WebUI.h

Lines changed: 42 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ const char index_html[] PROGMEM = R"rawliteral(
99
* { margin: 0; padding: 0; box-sizing: border-box; }
1010
body { font-family: Arial, sans-serif; background: #1a1a1a; color: #fff; padding: 20px; }
1111
.container { max-width: 1200px; margin: 0 auto; }
12-
h1 { margin-bottom: 20px; color: #4CAF50; }
13-
.card { background: #2a2a2a; padding: 20px; margin-bottom: 20px; border-radius: 8px; }
12+
h1 { color: #4CAF50; font-size: 20px; }
13+
.header-row { display: flex; align-items: center; gap: 30px; margin-bottom: 15px; }
14+
.header-row h1 { margin: 0; }
15+
.card { background: #2a2a2a; padding: 15px; margin-bottom: 15px; border-radius: 8px; }
1416
.card h2 { margin-bottom: 15px; color: #4CAF50; font-size: 18px; }
1517
.stepper-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 15px; }
1618
.pin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; max-height: 400px; overflow-y: auto; }
@@ -64,14 +66,13 @@ const char index_html[] PROGMEM = R"rawliteral(
6466
</head>
6567
<body>
6668
<div class="container">
67-
<h1>ESP32 Stepper Control</h1>
68-
69-
<div class="card">
70-
<h2>System Status <span class="connection-status" id="wsStatus"></span></h2>
71-
<div class="system-info">
72-
<div>IP: <span id="ip">-</span></div>
73-
<div>Free Heap: <span id="heap">-</span> bytes</div>
74-
<div>Uptime: <span id="uptime">-</span></div>
69+
<div class="header-row">
70+
<h1>ESP32 Stepper Control</h1>
71+
<div class="system-info" style="display:flex;gap:20px;align-items:center">
72+
<span class="connection-status" id="wsStatus"></span>
73+
<span>IP: <strong id="ip">-</strong></span>
74+
<span>Heap: <strong id="heap">-</strong></span>
75+
<span>Up: <strong id="uptime">-</strong></span>
7576
</div>
7677
</div>
7778
@@ -105,24 +106,8 @@ const char index_html[] PROGMEM = R"rawliteral(
105106
</div>
106107
107108
<div class="card">
108-
<h2>Quick Commands</h2>
109-
<div class="controls">
110-
<input type="number" id="stepperId" placeholder="Stepper ID" value="0" min="0">
111-
<input type="number" id="moveValue" placeholder="Steps" value="1000">
112-
<button class="btn-primary" onclick="sendCommand('move')">Move</button>
113-
<button class="btn-primary" onclick="sendCommand('move_to')">Move To</button>
114-
<button class="btn-secondary" onclick="sendCommand('stop')">Stop</button>
115-
<button class="btn-danger" onclick="sendCommand('force_stop')">Force Stop</button>
116-
</div>
117-
</div>
118-
119-
<div class="card">
120-
<h2>GPIO Pins</h2>
121-
<div class="controls" style="margin-bottom:15px">
122-
<button class="btn-secondary" onclick="loadPins()">Refresh Pins</button>
123-
<button class="btn-secondary" id="togglePinBtn" onclick="togglePinView()">Show All Pins</button>
124-
</div>
125-
<div id="pins" class="pin-grid">Loading...</div>
109+
<h2>GPIO Pins <span style="font-weight:normal;color:#888;font-size:12px">(click IN/OUT to toggle mode, click value to toggle 0/1)</span></h2>
110+
<div id="pins" style="display:grid;grid-template-columns:repeat(8,1fr);gap:5px;font-size:11px">Loading...</div>
126111
</div>
127112
128113
<div class="card">
@@ -375,12 +360,6 @@ const char index_html[] PROGMEM = R"rawliteral(
375360
}
376361
}
377362
378-
async function sendCommand(command) {
379-
const stepperId = parseInt(document.getElementById('stepperId').value);
380-
const value = parseInt(document.getElementById('moveValue').value);
381-
await sendStepperCommand(stepperId, command, value);
382-
}
383-
384363
async function updateSystemStatus() {
385364
try {
386365
const response = await fetch('/api/status');
@@ -406,14 +385,6 @@ const char index_html[] PROGMEM = R"rawliteral(
406385
updateSystemStatus();
407386
setInterval(updateSystemStatus, 5000);
408387
409-
let pinViewExpanded = false;
410-
411-
function togglePinView() {
412-
pinViewExpanded = !pinViewExpanded;
413-
document.getElementById('pins').classList.toggle('expanded', pinViewExpanded);
414-
document.getElementById('togglePinBtn').textContent = pinViewExpanded ? 'Hide All Pins' : 'Show All Pins';
415-
}
416-
417388
async function loadPins() {
418389
try {
419390
const response = await fetch('/api/pins');
@@ -492,39 +463,43 @@ const char index_html[] PROGMEM = R"rawliteral(
492463
return;
493464
}
494465
495-
container.innerHTML = usablePins.map(p => {
496-
const typeStr = p.type === 1 ? 'IN' : p.type === 2 ? 'OUT' : '-';
497-
const valueClass = p.value === 1 ? 'high' : 'low';
498-
const valueStr = p.value === -1 ? '-' : p.value.toString();
499-
const assignedStr = p.is_assigned ? ` (S${p.assigned_to})` : '';
500-
const itemClass = p.is_reserved ? 'pin-item reserved' : (p.is_assigned ? 'pin-item assigned' : 'pin-item');
466+
let html = '';
467+
for (const p of usablePins) {
468+
const canOutput = p.capabilities & 2;
469+
const isOutput = p.type === 2;
470+
const modeStr = isOutput ? 'OUT' : 'IN';
471+
const value = p.value === -1 ? '-' : p.value;
472+
const isAssigned = p.is_assigned;
473+
const bgColor = isOutput && value === 1 ? '#4CAF50' : '#333';
474+
const opacity = isAssigned ? '0.5' : '1';
475+
const modeCursor = (isAssigned || !canOutput) ? 'default' : 'pointer';
476+
const assignedTitle = isAssigned ? ` (S${p.assigned_to})` : '';
477+
const inputOnly = !canOutput ? ' (IN only)' : '';
501478
502-
return `
503-
<div class="${itemClass}">
504-
<div class="pin-header">
505-
<span class="pin-num">GPIO${p.pin}</span>
506-
<span class="pin-value ${valueClass}">${valueStr}</span>
507-
</div>
508-
<div style="color:#888;font-size:11px">${p.name}${assignedStr}</div>
509-
<div class="pin-actions">
510-
<select id="mode-${p.pin}" onchange="setPinMode(${p.pin})">
511-
<option value="none" ${p.type === 0 ? 'selected' : ''}>-</option>
512-
<option value="input" ${p.type === 1 ? 'selected' : ''}>IN</option>
513-
<option value="output" ${p.type === 2 ? 'selected' : ''}>OUT</option>
514-
</select>
515-
<button class="btn-secondary" onclick="togglePin(${p.pin})" ${p.type !== 2 ? 'disabled' : ''}>Toggle</button>
479+
html += `
480+
<div style="background:${bgColor};padding:5px;border-radius:3px;text-align:center;opacity:${opacity}"
481+
title="GPIO${p.pin}${assignedTitle}${inputOnly}">
482+
<div style="font-weight:bold;font-size:10px;color:#888">${p.pin}</div>
483+
<div style="display:flex;justify-content:center;gap:8px;font-weight:bold">
484+
<span style="cursor:${modeCursor};color:${canOutput ? '#fff' : '#888'}"
485+
onclick="${isAssigned || !canOutput ? '' : `cyclePinMode(${p.pin})`}">${modeStr}</span>
486+
<span style="cursor:${isOutput && !isAssigned ? 'pointer' : 'default'};color:${isOutput && value === 1 ? '#fff' : '#888'}"
487+
onclick="${isOutput && !isAssigned ? `togglePin(${p.pin})` : ''}">${value}</span>
516488
</div>
517489
</div>
518490
`;
519-
}).join('');
491+
}
492+
container.innerHTML = html;
520493
}
521494
522-
async function setPinMode(pin) {
523-
const mode = document.getElementById(`mode-${pin}`).value;
524-
if (mode === 'none') return;
495+
async function cyclePinMode(pin) {
496+
const pinData = gpioPins.find(p => p.pin === pin);
497+
if (!pinData) return;
498+
499+
const newMode = pinData.type === 2 ? 'input' : 'output';
525500
526501
try {
527-
const params = new URLSearchParams({ mode: mode, value: '0' });
502+
const params = new URLSearchParams({ mode: newMode, value: '0' });
528503
await fetch(`/api/pins/${pin}`, {
529504
method: 'POST',
530505
headers: {'Content-Type': 'application/x-www-form-urlencoded'},

extras/doc/memory_report.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# FastAccelStepper Memory Footprint
22

3-
Generated: 2026-03-01 12:03:44
3+
Generated: 2026-03-06 19:46:29
44

55
Library size measured using the difference method:
66
- Baseline: Empty Arduino sketch (setup/loop only)
@@ -11,13 +11,13 @@ Library size measured using the difference method:
1111
| ATmega2560 | 361 | 9590 |
1212
| ATmega328P | 243 | 8756 |
1313
| ATmega32U4 | 361 | 9026 |
14-
| ESP32 | 5360 | 30200 |
15-
| ESP32-C3 | 952 | 29434 |
16-
| ESP32-S2 | 1664 | 28304 |
17-
| ESP32-S3 | 3496 | 37784 |
14+
| ESP32 | 5656 | 42908 |
15+
| ESP32-C3 | 1024 | 34698 |
16+
| ESP32-S2 | 1896 | 40356 |
17+
| ESP32-S3 | 3816 | 50348 |
1818
| RP2040 | 2348 | 8548 |
19-
| RP2350 | 3424 | 8228 |
20-
| SAM3X8E | 2380 | 21716 |
19+
| RP2350 | 3424 | 8260 |
20+
| SAM3X8E | 2380 | 21756 |
2121

2222
**Notes:**
2323
- RAM = .data + .bss (static allocation)

extras/tests/simavr_based/test_sd_04_timing_2560/expect.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,26 @@
44
EnableA: 1*L->H, 1*H->L
55
EnableB: 2*L->H, 1*H->L
66
EnableC: 2*L->H, 1*H->L
7-
StepA: 64000*L->H, 64000*H->L, Max High<=35us Total High<=350000us
8-
StepB: 64000*L->H, 64000*H->L, Max High<=35us Total High<=400000us
9-
StepC: 64000*L->H, 64000*H->L, Max High<=40us Total High<=510000us
7+
StepA: 64000*L->H, 64000*H->L, Max High=29us Total High=499376us
8+
StepB: 64000*L->H, 64000*H->L, Max High=33us Total High=361086us
9+
StepC: 64000*L->H, 64000*H->L, Max High=35us Total High=382188us
1010
Position[A]=64000
1111

1212
Position[B]=64000
1313

1414
Position[C]=64000
1515

16-
Time in EnableA max<=234000 us, total<=234000 us
16+
Time in EnableA max=237687 us, total=237687 us
1717

18-
Time in EnableB max<=247000 us, total<=247000 us
18+
Time in EnableB max=247840 us, total=247840 us
1919

20-
Time in EnableC max<=255000 us, total<=255000 us
20+
Time in EnableC max=253650 us, total=253650 us
2121

22-
Time in FillISR max<=4000 us, total<=2200000 us
22+
Time in FillISR max=2909 us, total=2105612 us
2323

24-
Time in StepA max<=35 us, total<=350000 us
24+
Time in StepA max=29 us, total=499376 us
2525

26-
Time in StepB max<=35 us, total<=400000 us
26+
Time in StepB max=33 us, total=361086 us
27+
28+
Time in StepC max=35 us, total=382188 us
2729

28-
Time in StepC max<=40 us, total<=510000 us

extras/tests/simavr_based/test_sd_04_timing_328p/expect.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22
DirB: 1*L->H, 0*H->L
33
EnableA: 1*L->H, 1*H->L
44
EnableB: 2*L->H, 1*H->L
5-
StepA: 1000*L->H, 1000*H->L, Max High<=20us Total High<=4500us
6-
StepB: 1000*L->H, 1000*H->L, Max High<=25us Total High<=5300us
5+
StepA: 1000*L->H, 1000*H->L, Max High=13us Total High=4215us
6+
StepB: 1000*L->H, 1000*H->L, Max High=19us Total High=5056us
77
Position[A]=1000
88

99
Position[B]=1000
1010

11-
Time in EnableA max<=226000 us, total<=226000 us
11+
Time in EnableA max=229498 us, total=229498 us
1212

13-
Time in EnableB max<=239000 us, total<=239000 us
13+
Time in EnableB max=239770 us, total=239770 us
1414

15-
Time in FillISR max<=4000 us, total<=50000 us
15+
Time in FillISR max=2659 us, total=47748 us
1616

17-
Time in StepA max<=20 us, total<=4500 us
17+
Time in StepA max=13 us, total=4215 us
1818

19-
Time in StepB max<=25 us, total<=5300 us
19+
Time in StepB max=19 us, total=5056 us
2020

2121
Time in StepISR max=6 us, total=8566 us
22+

extras/tests/simavr_based/test_sd_04_timing_328p_37k/expect.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
DirB: 1*L->H, 0*H->L
33
EnableA: 1*L->H, 1*H->L
44
EnableB: 1*L->H, 0*H->L
5-
StepA: 1000*L->H, 1000*H->L, Max High<=15us Total High<=4200us
5+
StepA: 1000*L->H, 1000*H->L, Max High=9us Total High=3936us
66
StepB: 0*L->H, 0*H->L, Max High=0us Total High=0us
77
Position[A]=1000
88

9-
Time in EnableA max<=226000 us, total<=226000 us
9+
Time in EnableA max=229499 us, total=229499 us
1010

11-
Time in FillISR max<=3500 us, total<=29000 us
11+
Time in FillISR max=2043 us, total=27549 us
1212

13-
Time in StepA max<=15 us, total<=4200 us
13+
Time in StepA max=9 us, total=3936 us
1414

1515
Time in StepISR max=5 us, total=3975 us
16+

extras/tests/simavr_based/test_sd_05_328p/expect.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
DirB: 1*L->H, 0*H->L
33
EnableA: 1*L->H, 1*H->L
44
EnableB: 1*L->H, 0*H->L
5-
StepA: 14440*L->H, 14440*H->L, Max High=11us Total High=55558us
5+
StepA: 14572*L->H, 14572*H->L, Max High=11us Total High=55999us
66
StepB: 0*L->H, 0*H->L, Max High=0us Total High=0us
77
Position[A]=0
88

9-
Time in EnableA max=442487 us, total=442487 us
9+
Time in EnableA max=442486 us, total=442486 us
1010

11-
Time in StepA max=11 us, total=55558 us
11+
Time in StepA max=11 us, total=55999 us
1212

extras/tests/simavr_based/test_sd_11_328p/expect.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
DirB: 1*L->H, 0*H->L
33
EnableA: 1*L->H, 1*H->L
44
EnableB: 1*L->H, 0*H->L
5-
StepA: 99808*L->H, 99808*H->L, Max High=11us Total High=385248us
5+
StepA: 99908*L->H, 99908*H->L, Max High=11us Total High=383335us
66
StepB: 0*L->H, 0*H->L, Max High=0us Total High=0us
7-
Position[A]=50536~300
7+
Position[A]=50636
88

9-
Time in EnableA max=225395 us, total=225395 us
9+
Time in EnableA max=225399 us, total=225399 us
1010

11-
Time in StepA max=11 us, total=385248 us
11+
Time in StepA max=11 us, total=383335 us
1212

0 commit comments

Comments
 (0)