mi100 0.4.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +73 -74
  3. data/lib/mi100.rb +5 -28
  4. data/lib/mi100/version.rb +1 -1
  5. data/mi100.gemspec +26 -24
  6. metadata +46 -25
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 805a29bd87ad2f27e1842433ac003c3947096cfb
4
+ data.tar.gz: 0d9ca50d45a10989e47be2ce804093ed329320b8
5
+ SHA512:
6
+ metadata.gz: 578e5c700b800510ba23612cf9e670f3435d9c010486fe542e31a2b66069c71596bf3c8f0b153736f4092d7955e0d51b069b0bf488e4236208e9d837c7327007
7
+ data.tar.gz: 6b782f3be985da5611e0941f87d2e9b5479831b64bd3d9cc2ca02a6a9190e20e0ea9f8faa579e1ce4030377887edb53f71d7eabaa23a9c2dc8e7677a4856e1ec
data/README.md CHANGED
@@ -1,74 +1,73 @@
1
- # Mi100
2
-
3
- Controlling your Bluetooth<sup>&reg;</sup> wireless technology embedded robot MI100.
4
-
5
-
6
- ## Installation
7
-
8
- Add this line to your application's Gemfile:
9
-
10
- gem 'mi100'
11
-
12
- And then execute:
13
-
14
- $ bundle
15
-
16
- Or install it yourself as:
17
-
18
- $ gem install mi100
19
-
20
- ## Usage
21
-
22
- Pairing must be performed between a *Bluetooth* wireless technology enabled device and MI100 in advance.
23
- The below example shows that pairing is done between a Windows device and MI100, and the virtual serial port is COM12.
24
-
25
- require 'serialport' #hybridgroup-serialport
26
- require 'mi100'
27
-
28
- mi100 = Mi100.new 'COM12'
29
-
30
- 3.times do
31
- res = mi100.ping
32
-
33
- # Get battery level
34
- res = mi100.power
35
- puts res
36
-
37
- # Move forward 300mS
38
- mi100.move "forward", 300
39
-
40
- # Move backward 300mS
41
- mi100.move "backward", 300
42
-
43
- # Spin right 500mS
44
- mi100.spin "right", 500
45
-
46
- # Spin left 500mS
47
- mi100.spin "left", 500
48
-
49
- # Blink LED 100% red, 50% green, 20% blue 1000mS
50
- mi100.blink 100, 50, 20, 1000
51
-
52
- # LED random color blink
53
- mi100.blink
54
-
55
- # Tone 440Hz 200mS
56
- mi100.tone 440, 200
57
-
58
- # Do Re Mi
59
- mi100.sound "DO"
60
- mi100.sound "RE"
61
- mi100.sound "MI"
62
-
63
- sleep 1
64
- end
65
-
66
- mi100.close
67
-
68
- ## Contributing
69
-
70
- 1. Fork it
71
- 2. Create your feature branch (`git checkout -b my-new-feature`)
72
- 3. Commit your changes (`git commit -am 'Add some feature'`)
73
- 4. Push to the branch (`git push origin my-new-feature`)
74
- 5. Create new Pull Request
1
+ # Mi100
2
+
3
+ Controlling your Bluetooth<sup>&reg;</sup> wireless technology embedded robot MI100 of MONOxIT.
4
+ The version >=1.0.0 uses RubyFFI based rubyserial gem written by Hybridgroup.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'mi100'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install mi100
19
+
20
+ ## Usage
21
+
22
+ Pairing must be performed between a *Bluetooth* wireless technology enabled device and MI100 in advance.
23
+ The below example shows that pairing is done between a Windows device and MI100, and the virtual serial port is COM12.
24
+
25
+ require 'mi100'
26
+
27
+ mi100 = Mi100.new 'COM12'
28
+
29
+ 3.times do
30
+ res = mi100.ping
31
+
32
+ # Get battery level
33
+ res = mi100.power
34
+ puts res
35
+
36
+ # Move forward 300mS
37
+ mi100.move_forward 300
38
+
39
+ # Move backward 300mS
40
+ mi100.move_backward 300
41
+
42
+ # Spin right 500mS
43
+ mi100.spin_right 500
44
+
45
+ # Spin left 500mS
46
+ mi100.spin_left 500
47
+
48
+ # Blink LED 100% red, 50% green, 20% blue 1000mS
49
+ mi100.blink 100, 50, 20, 1000
50
+
51
+ # LED random color blink
52
+ mi100.blink
53
+
54
+ # Tone 440Hz 200mS
55
+ mi100.tone 440, 200
56
+
57
+ # Do Re Mi
58
+ mi100.sound "DO"
59
+ mi100.sound "RE"
60
+ mi100.sound "MI"
61
+
62
+ sleep 1
63
+ end
64
+
65
+ mi100.close
66
+
67
+ ## Contributing
68
+
69
+ 1. Fork it
70
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
71
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
72
+ 4. Push to the branch (`git push origin my-new-feature`)
73
+ 5. Create new Pull Request
data/lib/mi100.rb CHANGED
@@ -33,7 +33,7 @@ class Mi100
33
33
  CMD_DRIVE = "Z"
34
34
 
35
35
 
36
- DEFAULT_SPEED = 1023
36
+ DEFAULT_SPEED = 255
37
37
  DEFAULT_MOVE_DURATION = 300
38
38
  DEFAULT_SPIN_DURATION = 140
39
39
  DEFAULT_DRIVE_DURATION = 50
@@ -302,12 +302,8 @@ class Mi100
302
302
  private
303
303
 
304
304
  def initialize_serialport(dev)
305
- require 'serialport'
306
- @sp = SerialPort.new dev, 38400, 8, 1, SerialPort::NONE
307
- if is_windows?
308
- @sp.read_timeout = READ_TIMEOUT
309
- @sp.write_timeout = WRITE_TIMEOUT
310
- end
305
+ require 'rubyserial'
306
+ @sp = Serial.new dev, 9600
311
307
  end
312
308
 
313
309
  def initialize_robo
@@ -336,32 +332,13 @@ class Mi100
336
332
  end
337
333
 
338
334
  def empty_receive_buffer
339
- @sp.read_timeout = SHORT_READ_TIMEOUT
340
335
  begin
341
- char = @sp.read 1
336
+ char = @sp.getbyte
342
337
  end while char && char.length > 0
343
- @sp.read_timeout = READ_TIMEOUT
344
338
  end
345
339
 
346
340
  def receiveln
347
- if is_windows?
348
- start_time = Time.now
349
- str = ""
350
- while (Time.now - start_time) * 1000.0 < READ_TIMEOUT do
351
- char = @sp.read 1
352
- if char.length > 0
353
- str += char
354
- break if char == "\n"
355
- end
356
- end
357
- else
358
- str = @sp.gets
359
- end
360
- str
341
+ @sp.gets
361
342
  end
362
343
 
363
- def is_windows?
364
- os = RUBY_PLATFORM.split("-")[1]
365
- os == 'mswin' or os == 'bccwin' or os == 'mingw' or os == 'mingw32'
366
- end
367
344
  end
data/lib/mi100/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Mi100
2
- VERSION = "0.4.2"
2
+ VERSION = "1.0.0"
3
3
  end
data/mi100.gemspec CHANGED
@@ -1,24 +1,26 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'mi100/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "mi100"
8
- spec.version = Mi100::VERSION
9
- spec.authors = ["Masami Yamakawa"]
10
- spec.email = ["silkycove@gmail.com"]
11
- spec.description = %q{A ruby gem for controlling MI100 of monoxit through bluetooth virtual serial port.}
12
- spec.summary = %q{A ruby gem for controlling MI100}
13
- spec.homepage = ""
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec"
24
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mi100/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mi100"
8
+ spec.version = Mi100::VERSION
9
+ spec.authors = ["Masami Yamakawa"]
10
+ spec.email = ["silkycove@gmail.com"]
11
+ spec.description = %q{A ruby gem for controlling MI100 of monoxit through bluetooth virtual serial port.}
12
+ spec.summary = %q{A ruby gem for controlling MI100}
13
+ spec.homepage = "https://github.com/monoxit/mi100"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+
25
+ spec.add_dependency "rubyserial"
26
+ end
metadata CHANGED
@@ -1,49 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mi100
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Masami Yamakawa
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-07-09 00:00:00.000000000Z
11
+ date: 2015-12-17 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
- requirement: &20067036 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.3'
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *20067036
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: rake
27
- requirement: &20066784 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - ">="
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *20066784
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: rspec
38
- requirement: &20066508 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ! '>='
45
+ - - ">="
42
46
  - !ruby/object:Gem::Version
43
47
  version: '0'
44
48
  type: :development
45
49
  prerelease: false
46
- version_requirements: *20066508
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubyserial
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
47
69
  description: A ruby gem for controlling MI100 of monoxit through bluetooth virtual
48
70
  serial port.
49
71
  email:
@@ -52,9 +74,9 @@ executables: []
52
74
  extensions: []
53
75
  extra_rdoc_files: []
54
76
  files:
55
- - .gitignore
56
- - .rspec
57
- - .travis.yml
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
58
80
  - Gemfile
59
81
  - LICENSE.txt
60
82
  - README.md
@@ -65,30 +87,29 @@ files:
65
87
  - mi100.gemspec
66
88
  - spec/mi100_spec.rb
67
89
  - spec/spec_helper.rb
68
- homepage: ''
90
+ homepage: https://github.com/monoxit/mi100
69
91
  licenses:
70
92
  - MIT
93
+ metadata: {}
71
94
  post_install_message:
72
95
  rdoc_options: []
73
96
  require_paths:
74
97
  - lib
75
98
  required_ruby_version: !ruby/object:Gem::Requirement
76
- none: false
77
99
  requirements:
78
- - - ! '>='
100
+ - - ">="
79
101
  - !ruby/object:Gem::Version
80
102
  version: '0'
81
103
  required_rubygems_version: !ruby/object:Gem::Requirement
82
- none: false
83
104
  requirements:
84
- - - ! '>='
105
+ - - ">="
85
106
  - !ruby/object:Gem::Version
86
107
  version: '0'
87
108
  requirements: []
88
109
  rubyforge_project:
89
- rubygems_version: 1.7.2
110
+ rubygems_version: 2.4.5
90
111
  signing_key:
91
- specification_version: 3
112
+ specification_version: 4
92
113
  summary: A ruby gem for controlling MI100
93
114
  test_files:
94
115
  - spec/mi100_spec.rb