public
Fork of evanfarrar/opensprints
Description: Bringing GoldSprints to the masses.
Homepage: http://www.opensprints.com/
Clone URL: git://github.com/toothrot/opensprints.git
Sanity checkin
evanfarrar (author)
Fri Jun 27 16:51:30 -0700 2008
commit  637b28d4be41684734dc92cb4c50cda8810c1f30
tree    b1078cfebeef9dd86b4993b21e4c03771f5f9147
parent  1023f869787773a71dcd84f5b04bdc73dd53bfee
...
11
12
13
14
15
16
17
18
19
20
21
 
 
 
 
 
 
 
 
 
 
22
23
24
...
27
28
29
 
...
11
12
13
 
 
 
 
 
 
 
 
14
15
16
17
18
19
20
21
22
23
24
25
26
...
29
30
31
32
0
@@ -11,14 +11,16 @@ class Sensor
0
     Thread.abort_on_exception = true
0
     @t.kill if @t
0
     @t = Thread.new do
0
- sp = SerialPort.new(@filename, 115200, 8, 1, SerialPort::NONE )
0
- sp.putc 'h'
0
- sp.putc 'w'
0
- sp.putc "\n"
0
- sp.close
0
- @s = TCPSocket.new('127.0.0.1',5000)
0
- loop do
0
- @queue << @s.readline.strip
0
+ @f = File.new(@filename, 'w+')
0
+ @f.putc 'h'
0
+ @f.putc 'w'
0
+ @f.putc "\n"
0
+ while true do
0
+ l = @f.readline
0
+ if l=~/^[12];/
0
+ @queue << l
0
+ end
0
+ puts l
0
       end
0
     end
0
   end
0
@@ -27,3 +29,4 @@ class Sensor
0
     @s.close
0
   end
0
 end
0
+
...
13
14
15
16
 
17
18
19
...
13
14
15
 
16
17
18
19
0
@@ -13,7 +13,7 @@ class Sensor
0
       else
0
         t = 0
0
         f = []
0
- 800.times { f << "#{rand(2)+1};0:#{t+=rand(10)}" }
0
+ 8000.times { f << "#{rand(2)+1};0:#{t+=rand(10)}" }
0
       end
0
       t_start = Time.now.to_f
0
       while true do
...
15
16
17
18
19
 
 
20
21
22
...
32
33
34
35
36
 
 
37
38
39
...
85
86
87
88
89
 
 
90
91
 
92
93
94
...
104
105
106
107
108
 
 
 
109
110
111
...
15
16
17
 
 
18
19
20
21
22
...
32
33
34
 
 
35
36
37
38
39
...
85
86
87
 
 
88
89
90
 
91
92
93
94
...
104
105
106
 
 
107
108
109
110
111
112
0
@@ -15,8 +15,8 @@ require base_dir+'lib/racer'
0
 require base_dir+'lib/units/base'
0
 require base_dir+'lib/units/standard'
0
 require base_dir+'lib/secsy_time'
0
-Kernel::require Dir.pwd+'/lib/serialport.so'
0
-require base_dir+"lib/sensors/#{options['sensor']['file']}_sensor"
0
+#Kernel::require Dir.pwd+'/lib/serialport.so'
0
+require base_dir+"lib/sensors/#{options['sensor']['type']}_sensor"
0
 SENSOR_LOCATION = options['sensor']['device']
0
 RACE_DISTANCE = options['race_distance'].meters.to_km
0
 RED_WHEEL_CIRCUMFERENCE = options['roller_circumference']['red'].mm.to_km
0
@@ -32,8 +32,8 @@ end
0
 class Race
0
   def initialize(shoes_instance, distance, update_area)
0
     @shoes_instance = shoes_instance
0
- blue = @shoes_instance.ask "Who is on the blue bike?"
0
- red = @shoes_instance.ask "Who is on the red bike?"
0
+# blue = @shoes_instance.ask "Who is on the blue bike?"
0
+# red = @shoes_instance.ask "Who is on the red bike?"
0
     @red = Racer.new(:wheel_circumference => RED_WHEEL_CIRCUMFERENCE,
0
                      :name => "racer1",
0
                      :units => UNIT_SYSTEM)
0
@@ -85,10 +85,10 @@ class Race
0
         @shoes_instance.rect 60, 340, red_progress, 20
0
         if @blue.distance>RACE_DISTANCE and @red.distance>RACE_DISTANCE
0
           winner = (@red.tick_at(@race_distance)<@blue.tick_at(@race_distance)) ? "RED" : "BLUE"
0
- @shoes_instance.title "#{winner} WINS!!!\n", :align => "center",
0
- :top => 380, :width => 800
0
+ @shoes_instance.title "#{winner} WINS!!!\n", :align => "center",
0
+ :top => 380, :width => 800
0
           @shoes_instance.title "red: #{@red.tick_at(@race_distance)}, blue: #{@blue.tick_at(@race_distance)}",
0
- :align => 'center', :top => 450, :width => 800
0
+ :align => 'center', :top => 450, :width => 800
0
           @sensor.stop
0
           @continue = false
0
         end
0
@@ -104,8 +104,9 @@ end
0
 
0
 Shoes.app :width => 800, :height => 600 do
0
   stack{
0
- fill black
0
- banner TITLE, :align => "center"
0
+ image "track.jpg", :top => -450
0
+ # stroke magenta
0
+ banner TITLE, :top => 150, :align => "center", :background => magenta
0
     @update_area = stack {}
0
   race = lambda do
0
     @start.hide

Comments

    No one has commented yet.