本文整理匯總了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):