17
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
19
19
"""
20
- version = '0.41 '
20
+ version = '0.42 '
21
21
title_text = "K40 Whisperer V" + version
22
22
23
23
import sys
@@ -456,6 +456,9 @@ def createWidgets(self):
456
456
self .Veng_time .set ("0" )
457
457
self .Vcut_time .set ("0" )
458
458
self .Gcde_time .set ("0" )
459
+
460
+ self .min_vector_speed = 1.1 #in/min
461
+ self .min_raster_speed = 12 #in/min
459
462
460
463
##########################################################################
461
464
### END INITILIZING VARIABLES ###
@@ -1258,11 +1261,8 @@ def Close_Current_Window_Click(self,event=None):
1258
1261
def Entry_Reng_feed_Check (self ):
1259
1262
try :
1260
1263
value = float (self .Reng_feed .get ())
1261
- if self .units .get () == 'mm' :
1262
- vfactor = 25.4 / 60.0
1263
- else :
1264
- vfactor = 1.0
1265
- low_limit = 12 * vfactor
1264
+ vfactor = (25.4 / 60.0 )/ self .feed_factor ()
1265
+ low_limit = self .min_raster_speed * vfactor
1266
1266
if value < low_limit :
1267
1267
self .statusMessage .set (" Feed Rate should be greater than or equal to %f " % (low_limit ))
1268
1268
return 2 # Value is invalid number
@@ -1276,8 +1276,10 @@ def Entry_Reng_feed_Callback(self, varName, index, mode):
1276
1276
def Entry_Veng_feed_Check (self ):
1277
1277
try :
1278
1278
value = float (self .Veng_feed .get ())
1279
- if value <= 0.0 :
1280
- self .statusMessage .set (" Feed Rate should be greater than 0.0 " )
1279
+ vfactor = (25.4 / 60.0 )/ self .feed_factor ()
1280
+ low_limit = self .min_vector_speed * vfactor
1281
+ if value < low_limit :
1282
+ self .statusMessage .set (" Feed Rate should be greater than or equal to %f " % (low_limit ))
1281
1283
return 2 # Value is invalid number
1282
1284
except :
1283
1285
return 3 # Value not a number
@@ -1289,8 +1291,10 @@ def Entry_Veng_feed_Callback(self, varName, index, mode):
1289
1291
def Entry_Vcut_feed_Check (self ):
1290
1292
try :
1291
1293
value = float (self .Vcut_feed .get ())
1292
- if value <= 0.0 :
1293
- self .statusMessage .set (" Feed Rate should be greater than 0.0 " )
1294
+ vfactor = (25.4 / 60.0 )/ self .feed_factor ()
1295
+ low_limit = self .min_vector_speed * vfactor
1296
+ if value < low_limit :
1297
+ self .statusMessage .set (" Feed Rate should be greater than or equal to %f " % (low_limit ))
1294
1298
return 2 # Value is invalid number
1295
1299
except :
1296
1300
return 3 # Value not a number
@@ -1555,8 +1559,10 @@ def Entry_Laser_R_Scale_Callback(self, varName, index, mode):
1555
1559
def Entry_Laser_Rapid_Feed_Check (self ):
1556
1560
try :
1557
1561
value = float (self .rapid_feed .get ())
1558
- if value < 0.0 :
1559
- self .statusMessage .set (" Rapid feed should be greater than 0 (or 0 for default speed) " )
1562
+ vfactor = (25.4 / 60.0 )/ self .feed_factor ()
1563
+ low_limit = 1.0 * vfactor
1564
+ if value != 0 and value < low_limit :
1565
+ self .statusMessage .set (" Rapid feed should be greater than or equal to %f (or 0 for default speed) " % (low_limit ))
1560
1566
return 2 # Value is invalid number
1561
1567
except :
1562
1568
return 3 # Value not a number
@@ -1636,6 +1642,11 @@ def Entry_Trace_Gap_Callback(self, varName, index, mode):
1636
1642
def Entry_Trace_Speed_Check (self ):
1637
1643
try :
1638
1644
value = float (self .trace_speed .get ())
1645
+ vfactor = (25.4 / 60.0 )/ self .feed_factor ()
1646
+ low_limit = self .min_vector_speed * vfactor
1647
+ if value < low_limit :
1648
+ self .statusMessage .set (" Feed Rate should be greater than or equal to %f " % (low_limit ))
1649
+ return 2 # Value is invalid number
1639
1650
except :
1640
1651
return 3 # Value not a number
1641
1652
self .refreshTime ()
@@ -1651,7 +1662,10 @@ def Inkscape_Path_Click(self, event):
1651
1662
("All Files" ,"*" )],\
1652
1663
initialdir = self .inkscape_path .get ())
1653
1664
if newfontdir != "" and newfontdir != ():
1654
- self .inkscape_path .set (newfontdir .encode ("utf-8" ))
1665
+ if type (newfontdir ) is not str :
1666
+ newfontdir = newfontdir .encode ("utf-8" )
1667
+ self .inkscape_path .set (newfontdir )
1668
+
1655
1669
try :
1656
1670
win_id .withdraw ()
1657
1671
win_id .deiconify ()
@@ -1686,15 +1700,16 @@ def Scale_Linear_Inputs(self, new_units=None):
1686
1700
self .units_scale = 25.4
1687
1701
else :
1688
1702
return
1689
- self .LaserXsize .set ( self .Scale_Text_Value ('%.2f' ,self .LaserXsize .get (),factor ) )
1690
- self .LaserYsize .set ( self .Scale_Text_Value ('%.2f' ,self .LaserYsize .get (),factor ) )
1691
- self .jog_step .set ( self .Scale_Text_Value ('%.3f' ,self .jog_step .get () ,factor ) )
1692
- self .gotoX .set ( self .Scale_Text_Value ('%.3f' ,self .gotoX .get () ,factor ) )
1693
- self .gotoY .set ( self .Scale_Text_Value ('%.3f' ,self .gotoY .get () ,factor ) )
1694
- self .Reng_feed .set ( self .Scale_Text_Value ('%.1f' ,self .Reng_feed .get () ,vfactor ) )
1695
- self .Veng_feed .set ( self .Scale_Text_Value ('%.1f' ,self .Veng_feed .get () ,vfactor ) )
1696
- self .Vcut_feed .set ( self .Scale_Text_Value ('%.1f' ,self .Vcut_feed .get () ,vfactor ) )
1697
- self .trace_speed .set ( self .Scale_Text_Value ('%.1f' ,self .trace_speed .get () ,vfactor ) )
1703
+ self .LaserXsize .set ( self .Scale_Text_Value ('%.2f' ,self .LaserXsize .get () ,factor ) )
1704
+ self .LaserYsize .set ( self .Scale_Text_Value ('%.2f' ,self .LaserYsize .get () ,factor ) )
1705
+ self .jog_step .set ( self .Scale_Text_Value ('%.3f' ,self .jog_step .get () ,factor ) )
1706
+ self .gotoX .set ( self .Scale_Text_Value ('%.3f' ,self .gotoX .get () ,factor ) )
1707
+ self .gotoY .set ( self .Scale_Text_Value ('%.3f' ,self .gotoY .get () ,factor ) )
1708
+ self .Reng_feed .set ( self .Scale_Text_Value ('%.1f' ,self .Reng_feed .get () ,vfactor ) )
1709
+ self .Veng_feed .set ( self .Scale_Text_Value ('%.1f' ,self .Veng_feed .get () ,vfactor ) )
1710
+ self .Vcut_feed .set ( self .Scale_Text_Value ('%.1f' ,self .Vcut_feed .get () ,vfactor ) )
1711
+ self .trace_speed .set ( self .Scale_Text_Value ('%.1f' ,self .trace_speed .get () ,vfactor ) )
1712
+ self .rapid_feed .set ( self .Scale_Text_Value ('%.1f' ,self .rapid_feed .get () ,vfactor ) )
1698
1713
1699
1714
def Scale_Text_Value (self ,format_txt ,Text_Value ,factor ):
1700
1715
try :
@@ -2806,7 +2821,8 @@ def slow_jog(self,dxmils,dymils):
2806
2821
self .stop [0 ]= False
2807
2822
Rapid_data = []
2808
2823
Rapid_inst = egv (target = lambda s :Rapid_data .append (s ))
2809
- Rapid_inst .make_egv_rapid (dxmils ,dymils ,Feed = float (self .rapid_feed .get ()),board_name = self .board_name .get ())
2824
+ Rapid_feed = float (self .rapid_feed .get ())* self .feed_factor ()
2825
+ Rapid_inst .make_egv_rapid (dxmils ,dymils ,Feed = Rapid_feed ,board_name = self .board_name .get ())
2810
2826
self .send_egv_data (Rapid_data , 1 , None )
2811
2827
self .stop [0 ]= True
2812
2828
@@ -3053,9 +3069,6 @@ def make_trace_path(self):
3053
3069
Veng_coords = self .mirror_rotate_vector_coords (Veng_coords )
3054
3070
Gcode_coords = self .mirror_rotate_vector_coords (Gcode_coords )
3055
3071
3056
- Vcut_coords ,startx ,starty = self .scale_vector_coords (Vcut_coords ,startx ,starty )
3057
- Veng_coords ,startx ,starty = self .scale_vector_coords (Veng_coords ,startx ,starty )
3058
- Gcode_coords ,startx ,starty = self .scale_vector_coords (Gcode_coords ,startx ,starty )
3059
3072
#######################################
3060
3073
if self .RengData .ecoords == []:
3061
3074
if self .stop [0 ] == True :
@@ -3086,6 +3099,8 @@ def make_trace_path(self):
3086
3099
trace_coords = my_hull .convexHullecoords (all_coords )
3087
3100
gap = float (self .trace_gap .get ())/ self .units_scale
3088
3101
trace_coords = self .offset_eccords (trace_coords ,gap )
3102
+
3103
+ trace_coords ,startx ,starty = self .scale_vector_coords (trace_coords ,startx ,starty )
3089
3104
return trace_coords
3090
3105
3091
3106
@@ -3187,7 +3202,7 @@ def point_inside_polygon(self,x,y,poly):
3187
3202
return inside
3188
3203
3189
3204
def optimize_paths (self ,ecoords ,inside_check = True ):
3190
- order_out = self .Sort_Paths (ecoords )
3205
+ order_out = self .Sort_Paths (ecoords )
3191
3206
lastx = - 999
3192
3207
lasty = - 999
3193
3208
Acc = 0.004
@@ -3337,6 +3352,14 @@ def scale_vector_coords(self,coords,startx,starty):
3337
3352
scaled_starty = starty
3338
3353
3339
3354
return coords_scale ,scaled_startx ,scaled_starty
3355
+
3356
+
3357
+ def feed_factor (self ):
3358
+ if self .units .get ()== 'in' :
3359
+ feed_factor = 25.4 / 60.0
3360
+ else :
3361
+ feed_factor = 1.0
3362
+ return feed_factor
3340
3363
3341
3364
def send_data (self ,operation_type = None , output_filename = None ):
3342
3365
num_passes = 0
@@ -3345,11 +3368,8 @@ def send_data(self,operation_type=None, output_filename=None):
3345
3368
self .statusbar .configure ( bg = 'red' )
3346
3369
return
3347
3370
try :
3348
- if self .units .get ()== 'in' :
3349
- feed_factor = 25.4 / 60.0
3350
- else :
3351
- feed_factor = 1.0
3352
-
3371
+ feed_factor = self .feed_factor ()
3372
+
3353
3373
if self .inputCSYS .get () and self .RengData .image == None :
3354
3374
xmin ,xmax ,ymin ,ymax = 0.0 ,0.0 ,0.0 ,0.0
3355
3375
else :
@@ -3384,6 +3404,30 @@ def send_data(self,operation_type=None, output_filename=None):
3384
3404
self .master .update ()
3385
3405
if not self .VcutData .sorted and self .inside_first .get ():
3386
3406
self .VcutData .set_ecoords (self .optimize_paths (self .VcutData .ecoords ),data_sorted = True )
3407
+
3408
+
3409
+ ## DEBUG_PLOT=False
3410
+ ## test_ecoords=self.VcutData.ecoords
3411
+ ## if DEBUG_PLOT:
3412
+ ## import matplotlib.pyplot as plt
3413
+ ## plt.ion()
3414
+ ## plt.clf()
3415
+ ## X=[]
3416
+ ## Y=[]
3417
+ ## LOOP_OLD = test_ecoords[0][2]
3418
+ ## for i in range(len(test_ecoords)):
3419
+ ## LOOP = test_ecoords[i][2]
3420
+ ## if LOOP != LOOP_OLD:
3421
+ ## plt.plot(X,Y)
3422
+ ## plt.pause(.5)
3423
+ ## X=[]
3424
+ ## Y=[]
3425
+ ## LOOP_OLD=LOOP
3426
+ ## X.append(test_ecoords[i][0])
3427
+ ## Y.append(test_ecoords[i][1])
3428
+ ## plt.plot(X,Y)
3429
+
3430
+
3387
3431
self .statusMessage .set ("Generating EGV data..." )
3388
3432
self .master .update ()
3389
3433
@@ -3806,16 +3850,17 @@ def menu_Calc_Raster_Time(self,event=None):
3806
3850
3807
3851
def menu_Help_About (self ):
3808
3852
3809
- about = "K40 Whisperer by Scorch.\n "
3853
+ about = "K40 Whisperer Version %s\n \n " % (version )
3854
+ about = about + "By Scorch.\n "
3810
3855
about = about + "\163 \143 \157 \162 \143 \150 \100 \163 \143 \157 \162 "
3811
3856
about = about + "\143 \150 \167 \157 \162 \153 \163 \056 \143 \157 \155 \n "
3812
3857
about = about + "https://www.scorchworks.com/\n \n "
3813
3858
try :
3814
- version = "%d.%d.%d" % (sys .version_info .major ,sys .version_info .minor ,sys .version_info .micro )
3859
+ python_version = "%d.%d.%d" % (sys .version_info .major ,sys .version_info .minor ,sys .version_info .micro )
3815
3860
except :
3816
- version = ""
3817
- about = about + "Python " + version + " (%d bit)" % (struct .calcsize ("P" ) * 8 )
3818
- message_box ("About k40_whisperer " ,about )
3861
+ python_version = ""
3862
+ about = about + "Python " + python_version + " (%d bit)" % (struct .calcsize ("P" ) * 8 )
3863
+ message_box ("About k40 Whisperer " ,about )
3819
3864
3820
3865
def menu_Help_Web (self ):
3821
3866
webbrowser .open_new (r"https://www.scorchworks.com/K40whisperer/k40whisperer.html" )
0 commit comments