kinematics: Convert to Python3 string encoding

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2021-10-01 19:09:37 -04:00
parent 68b939c756
commit de38ef4290
9 changed files with 31 additions and 30 deletions

View File

@ -38,7 +38,7 @@ class ForceMove:
self.trapq_append = ffi_lib.trapq_append
self.trapq_finalize_moves = ffi_lib.trapq_finalize_moves
self.stepper_kinematics = ffi_main.gc(
ffi_lib.cartesian_stepper_alloc('x'), ffi_lib.free)
ffi_lib.cartesian_stepper_alloc(b'x'), ffi_lib.free)
# Register commands
gcode = self.printer.lookup_object('gcode')
gcode.register_command('STEPPER_BUZZ', self.cmd_STEPPER_BUZZ,

View File

@ -26,7 +26,7 @@ class ManualStepper:
self.trapq = ffi_main.gc(ffi_lib.trapq_alloc(), ffi_lib.trapq_free)
self.trapq_append = ffi_lib.trapq_append
self.trapq_finalize_moves = ffi_lib.trapq_finalize_moves
self.rail.setup_itersolve('cartesian_stepper_alloc', 'x')
self.rail.setup_itersolve('cartesian_stepper_alloc', b'x')
self.rail.set_trapq(self.trapq)
# Register commands
stepper_name = config.get_name().split()[1]

View File

@ -15,7 +15,7 @@ class CartKinematics:
self.rails = [stepper.LookupMultiRail(config.getsection('stepper_' + n))
for n in 'xyz']
for rail, axis in zip(self.rails, 'xyz'):
rail.setup_itersolve('cartesian_stepper_alloc', axis)
rail.setup_itersolve('cartesian_stepper_alloc', axis.encode())
for s in self.get_steppers():
s.set_trapq(toolhead.get_trapq())
toolhead.register_step_generator(s.generate_steps)
@ -37,7 +37,7 @@ class CartKinematics:
dc_axis = dc_config.getchoice('axis', {'x': 'x', 'y': 'y'})
self.dual_carriage_axis = {'x': 0, 'y': 1}[dc_axis]
dc_rail = stepper.LookupMultiRail(dc_config)
dc_rail.setup_itersolve('cartesian_stepper_alloc', dc_axis)
dc_rail.setup_itersolve('cartesian_stepper_alloc', dc_axis.encode())
for s in dc_rail.get_steppers():
toolhead.register_step_generator(s.generate_steps)
self.dual_carriage_rails = [

View File

@ -16,9 +16,9 @@ class CoreXYKinematics:
self.rails[1].get_steppers()[0])
self.rails[1].get_endstops()[0][0].add_stepper(
self.rails[0].get_steppers()[0])
self.rails[0].setup_itersolve('corexy_stepper_alloc', '+')
self.rails[1].setup_itersolve('corexy_stepper_alloc', '-')
self.rails[2].setup_itersolve('cartesian_stepper_alloc', 'z')
self.rails[0].setup_itersolve('corexy_stepper_alloc', b'+')
self.rails[1].setup_itersolve('corexy_stepper_alloc', b'-')
self.rails[2].setup_itersolve('cartesian_stepper_alloc', b'z')
for s in self.get_steppers():
s.set_trapq(toolhead.get_trapq())
toolhead.register_step_generator(s.generate_steps)

View File

@ -16,9 +16,9 @@ class CoreXZKinematics:
self.rails[2].get_steppers()[0])
self.rails[2].get_endstops()[0][0].add_stepper(
self.rails[0].get_steppers()[0])
self.rails[0].setup_itersolve('corexz_stepper_alloc', '+')
self.rails[1].setup_itersolve('cartesian_stepper_alloc', 'y')
self.rails[2].setup_itersolve('corexz_stepper_alloc', '-')
self.rails[0].setup_itersolve('corexz_stepper_alloc', b'+')
self.rails[1].setup_itersolve('cartesian_stepper_alloc', b'y')
self.rails[2].setup_itersolve('corexz_stepper_alloc', b'-')
for s in self.get_steppers():
s.set_trapq(toolhead.get_trapq())
toolhead.register_step_generator(s.generate_steps)

View File

@ -18,9 +18,9 @@ class HybridCoreXYKinematics:
stepper.LookupMultiRail(config.getsection('stepper_z'))]
self.rails[1].get_endstops()[0][0].add_stepper(
self.rails[0].get_steppers()[0])
self.rails[0].setup_itersolve('corexy_stepper_alloc', '-')
self.rails[1].setup_itersolve('cartesian_stepper_alloc', 'y')
self.rails[2].setup_itersolve('cartesian_stepper_alloc', 'z')
self.rails[0].setup_itersolve('corexy_stepper_alloc', b'-')
self.rails[1].setup_itersolve('cartesian_stepper_alloc', b'y')
self.rails[2].setup_itersolve('cartesian_stepper_alloc', b'z')
ranges = [r.get_range() for r in self.rails]
self.axes_min = toolhead.Coord(*[r[0] for r in ranges], e=0.)
self.axes_max = toolhead.Coord(*[r[1] for r in ranges], e=0.)
@ -33,15 +33,15 @@ class HybridCoreXYKinematics:
self.rails.append(stepper.PrinterRail(dc_config))
self.rails[1].get_endstops()[0][0].add_stepper(
self.rails[3].get_steppers()[0])
self.rails[3].setup_itersolve('cartesian_stepper_alloc', 'y')
self.rails[3].setup_itersolve('cartesian_stepper_alloc', b'y')
dc_rail_0 = idex_modes.DualCarriagesRail(
self.printer, self.rails[0], axis=0, active=True,
stepper_alloc_active=('corexy_stepper_alloc','-'),
stepper_alloc_inactive=('cartesian_reverse_stepper_alloc','y'))
stepper_alloc_active=('corexy_stepper_alloc', b'-'),
stepper_alloc_inactive=('cartesian_reverse_stepper_alloc',b'y'))
dc_rail_1 = idex_modes.DualCarriagesRail(
self.printer, self.rails[3], axis=0, active=False,
stepper_alloc_active=('corexy_stepper_alloc','+'),
stepper_alloc_inactive=('cartesian_stepper_alloc','y'))
stepper_alloc_active=('corexy_stepper_alloc', b'+'),
stepper_alloc_inactive=('cartesian_stepper_alloc', b'y'))
self.dc_module = idex_modes.DualCarriages(self.printer,
dc_rail_0, dc_rail_1, axis=0)
for s in self.get_steppers():

View File

@ -18,9 +18,9 @@ class HybridCoreXZKinematics:
stepper.LookupMultiRail(config.getsection('stepper_z'))]
self.rails[2].get_endstops()[0][0].add_stepper(
self.rails[0].get_steppers()[0])
self.rails[0].setup_itersolve('corexz_stepper_alloc', '-')
self.rails[1].setup_itersolve('cartesian_stepper_alloc', 'y')
self.rails[2].setup_itersolve('cartesian_stepper_alloc', 'z')
self.rails[0].setup_itersolve('corexz_stepper_alloc', b'-')
self.rails[1].setup_itersolve('cartesian_stepper_alloc', b'y')
self.rails[2].setup_itersolve('cartesian_stepper_alloc', b'z')
ranges = [r.get_range() for r in self.rails]
self.axes_min = toolhead.Coord(*[r[0] for r in ranges], e=0.)
self.axes_max = toolhead.Coord(*[r[1] for r in ranges], e=0.)
@ -33,15 +33,15 @@ class HybridCoreXZKinematics:
self.rails.append(stepper.PrinterRail(dc_config))
self.rails[2].get_endstops()[0][0].add_stepper(
self.rails[3].get_steppers()[0])
self.rails[3].setup_itersolve('cartesian_stepper_alloc', 'z')
self.rails[3].setup_itersolve('cartesian_stepper_alloc', b'z')
dc_rail_0 = idex_modes.DualCarriagesRail(
self.printer, self.rails[0], axis=0, active=True,
stepper_alloc_active=('corexz_stepper_alloc','-'),
stepper_alloc_inactive=('cartesian_reverse_stepper_alloc','z'))
stepper_alloc_active=('corexz_stepper_alloc', b'-'),
stepper_alloc_inactive=('cartesian_reverse_stepper_alloc',b'z'))
dc_rail_1 = idex_modes.DualCarriagesRail(
self.printer, self.rails[3], axis=0, active=False,
stepper_alloc_active=('corexz_stepper_alloc','+'),
stepper_alloc_inactive=('cartesian_stepper_alloc','z'))
stepper_alloc_active=('corexz_stepper_alloc', b'+'),
stepper_alloc_inactive=('cartesian_stepper_alloc', b'z'))
self.dc_module = idex_modes.DualCarriages(self.printer,
dc_rail_0, dc_rail_1, axis=0)
for s in self.get_steppers():

View File

@ -13,9 +13,9 @@ class PolarKinematics:
units_in_radians=True)
rail_arm = stepper.PrinterRail(config.getsection('stepper_arm'))
rail_z = stepper.LookupMultiRail(config.getsection('stepper_z'))
stepper_bed.setup_itersolve('polar_stepper_alloc', 'a')
rail_arm.setup_itersolve('polar_stepper_alloc', 'r')
rail_z.setup_itersolve('cartesian_stepper_alloc', 'z')
stepper_bed.setup_itersolve('polar_stepper_alloc', b'a')
rail_arm.setup_itersolve('polar_stepper_alloc', b'r')
rail_z.setup_itersolve('cartesian_stepper_alloc', b'z')
self.rails = [rail_arm, rail_z]
self.steppers = [stepper_bed] + [ s for r in self.rails
for s in r.get_steppers() ]

View File

@ -191,7 +191,8 @@ class MCU_stepper:
raise error("Internal error in stepcompress")
def is_active_axis(self, axis):
ffi_main, ffi_lib = chelper.get_ffi()
return ffi_lib.itersolve_is_active_axis(self._stepper_kinematics, axis)
a = axis.encode()
return ffi_lib.itersolve_is_active_axis(self._stepper_kinematics, a)
# Helper code to build a stepper object from a config section
def PrinterStepper(config, units_in_radians=False):