myo-ruby 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +28 -22
- data/lib/myo.rb +1 -0
- data/lib/myo/client.rb +9 -5
- data/lib/myo/version.rb +1 -1
- data/myo.gemspec +2 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9787925c5406af339c1283cf6a8ce408227e1ec5
|
4
|
+
data.tar.gz: e23f9ffe47699aea492475cfe66262a681c96196
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c2c653220a99b7e78d2f6e2e0f207f1186eb6db50b942778077f795aafba01768823c22fb1504704d349a20078debcb8126f5187648335a25f2f6205158c39d
|
7
|
+
data.tar.gz: 15d037fe829eaf2507e2389b2c81917df752634567337fbd670c9f93b6f94d624edcb3e63efbccaf2c7b146495df14d37d6df825a02c7b8d361ee42c9d46eb56
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,46 +1,52 @@
|
|
1
|
-
#
|
1
|
+
# myo-ruby
|
2
2
|
|
3
|
-
Connect to Myo armband in Ruby
|
3
|
+
Connect to [Myo armband](https://www.thalmic.com/en/myo/) in Ruby
|
4
4
|
|
5
|
-
##
|
5
|
+
## Usage
|
6
6
|
|
7
|
-
|
7
|
+
You must start __Myo Connect.app__ first.
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
|
11
|
-
```
|
12
|
-
|
13
|
-
And then execute:
|
14
|
-
|
15
|
-
$ bundle
|
16
|
-
|
17
|
-
Or install it yourself as:
|
10
|
+
require 'myo'
|
18
11
|
|
19
|
-
$ gem install myo-ruby
|
20
|
-
|
21
|
-
## Example
|
22
|
-
|
23
|
-
You should start __Myo Connect.app__ first.
|
24
|
-
|
25
|
-
```ruby
|
26
12
|
Myo.connect do |myo|
|
27
13
|
myo.on :connected do
|
28
14
|
puts "Myo connected!"
|
29
15
|
end
|
30
16
|
|
31
|
-
myo.on :pose do |
|
17
|
+
myo.on :pose do |pose, edge|
|
32
18
|
puts "#{pose}: #{edge}"
|
33
19
|
end
|
34
20
|
|
35
|
-
myo.on :periodic do |
|
21
|
+
myo.on :periodic do |orientation|
|
36
22
|
puts orientation.accel.x
|
37
23
|
end
|
38
24
|
end
|
39
25
|
```
|
40
26
|
|
27
|
+
## Installation
|
28
|
+
|
29
|
+
Add this line to your application's Gemfile:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
gem 'myo-ruby'
|
33
|
+
```
|
34
|
+
|
35
|
+
And then execute:
|
36
|
+
|
37
|
+
```
|
38
|
+
$ bundle
|
39
|
+
```
|
40
|
+
|
41
|
+
Or install it yourself as:
|
42
|
+
|
43
|
+
```
|
44
|
+
$ gem install myo-ruby
|
45
|
+
```
|
46
|
+
|
41
47
|
## Contributing
|
42
48
|
|
43
|
-
1. Fork it ( https://github.com/uetchy/myo
|
49
|
+
1. Fork it ( https://github.com/uetchy/myo-ruby/fork )
|
44
50
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
51
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
46
52
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/myo.rb
CHANGED
data/lib/myo/client.rb
CHANGED
@@ -16,11 +16,13 @@ class Myo::Chamber
|
|
16
16
|
conn = EventMachine::WebSocketClient.connect(@socket_url)
|
17
17
|
|
18
18
|
conn.callback do
|
19
|
-
@callbacks_[:connected]
|
19
|
+
return unless @callbacks_[:connected]
|
20
|
+
instance_eval(&@callbacks_[:connected])
|
20
21
|
end
|
21
22
|
|
22
23
|
conn.errback do |e|
|
23
|
-
@callbacks_[:error]
|
24
|
+
return unless @callbacks_[:error]
|
25
|
+
instance_eval(e, &@callbacks_[:error])
|
24
26
|
end
|
25
27
|
|
26
28
|
conn.stream do |msg|
|
@@ -29,11 +31,13 @@ class Myo::Chamber
|
|
29
31
|
event = JSON.parse(msg.data)[1]
|
30
32
|
case event['type']
|
31
33
|
when 'pose'
|
34
|
+
break unless @callbacks_[:pose]
|
32
35
|
pose = event['pose']
|
33
|
-
|
34
|
-
|
36
|
+
instance_eval(@pool_[:prev_pose], :off, &@callbacks_[:pose]) if @pool_[:prev_pose]
|
37
|
+
instance_eval(pose, :on, &@callbacks_[:pose])
|
35
38
|
@pool_[:prev_pose] = pose
|
36
39
|
when 'orientation'
|
40
|
+
break unless @callbacks_[:periodic]
|
37
41
|
e = OpenStruct.new({
|
38
42
|
:accel => OpenStruct.new({
|
39
43
|
:x => event['accelerometer'][0],
|
@@ -48,7 +52,7 @@ class Myo::Chamber
|
|
48
52
|
:orientation => OpenStruct.new(event['orientation'])
|
49
53
|
})
|
50
54
|
@pool_[:latest_orientation] = e
|
51
|
-
|
55
|
+
instance_eval(e, &@callbacks_[:periodic])
|
52
56
|
end
|
53
57
|
end
|
54
58
|
|
data/lib/myo/version.rb
CHANGED
data/myo.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["uetchy@randompaper.co"]
|
11
11
|
spec.summary = %q{Connect to Myo armband in Ruby}
|
12
12
|
spec.description = %q{Connect to Myo armband in Ruby}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/uetchy/myo-ruby"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "yard"
|
24
25
|
|
25
26
|
spec.add_dependency "em-websocket-client", "~> 0.1.2"
|
26
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myo-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yasuaki Uechi
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: em-websocket-client
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,7 +99,7 @@ files:
|
|
85
99
|
- myo.gemspec
|
86
100
|
- spec/myo_spec.rb
|
87
101
|
- spec/spec_helper.rb
|
88
|
-
homepage:
|
102
|
+
homepage: https://github.com/uetchy/myo-ruby
|
89
103
|
licenses:
|
90
104
|
- MIT
|
91
105
|
metadata: {}
|
@@ -112,3 +126,4 @@ summary: Connect to Myo armband in Ruby
|
|
112
126
|
test_files:
|
113
127
|
- spec/myo_spec.rb
|
114
128
|
- spec/spec_helper.rb
|
129
|
+
has_rdoc:
|