From dad91fa171d5489fbf85029dac8e9f3a1ac69603 Mon Sep 17 00:00:00 2001 From: ian Date: Thu, 5 Jan 2006 13:56:06 +0000 Subject: [PATCH] speed/dirn request immediate --- TODO | 4 ---- hostside/stopgap-controller | 37 ++++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/TODO b/TODO index 1fa0209..902e32b 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,3 @@ -more keystroke commands - -speed changes immediate - race between cdu off (due to watchdog or short) and points diff --git a/hostside/stopgap-controller b/hostside/stopgap-controller index 3b3348f..df5595b 100755 --- a/hostside/stopgap-controller +++ b/hostside/stopgap-controller @@ -390,19 +390,23 @@ proc newfuncs {} { return "funcs5to8 2 $value" } -proc maybechange {thing} { +proc maybechange {thing force} { global $thing ch upvar #0 ${thing}_fixed fixed if {![info exists fixed]} { - set rb 0x[randbyte][randbyte] - if { - $rb / 65536.0 > - 1.0 / (($ch(${thing}every) - $ch(minint)*0.001) * $ch(scale)) - } { - debug "maybechange $thing rb=$rb no" - return 0 + if {$force} { + debug "maybechange $thing forced ..." + } else { + set rb 0x[randbyte][randbyte] + if { + $rb / 65536.0 > + 1.0 / (($ch(${thing}every) - $ch(minint)*0.001) * $ch(scale)) + } { + debug "maybechange $thing rb=$rb no" + return 0 + } + debug "maybechange $thing rb=$rb yes ..." } - debug "maybechange $thing rb=$rb yes ..." set l [new$thing] } else { debug "fixed $thing $fixed" @@ -419,7 +423,7 @@ proc maybechange {thing} { proc changewhat {} { global ch chwa catch { after cancel $chwa } - if {[maybechange speeddirn] || [maybechange funcs]} { + if {[maybechange speeddirn 0] || [maybechange funcs 0]} { set interval $ch(minint) } else { set interval 1000 @@ -476,14 +480,17 @@ proc setup_complete {} { #---------- # for keyboard control -proc ask_fast {} { - global speeddirn_fixed; set speeddirn_fixed {speed126 2 126 0} -} -proc ask_slow {} { - global speeddirn_fixed; set speeddirn_fixed {speed126 2 10 0} +proc ask_speed_now {l} { + global speeddirn_fixed + set speeddirn_fixed $l + maybechange speeddirn 1 } + +proc ask_fast {} { ask_speed_now {speed126 2 126 0} } +proc ask_slow {} { ask_speed_now {speed126 2 10 0} } proc ask_randspeed {} { global speeddirn_fixed; catch { unset speeddirn_fixed } + maybechange speeddirn 1 } proc ask_manual {rightp} { global pointasked; set pointasked M$rightp } -- 2.30.2