Pause/Resume Button using one input

More
29 Apr 2011 22:14 - 14 Jun 2011 16:11 #9518 by BigJohnT
Thanks to piasdoms constant searching I added to his example to not get out of sync if the button is pressed when not running or paused

A pause/resume button using halui and hal. The input can be either a pyvcp button or a physical button. In this example I used a pyvcp button.

xml

<button>
<halpin>"pause-resume"</halpin>
<text>"Pause/Resume"</text>
</button>

custom.hal

loadrt and2 count=2
loadrt or2 count=1
loadrt toggle count=1
loadrt toggle2nist count=1

addf and2.0 servo-thread
addf and2.1 servo-thread
addf or2.0 servo-thread
addf toggle.0 servo-thread
addf toggle2nist.0 servo-thread

postgui.hal
# External Program Pause/Resume Button
net pause-resume-btn and2.0.in0 and2.1.in0 <= pyvcp.pause-resume
net pause-on toggle2nist.0.is-on and2.0.in1 <= halui.program.is-paused
net run-on and2.1.in1 <= halui.program.is-running
net pause-sig or2.0.in0 <= and2.0.out
net resume-sig or2.0.in1 <= and2.1.out
net toggle-ok toggle.0.in <= or2.0.out
net togglesig toggle2nist.0.in <= toggle.0.out
net toggleon halui.program.pause <= toggle2nist.0.on
net toggleoff halui.program.resume <= toggle2nist.0.off

John
Last edit: 14 Jun 2011 16:11 by BigJohnT.

Please Log in or Create an account to join the conversation.

More
19 May 2011 16:06 - 19 May 2011 16:34 #9929 by piasdom
here's another example

custom.hal
loadrt toggle2nist count=3
addf toggle2nist.0 servo-thread

custom_postgui.hal
#pause/resume
net pausesig pyvcp.prog-pause toggle.4.in
net togglesig toggle.4.out toggle2nist.0.in
net toggleon toggle2nist.0.on => halui.program.pause
net toggleoff toggle2nist.0.off => halui.program.resume
#net pauseison halui.program.is-paused => toggle2nist.0.is-on

xml
<button> <!-- program pause -->
<halpin>"prog-pause"</halpin>
<text>"Pause/Resume"</text>
<font>('Helvetica 2',18)</font>
<fg>"midnightblue"</fg>
</button>

Kenneth
Last edit: 19 May 2011 16:34 by piasdom.

Please Log in or Create an account to join the conversation.

More
19 May 2011 16:53 #9932 by piasdom
BigJohnT corrected me(Thanks), it WILL get out of sync if paused without
program running.

Please Log in or Create an account to join the conversation.

Time to create page: 0.058 seconds
Powered by Kunena Forum