Switch the motors off when the designs are done or stopped
After the last design (or a Stop), the player sends $SLP (GRBL and FluidNC sleep), so the motors stop holding and the table is quiet. The page shows "Motors off"; the next design wakes the controller (reset + unlock) and homes first, since the arm can be moved by hand while the motors are off. The jog panel wakes it too. Setting: motion.motors_off_when_done (default true). Checked on the real Uno: Idle -> $SLP -> Sleep -> reset -> Alarm -> $X -> Idle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8967271e90
commit
7afe562124
10 files changed
+104
-10
No files matched your search
@@ -34,6 +34,7 @@ class FakeGrbl:
|
||||
self.hold = False
|
||||
self.alarm = False
|
||||
self.unplugged = False # set to pretend the USB cable came out
|
||||
self.sleeping = False # after $SLP: motors off until a reset
|
||||
self.absolute = True
|
||||
self.settings = {'$3': '0', '$100': '250.000', '$101': '250.000', '$110': '500', '$111': '500'}
|
||||
self.max_rx = 0
|
||||
@@ -80,6 +81,8 @@ class FakeGrbl:
|
||||
self.hold = False
|
||||
elif b == 0x18:
|
||||
moving = bool(self.planner) and not self.hold
|
||||
if self.sleeping: # waking from sleep: GRBL comes up locked
|
||||
self.sleeping, self.alarm = False, True
|
||||
if moving:
|
||||
self.alarm = True
|
||||
self._emit('ALARM:3') # reset while in motion: position lost
|
||||
@@ -124,7 +127,7 @@ class FakeGrbl:
|
||||
f'{self.wco[0]:.3f},{self.wco[1]:.3f},0.000{pn}>')
|
||||
|
||||
def _take_line(self):
|
||||
if b'\n' not in self.rx or len(self.planner) >= self.PLANNER:
|
||||
if self.sleeping or b'\n' not in self.rx or len(self.planner) >= self.PLANNER:
|
||||
return
|
||||
raw, _, rest = bytes(self.rx).partition(b'\n')
|
||||
self.rx = bytearray(rest)
|
||||
@@ -146,6 +149,10 @@ class FakeGrbl:
|
||||
if ax in w:
|
||||
tgt[i] = (self.mpos[i] + float(w[ax])) if rel else float(w[ax]) + self.wco[i]
|
||||
self.planner.append(['jog', tgt, float(w.get('F', 600))])
|
||||
elif line == '$SLP':
|
||||
self.sleeping = True
|
||||
self.planner.clear()
|
||||
self.state = 'Sleep'
|
||||
elif line.startswith('$X'):
|
||||
self.alarm = False
|
||||
self.state = 'Idle'
|
||||
@@ -189,6 +196,9 @@ class FakeGrbl:
|
||||
dt = real_dt * self.speedup
|
||||
self.t_last = now
|
||||
self._take_line()
|
||||
if self.sleeping:
|
||||
self.state = 'Sleep'
|
||||
continue
|
||||
if self.alarm:
|
||||
self.state = 'Alarm'
|
||||
continue
|
||||
|
||||
Reference in new issue
Block a user