Skip to content

Commit

Permalink
Updates for v3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
oskay committed Oct 6, 2022
1 parent bf7d313 commit 6a03ba7
Show file tree
Hide file tree
Showing 13 changed files with 423 additions and 351 deletions.
7 changes: 5 additions & 2 deletions cli/axicli/axidraw_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
from plotink.plot_utils_import import from_dependency_import # plotink
exit_status = from_dependency_import("ink_extensions_utils.exit_status")

cli_version = "AxiDraw Command Line Interface 3.5.0"
cli_version = "AxiDraw Command Line Interface 3.6.0"

quick_help = '''
Basic syntax to plot a file: axicli svg_in [OPTIONS]
Expand Down Expand Up @@ -162,7 +162,7 @@ def axidraw_CLI(dev = False):

parser.add_argument("-w","--walk_dist", \
metavar='DISTANCE', type=float, \
help="Distance for manual walk (inches)")
help="Distance for manual walk")

parser.add_argument("-l","--layer", \
type=int, \
Expand Down Expand Up @@ -345,4 +345,7 @@ def axidraw_CLI(dev = False):
if utils.has_output(adc) and not use_trivial_file:
utils.output_result(args.output_file, adc.outdoc)

if adc.status_code >= 100: # Give non-zero exit code.
sys.exit(1) # No need to be more verbose; we have already printed error messages.

return adc if dev else None # returning adc is useful for tests
5 changes: 5 additions & 0 deletions inkscape driver/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Bail out if python is less than 3.7
import sys
MIN_VERSION = (3, 7)
if sys.version_info < MIN_VERSION:
sys.exit("AxiDraw software must be run with python 3.7 or greater.")
2 changes: 1 addition & 1 deletion inkscape driver/axidraw.inx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ the Return to Home Corner command.

</param>
<_param name="copyright" type="description" indent="5" xml:space="preserve"
>Version 3.5.0 — Copyright 2022 Evil Mad Scientist</_param>
>Version 3.6.0 — Copyright 2022 Evil Mad Scientist</_param>



Expand Down
250 changes: 97 additions & 153 deletions inkscape driver/axidraw.py

Large diffs are not rendered by default.

73 changes: 42 additions & 31 deletions inkscape driver/axidraw_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Part of the AxiDraw driver software
#
# https://github.com/evil-mad/axidraw
# Version 3.5.0, dated 2022-07-31.
# Version 3.6.0, dated 2022-10-01.
#
# Copyright 2022 Windell H. Oskay, Evil Mad Scientist Laboratories
#
Expand All @@ -18,48 +18,59 @@
behavior and performance of your AxiDraw to your application and taste.
These parameters are used as defaults when using AxiDraw with the command-
line interface (CLI) or with the python library. With the CLI, you can
make copies of this configuration file and specify a configuration file.
line interface (CLI) or with the python API. With the CLI, you can make
copies of this configuration file and specify one as a configuration file.
When using the Python API, override individual settings within your script.
If you are operating the AxiDraw from within Inkscape, please set your
preferences within Inkscape, using the AxiDraw Control dialog.
Most values listed here are ignored when running within Inkscape.
If you are operating the AxiDraw from within Inkscape, please set your
preferences within Inkscape, using the AxiDraw Control dialog. Settings
that appear both here and in AxiDraw Control will be ignored; those
from AxiDraw Control will be used. Other settings can be configured here.
Similarly, values set within Inkscape are ignored when using the CLI or
python library.
Settings within Inkscape only affect use within Inkscape, and do not affect
the behavior of the AxiDraw CLI or Python APIs.
'''

# DEFAULT VALUES

speed_pendown = 25 # Maximum plotting speed, when pen is down (1-100)
speed_penup = 75 # Maximum transit speed, when pen is up (1-100)
accel = 75 # Acceleration rate factor (1-100)
mode = 'plot' # Operational mode or GUI tab. Default: 'plot'

pen_pos_up = 60 # Height of pen when raised (0-100)
pen_pos_down = 30 # Height of pen when lowered (0-100)
speed_pendown = 25 # Maximum plotting speed, when pen is down (1-100). Default 25
speed_penup = 75 # Maximum transit speed, when pen is up (1-100). Default 75
accel = 75 # Acceleration rate factor (1-100). Default 75

pen_rate_raise = 75 # Rate of raising pen (1-100)
pen_rate_lower = 50 # Rate of lowering pen (1-100)
pen_pos_up = 60 # Height of pen when raised (0-100). Default 60
pen_pos_down = 30 # Height of pen when lowered (0-100). Default 30

pen_delay_up = 0 # Optional delay after pen is raised (ms)
pen_delay_down = 0 # Optional delay after pen is lowered (ms)
pen_rate_raise = 75 # Rate of raising pen (1-100). Default 75
pen_rate_lower = 50 # Rate of lowering pen (1-100). Default 50

const_speed = False # Use constant velocity mode when pen is down
report_time = False # Report time elapsed
default_layer = 1 # Layer(s) selected for layers mode (1-1000)
pen_delay_up = 0 # Optional delay after pen is raised (ms). Default 0
pen_delay_down = 0 # Optional delay after pen is lowered (ms). Default 0

const_speed = False # Use constant velocity mode when pen is down. Default False
report_time = False # Report time elapsed. Default False

default_layer = 1 # Layer(s) selected for layers mode (1-1000). Default 1

manual_cmd = 'fw_version' # Manual command to execute when in manual mode.
# Default 'fw_version'

walk_dist = 1.0 # Distance to walk in "walking" manual commands. Units may be
# selected with the value of manual_cmd. Default 1.0

copies = 1 # Copies to plot, or 0 for continuous plotting. Default: 1
page_delay = 15 # Optional delay between copies (s).
page_delay = 15 # Optional delay between copies (s). Default 15

preview = False # Preview mode; simulate plotting only.
preview = False # Preview mode; simulate plotting only. Default False
rendering = 3 # Preview mode rendering option (0-3):
# 0: Do not render previews
# 1: Render only pen-down movement
# 2: Render only pen-up movement
# 3: Render all movement (Default)

model = 1 # AxiDraw Model (1-6)
model = 1 # AxiDraw Model (1-6).
# 1: AxiDraw V2 or V3 (Default). 2: AxiDraw V3/A3 or SE/A3.
# 3: AxiDraw V3 XLX. 4: AxiDraw MiniKit.
# 5: AxiDraw SE/A1. 6: AxiDraw SE/A2.
Expand All @@ -81,26 +92,26 @@
# 2: Full; Also allow path reversal
# 4: None; Strictly preserve file order

random_start = False # Randomize start locations of closed paths. (Default: False)

resolution = 1 # Resolution: (1-2):
# 1: High resolution (smoother, slightly slower) (Default)
# 2: Low resolution (coarser, slightly faster)
random_start = False # Randomize start locations of closed paths. Default False

webhook = False # Enable webhook alerts when True
# Default: False
# Default False

webhook_url = None # URL for webhook alerts
webhook_url = None # URL for webhook alerts. Default None

digest = 0 # Plot digest output option. (NOT supported in Inkscape context.)
# 0: Disabled; No change to behavior or output (Default)
# 1: Output "plob" digest, not full SVG, when saving file
# 2: Disable plots and previews; generate digest only

progress = False # Enable progress bar display in AxiDraw CLI, when True
# Default: False
# Default False
# This option has no effect in Inkscape or Python API contexts.

resolution = 1 # Resolution: (1-2):
# 1: High resolution (smoother, slightly slower) (Default)
# 2: Low resolution (coarser, slightly faster)

# Effective motor resolution is approx. 1437 or 2874 steps per inch, in the two modes respectively.
# Note that these resolutions are defined along the native axes of the machine (X+Y) and (X-Y),
# not along the XY axes of the machine. This parameter chooses 8X or 16X motor microstepping.
Expand Down
3 changes: 2 additions & 1 deletion inkscape driver/axidraw_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def __init__( self, default_logging = True, params = None ):
# use default configuration file
params = import_module("axidrawinternal.axidraw_conf") # Configuration file
self.params = params
self.status_code = 0

inkex.Effect.__init__( self )

Expand Down Expand Up @@ -188,7 +189,6 @@ def effect( self ):
self.options.port = None
self.plot_to_axidraw(self.options.port, True)


def plot_to_axidraw( self, port, primary):
""" Delegate the plot to a particular AxiDraw """
# if primary:
Expand Down Expand Up @@ -242,6 +242,7 @@ def plot_to_axidraw( self, port, primary):
if primary:
self.document = ad.document
self.outdoc = ad.get_output() # Collect output from axidraw.py
self.status_code = ad.plot_status.stopped
else:
if ad.error_out:
if port is not None:
Expand Down
18 changes: 9 additions & 9 deletions inkscape driver/axidraw_options/common_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ def core_options(parser, config):
type="int", action="store", dest="reordering",\
default=config["reordering"],\
help="SVG reordering option (0-4; 3 deprecated)."\
+ " 0: Least; Only connect adjoining paths."\
+ " 1: Basic; Also reorder paths for speed."\
+ " 2: Full; Also allow path reversal."\
+ " 4: None; Strictly preserve file order.")
+ " 0: Least: Only connect adjoining paths."\
+ " 1: Basic: Also reorder paths for speed."\
+ " 2: Full: Also allow path reversal."\
+ " 4: None: Strictly preserve file order.")

options.add_option("--resolution",\
type="int", action="store", dest="resolution",\
Expand Down Expand Up @@ -158,11 +158,11 @@ def core_options(parser, config):
return options

def core_mode_options(parser, config):
options = OptionGroup(parser, "Mode Options")
options = OptionGroup(parser, "Mode Options")

options.add_option("--mode",\
action="store", type="string", dest="mode",\
default="plot", \
default=config["mode"], \
help="Mode or GUI tab. One of: [plot, layers, align, toggle, cycle"\
+ ", manual, sysinfo, version, res_plot, res_home]. Default: plot.")

Expand All @@ -173,16 +173,16 @@ def core_mode_options(parser, config):

options.add_option("--manual_cmd",\
type="string", action="store", dest="manual_cmd",\
default="fw_version",\
default=config["manual_cmd"],\
help="Manual command. One of: [fw_version, raise_pen, lower_pen, "\
+ "walk_x, walk_y, walk_mmx, walk_mmy, walk_home, enable_xy, "\
+ "disable_xy, bootload, strip_data, read_name, list_names, "\
+ "write_name]. Default: fw_version")

options.add_option("--walk_dist",\
type="float", action="store", dest="walk_dist",\
default=1,\
help="Distance for manual walk (inches)")
default=config["walk_dist"],\
help="Distance for manual walk")

options.add_option("--layer",\
type="int", action="store", dest="layer",\
Expand Down
14 changes: 7 additions & 7 deletions inkscape driver/axidraw_options/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ def get_versions_online():
url = "https://evilmadscience.s3.amazonaws.com/sites/axidraw/versions.txt"
text = None
try:
text = requests.get(url).text
text = requests.get(url, timeout=15).text
except requests.exceptions.Timeout as err:
raise RuntimeError("Unable to check for updates online; connection timed out.\n") from err
except (RuntimeError, requests.exceptions.ConnectionError) as err_info:
raise RuntimeError("Could not contact server to check for updates. " +
f"Are you connected to the internet?\n\n(Error details: {err_info})\n")
f"Are you connected to the internet?\n\n(Error details: {err_info})\n") from err_info

if text:
try:
Expand Down Expand Up @@ -76,8 +78,8 @@ def get_fw_version(serial_port):
fw_version_string = fw_version_string.strip() # For number comparisons
return fw_version_string
except RuntimeError as err_info:
raise RuntimeError(f"Error retrieving the EBB firmware version.\n\n(Error: {err_info})\n")

raise RuntimeError(f"Error retrieving the EBB firmware version.\n\n(Error: {err_info})\n")\
from err_info

def get_current(serial_port):
'''
Expand All @@ -104,8 +106,6 @@ def log_axidraw_control_version(online_versions, current_version_string, log_fun
`online_versions` is a Versions namedtuple or False,
e.g. the return value of get_versions_online
'''
log_fun(f"This is AxiDraw Control version {current_version_string}.")

if online_versions:
if parse(online_versions.axidraw_control) > parse(current_version_string):
log_fun("An update is available to a newer version, " +
Expand All @@ -128,7 +128,6 @@ def log_ebb_version(fw_version_string, online_versions, log_fun):
'''
`online_versions` is False if we failed or didn't try to get the online versions
'''
# log_fun("\nYour AxiDraw has firmware version {}.".format(fw_version_string))
log_fun(f"\nYour AxiDraw has firmware version {fw_version_string}.")

if online_versions:
Expand All @@ -144,6 +143,7 @@ def log_version_info(serial_port, check_updates, current_version_string, preview
works whether or not `check_updates` is True, online versions were successfully retrieved,
or `serial_port` is None (i.e. not connected AxiDraw)
'''
message_fun(f"This is AxiDraw Control version {current_version_string}.")
online_versions = False
if check_updates:
try:
Expand Down
Loading

0 comments on commit 6a03ba7

Please sign in to comment.