reamenagement
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,79 +1,79 @@
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
class Machine(Enum):
|
class Machine(Enum):
|
||||||
LASER = 1
|
LASER = 1
|
||||||
THREEAXIS = 2
|
THREEAXIS = 2
|
||||||
|
|
||||||
class Gcode:
|
class Gcode:
|
||||||
def __init__(self, file, mm_per_px, speed, machine, max_s=0, safe_z=0, work_z=0):
|
def __init__(self, file, mm_per_px, speed, machine, max_s=0, safe_z=0, work_z=0):
|
||||||
self.file = file
|
self.file = file
|
||||||
self.mm_per_px = mm_per_px
|
self.mm_per_px = mm_per_px
|
||||||
self.speed = speed
|
self.speed = speed
|
||||||
self.machine = machine
|
self.machine = machine
|
||||||
self.max_s = max_s
|
self.max_s = max_s
|
||||||
self.safe_z = safe_z
|
self.safe_z = safe_z
|
||||||
self.work_z = work_z
|
self.work_z = work_z
|
||||||
self.output = None
|
self.output = None
|
||||||
self.init_file()
|
self.init_file()
|
||||||
|
|
||||||
def init_file(self):
|
def init_file(self):
|
||||||
# self.output = open(f"{self.file}.gcode", "w")
|
# self.output = open(f"{self.file}.gcode", "w")
|
||||||
self.output = ""
|
self.output = ""
|
||||||
self.output += ("G21 ;Unit to mm\n")
|
self.output += ("G21 ;Unit to mm\n")
|
||||||
self.output += ("G90 ;Absolute positioning\n\n")
|
self.output += ("G90 ;Absolute positioning\n\n")
|
||||||
self.output += (f"F{self.speed}\n")
|
self.output += (f"F{self.speed}\n")
|
||||||
if self.machine == Machine.LASER:
|
if self.machine == Machine.LASER:
|
||||||
self.output += (f"S{self.max_s}\n")
|
self.output += (f"S{self.max_s}\n")
|
||||||
self.output += ("M3\n\n")
|
self.output += ("M3\n\n")
|
||||||
|
|
||||||
|
|
||||||
def draw_line(self, x1, y1, x2, y2):
|
def draw_line(self, x1, y1, x2, y2):
|
||||||
self.go_to(x1, y1)
|
self.go_to(x1, y1)
|
||||||
self.write_to(x2, y2)
|
self.write_to(x2, y2)
|
||||||
|
|
||||||
def go_to(self, x, y):
|
def go_to(self, x, y):
|
||||||
x_mm = x * self.mm_per_px
|
x_mm = x * self.mm_per_px
|
||||||
y_mm = y * self.mm_per_px
|
y_mm = y * self.mm_per_px
|
||||||
|
|
||||||
if self.machine == Machine.LASER:
|
if self.machine == Machine.LASER:
|
||||||
self.output+=(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:
|
elif self.machine == Machine.THREEAXIS:
|
||||||
self.output+=(f"G0 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")
|
self.output+=(f"G0 X{x_mm} Y{y_mm} Z{self.safe_z}\n")
|
||||||
|
|
||||||
def write_to(self, x, y):
|
def write_to(self, x, y):
|
||||||
x_mm = x * self.mm_per_px
|
x_mm = x * self.mm_per_px
|
||||||
y_mm = y * self.mm_per_px
|
y_mm = y * self.mm_per_px
|
||||||
|
|
||||||
if self.machine == Machine.LASER:
|
if self.machine == Machine.LASER:
|
||||||
self.output += (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:
|
elif self.machine == Machine.THREEAXIS:
|
||||||
self.output += (f"G0 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")
|
self.output += (f"G1 X{x_mm} Y{y_mm} Z{self.work_z}\n")
|
||||||
|
|
||||||
def refill(self, x, y, depth, dip_number):
|
def refill(self, x, y, depth, dip_number):
|
||||||
self.output += (";#################\n")
|
self.output += (";#################\n")
|
||||||
|
|
||||||
if self.machine == Machine.THREEAXIS:
|
if self.machine == Machine.THREEAXIS:
|
||||||
self.go_to(x, y)
|
self.go_to(x, y)
|
||||||
for _ in range(dip_number):
|
for _ in range(dip_number):
|
||||||
self.output += (f"G1 Z{depth}\n")
|
self.output += (f"G1 Z{depth}\n")
|
||||||
self.output += (f"G0 Z{self.safe_z}\n")
|
self.output += (f"G0 Z{self.safe_z}\n")
|
||||||
elif self.machine == Machine.LASER:
|
elif self.machine == Machine.LASER:
|
||||||
self.go_to(x, y)
|
self.go_to(x, y)
|
||||||
self.set_pause()
|
self.set_pause()
|
||||||
|
|
||||||
def set_pause(self):
|
def set_pause(self):
|
||||||
self.output += ("M0\n")
|
self.output += ("M0\n")
|
||||||
|
|
||||||
def end_gcode(self):
|
def end_gcode(self):
|
||||||
if self.machine == Machine.THREEAXIS:
|
if self.machine == Machine.THREEAXIS:
|
||||||
self.go_to(0, 0)
|
self.go_to(0, 0)
|
||||||
|
|
||||||
self.output += ("M5\n")
|
self.output += ("M5\n")
|
||||||
# self.output.close()
|
# self.output.close()
|
||||||
|
|
||||||
def new_file(self, new_file_name):
|
def new_file(self, new_file_name):
|
||||||
self.end_gcode()
|
self.end_gcode()
|
||||||
self.file = new_file_name
|
self.file = new_file_name
|
||||||
self.init_file()
|
self.init_file()
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
- fonction qui traite le texte utilisateur : ajoute des retours à la ligne quand les phrases sont trop longues. A ajouter dans la fonction getText de l'app web
|
- fonction qui traite le texte utilisateur : ajoute des retours à la ligne quand les phrases sont trop longues. A ajouter dans la fonction getText de l'app web
|
||||||
- Dans getText fair appel à text_to_gcode, récupérer le gcode et l'envoyer en serial
|
- Dans getText fair appel à text_to_gcode, récupérer le gcode et l'envoyer en serial
|
||||||
- Dans text_to_gcode faire une fonction convert_text qui prends un texte avec des retours à la ligne et qui revoit du gcode
|
- Dans text_to_gcode faire une fonction convert_text qui prends un texte avec des retours à la ligne et qui revoit du gcode
|
||||||
BIN
SOFTWARE/plotter-app/__pycache__/Gcode_generator.cpython-310.pyc
Normal file
BIN
SOFTWARE/plotter-app/__pycache__/Gcode_generator.cpython-310.pyc
Normal file
Binary file not shown.
BIN
SOFTWARE/plotter-app/__pycache__/app.cpython-310.pyc
Normal file
BIN
SOFTWARE/plotter-app/__pycache__/app.cpython-310.pyc
Normal file
Binary file not shown.
BIN
SOFTWARE/plotter-app/__pycache__/app.cpython-38.pyc
Normal file
BIN
SOFTWARE/plotter-app/__pycache__/app.cpython-38.pyc
Normal file
Binary file not shown.
BIN
SOFTWARE/plotter-app/__pycache__/streamer.cpython-310.pyc
Normal file
BIN
SOFTWARE/plotter-app/__pycache__/streamer.cpython-310.pyc
Normal file
Binary file not shown.
BIN
SOFTWARE/plotter-app/__pycache__/streamer.cpython-38.pyc
Normal file
BIN
SOFTWARE/plotter-app/__pycache__/streamer.cpython-38.pyc
Normal file
Binary file not shown.
BIN
SOFTWARE/plotter-app/__pycache__/svgToGcode.cpython-310.pyc
Normal file
BIN
SOFTWARE/plotter-app/__pycache__/svgToGcode.cpython-310.pyc
Normal file
Binary file not shown.
BIN
SOFTWARE/plotter-app/__pycache__/svgToGcode.cpython-38.pyc
Normal file
BIN
SOFTWARE/plotter-app/__pycache__/svgToGcode.cpython-38.pyc
Normal file
Binary file not shown.
BIN
SOFTWARE/plotter-app/__pycache__/text_to_gcode.cpython-310.pyc
Normal file
BIN
SOFTWARE/plotter-app/__pycache__/text_to_gcode.cpython-310.pyc
Normal file
Binary file not shown.
@@ -1,22 +1,22 @@
|
|||||||
from Gcode_generator import Gcode
|
from Gcode_generator import Gcode
|
||||||
from Gcode_generator import Machine
|
from Gcode_generator import Machine
|
||||||
|
|
||||||
machine_type = Machine.LASER
|
machine_type = Machine.LASER
|
||||||
|
|
||||||
# Create an instance of the Gcode class
|
# Create an instance of the Gcode class
|
||||||
gcode = Gcode(
|
gcode = Gcode(
|
||||||
file="test_gcode", # Output file name (no .gcode extension)
|
file="test_gcode", # Output file name (no .gcode extension)
|
||||||
mm_per_px=0.1, # Conversion factor: mm per pixel
|
mm_per_px=0.1, # Conversion factor: mm per pixel
|
||||||
speed=1000, # Speed in mm/min
|
speed=1000, # Speed in mm/min
|
||||||
machine=machine_type,
|
machine=machine_type,
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Draw a line from (10, 20) to (30, 40)
|
# Draw a line from (10, 20) to (30, 40)
|
||||||
gcode.draw_line(10, 20, 30, 40)
|
gcode.draw_line(10, 20, 30, 40)
|
||||||
|
|
||||||
|
|
||||||
# Finish the G-code file
|
# Finish the G-code file
|
||||||
gcode.end_gcode()
|
gcode.end_gcode()
|
||||||
|
|
||||||
print("G-code file generated: example.gcode")
|
print("G-code file generated: example.gcode")
|
||||||
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user