当前位置: 首页>>代码示例>>Python>>正文


Python Path.axis_to_index方法代码示例

本文整理汇总了Python中Path.Path.axis_to_index方法的典型用法代码示例。如果您正苦于以下问题:Python Path.axis_to_index方法的具体用法?Python Path.axis_to_index怎么用?Python Path.axis_to_index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Path.Path的用法示例。


在下文中一共展示了Path.axis_to_index方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _go_to_home

# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import axis_to_index [as 别名]
    def _go_to_home(self, axis):
        """
        go to the designated home position
        do this as a separate call from _home_internal due to delta platforms 
        performing home in cartesian mode
        """
        
        path_home = {}
        
        speed = Path.home_speed[0]
        accel = self.printer.acceleration[0]

        for a in axis:
            path_home[a] = self.home_pos[a]
            speed = min(abs(speed), abs(Path.home_speed[Path.axis_to_index(a)]))
            
        logging.debug("Home: %s" % path_home)
            
        # Move to home position
        p = AbsolutePath(path_home, speed, accel, True, False, False, False)
        self.add_path(p)
        self.wait_until_done()
        
        # Due to rounding errors, we explicitly set the found 
        # position to the right value. 
        # Reset (final) position to offset
        p = G92Path(path_home, speed)
        self.add_path(p)

        return
开发者ID:Sciumo,项目名称:redeem,代码行数:32,代码来源:PathPlanner.py

示例2: _home_internal

# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import axis_to_index [as 别名]
    def _home_internal(self, axis):
        """ Private method for homing a set or a single axis """
        logging.debug("homing " + str(axis))

        path_back = {}
        path_center = {}
        path_zero = {}

        speed = Path.home_speed[0]

        for a in axis:
            if not self.printer.steppers[a].has_endstop:
                logging.debug("Skipping homing for " + str(a))
                continue

            path_back[a] = -self.travel_length[a]
            path_center[a] = -self.center_offset[a]
            path_zero[a] = 0
            speed = min(speed, Path.home_speed[Path.axis_to_index(a)])

            # Move until endstop is hit
        p = RelativePath(path_back, speed, True)

        self.add_path(p)

        # Reset position to offset
        p = G92Path(path_center, speed)
        self.add_path(p)

        # Move to offset
        p = AbsolutePath(path_zero, speed)
        self.add_path(p)
        self.wait_until_done()
        logging.debug("homing done for " + str(axis))
开发者ID:tomstokes,项目名称:redeem,代码行数:36,代码来源:PathPlanner.py

示例3: set_microstepping

# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import axis_to_index [as 别名]
    def set_microstepping(self, value, force_update=False):        
        """ Microstepping (default = 0) 0 to 5 """        
        if not value in [0, 1, 2, 3, 4, 5]: # Full, half, 1/4, 1/8, 1/16, 1/32.
            logging.warning("Tried to set illegal microstepping value: {0} for stepper {1}".format(value, self.name))
            return
        self.microstepping = value
        self.microsteps  = 2**value     # 2^val
        # Keep bit 0, 4, 5, 6 intact but replace bit 1, 2, 3
        self.state = int("0b"+bin(self.state)[2:].rjust(8, '0')[:4]+bin(value)[2:].rjust(3, '0')[::-1]+"0", 2)
        #self.state = int("0b"+bin(self.state)[2:].rjust(8, '0')[:4]+bin(value)[2:].rjust(3, '0')+bin(self.state)[-1:], 2)
        self.mmPrStep    = 1.0/(self.steps_pr_mm*self.microsteps)

        # update the Path class with new values
        stepper_num = Path.axis_to_index(self.name)
        Path.steps_pr_meter[stepper_num] = self.get_steps_pr_meter()
        self.update()
开发者ID:quillford,项目名称:redeem,代码行数:18,代码来源:Stepper.py

示例4: set_microstepping

# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import axis_to_index [as 别名]
    def set_microstepping(self, value, force_update=False):                
        """ Todo: Find an elegant way for this """
        EN_CFG1  = (1<<7)
        DIS_CFG1 = (0<<7)
        EN_CFG2  = (1<<5)
        DIS_CFG2 = (0<<5)
        CFG2_H   = (1<<4)
        CFG2_L   = (0<<4)
        CFG1_H   = (1<<6)
        CFG1_L   = (0<<6)

        if   value == 0:   # GND, GND
            state = EN_CFG2 | CFG2_L | EN_CFG1 | CFG1_L
            self.microsteps = 1
        elif value == 1: # GND, VCC
            state = EN_CFG2 | CFG2_L | EN_CFG1 | CFG1_H
            self.microsteps = 2
        elif value == 2: # GND, open
            state = EN_CFG2 | CFG2_L | DIS_CFG1 | CFG1_L
            self.microsteps = 2
        elif value == 3: # VCC, GND
            state = EN_CFG2 | CFG2_H | EN_CFG1 | CFG1_L
            self.microsteps = 4
        elif value == 4: # VCC, VCC
            state = EN_CFG2 | CFG2_H | EN_CFG1 | CFG1_H
            self.microsteps = 16
        elif value == 5: # VCC, open
            state = EN_CFG2 | CFG2_H | DIS_CFG1 | CFG1_L
            self.microsteps = 4
        elif value == 6: # open, GND
            state = DIS_CFG2 | CFG2_L | EN_CFG1 | CFG1_L
            self.microsteps = 16
        elif value == 7: # open, VCC
            state = DIS_CFG2 | CFG2_L | EN_CFG1 | CFG1_H
            self.microsteps = 4
        elif value == 8: # open, open
            state = DIS_CFG2 | CFG2_L | DIS_CFG1 | CFG1_L
            self.microsteps = 16

        self.shift_reg.set_state(state,0xF0)
        self.mmPrStep    = 1.0/(self.steps_pr_mm*self.microsteps)

        # update the Path class with new values
        stepper_num = Path.axis_to_index(self.name)
        Path.steps_pr_meter[stepper_num] = self.get_steps_pr_meter()
        logging.debug("Updated stepper "+self.name+" to microstepping "+str(value)+" = "+str(self.microsteps))   
        self.microstepping = value
开发者ID:Sciumo,项目名称:redeem,代码行数:49,代码来源:Stepper.py

示例5: execute

# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import axis_to_index [as 别名]
    def execute(self, g):

        t = self.printer.acceleration[:];
      
        for i in range(g.num_tokens()):
            axis = Path.axis_to_index(g.token_letter(i))
            t[axis] = float(g.token_value(i)) / 3600.0

        if Path.axis_config == Path.AXIS_CONFIG_CORE_XY or Path.axis_config == Path.AXIS_CONFIG_H_BELT:
	    # x and y should have same accelerations for lines to be straight
	    t[1] = t[0]	
        elif Path.axis_config == Path.AXIS_CONFIG_DELTA:
	    # Delta should have same accelerations on all axis
	    t[1] = t[0]
	    t[2] = t[0]
	# setup 3d movement accel
        self.set_acceleration(tuple(t[:3]))
        # Setup the extruder accel
        for i in range(Path.NUM_AXES - 3):
            e = self.printer.path_planner.native_planner.getExtruder(i)
            self.set_extruder_acceleration(e,t[i + 3])
开发者ID:tomstokes,项目名称:redeem,代码行数:23,代码来源:M201.py

示例6: _go_to_home

# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import axis_to_index [as 别名]
    def _go_to_home(self, axis):
        """
        go to the designated home position
        do this as a separate call from _home_internal due to delta platforms 
        performing home in cartesian mode
        """
        
        path_home = {}
        
        speed = Path.home_speed[0]

        for a in axis:
            path_home[a] = self.home_pos[a]
            speed = min(abs(speed), abs(Path.home_speed[Path.axis_to_index(a)]))
            
        logging.debug("Home: %s" % path_home)
            
        # Move to home position
        p = AbsolutePath(path_home, speed, True, False, False, False)
        self.add_path(p)
        self.wait_until_done()
        
        return
开发者ID:quillford,项目名称:redeem,代码行数:25,代码来源:PathPlanner.py

示例7: _home_internal

# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import axis_to_index [as 别名]
    def _home_internal(self, axis):
        """ Private method for homing a set or a single axis """
        logging.debug("homing internal " + str(axis))
            

        path_search = {}
        path_backoff = {}
        path_fine_search = {}

        path_center = {}
        path_zero = {}

        speed = Path.home_speed[0]

        for a in axis:
            if not self.printer.steppers[a].has_endstop:
                logging.debug("Skipping homing for " + str(a))
                continue
            logging.debug("Doing homing for " + str(a))
            if Path.home_speed[Path.axis_to_index(a)] < 0:
                # Search to positive ends
                path_search[a] = self.travel_length[a]
                path_center[a] = self.center_offset[a]
            else:
                # Search to negative ends
                path_search[a] = -self.travel_length[a]
                path_center[a] = -self.center_offset[a]

            backoff_length = -np.sign(path_search[a]) * Path.home_backoff_offset[Path.axis_to_index(a)]
            path_backoff[a] = backoff_length;
            path_fine_search[a] = -backoff_length * 1.2;
            
            speed = min(abs(speed), abs(Path.home_speed[Path.axis_to_index(a)]))
            fine_search_speed =  min(abs(speed), abs(Path.home_backoff_speed[Path.axis_to_index(a)]))
            
            logging.debug("axis: "+str(a))
        
        logging.debug("Search: %s" % path_search)
        logging.debug("Backoff to: %s" % path_backoff)
        logging.debug("Fine search: %s" % path_fine_search)
        logging.debug("Center: %s" % path_center)

        # Move until endstop is hit
        p = RelativePath(path_search, speed, True, False, True, False)
        self.add_path(p)
        self.wait_until_done()

        # Reset position to offset
        p = G92Path(path_center, speed)
        self.add_path(p)
        self.wait_until_done()

        # Back off a bit
        p = RelativePath(path_backoff, speed, True, False, True, False)
        self.add_path(p)

        # Hit the endstop slowly
        p = RelativePath(path_fine_search, fine_search_speed, True, False, True, False)
        self.add_path(p)
        self.wait_until_done()

        # Reset (final) position to offset
        p = G92Path(path_center, speed)
        self.add_path(p)

        return path_center, speed
开发者ID:quillford,项目名称:redeem,代码行数:68,代码来源:PathPlanner.py

示例8: __init__

# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import axis_to_index [as 别名]
    def __init__(self):
        """ Init """
        logging.info("Redeem initializing " + version)

        printer = Printer()
        self.printer = printer
        
        # check for config files
        if not os.path.exists("/etc/redeem/default.cfg"):
            logging.error("/etc/redeem/default.cfg does not exist, this file is required for operation")
            sys.exit() # maybe use something more graceful?
            
        # Parse the config files.
        printer.config = CascadingConfigParser(
            ['/etc/redeem/default.cfg', '/etc/redeem/printer.cfg',
             '/etc/redeem/local.cfg'])

        # Find out which capes are connected
        self.printer.config.parse_capes()
        self.revision = self.printer.config.replicape_revision
        if self.revision:
            logging.info("Found Replicape rev. " + self.revision)
            Path.set_axes(5)
        else:
            logging.warning("Oh no! No Replicape present!")
            self.revision = "0A4A"
            # We set it to 5 axis by default
            Path.set_axes(5)
        if self.printer.config.reach_revision:
            Path.set_axes(8)
            logging.info("Found Reach rev. "+self.printer.config.reach_revision)

        # Get the revision and loglevel from the Config file
        level = self.printer.config.getint('System', 'loglevel')
        if level > 0:
            logging.getLogger().setLevel(level)

        if self.revision in ["00A4", "0A4A", "00A3"]:
            PWM.set_frequency(100)
        elif self.revision in ["00B1"]:
            PWM.set_frequency(1000)

        # Init the Paths
        Path.axis_config = printer.config.getint('Geometry', 'axis_config')

        # Init the end stops
        EndStop.callback = self.end_stop_hit
        EndStop.inputdev = self.printer.config.get("Endstops", "inputdev")
        for es in ["X1", "X2", "Y1", "Y2", "Z1", "Z2"]:
            pin = self.printer.config.get("Endstops", "pin_"+es)
            keycode = self.printer.config.getint("Endstops", "keycode_"+es)
            invert = self.printer.config.getboolean("Endstops", "invert_"+es)
            self.printer.end_stops[es] = EndStop(pin, keycode, es, invert)

        # Backwards compatibility with A3
        if self.revision == "00A3":
            # Init the 5 Stepper motors (step, dir, fault, DAC channel, name)
            printer.steppers["X"] = Stepper_00A3("GPIO0_27", "GPIO1_29", "GPIO2_4" , 0, "X", 0, 0)
            printer.steppers["Y"] = Stepper_00A3("GPIO1_12", "GPIO0_22", "GPIO2_5" , 1, "Y", 1, 1)
            printer.steppers["Z"] = Stepper_00A3("GPIO0_23", "GPIO0_26", "GPIO0_15", 2, "Z", 2, 2)
            printer.steppers["E"] = Stepper_00A3("GPIO1_28", "GPIO1_15", "GPIO2_1" , 3, "E", 3, 3)
            printer.steppers["H"] = Stepper_00A3("GPIO1_13", "GPIO1_14", "GPIO2_3" , 4, "H", 4, 4)
        elif self.revision == "00B1":
            # Init the 5 Stepper motors (step, dir, fault, DAC channel, name)
            printer.steppers["X"] = Stepper_00B1("GPIO0_27", "GPIO1_29", "GPIO2_4" , 11, 0, "X", 0, 0)
            printer.steppers["Y"] = Stepper_00B1("GPIO1_12", "GPIO0_22", "GPIO2_5" , 12, 1, "Y", 1, 1)
            printer.steppers["Z"] = Stepper_00B1("GPIO0_23", "GPIO0_26", "GPIO0_15", 13, 2, "Z", 2, 2)
            printer.steppers["E"] = Stepper_00B1("GPIO1_28", "GPIO1_15", "GPIO2_1" , 14, 3, "E", 3, 3)
            printer.steppers["H"] = Stepper_00B1("GPIO1_13", "GPIO1_14", "GPIO2_3" , 15, 4, "H", 4, 4)
        else:
            # Init the 5 Stepper motors (step, dir, fault, DAC channel, name)
            printer.steppers["X"] = Stepper_00A4("GPIO0_27", "GPIO1_29", "GPIO2_4" , 0, 0, "X", 0, 0)
            printer.steppers["Y"] = Stepper_00A4("GPIO1_12", "GPIO0_22", "GPIO2_5" , 1, 1, "Y", 1, 1)
            printer.steppers["Z"] = Stepper_00A4("GPIO0_23", "GPIO0_26", "GPIO0_15", 2, 2, "Z", 2, 2)
            printer.steppers["E"] = Stepper_00A4("GPIO1_28", "GPIO1_15", "GPIO2_1" , 3, 3, "E", 3, 3)
            printer.steppers["H"] = Stepper_00A4("GPIO1_13", "GPIO1_14", "GPIO2_3" , 4, 4, "H", 4, 4)

            if printer.config.reach_revision:
                printer.steppers["A"] = Stepper_00A4("GPIO2_2" , "GPIO1_18", "GPIO0_14", 5, 5, "A", 5, 5)
                printer.steppers["B"] = Stepper_00A4("GPIO1_14", "GPIO0_5" , "GPIO0_14", 6, 6, "B", 6, 6)
                printer.steppers["C"] = Stepper_00A4("GPIO0_3" , "GPIO3_19", "GPIO0_14", 7, 7, "C", 7, 7)


        # Enable the steppers and set the current, steps pr mm and
        # microstepping
        for name, stepper in self.printer.steppers.iteritems():
            stepper.in_use = printer.config.getboolean('Steppers', 'in_use_' + name)
            stepper.direction = printer.config.getint('Steppers', 'direction_' + name)
            stepper.has_endstop = printer.config.getboolean('Endstops', 'has_' + name)
            stepper.set_current_value(printer.config.getfloat('Steppers', 'current_' + name))
            stepper.set_steps_pr_mm(printer.config.getfloat('Steppers', 'steps_pr_mm_' + name))
            stepper.set_microstepping(printer.config.getint('Steppers', 'microstepping_' + name))
            stepper.set_decay(printer.config.getboolean("Steppers", "slow_decay_" + name))
            # Add soft end stops
            Path.soft_min[Path.axis_to_index(name)] = printer.config.getfloat('Endstops', 'soft_end_stop_min_' + name)
            Path.soft_max[Path.axis_to_index(name)] = printer.config.getfloat('Endstops', 'soft_end_stop_max_' + name)

        # Commit changes for the Steppers
        #Stepper.commit()

#.........这里部分代码省略.........
开发者ID:quillford,项目名称:redeem,代码行数:103,代码来源:Redeem.py

示例9: __init__

# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import axis_to_index [as 别名]

#.........这里部分代码省略.........
        elif self.revision == "00B3":
            printer.steppers["X"] = Stepper_00B3("GPIO0_27", "GPIO1_29", 90, 11, 0, "X")
            printer.steppers["Y"] = Stepper_00B3("GPIO1_12", "GPIO0_22", 91, 12, 1, "Y")
            printer.steppers["Z"] = Stepper_00B3("GPIO0_23", "GPIO0_26", 92, 13, 2, "Z")
            printer.steppers["E"] = Stepper_00B3("GPIO1_28", "GPIO1_15", 93, 14, 3, "E")
            printer.steppers["H"] = Stepper_00B3("GPIO1_13", "GPIO1_14", 94, 15, 4, "H")
        elif self.revision in ["00A4", "0A4A"]:
            printer.steppers["X"] = Stepper_00A4("GPIO0_27", "GPIO1_29", "GPIO2_4" , 0, 0, "X")
            printer.steppers["Y"] = Stepper_00A4("GPIO1_12", "GPIO0_22", "GPIO2_5" , 1, 1, "Y")
            printer.steppers["Z"] = Stepper_00A4("GPIO0_23", "GPIO0_26", "GPIO0_15", 2, 2, "Z")
            printer.steppers["E"] = Stepper_00A4("GPIO1_28", "GPIO1_15", "GPIO2_1" , 3, 3, "E")
            printer.steppers["H"] = Stepper_00A4("GPIO1_13", "GPIO1_14", "GPIO2_3" , 4, 4, "H")
        # Init Reach steppers, if present. 
        if printer.config.reach_revision == "00A0":
            printer.steppers["A"] = Stepper_reach_00A4("GPIO2_2" , "GPIO1_18", "GPIO0_14", 5, 5, "A")
            printer.steppers["B"] = Stepper_reach_00A4("GPIO1_16", "GPIO0_5" , "GPIO0_14", 6, 6, "B")
            printer.steppers["C"] = Stepper_reach_00A4("GPIO0_3" , "GPIO3_19", "GPIO0_14", 7, 7, "C")
        elif printer.config.reach_revision == "00B0":
            printer.steppers["A"] = Stepper_reach_00B0("GPIO1_16", "GPIO0_5",  "GPIO0_3", 5, 5, "A")
            printer.steppers["B"] = Stepper_reach_00B0("GPIO2_2" , "GPIO0_14", "GPIO0_3", 6, 6, "B")


        # Enable the steppers and set the current, steps pr mm and
        # microstepping
        for name, stepper in self.printer.steppers.iteritems():
            stepper.in_use = printer.config.getboolean('Steppers', 'in_use_' + name)
            stepper.direction = printer.config.getint('Steppers', 'direction_' + name)
            stepper.has_endstop = printer.config.getboolean('Endstops', 'has_' + name)
            stepper.set_current_value(printer.config.getfloat('Steppers', 'current_' + name))
            stepper.set_steps_pr_mm(printer.config.getfloat('Steppers', 'steps_pr_mm_' + name))
            stepper.set_microstepping(printer.config.getint('Steppers', 'microstepping_' + name))
            stepper.set_decay(printer.config.getint("Steppers", "slow_decay_" + name))
            # Add soft end stops
            Path.soft_min[Path.axis_to_index(name)] = printer.config.getfloat('Endstops', 'soft_end_stop_min_' + name)
            Path.soft_max[Path.axis_to_index(name)] = printer.config.getfloat('Endstops', 'soft_end_stop_max_' + name)
            slave = printer.config.get('Steppers', 'slave_' + name)
            if slave:
                Path.add_slave(name, slave)
                logging.debug("Axis "+name+" has slave "+slave)

        # Commit changes for the Steppers
        #Stepper.commit()

        Stepper.printer = printer

        # Delta printer setup
        if Path.axis_config == Path.AXIS_CONFIG_DELTA:
            opts = ["Hez", "L", "r", "Ae", "Be", "Ce", "A_radial", "B_radial", "C_radial", "A_tangential", "B_tangential", "C_tangential" ]
            for opt in opts:
                Delta.__dict__[opt] = printer.config.getfloat('Delta', opt)

            Delta.recalculate()

        # Discover and add all DS18B20 cold ends.
        import glob
        paths = glob.glob("/sys/bus/w1/devices/28-*/w1_slave")
        logging.debug("Found cold ends: "+str(paths))
        for i, path in enumerate(paths):
            self.printer.cold_ends.append(ColdEnd(path, "ds18b20-"+str(i)))
            logging.info("Found Cold end "+str(i)+" on " + path)

        # Make Mosfets, thermistors and extruders
        heaters = ["E", "H", "HBP"]
        if self.printer.config.reach_revision:
            heaters.extend(["A", "B", "C"])
        for e in heaters:
开发者ID:Sciumo,项目名称:redeem,代码行数:70,代码来源:Redeem.py

示例10: make_config_file

# 需要导入模块: from Path import Path [as 别名]
# 或者: from Path.Path import axis_to_index [as 别名]
    def make_config_file(self):
        
        # Create a config file
        configFile_0 = os.path.join("/tmp", 'config.h')

        with open(configFile_0, 'w') as configFile:
        
            # GPIO banks
            banks      = {"0": 0, "1": 0, "2": 0, "3": 0}
            step_banks = {"0": 0, "1": 0, "2": 0, "3": 0}
            dir_banks  = {"0": 0, "1": 0, "2": 0, "3": 0}
            direction_mask = 0

            # Define step and dir pins
            for name, stepper in self.printer.steppers.iteritems():
                step_pin  = str(stepper.get_step_pin())
                step_bank = str(stepper.get_step_bank())
                dir_pin   = str(stepper.get_dir_pin())
                dir_bank  = str(stepper.get_dir_bank())
                configFile.write('#define STEPPER_' + name + '_STEP_BANK\t\t' + "STEPPER_GPIO_"+step_bank+'\n')          
                configFile.write('#define STEPPER_' + name + '_STEP_PIN\t\t'  + step_pin+'\n')          
                configFile.write('#define STEPPER_' + name + '_DIR_BANK\t\t'  + "STEPPER_GPIO_"+dir_bank+'\n')          
                configFile.write('#define STEPPER_' + name + '_DIR_PIN\t\t'   + dir_pin+'\n')          

                # Define direction
                direction = "0" if self.config.getint('Steppers', 'direction_' + name) > 0 else "1"
                configFile.write('#define STEPPER_'+ name +'_DIRECTION\t\t'+ direction +'\n') 

                index = Path.axis_to_index(name)
                direction_mask |= (int(direction) << index)        

                # Generate the GPIO bank masks
                banks[step_bank]      |=  (1<<int(step_pin))
                banks[dir_bank]       |=  (1<<int(dir_pin))
                step_banks[step_bank] |=  (1<<int(step_pin))
                dir_banks[dir_bank]   |=  (1<<int(dir_pin))

            configFile.write('#define DIRECTION_MASK '+bin(direction_mask)+'\n')            
            configFile.write('\n')

            # Define end stop pins and banks
            for name, endstop in self.printer.end_stops.iteritems():
                bank, pin = endstop.get_gpio_bank_and_pin()
                configFile.write('#define STEPPER_'+ name +'_END_PIN\t\t'+ str(pin) +'\n')
                configFile.write('#define STEPPER_'+ name +'_END_BANK\t\t'+ "GPIO_"+str(bank) +'_IN\n')

            configFile.write('\n')

            # Construct the end stop inversion mask
            inversion_mask = "#define INVERSION_MASK\t\t0b00"
            for name in ["Z2", "Y2", "X2", "Z1", "Y1", "X1"]:
                inversion_mask += "1" if self.config.getboolean('Endstops', 'invert_' + name) else "0"

            configFile.write(inversion_mask + "\n");

            # Construct the endstop lookup table.
            for name, endstop in self.printer.end_stops.iteritems():
                mask = 0
                # stepper name is x_cw or x_ccw
                option = 'end_stop_' + name + '_stops'
                for stepper in self.config.get('Endstops', option).split(","):
                    stepper = stepper.strip()
                    if stepper == "":
                        continue
                    m = re.search('^([xyzehabc])_(ccw|cw|pos|neg)$', stepper)
                    if (m == None):
                        raise RuntimeError("'" + stepper + "' is invalid for " + option)

                    # direction should be 1 for normal operation and -1 to invert the stepper.
                    if (m.group(2) == "pos"):
                        direction = -1
                    elif (m.group(2) == "neg"):
                        direction = 1
                    else:
                        direction = 1 if self.config.getint('Steppers', 'direction_' + stepper[0]) > 0 else -1
                        if (m.group(2) == "ccw"): 
                            direction *= -1

                    cur = 1 << ("xyzehabc".index(m.group(1)))
                    if (direction == -1):
                        cur <<= 8
                    mask += cur
                bin_mask = "0b"+(bin(mask)[2:]).zfill(16)
                configFile.write("#define STEPPER_MASK_" + name + "\t\t" + bin_mask + "\n")
        
            configFile.write("\n");


            # Put each dir and step pin in the proper buck if they are for GPIO0 or GPIO1 bank. 
            # This is a restriction due to the limited capabilities of the pasm preprocessor.            
            for name, bank in banks.iteritems():
                #bank = (~bank & 0xFFFFFFFF)
                configFile.write("#define GPIO"+name+"_MASK\t\t" +bin(bank)+ "\n");
            #for name, bank in step_banks.iteritems():
                #bank = (~bank & 0xFFFFFFFF)
            #    configFile.write("#define GPIO"+name+"_STEP_MASK\t\t" +bin(bank)+ "\n");
            for name, bank in dir_banks.iteritems():
                #bank = (~bank & 0xFFFFFFFF)
                configFile.write("#define GPIO"+name+"_DIR_MASK\t\t" +bin(bank)+ "\n");

#.........这里部分代码省略.........
开发者ID:Sciumo,项目名称:redeem,代码行数:103,代码来源:PruFirmware.py


注:本文中的Path.Path.axis_to_index方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。