mcu: Track stepqueues separately from steppers

The MCU() class needs to track the stepqueues so that it can
initialize the steppersync object.  Track the stepqueues directly
instead of via the list of steppers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2017-08-23 18:59:25 -04:00
parent c727ed3592
commit 6ab8567d51
1 changed files with 6 additions and 6 deletions

View File

@ -48,7 +48,6 @@ class MCU_stepper:
" min_stop_interval=TICKS(%.9f) invert_step=%d" % ( " min_stop_interval=TICKS(%.9f) invert_step=%d" % (
self._oid, self._step_pin, self._dir_pin, self._oid, self._step_pin, self._dir_pin,
min_stop_interval, self._invert_step)) min_stop_interval, self._invert_step))
self._mcu.register_stepper(self)
step_cmd = self._mcu.lookup_command( step_cmd = self._mcu.lookup_command(
"queue_step oid=%c interval=%u count=%hu add=%hi") "queue_step oid=%c interval=%u count=%hu add=%hi")
dir_cmd = self._mcu.lookup_command( dir_cmd = self._mcu.lookup_command(
@ -63,6 +62,7 @@ class MCU_stepper:
max_error, step_cmd.msgid, dir_cmd.msgid, max_error, step_cmd.msgid, dir_cmd.msgid,
self._invert_dir, self._oid), self._invert_dir, self._oid),
self._ffi_lib.stepcompress_free) self._ffi_lib.stepcompress_free)
self._mcu.register_stepqueue(self._stepqueue)
def get_oid(self): def get_oid(self):
return self._oid return self._oid
def set_position(self, pos): def set_position(self, pos):
@ -417,7 +417,7 @@ class MCU:
ffi_main, self._ffi_lib = chelper.get_ffi() ffi_main, self._ffi_lib = chelper.get_ffi()
self._max_stepper_error = config.getfloat( self._max_stepper_error = config.getfloat(
'max_stepper_error', 0.000025, minval=0.) 'max_stepper_error', 0.000025, minval=0.)
self._steppers = [] self._stepqueues = []
self._steppersync = None self._steppersync = None
# Print time to clock epoch calculations # Print time to clock epoch calculations
self._print_start_time = 0. self._print_start_time = 0.
@ -617,9 +617,9 @@ class MCU:
"MCU config: %s" % (" ".join( "MCU config: %s" % (" ".join(
["%s=%s" % (k, v) for k, v in msgparser.config.items()]))] ["%s=%s" % (k, v) for k, v in msgparser.config.items()]))]
self._printer.bglogger.set_rollover_info("mcu", "\n".join(info)) self._printer.bglogger.set_rollover_info("mcu", "\n".join(info))
stepqueues = tuple(s._stepqueue for s in self._steppers)
self._steppersync = self._ffi_lib.steppersync_alloc( self._steppersync = self._ffi_lib.steppersync_alloc(
self.serial.serialqueue, stepqueues, len(stepqueues), move_count) self.serial.serialqueue, self._stepqueues, len(self._stepqueues),
move_count)
for c in self._init_cmds: for c in self._init_cmds:
self.send(self.create_command(c)) self.send(self.create_command(c))
# Config creation helpers # Config creation helpers
@ -644,8 +644,8 @@ class MCU:
self._config_cmds.append(cmd) self._config_cmds.append(cmd)
def register_msg(self, cb, msg, oid=None): def register_msg(self, cb, msg, oid=None):
self.serial.register_callback(cb, msg, oid) self.serial.register_callback(cb, msg, oid)
def register_stepper(self, stepper): def register_stepqueue(self, stepqueue):
self._steppers.append(stepper) self._stepqueues.append(stepqueue)
def alloc_command_queue(self): def alloc_command_queue(self):
return self.serial.alloc_command_queue() return self.serial.alloc_command_queue()
def lookup_command(self, msgformat): def lookup_command(self, msgformat):