Esempio n. 1
0
 def gen_extrusion_move(self, x, y, e_length):
     """
     Generate g-code line for extrusion move. Relative distances
     :param x: x coordinate
     :param y: y coordinate
     :param e_length: extrusion length
     :return: byte string
     """
     if utils.is_float_zero(x, 3):
         return ("G1 Y%.3f E%.4f" % (y, e_length)).encode()
     elif utils.is_float_zero(y, 3):
         return ("G1 X%.3f E%.4f" % (x, e_length)).encode()
     return ("G1 X%.3f Y%.3f E%.4f" % (x, y, e_length)).encode()
Esempio n. 2
0
 def gen_head_move(self, x, y, speed):
     """
     Generate g-code line for head move
     :param x: x coordinate
     :param y: y coordinate
     :param speed: movement speed
     :return: byte string
     """
     if utils.is_float_zero(x, 3):
         return ("G1 Y%.3f F%d" % (y, speed)).encode()
     elif utils.is_float_zero(y, 3):
         return ("G1 X%.3f F%d" % (x, speed)).encode()
     return ("G1 X%.3f Y%.3f F%d" % (x, y, speed)).encode()
Esempio n. 3
0
 def gen_head_move(self, x, y, speed):
     """
     Generate g-code line for head move
     :param x: x coordinate
     :param y: y coordinate
     :param speed: movement speed
     :return: byte string
     """
     # handle zeroes... cannot omit 0-len axes
     if utils.is_float_zero(x, 3):
         return ("G1 X0 Y%.3f F%d" % (y, speed)).encode()
     elif utils.is_float_zero(y, 3):
         return ("G1 X%.3f Y0 F%d" % (x, speed)).encode()
     return ("G1 X%.3f Y%.3f F%d" % (x, y, speed)).encode()
Esempio n. 4
0
 def gen_extrusion_move(x, y, e_length):
     """
     Generate g-code line for extrusion move. Relative distances
     :param x: x coordinate
     :param y: y coordinate
     :param e_length: extrusion length
     :return: byte string
     """
     # handle zeroes... cannot omit 0-len axes
     if utils.is_float_zero(x, 3):
         return ("G1 X0 Y%.3f E%.4f" % (y, e_length)).encode()
     elif utils.is_float_zero(y, 3):
         return ("G1 X%.3f Y0 E%.4f" % (x, e_length)).encode()
     return ("G1 X%.3f Y%.3f E%.4f" % (x, y, e_length)).encode()
Esempio n. 5
0
    def _get_prime(self, extruder):
        """
        Get g-code for prime. Calculate needed prime length from current e position
        :param extruder: extruder object
        :return: prime g-code
        """
        if not extruder.retract:
            return

        if self.e_pos < 0 and not utils.is_float_zero(self.e_pos, 3):
            prime = extruder.retract + self.e_pos
            self.e_pos = 0
            return extruder.get_prime_gcode(change=prime,
                                            comment=b" tower prime")
Esempio n. 6
0
 def _get_retraction(self, e_pos, extruder):
     """
     Get g-code for retraction. Calculate needed retraction length from current e position
     :param e_pos: extruder position
     :param extruder: extruder object
     :return: retraction g-code
     """
     retraction = extruder.retract + e_pos
     self.log.debug("Retraction to add: %s. E position: %s" %
                    (retraction, e_pos))
     if not utils.is_float_zero(retraction, 3):
         if retraction > extruder.retract:
             retraction = extruder.retract
         return ("G1 E%.4f F%.1f" % (-retraction, extruder.retract_speed)
                 ).encode(), b" tower retract"