Skip to content

Commit

Permalink
AxiDraw software version 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
oskay committed Feb 8, 2023
1 parent eeb37e4 commit 8dcc95e
Show file tree
Hide file tree
Showing 36 changed files with 4,032 additions and 2,602 deletions.
60 changes: 43 additions & 17 deletions cli/axicli/axidraw_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import print_function
'''
axicli - Command Line Interface (CLI) for AxiDraw.
Expand Down Expand Up @@ -36,7 +35,7 @@
Copyright 2022 Windell H. Oskay, Evil Mad Scientist Laboratories
Copyright 2023 Windell H. Oskay, Evil Mad Scientist Laboratories
The MIT License (MIT)
Expand All @@ -63,17 +62,15 @@
import argparse
import copy
import sys

from lxml import etree

from pyaxidraw.axidraw_options import common_options

from axicli import utils

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.7.2"
cli_version = "AxiDraw Command Line Interface 3.8.0"

quick_help = '''
Basic syntax to plot a file: axicli svg_in [OPTIONS]
Expand All @@ -84,7 +81,7 @@
For full user guide, please see: https://axidraw.com/doc/cli_api/
(c) 2022 Evil Mad Scientist Laboratories
(c) 2023 Evil Mad Scientist Laboratories
'''

def axidraw_CLI(dev = False):
Expand Down Expand Up @@ -157,12 +154,13 @@ def axidraw_CLI(dev = False):
metavar='COMMAND', type=str, \
help="Manual command. One of: [fw_version, lower_pen, raise_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")
+ "bootload, strip_data, read_name, "\
+ "list_names, write_name]. Default: fw_version")

parser.add_argument("-w","--walk_dist", \
parser.add_argument("-w","--dist","--walk_dist", \
metavar='DISTANCE', type=float, \
help="Distance for manual walk")
help="Distance for manual walk or changing resume position. "\
+ "(The argument name walk_dist is deprecated.)")

parser.add_argument("-l","--layer", \
type=int, \
Expand Down Expand Up @@ -200,9 +198,16 @@ def axidraw_CLI(dev = False):
parser.add_argument("-L","--model",\
metavar='MODELCODE', type=int,\
help="AxiDraw Model (1-7). 1: AxiDraw V2, V3, or SE/A4. " \
+ "2:AxiDraw V3/A3 or SE/A3. 3: AxiDraw V3 XLX. " \
+ "4:AxiDraw MiniKit. 5:AxiDraw SE/A1. 6: AxiDraw SE/A2. " \
+ "7:AxiDraw V3/B6." )
+ "2: AxiDraw V3/A3 or SE/A3. 3: AxiDraw V3 XLX. " \
+ "4: AxiDraw MiniKit. 5:AxiDraw SE/A1. 6: AxiDraw SE/A2. " \
+ "7: AxiDraw V3/B6." )

parser.add_argument("-q","--penlift",\
metavar='LIFTCODE', type=int,\
help="Pen lift servo configuration (1-3). " \
+ "1: Default for AxiDraw model. " \
+ "2: Standard servo (lowest connector position). " \
+ "3: Narrow-band brushless servo (3rd position up)." )

parser.add_argument("-p","--port",\
metavar='PORTNAME', type=str,\
Expand Down Expand Up @@ -257,7 +262,10 @@ def axidraw_CLI(dev = False):

# Detect certain "trivial" cases that do not require an input file
use_trivial_file = False
if args.mode in ["align", "toggle", "cycle", "version", "sysinfo", "manual"]:
if args.mode in ("align", "toggle", "cycle", "version", "sysinfo"):
use_trivial_file = True
if args.mode == "manual" and args.manual_cmd not in\
("strip_data", "res_read","res_off_in", "res_adj_mm"):
use_trivial_file = True

svg_input = args.svg_in
Expand Down Expand Up @@ -299,7 +307,25 @@ def axidraw_CLI(dev = False):
quit()

# For nontrivial cases, import the axidraw module and go from there:

# THIS SECTION: SLATED FOR REMOVAL IN AXIDRAW SOFTWARE 4.0
# Backwards compatibility for custom configuration files including `walk_dist`,
# the deprecated predecessor to `dist`
#
# If a custom config file specifies walk_dist (deprecated version of dist),
# that overrides the value in the default config file.
# If a custom config file specifies dist, that overrides both:
config_dict = utils.load_configs([args.config]) # Remove in v 4.0
new_dist = config_dict.get('dist') # Remove in v 4.0
new_walk_dist = config_dict.get('walk_dist') # Remove in v 4.0

config_dict = utils.load_configs([args.config, 'axidrawinternal.axidraw_conf'])

if new_walk_dist is not None: # Remove in v 4.0
config_dict['dist'] = new_walk_dist # Remove in v 4.0
if new_dist is not None: # Remove in v 4.0
config_dict['dist'] = new_dist # Remove in v 4.0

combined_config = utils.FakeConfigModule(config_dict)

from pyaxidraw import axidraw_control
Expand Down Expand Up @@ -334,9 +360,9 @@ def axidraw_CLI(dev = False):
option_names = ['mode', 'speed_pendown', 'speed_penup', 'accel', 'pen_pos_down', 'pen_pos_up',
'pen_rate_lower', 'pen_rate_raise', 'pen_delay_down', 'pen_delay_up',
'random_start', 'reordering', 'no_rotate', 'const_speed', 'report_time',
'manual_cmd', 'walk_dist', 'layer', 'copies', 'page_delay', 'preview',
'rendering', 'model', 'port', 'port_config', 'webhook', 'webhook_url',
'digest', 'progress']
'manual_cmd', 'dist', 'layer', 'copies', 'page_delay', 'preview',
'rendering', 'model', 'penlift', 'port', 'port_config', 'webhook',
'webhook_url', 'digest', 'progress']
utils.assign_option_values(adc.options, args, [config_dict], option_names)

adc.cli_api = True # Set flag that this is being called from the CLI.
Expand Down
15 changes: 13 additions & 2 deletions cli/examples_python/estimate_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
---------------------------------------------------------------------
Copyright 2022 Windell H. Oskay, Evil Mad Scientist Laboratories
Copyright 2023 Windell H. Oskay, Evil Mad Scientist Laboratories
The MIT License (MIT)
Expand Down Expand Up @@ -108,8 +108,19 @@
# ad.plot_setup("AxiDraw_trivial.svg")

ad.options.preview = True
ad.options.report_time = True # Enable time estimates
ad.options.report_time = True # Enable time and distance estimates

ad.plot_run() # plot the document

print_time_seconds = ad.time_estimate
dist_pen_down = ad.distance_pendown
dist_pen_total = ad.distance_total
pen_lifts = ad.pen_lifts
elasped_time = ad.time_elapsed

print("Printing estimates read from python API variables:")
print(f"Estimated print time: {print_time_seconds} s")
print(f"Pen-down motion distance: {dist_pen_down:.3f} m")
print(f"Total motion distance: {dist_pen_total:.3f} m")
print(f"Pen lift count: {pen_lifts}")
print(f"Elapsed time for this estimate: {elasped_time:.3f} s")
20 changes: 13 additions & 7 deletions cli/examples_python/interactive_usb_com.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
http://evil-mad.github.io/EggBot/ebb.html
https://axidraw.com/doc/py_api/#additional-parameters
* This script will run continuously until interrupted. *
Hardware setup:
Hardware setup (important!):
The pen-lift servo on an AxiDraw V3 is normally connected to output B1,
the *lowest* set of three pins on the AxiDraw's EBB control board, with the
Expand All @@ -31,6 +27,11 @@
connection from the lowest three pins and moving it to the highest three pins,
keeping the black wire towards the back of the machine.
Note that this example file assumes that a *standard* servo, not a
narrow-band servo is being used for the servo control signal values.
---------------------------------------------------------------------
About the interactive API:
Expand Down Expand Up @@ -68,7 +69,7 @@
---------------------------------------------------------------------
Copyright 2022 Windell H. Oskay, Evil Mad Scientist Laboratories
Copyright 2023 Windell H. Oskay, Evil Mad Scientist Laboratories
The MIT License (MIT)
Expand Down Expand Up @@ -131,8 +132,10 @@
pen_up_pos = int (PEN_UP_PERCENT * servo_range / 100 + servo_min)
pen_down_pos = int (PEN_DOWN_PERCENT * servo_range / 100 + servo_min)

index = 0

try:
while True: # Repeat until interrupted
while index < 20: # Repeat many times (unless interrupted)

if PEN_IS_UP:
position = pen_down_pos
Expand All @@ -154,6 +157,9 @@
ad.usb_command(COMMAND + "\r")

time.sleep(WAIT_TIME_S)
index += 1

except KeyboardInterrupt:
ad.disconnect() # Close serial port to AxiDraw

ad.disconnect() # Close serial port to AxiDraw in any case.
6 changes: 3 additions & 3 deletions cli/examples_python/plot_inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
---------------------------------------------------------------------
Copyright 2022 Windell H. Oskay, Evil Mad Scientist Laboratories
Copyright 2023 Windell H. Oskay, Evil Mad Scientist Laboratories
The MIT License (MIT)
Expand Down Expand Up @@ -135,8 +135,8 @@
# Add a programatic ellipse, with randomly generated size and position.
# This will be different every time that you run this script.

cx = 20 + 140 * random.random()
cy = 20 + 80 * random.random()
cx = 20 + 80 * random.random()
cy = 20 + 40 * random.random()
rx = 20 * random.random()
ry = 20 * random.random()

Expand Down
4 changes: 2 additions & 2 deletions cli/examples_python/turtle_pos.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
---------------------------------------------------------------------
Copyright 2022 Windell H. Oskay, Evil Mad Scientist Laboratories
Copyright 2023 Windell H. Oskay, Evil Mad Scientist Laboratories
The MIT License (MIT)
Expand Down Expand Up @@ -91,7 +91,7 @@ def print_position():
turtle_pen_state = ad.turtle_pen()
current_pen_state = ad.current_pen()
print("Turtle pen up: " + str(turtle_pen_state))
print("Actutal pen up: " + str(current_pen_state) + "\n")
print("Actual pen up: " + str(current_pen_state) + "\n")

ad.interactive() # Enter interactive mode
connected = ad.connect() # Open serial port to AxiDraw
Expand Down

0 comments on commit 8dcc95e

Please sign in to comment.