✅ GitHub Issue: Add runtime motor speed settings to web interface
Summary
I added a feature to set the motor speeds (printSpeed and moveSpeed) at runtime from the web interface.
This makes it possible to fine-tune drawing speed without recompiling the firmware.
The feature consists of:
new input fields in index.html
a new request handler /setSpeeds in main.cpp
two global variables: printSpeedSteps and moveSpeedSteps
a new function Movement::setSpeeds()
updating both AccelStepper motors dynamically
✅ Changes in detail
- Global speed variables
Added to movement.cpp:
int printSpeedSteps = 1200; // default
int moveSpeedSteps = 2000; // default
These values can now be modified at runtime instead of being fixed constants.
- New function in Movement class
Added to movement.h:
void setSpeeds(int newPrintSpeed, int newMoveSpeed);
Implementation in movement.cpp:
void Movement::setSpeeds(int newPrintSpeed, int newMoveSpeed) {
printSpeedSteps = newPrintSpeed;
moveSpeedSteps = newMoveSpeed;
leftMotor->setMaxSpeed(moveSpeedSteps);
rightMotor->setMaxSpeed(moveSpeedSteps);
}
This allows both motors to update their speed instantly.
- New REST endpoint in main.cpp
Added:
server.on("/setSpeeds", HTTP_POST, [](AsyncWebServerRequest *request)
{
if (!request->hasParam("printSpeed", true) ||
!request->hasParam("moveSpeed", true)) {
request->send(400, "text/plain", "Missing parameters");
return;
}
int printSpeed = request->getParam("printSpeed", true)->value().toInt();
int moveSpeed = request->getParam("moveSpeed", true)->value().toInt();
if (printSpeed <= 0 || moveSpeed <= 0) {
request->send(400, "text/plain", "Invalid values");
return;
}
movement->setSpeeds(printSpeed, moveSpeed);
request->send(200, "text/plain", "OK");
});
This receives the speed values from the browser and updates the Movement module.
- Web UI: two new input fields + button
Added to index.html (Distance slide):
Print speed (steps/s)
Move speed (steps/s)
Set speeds
- JavaScript handler in main.js
Added:
$("#setSpeeds").click(function () {
const printSpeed = parseInt($("#printSpeedInput").val());
const moveSpeed = parseInt($("#moveSpeedInput").val());
if (isNaN(printSpeed) || isNaN(moveSpeed)) {
alert("Bitte Zahlen für beide Geschwindigkeiten eingeben.");
return;
}
$.post("/setSpeeds", { printSpeed: printSpeed, moveSpeed: moveSpeed })
.done(() => alert("Speeds updated"))
.fail(() => alert("Setting speeds failed"));
});
This sends the values directly to the ESP32.
✅ Benefit
No flashing required to adjust motor speed
Users can tune drawing speed depending on:
wall surface
marker friction
belt tension
detail level of SVG
Makes the plotter more flexible and user-friendly.
✅ GitHub Issue: Add runtime motor speed settings to web interface
Summary
I added a feature to set the motor speeds (printSpeed and moveSpeed) at runtime from the web interface.
This makes it possible to fine-tune drawing speed without recompiling the firmware.
The feature consists of:
new input fields in index.html
a new request handler /setSpeeds in main.cpp
two global variables: printSpeedSteps and moveSpeedSteps
a new function Movement::setSpeeds()
updating both AccelStepper motors dynamically
✅ Changes in detail
Added to movement.cpp:
int printSpeedSteps = 1200; // default
int moveSpeedSteps = 2000; // default
These values can now be modified at runtime instead of being fixed constants.
Added to movement.h:
void setSpeeds(int newPrintSpeed, int newMoveSpeed);
Implementation in movement.cpp:
void Movement::setSpeeds(int newPrintSpeed, int newMoveSpeed) {
printSpeedSteps = newPrintSpeed;
moveSpeedSteps = newMoveSpeed;
}
This allows both motors to update their speed instantly.
Added:
server.on("/setSpeeds", HTTP_POST, [](AsyncWebServerRequest *request)
{
if (!request->hasParam("printSpeed", true) ||
!request->hasParam("moveSpeed", true)) {
request->send(400, "text/plain", "Missing parameters");
return;
}
});
This receives the speed values from the browser and updates the Movement module.
Added to index.html (Distance slide):
Print speed (steps/s)
Move speed (steps/s)
Set speeds
Added:
$("#setSpeeds").click(function () {
const printSpeed = parseInt($("#printSpeedInput").val());
const moveSpeed = parseInt($("#moveSpeedInput").val());
});
This sends the values directly to the ESP32.
✅ Benefit
No flashing required to adjust motor speed
Users can tune drawing speed depending on:
wall surface
marker friction
belt tension
detail level of SVG
Makes the plotter more flexible and user-friendly.