-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrinter.py
More file actions
85 lines (75 loc) · 4.06 KB
/
Printer.py
File metadata and controls
85 lines (75 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from typing import Dict, Any
import tkinter as tk
import Recore_pin_maps
from ConfigSection import ConfigSection
from Recore import Recore
class PrinterConfig:
def __init__(self, parent):
self.board = None
self.parent = parent
self.printer = ConfigSection("printer")
def create_printer_section(self, parent, board):
self.board = board
parent.create_window()
return_button = tk.Button(master=parent.mainframe, relief=parent.border_effects.get("groove"),
text="Back",
width=5, height=5, bg="black", fg="white")
return_button['command'] = self.return_to_board_selection_gui
return_button.pack()
# list of options taken from https://www.klipper3d.org/Config_Reference.html#printer
geometry_options = ["cartesian", "corexy", "corexz", "hybrid_corexy", "hybrid_corexz", "rotary_delta", "delta",
"deltesian", "polar", "winch", "none"]
geometry_selected = tk.StringVar(parent.mainframe)
geometry_selected.set(geometry_options[0])
geometry_selection = tk.OptionMenu(parent.mainframe, geometry_selected, *geometry_options)
geometry_selection.pack()
max_velocity = "100"
max_velocity_label = tk.Label(master=parent.mainframe, text="Max velocity")
max_velocity_entry = tk.Entry(master=parent.mainframe, fg="black", bg="white", width=10,
textvariable=max_velocity)
max_velocity_entry.insert(index=0, string="100")
max_velocity_label.pack()
max_velocity_entry.pack()
max_accel = "1000"
max_accel_label = tk.Label(master=parent.mainframe, text="Max Accel")
max_accel_entry = tk.Entry(master=parent.mainframe, fg="black", bg="white", width=10, textvariable=max_accel)
max_accel_entry.insert(index=0, string="1000")
max_accel_label.pack()
max_accel_entry.pack()
square_corner_velocity = 5
scv_label = tk.Label(master=parent.mainframe, text="Square Corner Velocity")
scv_entry = tk.Entry(master=parent.mainframe, fg="black", bg="white", width=10,
textvariable=square_corner_velocity)
scv_entry.insert(0, square_corner_velocity)
scv_label.pack()
scv_entry.pack()
printer_confirm_button = tk.Button(master=parent.mainframe, relief=parent.border_effects.get("groove"),
text="Ok", width=5, height=5, bg="black", fg="white")
printer_confirm_button['command'] = \
lambda kinematics=geometry_selected, max_v=max_velocity, max_a=max_accel, \
scv=scv_entry.get(): self.set_printer(kinematics, max_v, max_a, scv)
printer_confirm_button.pack()
parent.mainframe.pack()
parent.window.mainloop()
def set_printer(self, kinematics, max_vel=100, max_accel=1000, scv=5):
self.printer.add_setting("kinematics", kinematics.get())
self.printer.add_setting("max_velocity", max_vel)
self.printer.add_setting("max_accel", max_accel)
self.printer.add_setting("square_corner_velocity", scv)
recore = Recore(self.board)
self.parent.add_config_section(recore.get_recore_config())
self.parent.add_config_section(recore.get_mcu_config())
self.parent.add_config_section(recore.get_mcu_ar100_config())
self.parent.add_config_section(self.printer)
if self.board.get() == "Recore A5":
self.parent.set_pin_map(Recore_pin_maps.RecoreA5PinMaps())
elif self.board.get() == "Recore A6":
self.parent.set_pin_map(Recore_pin_maps.RecoreA6PinMaps())
elif self.board.get() == "Recore A7":
self.parent.set_pin_map(Recore_pin_maps.RecoreA7PinMaps())
self.parent.destroy_window()
self.parent.init_stepper()
self.parent.stepper_config.create_stepper_section(self.parent)
def return_to_board_selection_gui(self, parent):
parent.destroy_window()
parent.board_config.board_selection_gui(parent)