bedSlinger.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * Which part of the printer the Z axis actually moves.
  3. *
  4. * This is a question about the machine standing in front of the user, not
  5. * about G-code. `G1 Z+` opens the nozzle-bed gap on every Bambu model — that
  6. * is what the axis means — so nothing on the wire depends on the answer, and
  7. * `POST /printers/{id}/bed-jog` takes a signed gap that means one physical
  8. * thing everywhere (see its docstring for the #1334 history).
  9. *
  10. * The answer is needed anyway, because a jog button carries an arrow, and an
  11. * arrow promises the user a direction of *motion*. On an X1 / P1 / H2 the
  12. * plate itself rides the Z axis, so "up" is the plate climbing toward the
  13. * nozzle and the gap closing. On the A1 family and the A2L the plate only
  14. * moves in Y; Z carries the toolhead, so "up" is the toolhead lifting off the
  15. * plate and the gap opening. Same arrow, opposite gap.
  16. *
  17. * The model list mirrors the A-series entries in the backend registries
  18. * (`LINEAR_RAIL_MODELS` / `SINGLE_NOZZLE_FLOW_MODELS` in
  19. * `backend/app/utils/printer_models.py`, and `PRINTER_MODEL_ID_MAP` for the
  20. * codes). A new bed-slinger has to be added here too.
  21. */
  22. /**
  23. * Models whose Z axis carries the toolhead, normalised (upper-case, letters
  24. * and digits only) so display names, internal MQTT/SSDP codes and Bambu's
  25. * terser cloud renames all land on the same entry.
  26. *
  27. * Kept as an explicit list rather than a prefix match: "A2L" and "A1" share a
  28. * letter with nothing else today, but "A" would sweep in whatever the next
  29. * A-series machine turns out to be, and the wrong answer here points an arrow
  30. * at someone's plate.
  31. */
  32. const BED_SLINGER_MODELS: ReadonlySet<string> = new Set([
  33. // Display names
  34. 'A1',
  35. 'A1MINI',
  36. 'A2L',
  37. // Bambu cloud short code for the A1 Mini (#1649)
  38. 'A1M',
  39. // Internal MQTT / SSDP codes
  40. 'N1', // A1 Mini
  41. 'N2S', // A1
  42. 'N9', // A2L
  43. 'A04', // A1 Mini (alternate)
  44. 'A11', // A1
  45. 'A12', // A1 Mini
  46. ]);
  47. /** True when this printer's Z axis moves the toolhead rather than the plate. */
  48. export function isBedSlinger(model: string | null | undefined): boolean {
  49. if (!model) return false;
  50. return BED_SLINGER_MODELS.has(model.toUpperCase().replace(/[^A-Z0-9]/g, ''));
  51. }