smalrubot 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bce2e97fd3fff2dcf1019a4d60544dc52511e20d
4
- data.tar.gz: df2409e867c64bd896c51ba7b0c294e55b43044d
3
+ metadata.gz: d8c5524cac06724e181f71cccf31f0d06cae2d0c
4
+ data.tar.gz: 9c652f66ed763b167ea638acb9db33d6da93e8c5
5
5
  SHA512:
6
- metadata.gz: eeb5279b6bca843cd950c8eff66b10038b6dc1c0116e1d3ec83a8aba4317343bc7698530ea8c17668b320c3a529b1b622ace26446c9a4cbfe09e7544cab0e00d
7
- data.tar.gz: 02f62597953d17185210b721f656c8acf2b637baa5b822f37ddf55bebc9f386fa630c662cfe95f8ae4ac3e892f43186cffeac65b506518030bc25e575f0442bd
6
+ metadata.gz: 978c66f080b78fc21c1f25d5dfe36db9c29c1638ef6d716c0ef16efe400fcc98e10372ad4a8a76abfa686b183fe256f2564b288cd046b45578f33f8ca817cdc2
7
+ data.tar.gz: 81cae31984c60a1ce5a960ea8e95a308c872ea10870a21da0dd10cf4247b7b57162ab6139866d06dc30540106330a851fed49dedd99d41315e37c0ae885182e2
data/examples/test.rb CHANGED
@@ -3,11 +3,23 @@ require 'smalrubot'
3
3
  Smalrubot.debug_mode = true
4
4
  board = Smalrubot::Board.new(Smalrubot::TxRx::Serial.new)
5
5
 
6
+ =begin
6
7
  board.digital_write(13, 255)
7
8
  sleep(1)
8
9
  board.digital_write(13, 0)
10
+ =end
9
11
 
12
+ =begin
10
13
  10.times do
11
14
  p board.analog_read(0)
12
15
  sleep(0.5)
13
16
  end
17
+ =end
18
+
19
+ =begin
20
+ 10.times do
21
+ p board.digital_read(3)
22
+ p board.digital_read(4)
23
+ sleep(0.5)
24
+ end
25
+ =end
@@ -56,21 +56,21 @@ module Smalrubot
56
56
  READ_COMMANDS.each_key do |command|
57
57
  define_method(command) do |pin|
58
58
  cmd = normalize_cmd(READ_COMMANDS[command])
59
- req_pin = nil
60
- res_pin = nil
61
- message = nil
62
59
  @mutex.synchronize do
63
60
  req_pin = normalize_pin(pin)
64
61
  write("#{cmd}#{req_pin}#{normalize_value(0)}")
65
- res_pin, message = *read
66
- end
67
- if res_pin && message
68
- if res_pin != req_pin
69
- raise "FATAL: request and response pins are differece: request #{req_pin}, response: #{res_pin}"
62
+ loop do
63
+ res_pin, message = *read
64
+ if res_pin && message
65
+ if res_pin == req_pin
66
+ return message.to_i
67
+ else
68
+ Smalrubot.debug_log('WARN: detected noise!')
69
+ end
70
+ else
71
+ return nil
72
+ end
70
73
  end
71
- message.to_i
72
- else
73
- nil
74
74
  end
75
75
  end
76
76
  end
@@ -2,8 +2,6 @@ module Smalrubot
2
2
  module Components
3
3
  require 'smalrubot/components/base_component'
4
4
  autoload :Led, 'smalrubot/components/led'
5
- autoload :Button, 'smalrubot/components/button'
6
- autoload :Sensor, 'smalrubot/components/sensor'
7
5
  autoload :Servo, 'smalrubot/components/servo'
8
6
  end
9
7
  end
@@ -1,3 +1,3 @@
1
1
  module Smalrubot
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smalrubot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouji Takao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-21 00:00:00.000000000 Z
11
+ date: 2015-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyserial
@@ -137,4 +137,3 @@ test_files:
137
137
  - spec/lib/components/servo_spec.rb
138
138
  - spec/lib/tx_rx/serial_spec.rb
139
139
  - spec/spec_helper.rb
140
- has_rdoc: