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 +4 -4
- data/examples/test.rb +12 -0
- data/lib/smalrubot/board.rb +11 -11
- data/lib/smalrubot/components.rb +0 -2
- data/lib/smalrubot/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8c5524cac06724e181f71cccf31f0d06cae2d0c
|
4
|
+
data.tar.gz: 9c652f66ed763b167ea638acb9db33d6da93e8c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/smalrubot/board.rb
CHANGED
@@ -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
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
data/lib/smalrubot/components.rb
CHANGED
@@ -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
|
data/lib/smalrubot/version.rb
CHANGED
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.
|
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-
|
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:
|