本文整理汇总了Python中machine.Machine.read_positon方法的典型用法代码示例。如果您正苦于以下问题:Python Machine.read_positon方法的具体用法?Python Machine.read_positon怎么用?Python Machine.read_positon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类machine.Machine
的用法示例。
在下文中一共展示了Machine.read_positon方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Printer
# 需要导入模块: from machine import Machine [as 别名]
# 或者: from machine.Machine import read_positon [as 别名]
#.........这里部分代码省略.........
self.extruder_heater = self._configure_heater(extruder_heater_config)
for axis_name, config_name in _axis_config.iteritems():
_logger.info("Configuring axis \'%s\' according to conf \'%s\'", axis_name, config_name)
axis = {'name': axis_name}
self.axis[axis_name] = axis
self._configure_axis(axis, config[config_name])
self._postconfig()
def connect(self):
_logger.debug("Connecting printer")
self.machine.connect()
def start_print(self):
self._print_queue = PrintQueue(axis_config=self.axis, min_length=self.print_queue_min_length,
max_length=self.print_queue_max_length, default_target_speed=self.default_speed)
self.machine.start_motion()
self.printing = True
self.led_manager.light(1, True)
def finish_print(self):
self._print_queue.finish()
self.machine.finish_motion()
self.printing = False
self.led_manager.light(1, False)
def read_motor_positons(self):
positions = {}
for axis_name in self.axis:
axis_config = self.axis[axis_name]
motor = axis_config['motor']
position = self.machine.read_positon(motor)
positions[axis_name] = position / axis_config['steps_per_mm']
return positions
def read_axis_status(self):
status = {}
for axis_name in self.axis:
axis_config = self.axis[axis_name]
motor = axis_config['motor']
if motor:
internal_status = self.machine.read_axis_status(motor)
position = internal_status['position']
position = position / axis_config['steps_per_mm']
encoder_pos = internal_status['encoder_pos']
encoder_pos = encoder_pos / axis_config['steps_per_mm']
left_endstop_ = internal_status['left_endstop']
right_endstop_ = internal_status['right_endstop']
else:
# todo implement
position = 0
encoder_pos = 0
left_endstop_ = False
right_endstop_ = False
status[axis_name] = {
"position": position,
"encoder_pos": encoder_pos,
"left_endstop": left_endstop_,
"right_endstop": right_endstop_
}
return status
def home(self, axis):