Fix set feedrate

This commit is contained in:
Skylar Grant 2024-11-30 17:30:03 -05:00
parent 0834facb54
commit 83c040b800
2 changed files with 24 additions and 17 deletions

View File

@ -26,6 +26,8 @@ const config = {
const psState = new State(config);
const comms = new Communicator(psState);
const setFeedRateButton = document.getElementById("set-feed-rate");
export function refreshState(doc, state) {
const igniterStatus = doc.getElementById("igniter-status");
const exhaustStatus = doc.getElementById("exhaust-status");
@ -74,3 +76,10 @@ window.onload = function() {
comms.init(psState, config);
refreshState(window.document, psState);
};
setFeedRateButton.addEventListener("click", function() {
const feedRate = document.getElementById("feed-rate").value;
psState.auger.feedRate = feedRate;
comms.send(config.mqtt.topics.auger, JSON.stringify(psState.auger));
refreshState(window.document, psState);
});

View File

@ -72,11 +72,10 @@
<div class="button-container flex mt-4">
<input class="btn bg-gray-700 hover:bg-purple-600 text-white py-2 w-full rounded mx-auto" type="submit" id="stop-btn" value="Shutdown" name="stopButton" onclick="shutdown()">
</div>
<form action="/" method="post">
<!-- Set feed rates -->
<div class="form-group mt-4">
<label for="feedRate" class="block text-sm font-medium text-purple-400">Feed Rate:</label>
<select name="feedRate" class="form-control bg-gray-700 text-white mt-1 block w-full rounded border-gray-600 focus:border-purple-500 focus:ring-purple-500 py-2 px-4">
<label for="feed-rate" class="block text-sm font-medium text-purple-400">Feed Rate:</label>
<select name="feed-rate" id="feed-rate" class="form-control bg-gray-700 text-white mt-1 block w-full rounded border-gray-600 focus:border-purple-500 focus:ring-purple-500 py-2 px-4">
<option value="500">Low</option>
<option value="625">Medium-Low</option>
<option value="750">Medium</option>
@ -85,9 +84,8 @@
</select>
</div>
<div class="button-container flex justify-end mt-4">
<input class="btn bg-purple-600 hover:bg-purple-700 text-white py-2 px-4 rounded w-full" type="submit" id="reload" value="Set Feed Rate" name="reload">
<button class="btn bg-purple-600 hover:bg-purple-700 text-white py-2 px-4 rounded w-full" id="set-feed-rate" name="reload">Set Feed Rate</button>
</div>
</form>
</div>
<div class="text-center my-8">