mirror of
				https://github.com/BKLronin/touchCNC.git
				synced 2025-10-30 22:09:41 +01:00 
			
		
		
		
	- added settings externalized into settings.py (not for the executable version yet)
-Changed depency to the pip package version from submodule -Updated requirements.txt
This commit is contained in:
		| @@ -3,7 +3,8 @@ import time | |||||||
| from tkinter import Button, Label, Variable, IntVar, Canvas, Frame, Listbox, Entry, Radiobutton, Tk, constants, LEFT | from tkinter import Button, Label, Variable, IntVar, Canvas, Frame, Listbox, Entry, Radiobutton, Tk, constants, LEFT | ||||||
| from tkinter import filedialog as fd | from tkinter import filedialog as fd | ||||||
| import os | import os | ||||||
| from gerbil.gerbil import Gerbil | from grbl_streamer import GrblStreamer | ||||||
|  | import settings | ||||||
|  |  | ||||||
| class touchCNC: | class touchCNC: | ||||||
|     def __init__(self, root): |     def __init__(self, root): | ||||||
| @@ -313,8 +314,7 @@ class touchCNC: | |||||||
|  |  | ||||||
|     def grblConnect2(self, baudrate=115200, max_retries=5, retry_interval=3): |     def grblConnect2(self, baudrate=115200, max_retries=5, retry_interval=3): | ||||||
|         retry_count = 0 |         retry_count = 0 | ||||||
|         locations = ['/dev/ttyUSB0', '/dev/ttyACM0', '/dev/ttyUSB1', '/dev/ttyACM1', '/dev/ttyACM2', '/dev/ttyACM3', |         locations = settings.portlist | ||||||
|                      '/dev/ttyS0', '/dev/ttyS1', '/dev/ttyS2', '/dev/ttyS3'] |  | ||||||
|  |  | ||||||
|         # Configure logging |         # Configure logging | ||||||
|         logging.basicConfig(level=logging.DEBUG) |         logging.basicConfig(level=logging.DEBUG) | ||||||
| @@ -409,13 +409,13 @@ class touchCNC: | |||||||
|  |  | ||||||
|     def get_grbl_command(self, CMD): |     def get_grbl_command(self, CMD): | ||||||
|         if CMD == 'M3': |         if CMD == 'M3': | ||||||
|             return 'M3 S1000' if self.states['M3'] == '1' else 'M5' |             return settings.spindle_on if self.states['M3'] == '1' else settings.spindle_off | ||||||
|  |  | ||||||
|         elif CMD == 'M8': |         elif CMD == 'M8': | ||||||
|             return CMD if self.states[CMD] == '1' else 'M9' |             return settings.cooling_on if self.states[CMD] == '1' else settings.cooling_off | ||||||
|  |  | ||||||
|         elif CMD == 'G10': |         elif CMD == 'G10': | ||||||
|             return 'G10 P0 L20 X0 Y0 Z0' |             return settings.toolchange | ||||||
|  |  | ||||||
|         elif CMD == '32': |         elif CMD == '32': | ||||||
|             return '$32=0' if self.states['32'] == '1' else '$32=1' |             return '$32=0' if self.states['32'] == '1' else '$32=1' | ||||||
| @@ -428,7 +428,7 @@ class touchCNC: | |||||||
|     def openGCODE(self): |     def openGCODE(self): | ||||||
|         filetypes = (('GCODE', '*.nc'), ('All files', '*.*')) |         filetypes = (('GCODE', '*.nc'), ('All files', '*.*')) | ||||||
|         if not self.file_list: |         if not self.file_list: | ||||||
|             GCODE = fd.askopenfilename(title='Open a file', initialdir='/home/', filetypes=filetypes) |             GCODE = fd.askopenfilename(title='Open a file', initialdir=settings.basepath, filetypes=filetypes) | ||||||
|         else: |         else: | ||||||
|             GCODE = self.load_gcode_from_listbox() |             GCODE = self.load_gcode_from_listbox() | ||||||
|  |  | ||||||
| @@ -471,7 +471,7 @@ class touchCNC: | |||||||
|     def openDir(self): |     def openDir(self): | ||||||
|         self.file_list = [] |         self.file_list = [] | ||||||
|         self.path_list = [] |         self.path_list = [] | ||||||
|         directory = fd.askdirectory(title='Open a Folder', initialdir='/home/') |         directory = fd.askdirectory(title='Open a Folder', initialdir=settings.basepath) | ||||||
|         allowed_extensions = {'nc', 'GCODE'}  # Use a set for efficient membership testing |         allowed_extensions = {'nc', 'GCODE'}  # Use a set for efficient membership testing | ||||||
|  |  | ||||||
|         if directory: |         if directory: | ||||||
| @@ -602,7 +602,7 @@ class DrawonTable: | |||||||
|         self.mill_table.delete('all') |         self.mill_table.delete('all') | ||||||
|  |  | ||||||
|         self.mill_table.create_rectangle(50, 50, 350, 350, fill='white') |         self.mill_table.create_rectangle(50, 50, 350, 350, fill='white') | ||||||
|         self.mill_table.create_text(200, 25, text='Fräsbereich 300mm x 300mm') |         self.mill_table.create_text(200, 25, text=settings.table_text) | ||||||
|  |  | ||||||
|         for x in range(50, 350, 50): |         for x in range(50, 350, 50): | ||||||
|             self.mill_table.create_text(x, 400 - x, text=x - 50) |             self.mill_table.create_text(x, 400 - x, text=x - 50) | ||||||
| @@ -616,16 +616,15 @@ class DrawonTable: | |||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|     root = Tk() |     root = Tk() | ||||||
|     root.title('touchCNC') |     root.title('touchCNC') | ||||||
|     root.geometry('1024x600+0+0') |     root.geometry(settings.resolution) | ||||||
|     root.grid_propagate(True) |     root.grid_propagate(True) | ||||||
|     root.resizable(False, False)  # 17203b |     root.resizable(False, False)  # 17203b | ||||||
|     root.attributes('-fullscreen', False) |     root.attributes('-fullscreen', settings.set_fullscreen) | ||||||
|     root.tk_setPalette(background='#4B4A67', foreground='black', activeBackground='#F99417', |     root.tk_setPalette(background='#4B4A67', foreground='black', activeBackground='#F99417', | ||||||
|                        activeForeground='lightgrey') |                        activeForeground='lightgrey') | ||||||
|  |  | ||||||
|  |  | ||||||
|     app = touchCNC(root) |     app = touchCNC(root) | ||||||
|     grbl = Gerbil(app.gui_callback) |     grbl = GrblStreamer(app.gui_callback) | ||||||
|     grbl.hash_state_requested = True |     grbl.hash_state_requested = True | ||||||
|     grbl.gcode_parser_state_requested = True |     grbl.gcode_parser_state_requested = True | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										22
									
								
								dist/settings.py
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								dist/settings.py
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | |||||||
|  |  | ||||||
|  | # The resolution of your SBC-screen | ||||||
|  | resolution = '1024x600+0+0' | ||||||
|  |  | ||||||
|  | # When running on SBC with touch set to: True | ||||||
|  | set_fullscreen = False | ||||||
|  |  | ||||||
|  | # Platform dependent | ||||||
|  | portlist = ['/dev/ttyUSB0', '/dev/ttyACM0', '/dev/ttyUSB1', '/dev/ttyACM1', '/dev/ttyACM2', '/dev/ttyACM3', | ||||||
|  |                      '/dev/ttyS0', '/dev/ttyS1', '/dev/ttyS2', '/dev/ttyS3'] | ||||||
|  | # Where the file dialog points to. Ideally some Nextcloud folder or Samba share etc. | ||||||
|  | basepath = '/home/' | ||||||
|  |  | ||||||
|  | # Machine commands | ||||||
|  | spindle_on = 'M3S1000' | ||||||
|  | spindle_off = 'M5' | ||||||
|  | cooling_on = 'M8' | ||||||
|  | cooling_off = 'M9' | ||||||
|  | toolchange = 'G10 P0 L20 X0 Y0 Z0' | ||||||
|  |  | ||||||
|  | # Table Info Text | ||||||
|  | table_text = 'Fräsbereich 300mm x 300mm' | ||||||
 Submodule gcode_machine deleted from 624f71ae15
									
								
							
							
								
								
									
										1
									
								
								gerbil
									
									
									
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								gerbil
									
									
									
									
									
								
							 Submodule gerbil deleted from 78aa148f0a
									
								
							| @@ -1,3 +1,5 @@ | |||||||
| altgraph==0.17.4 | altgraph==0.17.4 | ||||||
|  | gcode-machine==1.0.3 | ||||||
|  | grbl-streamer==1.0.3 | ||||||
| numpy==1.26.2 | numpy==1.26.2 | ||||||
| pyserial==3.5 | pyserial==3.5 | ||||||
|   | |||||||
							
								
								
									
										22
									
								
								settings.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								settings.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | |||||||
|  |  | ||||||
|  | # The resolution of your SBC-screen | ||||||
|  | resolution = '1024x600+0+0' | ||||||
|  |  | ||||||
|  | # When running on SBC with touch set to: True | ||||||
|  | set_fullscreen = False | ||||||
|  |  | ||||||
|  | # Platform dependent | ||||||
|  | portlist = ['/dev/ttyUSB0', '/dev/ttyACM0', '/dev/ttyUSB1', '/dev/ttyACM1', '/dev/ttyACM2', '/dev/ttyACM3', | ||||||
|  |                      '/dev/ttyS0', '/dev/ttyS1', '/dev/ttyS2', '/dev/ttyS3'] | ||||||
|  | # Where the file dialog points to. Ideally some Nextcloud folder or Samba share etc. | ||||||
|  | basepath = '/home/' | ||||||
|  |  | ||||||
|  | # Machine commands | ||||||
|  | spindle_on = 'M3S1000' | ||||||
|  | spindle_off = 'M5' | ||||||
|  | cooling_on = 'M8' | ||||||
|  | cooling_off = 'M9' | ||||||
|  | toolchange = 'G10 P0 L20 X0 Y0 Z0' | ||||||
|  |  | ||||||
|  | # Table Info Text | ||||||
|  | table_text = 'Fräsbereich 300mm x 300mm' | ||||||
		Reference in New Issue
	
	Block a user