From 7c5772d5651ad93035243963d638753e4d25f298 Mon Sep 17 00:00:00 2001 From: El Kaplan Date: Thu, 14 Mar 2024 17:36:12 -0400 Subject: [PATCH] power on warning --- elkplot/device.py | 5 +++++ elkplot/util.py | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/elkplot/device.py b/elkplot/device.py index d5ea037..556f75b 100644 --- a/elkplot/device.py +++ b/elkplot/device.py @@ -302,3 +302,8 @@ def pen_up(self): def pen_down(self): """Lower the pen""" return self._command("SP", 0, self.pen_down_delay, self.pen_lift_pin) + + def powered_on(self): + stepper, motor = (int(elem) for elem in self._command("QC").split(",")) + self._readline() + return stepper > 200 and motor > 200 diff --git a/elkplot/util.py b/elkplot/util.py index a14f91e..96afd06 100644 --- a/elkplot/util.py +++ b/elkplot/util.py @@ -85,10 +85,13 @@ def draw( f"Drawing has bounds ({min_x}, {min_y}) to ({max_x}, {max_y}), which extends outside the plottable bounds (0, 0) to ({width}, {height})" ) if not elkplot.device.axidraw_available(): - raise AxidrawNotFoundError() + raise AxidrawNotFoundError("Unable to communicate with device. Is the USB cable plugged in?") device = elkplot.Device() if device is None else device + if not device.powered_on(): + raise AxidrawNotFoundError("Motors do not have power. Is the AxiDraw plugged in and turned on?") device.zero_position() device.enable_motors() + device.pen_up() for layer, label in zip(layers, layer_labels): input(f"Press enter when you're ready to draw {label}") for _ in range(retrace):