home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / tcom96 / debugger / a_to_d.seq < prev    next >
Encoding:
Text File  |  1990-09-11  |  1.6 KB  |  45 lines

  1. \ A-TO-D.SEQ    words to measure 80c196 a-to-d channels
  2.  
  3.  
  4. : .RZ ( 16bit n -- )  \ type a 16bit number with leading zeros
  5.         >R  (.)  R>  OVER - 0 ?DO ASCII 0 FEMIT LOOP  TYPE  ;
  6.  
  7. : .volts ( adresult -- )        \ display voltage
  8.         u16/ u2/ ( /32 ) 1 or ( add .5 LSB )  5000 2048 */
  9.         1000 /mod  2 .R  ascii . femit  3 .RZ ." v.\0 "  ;
  10.  
  11. : measure ( channel -- ) \ measure A to D channel
  12.         5 command
  13.         com-out         \ send channel number
  14.         getword         \ wait for result
  15.         .volts          \ show the result
  16.         key? if key drop ." aborted" then  ;
  17.  
  18.  
  19. create old-vertical 8 allot
  20.  
  21. : measure-all ( -- ) \ measure all channels repeatedly
  22.    savecursor
  23.    cursor-off  cls  old-vertical 8 erase
  24.    0 1 at  16 spaces ." Mike's 80c196 8-channel voltmeter"   0 3 at
  25.    ."   0        1        2        3        4        5        6        7"
  26.    0 22 at
  27.    ."   0        1        2        3        4        5        6        7"
  28.    begin
  29.         8 0 do
  30.             5 command  i com-out  getword  \ measure channel i
  31.             key? if  drop leave  then
  32.             20  over  U16/ U16/ U16/  -   \ vertical position for this voltage
  33.             old-vertical i + c@               \ old vertical position
  34.             2dup <> if  i 9 * swap at  9 spaces  \ blank old position
  35.                     else  drop  then
  36.             i 9 *  over at      \ go to new position
  37.             old-vertical i + c!     \ save new position
  38.             >rev .volts >norm
  39.         loop
  40.         key? until
  41.    key drop
  42.    purge
  43.    restcursor  0 23 at    ;
  44.  
  45.