@@ -1091,8 +1091,8 @@ def save_setup_clicked():
10911091 putPrefs (PREF , 'GUI_OPTIONS' , 'Arc OK color' , colorArc , str )
10921092 putPrefs (PREF , 'GUI_OPTIONS' , 'LED color' , colorLed , str )
10931093 putPrefs (PREF , 'GUI_OPTIONS' , 'Trough color' , colorTrough , str )
1094- for key in togglePins :
1095- set_toggle_pins (togglePins [ key ] )
1094+ for button in togglePins :
1095+ set_toggle_pins (button )
10961096
10971097
10981098##############################################################################
@@ -1134,15 +1134,15 @@ def set_probe_offset_pins():
11341134 hal .set_p ('plasmac.offset-probe-y' , f'{ probeOffsets ["Y" ]} ' )
11351135 hal .set_p ('plasmac.offset-probe-delay' , f'{ probeOffsets ["Delay" ]} ' )
11361136
1137- def set_toggle_pins (pin ):
1138- pin [ 'state' ] = hal .get_value (pin ['pin' ])
1139- if pin ['state' ]:
1140- rC (f'{ fbuttons } .button{ pin [ " button" ] } ' ,'configure' ,'-bg' ,colorActive )
1137+ def set_toggle_pins (button ):
1138+ togglePins [ button ][ 'state' ] = hal .get_value (togglePins [ button ] ['pin' ])
1139+ if togglePins [ button ] ['state' ]:
1140+ rC (f'{ fbuttons } .button{ button } ' ,'configure' ,'-bg' ,colorActive )
11411141 else :
1142- if pin ['runcritical' ]:
1143- rC (f'{ fbuttons } .button{ pin [ " button" ] } ' ,'configure' ,'-bg' ,colorWarn )
1142+ if togglePins [ button ] ['runcritical' ]:
1143+ rC (f'{ fbuttons } .button{ button } ' ,'configure' ,'-bg' ,colorWarn )
11441144 else :
1145- rC (f'{ fbuttons } .button{ pin [ " button" ] } ' ,'configure' ,'-bg' ,colorBack )
1145+ rC (f'{ fbuttons } .button{ button } ' ,'configure' ,'-bg' ,colorBack )
11461146
11471147def jog_default_changed (value ):
11481148 set_jog_slider (int (value ) / (vars .max_speed .get () * 60 ))
@@ -1345,9 +1345,13 @@ def laser_button_toggled(state, button):
13451345 return
13461346 # long press timer
13471347 elif isIdleHomed :
1348- laserTimer = 0.7
1348+ laserTimer = 700
1349+ root_window .after (100 , laser_long_press_timer )
13491350 else : # button released
1350- laserTimer = 0.0
1351+ if laserButtonState == 'reset' :
1352+ laserButtonState = 'laser'
1353+ return
1354+ laserTimer = 0
13511355 if not isIdleHomed :
13521356 return
13531357 xPos = s .position [0 ] - laserOffsets ['X' ]
@@ -1356,10 +1360,7 @@ def laser_button_toggled(state, button):
13561360 msg0 = _ ('Laser is outside the machine boundary' )
13571361 notifications .add ('error' , f'{ title } :\n { msg0 } ' )
13581362 return
1359- if laserButtonState == 'reset' :
1360- laserButtonState = 'laser'
1361- return
1362- elif laserButtonState == 'laser' :
1363+ if laserButtonState == 'laser' :
13631364 pVars .laserText .set (_ ('Mark' ))
13641365 laserButtonState = 'markedge'
13651366 comp ['laser-on' ] = 1
@@ -1368,6 +1369,17 @@ def laser_button_toggled(state, button):
13681369 comp ['laser-on' ] = 0
13691370 laserButtonState = sheet_align ('laser' , laserButtonState , laserOffsets ['X' ], laserOffsets ['Y' ])
13701371
1372+ def laser_long_press_timer ():
1373+ global laserTimer , laserButtonState
1374+ if laserTimer > 0 :
1375+ laserTimer -= 100
1376+ if laserTimer <= 0 :
1377+ comp ['laser-on' ] = 0
1378+ laserButtonState = 'reset'
1379+ pVars .laserText .set (_ ('Laser' ))
1380+ else :
1381+ root_window .after (100 , laser_long_press_timer )
1382+
13711383def sheet_align (mode , buttonState , offsetX , offsetY ):
13721384 global relPos , startAlignPos
13731385 msgList = []
@@ -1873,11 +1885,11 @@ def reload_file(refilter=True):
18731885 live_plotter .clear ()
18741886
18751887def task_run (* event ):
1876- for key in togglePins :
1877- if togglePins [key ]['runcritical' ] and not togglePins [key ]['state' ]:
1888+ for button in togglePins :
1889+ if togglePins [button ]['runcritical' ] and not togglePins [button ]['state' ]:
18781890 title = _ ('RUN ERROR' )
18791891 msg0 = _ ('Cannot run program while critical button is not active' )
1880- btn = rC (f'{ fbuttons } .button{ togglePins [ key ][ " button" ] } ' ,'cget' ,'-text' )
1892+ btn = rC (f'{ fbuttons } .button{ button } ' ,'cget' ,'-text' )
18811893 notifications .add ('error' , f'{ title } :\n { msg0 } : { btn } \n ' )
18821894 return
18831895 if run_warn (): return
@@ -2308,12 +2320,10 @@ def user_button_setup():
23082320 if len (bCode .split ()) > 1 and len (bCode .split ()) < 4 :
23092321 codes = bCode .strip ().split ()
23102322 if validate_hal_pin (codes [1 ], n , 'pulse-halpin' ):
2311- outCode = {'code' :'pulse-halpin' , 'pin' :codes [1 ], 'time' :1.0 }
2312- outCode ['pin' ] = codes [1 ]
23132323 try :
23142324 value = round (float (codes [2 ]), 1 )
2315- outCode [ 'time' ] = value
2316- pulsePins [str (n )] = {'button' : str ( n ), ' pin' :outCode [ 'pin' ], 'text' :None , 'timer' : 0 , 'counter ' :0 , 'state' :False }
2325+ outCode = { 'code' : 'pulse-halpin' , 'pin' : codes [ 1 ], 'time' : value }
2326+ pulsePins [str (n )] = {'pin' :codes [ 1 ], 'text' :None , 'pulse ' :0 , 'state' :False }
23172327 except :
23182328 outCode = {'code' :None }
23192329 else :
@@ -2327,7 +2337,7 @@ def user_button_setup():
23272337 if len (codes ) == 3 and codes [2 ] == 'runcritical' :
23282338 outCode ['critical' ] = True
23292339 criticalButtons .append (n )
2330- togglePins [str (n )] = {'button' : str ( n ), ' pin' :outCode ['pin' ], 'state' :hal .get_value (outCode ['pin' ]), 'runcritical' :outCode ['critical' ]}
2340+ togglePins [str (n )] = {'pin' :outCode ['pin' ], 'state' :hal .get_value (outCode ['pin' ]), 'runcritical' :outCode ['critical' ]}
23312341 else :
23322342 parmError = True
23332343 elif bCode and bCode not in singleCodes :
@@ -2394,8 +2404,8 @@ def user_button_setup():
23942404
23952405def user_button_pressed (button , code ):
23962406 global colorBack , activeFunction
2397- global probePressed , probeStart , probeTimer , probeButton
2398- global torchPressed , torchStart , torchTimer , torchButton
2407+ global probePressed , probeTimer , probeButton
2408+ global torchPressed , torchTimer , torchButton
23992409 if rC (f'{ fbuttons } .button{ button } ' ,'cget' ,'-state' ) == 'disabled' or not code :
24002410 return
24012411 if code ['code' ] == 'ohmic-test' :
@@ -2412,25 +2422,27 @@ def user_button_pressed(button, code):
24122422 elif code ['code' ] == 'probe-test' and not hal .get_value ('halui.program.is-running' ):
24132423 if probeTimer :
24142424 probeTimer = 0
2425+ probe_test_timer ()
24152426 elif not hal .get_value ('plasmac.z-offset-counts' ):
24162427 activeFunction = True
24172428 probePressed = True
2418- probeStart = time .time ()
2419- probeTimer = code ['time' ]
2429+ probeTimer = code ['time' ] * 1000
24202430 hal .set_p ('plasmac.probe-test' ,'1' )
24212431 rC (f'{ fbuttons } .button{ probeButton } ' ,'configure' ,'-text' ,str (int (probeTimer )))
24222432 rC (f'{ fbuttons } .button{ probeButton } ' ,'configure' ,'-bg' ,colorActive )
2433+ root_window .after (100 , probe_test_timer )
24232434 elif code ['code' ] == 'torch-pulse' :
24242435 if torchTimer :
24252436 torchTimer = 0
2437+ torch_pulse_timer ()
24262438 elif not hal .get_value ('plasmac.z-offset-counts' ):
24272439 torchPressed = True
2428- torchStart = time .time ()
2429- torchTimer = code ['time' ]
2440+ torchTimer = code ['time' ] * 1000
24302441 hal .set_p ('plasmac.torch-pulse-time' ,f'{ torchTimer } ' )
24312442 hal .set_p ('plasmac.torch-pulse-start' ,'1' )
24322443 rC (f'{ fbuttons } .button{ torchButton } ' ,'configure' ,'-text' ,str (int (torchTimer )))
24332444 rC (f'{ fbuttons } .button{ torchButton } ' ,'configure' ,'-bg' ,colorActive )
2445+ root_window .after (100 , torch_pulse_timer )
24342446 elif code ['code' ] == 'change-consumables' and not hal .get_value ('plasmac.breakaway' ):
24352447 if hal .get_value ('axis.x.eoffset-counts' ) or hal .get_value ('axis.y.eoffset-counts' ):
24362448 hal .set_p ('plasmac.consumable-change' , '0' )
@@ -2460,13 +2472,13 @@ def user_button_pressed(button, code):
24602472 comp [code ['pin' ].replace ('axisui.' ,'' )] = not hal .get_value (code ['pin' ])
24612473 else :
24622474 hal .set_p (code ['pin' ], str (not hal .get_value (code ['pin' ])))
2463- if not pulsePins [button ]['timer' ]:
2464- pulsePins [button ]['text' ] = rC (f'{ fbuttons } .button{ button } ' ,'cget' ,'-text' )
2465- pulsePins [button ]['timer' ] = code ['time' ]
2466- pulsePins [button ]['counter' ] = time .time ()
2467- else :
2468- pulsePins [button ]['timer' ] = 0
2475+ if pulsePins [button ]['pulse' ]:
2476+ pulsePins [button ]['pulse' ] = 0
24692477 rC (f'{ fbuttons } .button{ button } ' ,'configure' ,'-text' ,pulsePins [button ]['text' ])
2478+ else :
2479+ pulsePins [button ]['pulse' ] = code ['time' ] * 1000
2480+ pulsePins [button ]['text' ] = rC (f'{ fbuttons } .button{ button } ' ,'cget' ,'-text' )
2481+ root_window .after (100 , pulse_halpin_off , button )
24702482 elif code ['code' ] == 'toggle-halpin' and hal .get_value ('halui.machine.is-on' ):
24712483 if code ['pin' ].startswith ('axisui.ext.out_' ):
24722484 comp [code ['pin' ].replace ('axisui.' ,'' )] = not hal .get_value (code ['pin' ])
@@ -2560,6 +2572,56 @@ def user_button_save():
25602572 rC (f'{ fsetup } .r.ubuttons.canvas.frame.code{ n } ' ,'delete' ,0 ,'end' )
25612573 user_button_setup ()
25622574
2575+ def probe_test_timer ():
2576+ global probeTimer , activeFunction
2577+ if probeTimer > 0 :
2578+ probeTimer -= 100
2579+ if hal .get_value ('plasmac.probe-test-error' ) and not probePressed :
2580+ probeTimer = 0
2581+ if probeTimer > 0 :
2582+ rC (f'{ fbuttons } .button{ probeButton } ' ,'configure' ,'-text' ,f'{ round (probeTimer / 1000 , 1 )} ' )
2583+ root_window .after (100 , probe_test_timer )
2584+ if probeTimer <= 0 :
2585+ if probePressed :
2586+ root_window .after (100 , probe_test_timer )
2587+ else :
2588+ hal .set_p ('plasmac.probe-test' ,'0' )
2589+ rC (f'{ fbuttons } .button{ probeButton } ' ,'configure' ,'-text' ,probeText )
2590+ rC (f'{ fbuttons } .button{ probeButton } ' ,'configure' ,'-bg' ,colorBack )
2591+ probeTimer = 0
2592+ activeFunction = False
2593+
2594+ def torch_pulse_timer ():
2595+ global torchTimer
2596+ if torchTimer > 0 :
2597+ torchTimer -= 100
2598+ if torchTimer > 0 :
2599+ rC (f'{ fbuttons } .button{ torchButton } ' ,'configure' ,'-text' ,f'{ round (torchTimer / 1000 , 1 )} ' )
2600+ root_window .after (100 , torch_pulse_timer )
2601+ if torchTimer <= 0 :
2602+ if torchPressed :
2603+ root_window .after (100 , torch_pulse_timer )
2604+ else :
2605+ hal .set_p ('plasmac.torch-pulse-start' ,'0' )
2606+ hal .set_p ('plasmac.torch-pulse-time' , '0' )
2607+ rC (f'{ fbuttons } .button{ torchButton } ' ,'configure' ,'-text' ,torchText )
2608+ rC (f'{ fbuttons } .button{ torchButton } ' ,'configure' ,'-bg' ,colorBack )
2609+ torchTimer = 0
2610+
2611+ def pulse_halpin_off (button ):
2612+ if pulsePins [button ]['pulse' ] > 0 :
2613+ pulsePins [button ]['pulse' ] -= 100
2614+ if pulsePins [button ]['pulse' ] > 0 :
2615+ rC (f'{ fbuttons } .button{ button } ' ,'configure' ,'-text' ,f'{ round (pulsePins [button ]["pulse" ] / 1000 , 1 )} ' )
2616+ root_window .after (100 , pulse_halpin_off , button )
2617+ if pulsePins [button ]['pulse' ] <= 0 :
2618+ rC (f'{ fbuttons } .button{ button } ' ,'configure' ,'-text' ,pulsePins [button ]['text' ])
2619+ if pulsePins [button ]['pin' ].startswith ('axisui.ext.out_' ):
2620+ comp [pulsePins [button ]['pin' ].replace ('axisui.' ,'' )] = not hal .get_value (pulsePins [button ]['pin' ])
2621+ else :
2622+ hal .set_p (pulsePins [button ]['pin' ], str (not hal .get_value (pulsePins [button ]['pin' ])))
2623+ pulsePins [button ]['pulse' ] = 0
2624+
25632625
25642626##############################################################################
25652627# MATERIAL HANDLING FUNCTIONS #
@@ -4139,11 +4201,9 @@ def recreate_widget_list():
41394201 probePressed = False
41404202 probeTimer = 0
41414203 probeButton = ''
4142- probeStart = 0
41434204 torchPressed = False
41444205 torchTimer = 0
41454206 torchButton = ''
4146- torchStart = 0
41474207 torchHeight = 0
41484208 cChangeButton = ''
41494209 cutType = 0
@@ -5417,12 +5477,8 @@ def user_live_update():
54175477 if orientStart :
54185478 return
54195479 global isIdle , isIdleHomed , isPaused , isRunning
5420- global runState , pausedState , relPos
5421- global probeTimer , probeStart , probeButton
5422- global probeText , probePressed , previewSize
5423- global torchTimer , torchStart , torchButton
5424- global torchText , torchPressed , torchColor
5425- global laserTimer , laserButtonState
5480+ global runState , pausedState , relPos , previewSize
5481+ global probeTimer , laserButtonState
54265482 global framingState , activeFunction
54275483 global currentTool , pmx485 , homeInProgress
54285484 global materialChangePin , materialChangeNumberPin
@@ -5477,60 +5533,19 @@ def user_live_update():
54775533 rC (widget ,'configure' ,'-state' ,'disabled' )
54785534 # update arc voltage
54795535 rC (f'{ fplasma } .arc-voltage' ,'configure' ,'-text' ,f'{ comp ["arc-voltage" ]:3.0f} v' )
5480- # probe-test
5481- if probeTimer > 0 :
5482- if hal .get_value ('plasmac.probe-test-error' ) and not probePressed :
5483- probeTimer = 0
5484- elif time .time () >= probeStart + 0.1 :
5485- probeStart += 0.1
5486- probeTimer -= 0.1
5487- rC (f'{ fbuttons } .button{ probeButton } ' ,'configure' ,'-text' ,str (round (probeTimer , 1 )))
5488- elif probeStart and probeTimer <= 0 and not probePressed :
5489- hal .set_p ('plasmac.probe-test' ,'0' )
5490- rC (f'{ fbuttons } .button{ probeButton } ' ,'configure' ,'-text' ,probeText )
5491- rC (f'{ fbuttons } .button{ probeButton } ' ,'configure' ,'-bg' ,colorBack )
5492- probeStart = 0
5493- probeTimer = 0
5494- activeFunction = False
5495- # torch pulse
5496- if torchTimer > 0 :
5497- if time .time () >= torchStart + 0.1 :
5498- torchStart += 0.1
5499- torchTimer -= 0.1
5500- rC (f'{ fbuttons } .button{ torchButton } ' ,'configure' ,'-text' ,str (abs (round (torchTimer , 1 ))))
5501- elif torchStart and torchTimer <= 0 and not torchPressed :
5502- hal .set_p ('plasmac.torch-pulse-start' ,'0' )
5503- hal .set_p ('plasmac.torch-pulse-time' , '0' )
5504- rC (f'{ fbuttons } .button{ torchButton } ' ,'configure' ,'-text' ,torchText )
5505- rC (f'{ fbuttons } .button{ torchButton } ' ,'configure' ,'-bg' ,colorBack )
5506- torchStart = 0
5507- torchTimer = 0
55085536 # halpin toggle
5509- for key in togglePins :
5510- if hal .get_value (togglePins [key ]['pin' ]) != togglePins [key ]['state' ]:
5511- set_toggle_pins (togglePins [ key ] )
5537+ for button in togglePins :
5538+ if hal .get_value (togglePins [button ]['pin' ]) != togglePins [button ]['state' ]:
5539+ set_toggle_pins (button )
55125540 # halpin pulse
5513- for key in pulsePins :
5514- # service the timers
5515- if pulsePins [key ]['timer' ]:
5516- if time .time () >= pulsePins [key ]['counter' ] + 0.1 :
5517- pulsePins [key ]['counter' ] += 0.1
5518- pulsePins [key ]['timer' ] -= 0.1
5519- rC (f'{ fbuttons } .button{ pulsePins [key ]["button" ]} ' ,'configure' ,'-text' ,str (abs (round (pulsePins [key ]['timer' ], 1 ))))
5520- if pulsePins [key ]['timer' ] <= 0 :
5521- pulsePins [key ]['timer' ] = 0
5522- rC (f'{ fbuttons } .button{ pulsePins [key ]["button" ]} ' ,'configure' ,'-text' ,pulsePins [key ]['text' ])
5523- if pulsePins [key ]['pin' ].startswith ('axisui.ext.out_' ):
5524- comp [pulsePins [key ]['pin' ].replace ('axisui.' ,'' )] = not hal .get_value (pulsePins [key ]['pin' ])
5525- else :
5526- hal .set_p (pulsePins [key ]['pin' ], str (not hal .get_value (pulsePins [key ]['pin' ])))
5541+ for button in pulsePins :
55275542 # set button color for pulse-halpin buttons
5528- if hal .get_value (pulsePins [key ]['pin' ]) != pulsePins [key ]['state' ]:
5529- pulsePins [key ]['state' ] = hal .get_value (pulsePins [key ]['pin' ])
5530- if pulsePins [key ]['state' ]:
5531- rC (f'{ fbuttons } .button{ pulsePins [ key ][ " button" ] } ' ,'configure' ,'-bg' ,colorActive )
5543+ if hal .get_value (pulsePins [button ]['pin' ]) != pulsePins [button ]['state' ]:
5544+ pulsePins [button ]['state' ] = hal .get_value (pulsePins [button ]['pin' ])
5545+ if pulsePins [button ]['state' ]:
5546+ rC (f'{ fbuttons } .button{ button } ' ,'configure' ,'-bg' ,colorActive )
55325547 else :
5533- rC (f'{ fbuttons } .button{ pulsePins [ key ][ " button" ] } ' ,'configure' ,'-bg' ,colorBack )
5548+ rC (f'{ fbuttons } .button{ button } ' ,'configure' ,'-bg' ,colorBack )
55345549 # reset a consumable change
55355550 if (hal .get_value ('plasmac.consumable-change' ) or hal .get_value ('plasmac.consumable-change' )) and \
55365551 (hal .get_value ('axisui.abort' ) or not s .paused ):
@@ -5546,13 +5561,6 @@ def user_live_update():
55465561 vars .jog_speed .set (manualCut ['feed' ])
55475562 rC ('.pane.top.jogspeed.s' ,'configure' ,'-state' ,'normal' )
55485563 save_total_stats ()
5549- # laser timer
5550- if laserTimer > 0 :
5551- laserTimer -= 0.1
5552- if laserTimer <= 0 :
5553- comp ['laser-on' ] = 0
5554- laserButtonState = 'reset'
5555- pVars .laserText .set (_ ('Laser' ))
55565564 # show cut recovery tab
55575565 if s .paused and 'manual' in rC (ftabs ,'pages' ):
55585566 rC (ftabs ,'delete' ,'manual' ,0 )
0 commit comments