Settings: add W axis (auxcnc) panel
Expose the aux.json fields under a new 'W Axis (auxcnc)' section in Settings: serial port/baud, mechanics (steps/mm, dir sign, soft limits, max feed), homing (direction, position, fast/slow seek, backoff, max travel, limit polarity) and the step profile (max/start rate, accel). The 'enabled' flag stays read-only in the UI; flipping the W axis on/off is still done via aux.json so a fresh install can't surprise the user with hardware that isn't there. Live status (offline / unhomed / homed at <pos> mm) is shown above the form. Saving PUTs the merged config to /api/aux/config/save, which writes aux.json and pushes the homing/step config to the ESP.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import configTemplate from "../../../resources/config-template.json";
|
||||
import ScreenRotationDialog from "$dialogs/ScreenRotationDialog.svelte";
|
||||
import ConfigTemplatedInput from "./ConfigTemplatedInput.svelte";
|
||||
import WAxisSettings from "./WAxisSettings.svelte";
|
||||
import SetTimeDialog from "$dialogs/SetTimeDialog.svelte";
|
||||
import Button, { Label } from "@smui/button";
|
||||
|
||||
@@ -94,6 +95,11 @@
|
||||
{/each}
|
||||
</fieldset>
|
||||
|
||||
<h2>W Axis (auxcnc)</h2>
|
||||
<fieldset>
|
||||
<WAxisSettings />
|
||||
</fieldset>
|
||||
|
||||
<h2>Path Accuracy</h2>
|
||||
<fieldset>
|
||||
<ConfigTemplatedInput key={`settings.max-deviation`} />
|
||||
|
||||
262
src/svelte-components/src/components/WAxisSettings.svelte
Normal file
262
src/svelte-components/src/components/WAxisSettings.svelte
Normal file
@@ -0,0 +1,262 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import Button, { Label } from "@smui/button";
|
||||
import * as api from "$lib/api";
|
||||
|
||||
// Mirrors the DEFAULTS in src/py/bbctrl/AuxAxis.py. The "enabled"
|
||||
// flag is read-only here; toggling the W axis on/off is done via
|
||||
// aux.json on disk, so adding/removing the hardware doesn't have a
|
||||
// surprise UI that bricks bring-up.
|
||||
type AuxConfig = {
|
||||
enabled: boolean;
|
||||
port: string;
|
||||
baud: number;
|
||||
steps_per_mm: number;
|
||||
dir_sign: number;
|
||||
min_w: number;
|
||||
max_w: number;
|
||||
max_feed_mm_min: number;
|
||||
home_dir: string;
|
||||
home_position_mm: number;
|
||||
home_fast_sps: number;
|
||||
home_slow_sps: number;
|
||||
home_backoff_steps: number;
|
||||
home_maxtravel_steps: number;
|
||||
step_max_sps: number;
|
||||
step_accel_sps2: number;
|
||||
step_start_sps: number;
|
||||
limit_low: boolean;
|
||||
};
|
||||
|
||||
let cfg: AuxConfig | null = null;
|
||||
let status: { enabled: boolean; present: boolean; homed: boolean; pos_mm: number } | null = null;
|
||||
let busy = false;
|
||||
let saveMessage = "";
|
||||
|
||||
onMount(async () => {
|
||||
await refresh();
|
||||
});
|
||||
|
||||
async function refresh() {
|
||||
try {
|
||||
cfg = await api.GET("aux/config");
|
||||
status = await api.GET("aux/status");
|
||||
} catch (e) {
|
||||
console.error("Failed to load aux config/status:", e);
|
||||
}
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (!cfg) return;
|
||||
busy = true;
|
||||
saveMessage = "";
|
||||
try {
|
||||
await api.PUT("aux/config/save", cfg);
|
||||
saveMessage = "Saved.";
|
||||
await refresh();
|
||||
setTimeout(() => (saveMessage = ""), 3000);
|
||||
} catch (e) {
|
||||
console.error("Failed to save aux config:", e);
|
||||
saveMessage = "Save failed - see console.";
|
||||
} finally {
|
||||
busy = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="w-axis-settings">
|
||||
{#if !cfg}
|
||||
<p class="tip">Loading W axis configuration...</p>
|
||||
{:else}
|
||||
<div class="status">
|
||||
{#if status}
|
||||
<span>
|
||||
Status:
|
||||
{#if !status.enabled}
|
||||
disabled
|
||||
{:else if !status.present}
|
||||
offline
|
||||
{:else if status.homed}
|
||||
homed at {status.pos_mm.toFixed(3)} mm
|
||||
{:else}
|
||||
connected, unhomed
|
||||
{/if}
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="pure-form pure-form-aligned">
|
||||
<fieldset>
|
||||
<div class="pure-control-group" title="Enable the auxcnc W axis. Edit aux.json to toggle.">
|
||||
<label for="enabled">enabled</label>
|
||||
<input id="enabled" type="checkbox" checked={cfg.enabled} disabled />
|
||||
<label for="" class="units">(edit aux.json)</label>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group" title="Serial port for the auxcnc ESP32.">
|
||||
<label for="port">serial port</label>
|
||||
<input id="port" type="text" bind:value={cfg.port} />
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group" title="Serial baud rate.">
|
||||
<label for="baud">baud</label>
|
||||
<input id="baud" type="number" bind:value={cfg.baud} min={1200} step={1} />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<h3>Mechanics</h3>
|
||||
<fieldset>
|
||||
<div class="pure-control-group" title="Logical steps per mm of W travel.">
|
||||
<label for="steps_per_mm">steps per mm</label>
|
||||
<input id="steps_per_mm" type="number" bind:value={cfg.steps_per_mm} step="any" />
|
||||
<label for="" class="units">steps/mm</label>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group" title="Direction sign: +1 or -1. Flip if W+ moves the wrong way.">
|
||||
<label for="dir_sign">direction sign</label>
|
||||
<select id="dir_sign" bind:value={cfg.dir_sign}>
|
||||
<option value={1}>+1</option>
|
||||
<option value={-1}>-1</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group" title="Soft-limit minimum W in mm.">
|
||||
<label for="min_w">soft min</label>
|
||||
<input id="min_w" type="number" bind:value={cfg.min_w} step="any" />
|
||||
<label for="" class="units">mm</label>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group" title="Soft-limit maximum W in mm.">
|
||||
<label for="max_w">soft max</label>
|
||||
<input id="max_w" type="number" bind:value={cfg.max_w} step="any" />
|
||||
<label for="" class="units">mm</label>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group" title="Informational max feed; rate caps live on the ESP.">
|
||||
<label for="max_feed_mm_min">max feed</label>
|
||||
<input id="max_feed_mm_min" type="number" bind:value={cfg.max_feed_mm_min} step="any" />
|
||||
<label for="" class="units">mm/min</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<h3>Homing</h3>
|
||||
<fieldset>
|
||||
<div class="pure-control-group" title="Direction the axis moves when looking for the home limit switch.">
|
||||
<label for="home_dir">home direction</label>
|
||||
<select id="home_dir" bind:value={cfg.home_dir}>
|
||||
<option value="-">- (toward W-)</option>
|
||||
<option value="+">+ (toward W+)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group" title="W position assigned when homing completes.">
|
||||
<label for="home_position_mm">home position</label>
|
||||
<input id="home_position_mm" type="number" bind:value={cfg.home_position_mm} step="any" />
|
||||
<label for="" class="units">mm</label>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group" title="Fast seek rate during homing search.">
|
||||
<label for="home_fast_sps">fast seek</label>
|
||||
<input id="home_fast_sps" type="number" bind:value={cfg.home_fast_sps} step={1} min={1} />
|
||||
<label for="" class="units">steps/s</label>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group" title="Slow seek rate during homing latch.">
|
||||
<label for="home_slow_sps">slow seek</label>
|
||||
<input id="home_slow_sps" type="number" bind:value={cfg.home_slow_sps} step={1} min={1} />
|
||||
<label for="" class="units">steps/s</label>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group" title="Backoff after the limit triggers, before the slow seek.">
|
||||
<label for="home_backoff_steps">backoff</label>
|
||||
<input id="home_backoff_steps" type="number" bind:value={cfg.home_backoff_steps} step={1} min={0} />
|
||||
<label for="" class="units">steps</label>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group" title="Maximum travel before homing aborts as a runaway.">
|
||||
<label for="home_maxtravel_steps">max travel</label>
|
||||
<input id="home_maxtravel_steps" type="number" bind:value={cfg.home_maxtravel_steps} step={1} min={1} />
|
||||
<label for="" class="units">steps</label>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group" title="Limit switch active-low? Off = active-high.">
|
||||
<label for="limit_low">limit active low</label>
|
||||
<input id="limit_low" type="checkbox" bind:checked={cfg.limit_low} />
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<h3>Step Profile</h3>
|
||||
<fieldset>
|
||||
<div class="pure-control-group" title="Maximum step rate during normal moves.">
|
||||
<label for="step_max_sps">max rate</label>
|
||||
<input id="step_max_sps" type="number" bind:value={cfg.step_max_sps} step={1} min={1} />
|
||||
<label for="" class="units">steps/s</label>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group" title="Acceleration in steps per second squared.">
|
||||
<label for="step_accel_sps2">acceleration</label>
|
||||
<input id="step_accel_sps2" type="number" bind:value={cfg.step_accel_sps2} step={1} min={1} />
|
||||
<label for="" class="units">steps/s²</label>
|
||||
</div>
|
||||
|
||||
<div class="pure-control-group" title="Initial step rate at the start of a move.">
|
||||
<label for="step_start_sps">start rate</label>
|
||||
<input id="step_start_sps" type="number" bind:value={cfg.step_start_sps} step={1} min={1} />
|
||||
<label for="" class="units">steps/s</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="actions">
|
||||
<Button
|
||||
touch
|
||||
variant="raised"
|
||||
on:click={save}
|
||||
disabled={busy}
|
||||
>
|
||||
<Label>Save W Axis Settings</Label>
|
||||
</Button>
|
||||
{#if saveMessage}
|
||||
<span class="save-msg">{saveMessage}</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="tip">
|
||||
Changes are written to aux.json. Homing rates and the
|
||||
limit polarity are pushed to the ESP immediately; any
|
||||
running motion is unaffected. Re-home the W axis after
|
||||
changing direction, sign, or step settings.
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
.w-axis-settings {
|
||||
.status {
|
||||
margin-bottom: 1em;
|
||||
font-size: 90%;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.actions {
|
||||
margin-left: 210px;
|
||||
margin-top: 1em;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1em;
|
||||
}
|
||||
|
||||
.save-msg {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.tip {
|
||||
margin-left: 210px;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 15px;
|
||||
font-style: italic;
|
||||
font-size: 90%;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user