birdbrain 0.9.1 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +59 -4
- data/birdbrain.gemspec +3 -3
- data/lib/birdbrain/birdbrain_device.rb +8 -4
- data/lib/birdbrain/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c19db414d18dc4c867da7c20996eac4776988a6d2cec9f647b0421331f497533
|
4
|
+
data.tar.gz: b1a327063e601aa60b6d52d14ac9839763a77605e8a8b026e73e413864247293
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caf7ad0fd88ed312cef45ad0c57e5cf2dd1fa475a5fcb9af17c4ff548b6f56107333202246509cfdcd8658128566a433c8bd38333aaca81b1835be89b120b040
|
7
|
+
data.tar.gz: a7da2556c64c151423cc04fa108a3d6fc9cb5dc72aef2998c86c04bb94f0cb595c4b97132bd5ef491bf3b2c71763e8e0bc3f1116811acc2b8b28e3a780365041
|
data/README.md
CHANGED
@@ -4,9 +4,9 @@ Ruby Library for the BirdBrainTechnologies Hummingbird Bit and Finch 2
|
|
4
4
|
|
5
5
|
This Ruby library allows students to use Ruby to read sensors and set motors and LEDs with the Hummingbird Bit. To use Ruby with the Hummingbird Bit, you must connect to the Hummingbird Bit via bluetooth with the BlueBird Connector.
|
6
6
|
|
7
|
-
For more information about setting up the BlueBird Connector used with their Python library, see www.birdbraintechnologies.com/hummingbirdbit/python
|
7
|
+
For more information about setting up the BlueBird Connector used with their Python library, see www.birdbraintechnologies.com/hummingbirdbit/python
|
8
8
|
|
9
|
-
|
9
|
+
RubyDoc files are available at https://rubydoc.info/github/fmorton/BirdBrain-Ruby-Library
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
@@ -24,11 +24,64 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
$ gem install birdbrain
|
26
26
|
|
27
|
-
The library is distributed through https://rubygems.org/gems/birdbrain
|
27
|
+
The library is distributed through https://rubygems.org/gems/birdbrain
|
28
28
|
|
29
29
|
## Usage
|
30
30
|
|
31
|
-
|
31
|
+
Below are two examples causing a Finch 2 to move in the path of a box. The first example is the long way to do it:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require 'birdbrain'
|
35
|
+
|
36
|
+
finch = BirdbrainFinch.connect('A')
|
37
|
+
|
38
|
+
finch.beak(0, 50, 0)
|
39
|
+
|
40
|
+
finch.tail(1, 0, 50, 0)
|
41
|
+
finch.move(BirdbrainFinch::FORWARD, 2, 20)
|
42
|
+
finch.turn(BirdbrainFinch::LEFT, 90, 50)
|
43
|
+
|
44
|
+
finch.tail(2, 0, 50, 0)
|
45
|
+
finch.move(BirdbrainFinch::FORWARD, 2, 20)
|
46
|
+
finch.turn(BirdbrainFinch::RIGHT, 90, 50)
|
47
|
+
finch.tail(3, 0, 50, 0)
|
48
|
+
|
49
|
+
finch.move(BirdbrainFinch::BACKWARD, 2, 20)
|
50
|
+
finch.turn(BirdbrainFinch::RIGHT, 90, 50)
|
51
|
+
finch.tail(4, 0, 50, 0)
|
52
|
+
|
53
|
+
finch.move(BirdbrainFinch::FORWARD, 2, 20)
|
54
|
+
finch.turn(BirdbrainFinch::LEFT, 90, 50)
|
55
|
+
sleep(1)
|
56
|
+
|
57
|
+
finch.disconnect
|
58
|
+
```
|
59
|
+
|
60
|
+
The second way has the same result, but is more concise:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
require 'birdbrain'
|
64
|
+
|
65
|
+
def draw(finch, step, move_direction, turn_direction)
|
66
|
+
finch.tail(step, 0, 50, 0)
|
67
|
+
finch.move(move_direction, 2, 20)
|
68
|
+
finch.turn(turn_direction, 90, 50)
|
69
|
+
end
|
70
|
+
|
71
|
+
finch = BirdbrainFinch.connect('A')
|
72
|
+
|
73
|
+
finch.beak(0, 50, 0)
|
74
|
+
|
75
|
+
draw(finch, 1, BirdbrainFinch::FORWARD, BirdbrainFinch::LEFT)
|
76
|
+
draw(finch, 2, BirdbrainFinch::FORWARD, BirdbrainFinch::RIGHT)
|
77
|
+
draw(finch, 3, BirdbrainFinch::BACKWARD, BirdbrainFinch::RIGHT)
|
78
|
+
draw(finch, 4, BirdbrainFinch::FORWARD, BirdbrainFinch::LEFT)
|
79
|
+
sleep(1)
|
80
|
+
|
81
|
+
finch.disconnect
|
82
|
+
```
|
83
|
+
|
84
|
+
RubyDoc files are available at https://rubydoc.info/github/fmorton/BirdBrain-Ruby-Library
|
32
85
|
|
33
86
|
## Development
|
34
87
|
|
@@ -43,3 +96,5 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/fmorto
|
|
43
96
|
## License
|
44
97
|
|
45
98
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
99
|
+
|
100
|
+
|
data/birdbrain.gemspec
CHANGED
@@ -6,10 +6,10 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.authors = ['fmorton']
|
7
7
|
spec.email = ['fmorton@mac.com']
|
8
8
|
|
9
|
-
spec.summary = 'Ruby Library for Hummingbird Bit
|
9
|
+
spec.summary = 'Ruby Library for BirdBrain Technologies Hummingbird Bit and Finch 2'
|
10
10
|
spec.description = 'This Ruby library allows students to use Ruby to read sensors and set motors and LEDs with the '\
|
11
|
-
'Birdbrain Technologies Hummingbird Bit. To use Ruby with the Hummingbird Bit
|
12
|
-
'
|
11
|
+
'Birdbrain Technologies Hummingbird Bit and Finch 2. To use Ruby with the Hummingbird Bit or '\
|
12
|
+
'Finch 2, you must connect via bluetooth with the BlueBird Connector.'
|
13
13
|
spec.homepage = 'https://github.com/fmorton/BirdBrain-Ruby-Library'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
|
@@ -13,20 +13,24 @@ class BirdbrainDevice
|
|
13
13
|
|
14
14
|
def initialize(device = DEFAULT_DEVICE)
|
15
15
|
self.state = BirdbrainState.new
|
16
|
-
self.device = device
|
16
|
+
self.device = remap_device(device)
|
17
17
|
self.connected = nil
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.connect(device = DEFAULT_DEVICE, raise_exception_if_no_connection = false)
|
21
|
+
device_object = new(device)
|
22
|
+
|
21
23
|
raise(BirdbrainException, 'Missing device name') if device.nil?
|
22
24
|
raise(BirdbrainException, "Invalid device name: #{device}") unless VALID_DEVICES.include?(device)
|
23
25
|
|
24
|
-
|
26
|
+
device_object.connect
|
25
27
|
|
26
|
-
|
28
|
+
raise(BirdbrainException, 'No connection') if raise_exception_if_no_connection && !device_object.connected?
|
27
29
|
|
28
|
-
|
30
|
+
device_object
|
31
|
+
end
|
29
32
|
|
33
|
+
def remap_device(device = DEFAULT_DEVICE)
|
30
34
|
device
|
31
35
|
end
|
32
36
|
|
data/lib/birdbrain/version.rb
CHANGED
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: birdbrain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fmorton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This Ruby library allows students to use Ruby to read sensors and set
|
14
|
-
motors and LEDs with the Birdbrain Technologies Hummingbird Bit
|
15
|
-
the Hummingbird Bit, you must connect
|
14
|
+
motors and LEDs with the Birdbrain Technologies Hummingbird Bit and Finch 2. To
|
15
|
+
use Ruby with the Hummingbird Bit or Finch 2, you must connect via bluetooth with
|
16
16
|
the BlueBird Connector.
|
17
17
|
email:
|
18
18
|
- fmorton@mac.com
|
@@ -72,5 +72,5 @@ requirements: []
|
|
72
72
|
rubygems_version: 3.2.5
|
73
73
|
signing_key:
|
74
74
|
specification_version: 4
|
75
|
-
summary: Ruby Library for Hummingbird Bit
|
75
|
+
summary: Ruby Library for BirdBrain Technologies Hummingbird Bit and Finch 2
|
76
76
|
test_files: []
|