1#!/usr/bin/env ruby 2 3require 'tk' 4require 'tkextlib/vu/charts' 5 6#---USAGE 7info = "...the heart of a Realtime Oscilloscope, where the PCIs 8joystick port gives 4 digtal inputs and 4 analog 8 bit 9values with an resolution of ~1 millisecond (!!!) 10running Realtime Linux. 11<p> creates DEMO.ps 12<B1-Motion> see what happens" 13puts info 14 15#---GEOMETRY 16geo_fr = [10, 10, 210, 180] 17geo_ch0 = [10, 10, 210, 90] 18geo_ch1 = [10, 90, 210, 180] 19geo_t1 = [15, 88] 20 21#---GUI 22c = TkCanvas.new(:width=>220, :height=>190).pack(:fill=>:both, :expand=>true) 23 24#---background 25TkcRectangle.new(c, geo_fr, :width=>4, :fill=>'aquamarine3', 26 :tags=>['osc', 'frbg']) 27 28#---channel 0 29ch0 = Tk::Vu::TkcStripchart.new(c, geo_ch0, 30 :fill=>'', :jumpscroll=>false, 31 :outline=>'', :scaleline=>'', 32 :stripline=>'cyan', :tags=>['osc', 'ch0']) 33 34#---channel 1 35ch1 = Tk::Vu::TkcStripchart.new(c, geo_ch1, 36 :fill=>'', :jumpscroll=>0, 37 :outline=>'', :scaleline=>'', 38 :stripline=>'red', :tags=>['osc', 'ch1']) 39 40#---frame 41TkcRectangle.new(c, geo_fr, :width=>4, :tags=>['osc', 'frfg']) 42 43#---position 44txt1 = TkcText.new(c, geo_t1, :text=>"B1-Motion: X:%X\tY:%Y", 45 :anchor=>:nw, :tags=>['osc', 'txt1']) 46 47#---BINDINGS 48c.bind('B1-Motion', proc{|x, y, xx, yy| 49 ch0[:values] = x 50 ch1[:values] = y 51 txt1[:text] = "B1-Motion: X:#{xx}\tY:#{yy}" 52 }, '%x %y %X %Y') 53 54Tk.root.bind('v', proc{ 55 puts ch0[:values].join(' ') 56 puts ch0[:values].size 57 }) 58 59Tk.root.bind('p', proc{ 60 c.postscript(:file=>'DEMO.ps') 61 puts "DEMO.ps printed" 62 }) 63 64Tk.root.bind('q', proc{exit}) 65 66##################### 67 68Tk.mainloop 69