hybridgroup-sphero 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/sphero.rb +20 -2
  2. data/test/test_sphero.rb +7 -0
  3. metadata +2 -2
@@ -4,7 +4,12 @@ require 'sphero/response'
4
4
  require 'thread'
5
5
 
6
6
  class Sphero
7
- VERSION = '1.1.3'
7
+ VERSION = '1.1.4'
8
+
9
+ FORWARD = 0
10
+ RIGHT = 90
11
+ BACKWARD = 180
12
+ LEFT = 270
8
13
 
9
14
  class << self
10
15
  def start(dev, &block)
@@ -22,7 +27,7 @@ class Sphero
22
27
  @seq = 0x00
23
28
  @lock = Mutex.new
24
29
  end
25
-
30
+
26
31
  def ping
27
32
  write Request::Ping.new(@seq)
28
33
  end
@@ -94,8 +99,21 @@ class Sphero
94
99
 
95
100
  private
96
101
 
102
+ def is_windows?
103
+ os = RUBY_PLATFORM.split("-")[1]
104
+ if (os == 'mswin' or os == 'bccwin' or os == 'mingw' or os == 'mingw32')
105
+ true
106
+ else
107
+ false
108
+ end
109
+ end
97
110
  def initialize_serialport dev
98
111
  @sp = SerialPort.new dev, 115200, 8, 1, SerialPort::NONE
112
+ if is_windows?
113
+ @sp.read_timeout=1000
114
+ @sp.write_timeout=0
115
+ @sp.initial_byte_offset=5
116
+ end
99
117
  end
100
118
 
101
119
  def write packet
@@ -93,4 +93,11 @@ class TestSphero < MiniTest::Unit::TestCase
93
93
  Kernel.expects(:sleep).with(3)
94
94
  @sphero.keep_going 3
95
95
  end
96
+
97
+ def test_directions
98
+ assert_equal 0, Sphero::FORWARD
99
+ assert_equal 90, Sphero::RIGHT
100
+ assert_equal 180, Sphero::BACKWARD
101
+ assert_equal 270, Sphero::LEFT
102
+ end
96
103
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hybridgroup-sphero
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-07 00:00:00.000000000 Z
12
+ date: 2013-01-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: serialport