All pastes #740843 Raw Edit

Something

public text v1 · immutable
·published 2007-10-18 09:09 UTC
rendered paste body
: skip_samples ( samples -- )
    &2000 ms ahead >r  \ timeout value
    0 >r               \ lastcnt
    0 >r               \ intcnttmp
    intcnt off
    BEGIN
        intcnt @ dup r! over <
    WHILE
        2 l@ timeout? THROW drop
        r@ 1 l@ -  \ 
        IF &2000 ms ahead 2 l! THEN
        &10 ms sleep
    REPEAT
    drop \ samples
    rdrop rdrop rdrop \ 3 local variables
;

: ss ( u --> )
     >R 0  -1                                 ( 0 -1 r: u)
     BEGIN IF 2000 ms ahead THEN              ( 0 ahead r :u ) 
           intcnt @ DUP R@ < WHILE            ( 0 ahead intcnt r :u )
                    SWAP timeout? THROW drop  ( 0 intcnt )
           TUCK -
         10 ms sleep
     REPEAT RDROP 2DROP ;