hybridgroup-sphero 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -0
- data/lib/sphero.rb +163 -15
- metadata +6 -22
data/README.markdown
CHANGED
data/lib/sphero.rb
CHANGED
@@ -3,7 +3,7 @@ require 'sphero/response'
|
|
3
3
|
require 'thread'
|
4
4
|
|
5
5
|
class Sphero
|
6
|
-
VERSION = '1.
|
6
|
+
VERSION = '1.3.0'
|
7
7
|
|
8
8
|
FORWARD = 0
|
9
9
|
RIGHT = 90
|
@@ -17,20 +17,22 @@ class Sphero
|
|
17
17
|
class << self
|
18
18
|
def start(dev, &block)
|
19
19
|
retries_left = DEFAULT_RETRIES
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
begin
|
21
|
+
sphero = self.new dev
|
22
|
+
if (block_given?)
|
23
|
+
begin
|
24
|
+
sphero.instance_eval(&block)
|
25
|
+
ensure
|
26
|
+
sphero.close
|
27
|
+
end
|
28
|
+
return nil
|
26
29
|
end
|
27
|
-
return
|
30
|
+
return sphero
|
31
|
+
rescue Errno::EBUSY
|
32
|
+
puts retries_left
|
33
|
+
retries_left = retries_left - 1
|
34
|
+
retry unless retries_left < 0
|
28
35
|
end
|
29
|
-
return sphero
|
30
|
-
rescue Errno::EBUSY
|
31
|
-
puts retries_left
|
32
|
-
retries_left = retries_left - 1
|
33
|
-
retry unless retries_left > 0
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
@@ -97,6 +99,11 @@ class Sphero
|
|
97
99
|
write Request::Heading.new(@seq, h)
|
98
100
|
end
|
99
101
|
|
102
|
+
def color colorname, persistant = false
|
103
|
+
color = COLORS[colorname]
|
104
|
+
rgb color[:r], color[:g], color[:b], persistant
|
105
|
+
end
|
106
|
+
|
100
107
|
def rgb r, g, b, persistant = false
|
101
108
|
write Request::SetRGB.new(@seq, r, g, b, persistant ? 0x01 : 0x00)
|
102
109
|
end
|
@@ -248,7 +255,6 @@ class Sphero
|
|
248
255
|
def read_next_chunk(len, blocking=false)
|
249
256
|
begin
|
250
257
|
if blocking || is_windows?
|
251
|
-
rs, ws, = IO.select([@sp], [], [], 20)
|
252
258
|
data = @sp.read(len)
|
253
259
|
return nil unless data && data.length == len
|
254
260
|
else
|
@@ -263,5 +269,147 @@ class Sphero
|
|
263
269
|
end
|
264
270
|
data
|
265
271
|
end
|
266
|
-
end
|
267
272
|
|
273
|
+
COLORS = {
|
274
|
+
'aliceblue' => {:r => 240, :g => 248, :b => 255},
|
275
|
+
'antiquewhite' => {:r => 250, :g => 235, :b => 215},
|
276
|
+
'aqua' => {:r => 0, :g => 255, :b => 255},
|
277
|
+
'aquamarine' => {:r => 127, :g => 255, :b => 212},
|
278
|
+
'azure' => {:r => 240, :g => 255, :b => 255},
|
279
|
+
'beige' => {:r => 245, :g => 245, :b => 220},
|
280
|
+
'bisque' => {:r => 255, :g => 228, :b => 196},
|
281
|
+
'black' => {:r => 0, :g => 0, :b => 0},
|
282
|
+
'blanchedalmond' => {:r => 255, :g => 235, :b => 205},
|
283
|
+
'blue' => {:r => 0, :g => 0, :b => 255},
|
284
|
+
'blueviolet' => {:r => 138, :g => 43, :b => 226},
|
285
|
+
'brown' => {:r => 165, :g => 42, :b => 42},
|
286
|
+
'burlywood' => {:r => 222, :g => 184, :b => 135},
|
287
|
+
'cadetblue' => {:r => 95, :g => 158, :b => 160},
|
288
|
+
'chartreuse' => {:r => 127, :g => 255, :b => 0},
|
289
|
+
'chocolate' => {:r => 210, :g => 105, :b => 30},
|
290
|
+
'coral' => {:r => 255, :g => 127, :b => 80},
|
291
|
+
'cornflowerblue' => {:r => 100, :g => 149, :b => 237},
|
292
|
+
'cornsilk' => {:r => 255, :g => 248, :b => 220},
|
293
|
+
'crimson' => {:r => 220, :g => 20, :b => 60},
|
294
|
+
'cyan' => {:r => 0, :g => 255, :b => 255},
|
295
|
+
'darkblue' => {:r => 0, :g => 0, :b => 139},
|
296
|
+
'darkcyan' => {:r => 0, :g => 139, :b => 139},
|
297
|
+
'darkgoldenrod' => {:r => 184, :g => 134, :b => 11},
|
298
|
+
'darkgray' => {:r => 169, :g => 169, :b => 169},
|
299
|
+
'darkgreen' => {:r => 0, :g => 100, :b => 0},
|
300
|
+
'darkkhaki' => {:r => 189, :g => 183, :b => 107},
|
301
|
+
'darkmagenta' => {:r => 139, :g => 0, :b => 139},
|
302
|
+
'darkolivegreen' => {:r => 85, :g => 107, :b => 47},
|
303
|
+
'darkorange' => {:r => 255, :g => 140, :b => 0},
|
304
|
+
'darkorchid' => {:r => 153, :g => 50, :b => 204},
|
305
|
+
'darkred' => {:r => 139, :g => 0, :b => 0},
|
306
|
+
'darksalmon' => {:r => 233, :g => 150, :b => 122},
|
307
|
+
'darkseagreen' => {:r => 143, :g => 188, :b => 143},
|
308
|
+
'darkslateblue' => {:r => 72, :g => 61, :b => 139},
|
309
|
+
'darkslategray' => {:r => 47, :g => 79, :b => 79},
|
310
|
+
'darkturquoise' => {:r => 0, :g => 206, :b => 209},
|
311
|
+
'darkviolet' => {:r => 148, :g => 0, :b => 211},
|
312
|
+
'deeppink' => {:r => 255, :g => 20, :b => 147},
|
313
|
+
'deepskyblue' => {:r => 0, :g => 191, :b => 255},
|
314
|
+
'dimgray' => {:r => 105, :g => 105, :b => 105},
|
315
|
+
'dodgerblue' => {:r => 30, :g => 144, :b => 255},
|
316
|
+
'firebrick' => {:r => 178, :g => 34, :b => 34},
|
317
|
+
'floralwhite' => {:r => 255, :g => 250, :b => 240},
|
318
|
+
'forestgreen' => {:r => 34, :g => 139, :b => 34},
|
319
|
+
'fuchsia' => {:r => 255, :g => 0, :b => 255},
|
320
|
+
'gainsboro' => {:r => 220, :g => 220, :b => 220},
|
321
|
+
'ghostwhite' => {:r => 248, :g => 248, :b => 255},
|
322
|
+
'gold' => {:r => 255, :g => 215, :b => 0},
|
323
|
+
'goldenrod' => {:r => 218, :g => 165, :b => 32},
|
324
|
+
'gray' => {:r => 128, :g => 128, :b => 128},
|
325
|
+
'green' => {:r => 0, :g => 128, :b => 0},
|
326
|
+
'greenyellow' => {:r => 173, :g => 255, :b => 47},
|
327
|
+
'honeydew' => {:r => 240, :g => 255, :b => 240},
|
328
|
+
'hotpink' => {:r => 255, :g => 105, :b => 180},
|
329
|
+
'indianred' => {:r => 205, :g => 92, :b => 92},
|
330
|
+
'indigo' => {:r => 75, :g => 0, :b => 130},
|
331
|
+
'ivory' => {:r => 255, :g => 255, :b => 240},
|
332
|
+
'khaki' => {:r => 240, :g => 230, :b => 140},
|
333
|
+
'lavender' => {:r => 230, :g => 230, :b => 250},
|
334
|
+
'lavenderblush' => {:r => 255, :g => 240, :b => 245},
|
335
|
+
'lawngreen' => {:r => 124, :g => 252, :b => 0},
|
336
|
+
'lemonchiffon' => {:r => 255, :g => 250, :b => 205},
|
337
|
+
'lightblue' => {:r => 173, :g => 216, :b => 230},
|
338
|
+
'lightcoral' => {:r => 240, :g => 128, :b => 128},
|
339
|
+
'lightcyan' => {:r => 224, :g => 255, :b => 255},
|
340
|
+
'lightgoldenrodyellow' => {:r => 250, :g => 250, :b => 210},
|
341
|
+
'lightgreen' => {:r => 144, :g => 238, :b => 144},
|
342
|
+
'lightgrey' => {:r => 211, :g => 211, :b => 211},
|
343
|
+
'lightpink' => {:r => 255, :g => 182, :b => 193},
|
344
|
+
'lightsalmon' => {:r => 255, :g => 160, :b => 122},
|
345
|
+
'lightseagreen' => {:r => 32, :g => 178, :b => 170},
|
346
|
+
'lightskyblue' => {:r => 135, :g => 206, :b => 250},
|
347
|
+
'lightslategray' => {:r => 119, :g => 136, :b => 153},
|
348
|
+
'lightsteelblue' => {:r => 176, :g => 196, :b => 222},
|
349
|
+
'lightyellow' => {:r => 255, :g => 255, :b => 224},
|
350
|
+
'lime' => {:r => 0, :g => 255, :b => 0},
|
351
|
+
'limegreen' => {:r => 50, :g => 205, :b => 50},
|
352
|
+
'linen' => {:r => 250, :g => 240, :b => 230},
|
353
|
+
'magenta' => {:r => 255, :g => 0, :b => 255},
|
354
|
+
'maroon' => {:r => 128, :g => 0, :b => 0},
|
355
|
+
'mediumaquamarine' => {:r => 102, :g => 205, :b => 170},
|
356
|
+
'mediumblue' => {:r => 0, :g => 0, :b => 205},
|
357
|
+
'mediumorchid' => {:r => 186, :g => 85, :b => 211},
|
358
|
+
'mediumpurple' => {:r => 147, :g => 112, :b => 219},
|
359
|
+
'mediumseagreen' => {:r => 60, :g => 179, :b => 113},
|
360
|
+
'mediumslateblue' => {:r => 123, :g => 104, :b => 238},
|
361
|
+
'mediumspringgreen' => {:r => 0, :g => 250, :b => 154},
|
362
|
+
'mediumturquoise' => {:r => 72, :g => 209, :b => 204},
|
363
|
+
'mediumvioletred' => {:r => 199, :g => 21, :b => 133},
|
364
|
+
'midnightblue' => {:r => 25, :g => 25, :b => 112},
|
365
|
+
'mintcream' => {:r => 245, :g => 255, :b => 250},
|
366
|
+
'mistyrose' => {:r => 255, :g => 228, :b => 225},
|
367
|
+
'moccasin' => {:r => 255, :g => 228, :b => 181},
|
368
|
+
'navajowhite' => {:r => 255, :g => 222, :b => 173},
|
369
|
+
'navy' => {:r => 0, :g => 0, :b => 128},
|
370
|
+
'oldlace' => {:r => 253, :g => 245, :b => 230},
|
371
|
+
'olive' => {:r => 128, :g => 128, :b => 0},
|
372
|
+
'olivedrab' => {:r => 107, :g => 142, :b => 35},
|
373
|
+
'orange' => {:r => 255, :g => 165, :b => 0},
|
374
|
+
'orangered' => {:r => 255, :g => 69, :b => 0},
|
375
|
+
'orchid' => {:r => 218, :g => 112, :b => 214},
|
376
|
+
'palegoldenrod' => {:r => 238, :g => 232, :b => 170},
|
377
|
+
'palegreen' => {:r => 152, :g => 251, :b => 152},
|
378
|
+
'paleturquoise' => {:r => 175, :g => 238, :b => 238},
|
379
|
+
'palevioletred' => {:r => 219, :g => 112, :b => 147},
|
380
|
+
'papayawhip' => {:r => 255, :g => 239, :b => 213},
|
381
|
+
'peachpuff' => {:r => 255, :g => 218, :b => 185},
|
382
|
+
'peru' => {:r => 205, :g => 133, :b => 63},
|
383
|
+
'pink' => {:r => 255, :g => 192, :b => 203},
|
384
|
+
'plum' => {:r => 221, :g => 160, :b => 221},
|
385
|
+
'powderblue' => {:r => 176, :g => 224, :b => 230},
|
386
|
+
'purple' => {:r => 128, :g => 0, :b => 128},
|
387
|
+
'red' => {:r => 255, :g => 0, :b => 0},
|
388
|
+
'rosybrown' => {:r => 188, :g => 143, :b => 143},
|
389
|
+
'royalblue' => {:r => 65, :g => 105, :b => 225},
|
390
|
+
'saddlebrown' => {:r => 139, :g => 69, :b => 19},
|
391
|
+
'salmon' => {:r => 250, :g => 128, :b => 114},
|
392
|
+
'sandybrown' => {:r => 244, :g => 164, :b => 96},
|
393
|
+
'seagreen' => {:r => 46, :g => 139, :b => 87},
|
394
|
+
'seashell' => {:r => 255, :g => 245, :b => 238},
|
395
|
+
'sienna' => {:r => 160, :g => 82, :b => 45},
|
396
|
+
'silver' => {:r => 192, :g => 192, :b => 192},
|
397
|
+
'skyblue' => {:r => 135, :g => 206, :b => 235},
|
398
|
+
'slateblue' => {:r => 106, :g => 90, :b => 205},
|
399
|
+
'slategray' => {:r => 112, :g => 128, :b => 144},
|
400
|
+
'snow' => {:r => 255, :g => 250, :b => 250},
|
401
|
+
'springgreen' => {:r => 0, :g => 255, :b => 127},
|
402
|
+
'steelblue' => {:r => 70, :g => 130, :b => 180},
|
403
|
+
'tan' => {:r => 210, :g => 180, :b => 140},
|
404
|
+
'teal' => {:r => 0, :g => 128, :b => 128},
|
405
|
+
'thistle' => {:r => 216, :g => 191, :b => 216},
|
406
|
+
'tomato' => {:r => 255, :g => 99, :b => 71},
|
407
|
+
'turquoise' => {:r => 64, :g => 224, :b => 208},
|
408
|
+
'violet' => {:r => 238, :g => 130, :b => 238},
|
409
|
+
'wheat' => {:r => 245, :g => 222, :b => 179},
|
410
|
+
'white' => {:r => 255, :g => 255, :b => 255},
|
411
|
+
'whitesmoke' => {:r => 245, :g => 245, :b => 245},
|
412
|
+
'yellow' => {:r => 255, :g => 255, :b => 0},
|
413
|
+
'yellowgreen' => {:r => 154, :g => 205, :b => 50}
|
414
|
+
}
|
415
|
+
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.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: minitest
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '3.3'
|
22
|
-
type: :development
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '3.3'
|
30
14
|
- !ruby/object:Gem::Dependency
|
31
15
|
name: rdoc
|
32
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +18,7 @@ dependencies:
|
|
34
18
|
requirements:
|
35
19
|
- - ~>
|
36
20
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
21
|
+
version: '4.0'
|
38
22
|
type: :development
|
39
23
|
prerelease: false
|
40
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +26,7 @@ dependencies:
|
|
42
26
|
requirements:
|
43
27
|
- - ~>
|
44
28
|
- !ruby/object:Gem::Version
|
45
|
-
version: '
|
29
|
+
version: '4.0'
|
46
30
|
- !ruby/object:Gem::Dependency
|
47
31
|
name: hoe
|
48
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +34,7 @@ dependencies:
|
|
50
34
|
requirements:
|
51
35
|
- - ~>
|
52
36
|
- !ruby/object:Gem::Version
|
53
|
-
version: '3.
|
37
|
+
version: '3.6'
|
54
38
|
type: :development
|
55
39
|
prerelease: false
|
56
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +42,7 @@ dependencies:
|
|
58
42
|
requirements:
|
59
43
|
- - ~>
|
60
44
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
45
|
+
version: '3.6'
|
62
46
|
description: ! 'A ruby gem for controlling your Sphero ball. Sends commands over
|
63
47
|
the TTY
|
64
48
|
|