當前位置: 首頁>>代碼示例>>Python>>正文


Python Machine.start_motion方法代碼示例

本文整理匯總了Python中machine.Machine.start_motion方法的典型用法代碼示例。如果您正苦於以下問題:Python Machine.start_motion方法的具體用法?Python Machine.start_motion怎麽用?Python Machine.start_motion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在machine.Machine的用法示例。


在下文中一共展示了Machine.start_motion方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Printer

# 需要導入模塊: from machine import Machine [as 別名]
# 或者: from machine.Machine import start_motion [as 別名]
class Printer(Thread):
    def __init__(self, serial_port, reset_pin, print_queue_min_length=50, print_queue_max_length=100):
        Thread.__init__(self)
        self.ready = False
        self.printing = False
        self.config = None
        self.homed_axis = []

        self.heated_bed = None
        self.extruder_heater = None
        self.axis = {}

        self.axis_position = {}
        for axis_name in _axis_config:
            self.axis_position[axis_name] = 0

        self.printer_thread = None
        self._print_queue = None
        self.print_queue_min_length = print_queue_min_length
        self.print_queue_max_length = print_queue_max_length
        self._default_homing_retraction = None
        self._x_step_conversion = None
        self._y_step_conversion = None

        self._homing_timeout = 10
        self._print_queue_wait_time = 0.1
        self.homed = False

        self.led_manager = LedManager()

        # todo why didn't this work as global constant?? - should be confugired anyway
        self._FAN_OUTPUT = beagle_bone_pins.pwm_config[2]['out']

        # finally create the machine
        self.machine = Machine(serial_port=serial_port, reset_pin=reset_pin)
        self.running = True
        self.start()

    def stop(self):
        if self.running:
            self.running = False
        if self.isAlive():
            self.join()
        self.machine.disconnect()

    def axis_names(self):
        return _axis_names

    def configure(self, config):
        if not config:
            raise PrinterError("No printer config given!")

        self.config = config

        printer_config = config['printer']
        print_queue_config = printer_config["print-queue"]
        self.print_queue_min_length = print_queue_config['min-length']
        self.print_queue_max_length = print_queue_config['max-length']
        self._homing_timeout = printer_config['homing-timeout']
        self._default_homing_retraction = printer_config['home-retract']
        self.default_speed = printer_config['default-speed']

        # todo this is the fan and should be configured
        PWM.start(self._FAN_OUTPUT, printer_config['fan-duty-cycle'], printer_config['fan-frequency'], 0)

        if 'heated-bed' in printer_config:
            bed_heater_config = printer_config['heated-bed']
            self.heated_bed = self._configure_heater(bed_heater_config)

        extruder_heater_config = config['extruder']['heater']
        # we do not care if it the extruder heate may not be given in the config
        # # - the whole point of additive printing is pretty dull w/o an heated extruder
        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)

#.........這裏部分代碼省略.........
開發者ID:MbedTinkerer,項目名稱:T-Bone,代碼行數:103,代碼來源:printer.py


注:本文中的machine.Machine.start_motion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。