Added convert_text fucntion to the text_to_gcode file, that takes user's text and return gcode
This commit is contained in:
@@ -17,13 +17,14 @@ class Gcode:
|
||||
self.init_file()
|
||||
|
||||
def init_file(self):
|
||||
self.output = open(f"{self.file}.gcode", "w")
|
||||
self.output.write("G21 ;Unit to mm\n")
|
||||
self.output.write("G90 ;Absolute positioning\n\n")
|
||||
self.output.write(f"F{self.speed}\n")
|
||||
# self.output = open(f"{self.file}.gcode", "w")
|
||||
self.output = ""
|
||||
self.output += ("G21 ;Unit to mm\n")
|
||||
self.output += ("G90 ;Absolute positioning\n\n")
|
||||
self.output += (f"F{self.speed}\n")
|
||||
if self.machine == Machine.LASER:
|
||||
self.output.write(f"S{self.max_s}\n")
|
||||
self.output.write("M3\n\n")
|
||||
self.output += (f"S{self.max_s}\n")
|
||||
self.output += ("M3\n\n")
|
||||
|
||||
|
||||
def draw_line(self, x1, y1, x2, y2):
|
||||
@@ -35,42 +36,42 @@ class Gcode:
|
||||
y_mm = y * self.mm_per_px
|
||||
|
||||
if self.machine == Machine.LASER:
|
||||
self.output.write(f"G0 X{x_mm} Y{y_mm}\n")
|
||||
self.output+=(f"G0 X{x_mm} Y{y_mm}\n")
|
||||
elif self.machine == Machine.THREEAXIS:
|
||||
self.output.write(f"G0 Z{self.safe_z}\n")
|
||||
self.output.write(f"G0 X{x_mm} Y{y_mm} Z{self.safe_z}\n")
|
||||
self.output+=(f"G0 Z{self.safe_z}\n")
|
||||
self.output+=(f"G0 X{x_mm} Y{y_mm} Z{self.safe_z}\n")
|
||||
|
||||
def write_to(self, x, y):
|
||||
x_mm = x * self.mm_per_px
|
||||
y_mm = y * self.mm_per_px
|
||||
|
||||
if self.machine == Machine.LASER:
|
||||
self.output.write(f"G1 X{x_mm} Y{y_mm}\n")
|
||||
self.output += (f"G1 X{x_mm} Y{y_mm}\n")
|
||||
elif self.machine == Machine.THREEAXIS:
|
||||
self.output.write(f"G0 Z{self.work_z}\n")
|
||||
self.output.write(f"G1 X{x_mm} Y{y_mm} Z{self.work_z}\n")
|
||||
self.output += (f"G0 Z{self.work_z}\n")
|
||||
self.output += (f"G1 X{x_mm} Y{y_mm} Z{self.work_z}\n")
|
||||
|
||||
def refill(self, x, y, depth, dip_number):
|
||||
self.output.write(";#################\n")
|
||||
self.output += (";#################\n")
|
||||
|
||||
if self.machine == Machine.THREEAXIS:
|
||||
self.go_to(x, y)
|
||||
for _ in range(dip_number):
|
||||
self.output.write(f"G1 Z{depth}\n")
|
||||
self.output.write(f"G0 Z{self.safe_z}\n")
|
||||
self.output += (f"G1 Z{depth}\n")
|
||||
self.output += (f"G0 Z{self.safe_z}\n")
|
||||
elif self.machine == Machine.LASER:
|
||||
self.go_to(x, y)
|
||||
self.set_pause()
|
||||
|
||||
def set_pause(self):
|
||||
self.output.write("M0\n")
|
||||
self.output += ("M0\n")
|
||||
|
||||
def end_gcode(self):
|
||||
if self.machine == Machine.THREEAXIS:
|
||||
self.go_to(0, 0)
|
||||
|
||||
self.output.write("M5\n")
|
||||
self.output.close()
|
||||
self.output += ("M5\n")
|
||||
# self.output.close()
|
||||
|
||||
def new_file(self, new_file_name):
|
||||
self.end_gcode()
|
||||
|
||||
Reference in New Issue
Block a user