本文整理匯總了Python中machine.Machine.configure_endstop方法的典型用法代碼示例。如果您正苦於以下問題:Python Machine.configure_endstop方法的具體用法?Python Machine.configure_endstop怎麽用?Python Machine.configure_endstop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類machine.Machine
的用法示例。
在下文中一共展示了Machine.configure_endstop方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Printer
# 需要導入模塊: from machine import Machine [as 別名]
# 或者: from machine.Machine import configure_endstop [as 別名]
#.........這裏部分代碼省略.........
for end_stop_pos in ('left', 'right'):
if end_stop_pos in end_stops_config:
_logger.debug("Configuring %s endstops", end_stop_pos)
end_stop_config = end_stops_config[end_stop_pos]
polarity = end_stop_config['polarity']
if 'virtual' == polarity:
position = float(end_stop_config['position'])
_logger.debug(" %s endstop is virtual at %s", end_stop_pos, position)
axis['end-stops'][end_stop_pos] = {
'type': 'virtual',
'position': position
}
# left endstop get's 0 posiotn - makes sense and distance for homing use
if end_stop_pos == 'left':
axis['end-stops'][end_stop_pos]['distance'] = axis['end-stops'][end_stop_pos]['position']
axis['end-stops'][end_stop_pos]['position'] = 0
elif polarity in ('positive', 'negative'):
_logger.debug(" %s endstop is real with %s polarity", end_stop_pos, polarity)
axis['end-stops'][end_stop_pos] = {
'type': 'real',
'polarity': polarity
}
if 'motor' in end_stop_config:
motor_ = end_stop_config['motor']
_logger.debug(" %s endstops applies to motor %s", end_stop_pos, motor_)
axis['end-stops'][end_stop_pos]['motor'] = motor_
else:
raise PrinterError("Unknown end stop type " + polarity)
end_stop = deepcopy(axis['end-stops'][end_stop_pos])
if 'position' in end_stop:
end_stop['position'] = convert_mm_to_steps(end_stop['position'], axis['steps_per_mm'])
if axis['motor']:
self.machine.configure_endstop(motor=axis['motor'], position=end_stop_pos,
end_stop_config=end_stop)
else:
# endstop config is a bit more complicated for multiple motors
if end_stop_config['polarity'] == 'virtual':
for motor in axis['motors']:
self.machine.configure_endstop(motor=motor, position=end_stop_pos,
end_stop_config=end_stop)
else:
if 'motor' in end_stop_config:
motor = end_stop_config['motor']
else:
motor = axis['motors'][0]
self.machine.configure_endstop(motor=motor, position=end_stop_pos, end_stop_config=end_stop)
else:
_logger.debug("No endstops for axis %s", axis_name)
if 'encoder' in config:
# read out the encoder config
encoder_config = config['encoder']
increments = int(encoder_config['increments-per-revolution'])
if 'differential' in encoder_config and encoder_config['differential']:
differential = True
else:
differential = False
if 'inverted' in encoder_config and encoder_config['inverted']:
inverted = True
else:
inverted = False
axis['encoder'] = {
'steps-per-rev': config['steps-per-revolution'],
'increments-per-rev': increments,
'differential': differential,