本文整理汇总了Python中machine.Machine.configure_encoder方法的典型用法代码示例。如果您正苦于以下问题:Python Machine.configure_encoder方法的具体用法?Python Machine.configure_encoder怎么用?Python Machine.configure_encoder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类machine.Machine
的用法示例。
在下文中一共展示了Machine.configure_encoder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Printer
# 需要导入模块: from machine import Machine [as 别名]
# 或者: from machine.Machine import configure_encoder [as 别名]
#.........这里部分代码省略.........
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,
'inverted': inverted
}
self.machine.configure_encoder(axis['motor'], deepcopy(axis['encoder']))
current = config["current"]
if axis["motor"]:
self.machine.set_current(axis["motor"], current)
else:
for motor in axis['motors']:
self.machine.set_current(motor, current)
# let's see if there are any inverted motors
if 'motor' in config:
if "inverted" in config and config["inverted"]:
axis['inverted'] = True
else:
axis['inverted'] = False
self.machine.invert_motor(axis["motor"], axis['inverted'])
else:
# todo this is ok - but no perfect structure
if "inverted" in config:
axis['inverted'] = config["inverted"]
for motor in axis['motors']:
if str(motor) in config['inverted'] and config['inverted'][str(motor)]:
self.machine.invert_motor(motor, True)
def _configure_heater(self, heater_config):
output_number = heater_config['output'] - 1
if output_number < 0 or output_number >= len(beagle_bone_pins.pwm_config):
raise PrinterError("PWM pins can only be between 1 and %s" % len(beagle_bone_pins.pwm_config))
output = beagle_bone_pins.pwm_config[output_number]['out']
thermometer = Thermometer(themistor_type=heater_config['sensor-type'],
analog_input=beagle_bone_pins.pwm_config[output_number]['temp'])
if 'current_input' in beagle_bone_pins.pwm_config[output_number]:
current_pin = beagle_bone_pins.pwm_config[output_number]['current_input']