From b029d0466841b90b54279500f70a92deacfd6c5a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Viesturs=20Zari=C5=86=C5=A1?= <viesturz@gmail.com>
Date: Thu, 4 Apr 2024 22:46:30 +0200
Subject: [PATCH] manual_stepper: Add basic status. (#6527)

Adding position and enabled in manual_stepper status. Enabled is already available through stepper_enable object. But this makes it more straightforward to access it.

Signed-off-by: Viesturs Zarins <viesturz@gmail.com>
---
 docs/Status_Reference.md        | 7 +++++++
 klippy/extras/manual_stepper.py | 5 +++++
 2 files changed, 12 insertions(+)

diff --git a/docs/Status_Reference.md b/docs/Status_Reference.md
index 0e72a12b1..80f53d9f3 100644
--- a/docs/Status_Reference.md
+++ b/docs/Status_Reference.md
@@ -293,6 +293,13 @@ understands it).
 - `z_position_lower`: Last probe attempt just lower than the current height.
 - `z_position_upper`: Last probe attempt just greater than the current height.
 
+## manual_stepper
+
+The following information is available in the
+`manual_stepper` object:
+- `enabled`: Returns True if the stepper is currently enabled.
+- `position`: The requested position.
+
 ## mcu
 
 The following information is available in
diff --git a/klippy/extras/manual_stepper.py b/klippy/extras/manual_stepper.py
index 40db4a503..e18989d3a 100644
--- a/klippy/extras/manual_stepper.py
+++ b/klippy/extras/manual_stepper.py
@@ -104,6 +104,11 @@ class ManualStepper:
             self.do_move(movepos, speed, accel, sync)
         elif gcmd.get_int('SYNC', 0):
             self.sync_print_time()
+
+    def get_status(self, eventtime):
+        return {'position': self.rail.get_commanded_position(),
+                'enabled': self.steppers[0].is_motor_enabled()}
+
     # Toolhead wrappers to support homing
     def flush_step_generation(self):
         self.sync_print_time()