smalruby 0.0.26-x86-mingw32 → 0.0.27-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of smalruby might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/smalruby/character.rb +2 -0
- data/lib/smalruby/event_handler.rb +9 -2
- data/lib/smalruby/hardware/two_wheel_drive_car.rb +17 -24
- data/lib/smalruby/hardware.rb +3 -1
- data/lib/smalruby/util.rb +15 -1
- data/lib/smalruby/version.rb +1 -1
- data/lib/smalruby.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa8c09967a7b2bbc4f20c9ed175e4cf0de7815c8
|
4
|
+
data.tar.gz: 44f19f82f887bd606f622ce377e826d8cf7c0735
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c5ee978cdf45f04acd54f58d8d1fde907d858a34c5ea1f63f87db1c1aa8a2ab37dc4770505463c1655e136cacdfd42428edc9de2c312dbbb34b6f8ca7023885
|
7
|
+
data.tar.gz: 940819b7d174f5dfccebc7a48ed2b37b30d63e87a58ef518cb791ff758959b281cb15c4bed74d6098da56569bc189afba2af9499d80b65729d83c650cc5cfa68
|
data/lib/smalruby/character.rb
CHANGED
@@ -497,6 +497,7 @@ module Smalruby
|
|
497
497
|
end
|
498
498
|
|
499
499
|
def alive?
|
500
|
+
@threads.compact!
|
500
501
|
@threads.delete_if { |t|
|
501
502
|
if t.alive?
|
502
503
|
false
|
@@ -514,6 +515,7 @@ module Smalruby
|
|
514
515
|
end
|
515
516
|
|
516
517
|
def join
|
518
|
+
@threads.compact!
|
517
519
|
@threads.each(&:join)
|
518
520
|
end
|
519
521
|
|
@@ -13,12 +13,19 @@ module Smalruby
|
|
13
13
|
@object = object
|
14
14
|
@options = options
|
15
15
|
@block = block
|
16
|
+
@running = false
|
16
17
|
end
|
17
18
|
|
18
19
|
def call(*args)
|
20
|
+
return nil if @running
|
19
21
|
return Thread.start(@object, @block) { |object, block|
|
20
|
-
|
21
|
-
|
22
|
+
begin
|
23
|
+
@running = true
|
24
|
+
object.instance_exec(*args, &block)
|
25
|
+
ensure
|
26
|
+
@running = false
|
27
|
+
end
|
28
|
+
}
|
22
29
|
end
|
23
30
|
end
|
24
31
|
end
|
@@ -16,38 +16,29 @@ module Smalruby
|
|
16
16
|
end
|
17
17
|
|
18
18
|
# 前進する
|
19
|
-
def forward(left_level =
|
20
|
-
right_level =
|
21
|
-
digital_write_pins(left_level,
|
22
|
-
right_level, Dino::Board::LOW)
|
19
|
+
def forward(left_level = 100,
|
20
|
+
right_level = 100)
|
21
|
+
digital_write_pins(left_level, 0, right_level, 0)
|
23
22
|
end
|
24
23
|
|
25
24
|
# 後退する
|
26
|
-
def backward(left_level =
|
27
|
-
|
28
|
-
digital_write_pins(Dino::Board::LOW, left_level,
|
29
|
-
Dino::Board::LOW, right_level)
|
25
|
+
def backward(left_level = 100, right_level = 100)
|
26
|
+
digital_write_pins(0, left_level, 0, right_level)
|
30
27
|
end
|
31
28
|
|
32
29
|
# 左に曲がる
|
33
|
-
def turn_left(left_level =
|
34
|
-
|
35
|
-
digital_write_pins(Dino::Board::LOW, left_level,
|
36
|
-
right_level, Dino::Board::LOW)
|
30
|
+
def turn_left(left_level = 100, right_level = 100)
|
31
|
+
digital_write_pins(0, left_level, right_level, 0)
|
37
32
|
end
|
38
33
|
|
39
34
|
# 右に曲がる
|
40
|
-
def turn_right(left_level =
|
41
|
-
|
42
|
-
digital_write_pins(left_level, Dino::Board::LOW,
|
43
|
-
Dino::Board::LOW, right_level)
|
35
|
+
def turn_right(left_level = 100, right_level = 100)
|
36
|
+
digital_write_pins(left_level, 0, 0, right_level)
|
44
37
|
end
|
45
38
|
|
46
39
|
# 停止する
|
47
|
-
def stop
|
48
|
-
|
49
|
-
digital_write_pins(Dino::Board::LOW, Dino::Board::LOW,
|
50
|
-
Dino::Board::LOW, Dino::Board::LOW)
|
40
|
+
def stop
|
41
|
+
digital_write_pins(0, 0, 0, 0)
|
51
42
|
end
|
52
43
|
|
53
44
|
# 命令する
|
@@ -75,10 +66,12 @@ module Smalruby
|
|
75
66
|
end
|
76
67
|
|
77
68
|
def digital_write_pins(*levels)
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
69
|
+
2.times do
|
70
|
+
levels.each.with_index do
|
71
|
+
|level, i|
|
72
|
+
digital_write(pins[i], (Dino::Board::HIGH * level / 100.0).to_i)
|
73
|
+
sleep(0.05) if i.odd?
|
74
|
+
end
|
82
75
|
end
|
83
76
|
end
|
84
77
|
end
|
data/lib/smalruby/hardware.rb
CHANGED
@@ -31,7 +31,8 @@ module Smalruby
|
|
31
31
|
|
32
32
|
defaults = {
|
33
33
|
device: nil,
|
34
|
-
baud: 115_200
|
34
|
+
baud: 115_200,
|
35
|
+
heart_rate: 40 # HACK: 実機で調整した値
|
35
36
|
}
|
36
37
|
opt = Util.process_options(options, defaults)
|
37
38
|
|
@@ -42,6 +43,7 @@ module Smalruby
|
|
42
43
|
txrx.io = opt[:device] if opt[:device]
|
43
44
|
end
|
44
45
|
world.board = Dino::Board.new(txrx)
|
46
|
+
world.board.heart_rate = opt[:heart_rate]
|
45
47
|
|
46
48
|
@initialized_hardware = true
|
47
49
|
end
|
data/lib/smalruby/util.rb
CHANGED
@@ -21,7 +21,21 @@ module Smalruby
|
|
21
21
|
#
|
22
22
|
# @return [Boolean] Windowsの場合はtrue、そうでない場合はfalseを返す
|
23
23
|
def windows?
|
24
|
-
/windows|mingw|cygwin/i =~ RbConfig::CONFIG['arch']
|
24
|
+
ENV['SMALRUBY_WINDOWS_MODE'] || /windows|mingw|cygwin/i =~ RbConfig::CONFIG['arch']
|
25
|
+
end
|
26
|
+
|
27
|
+
# プラットフォームがRaspberry Piかどうかを返す
|
28
|
+
#
|
29
|
+
# @return [Boolean] Raspberry Piの場合はtrue、そうでない場合はfalseを返す
|
30
|
+
def raspberrypi?
|
31
|
+
ENV['SMALRUBY_RASPBERRYPI_MODE'] || /armv6l-linux-eabihf/i =~ RbConfig::CONFIG['arch']
|
32
|
+
end
|
33
|
+
|
34
|
+
# プラットフォームがMac OS Xかどうかを返す
|
35
|
+
#
|
36
|
+
# @return [Boolean] Mac OS Xの場合はtrue、そうでない場合はfalseを返す
|
37
|
+
def osx?
|
38
|
+
ENV['SMALRUBY_OSX_MODE'] || /darwin/i =~ RbConfig::CONFIG['arch']
|
25
39
|
end
|
26
40
|
end
|
27
41
|
end
|
data/lib/smalruby/version.rb
CHANGED
data/lib/smalruby.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smalruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.27
|
5
5
|
platform: x86-mingw32
|
6
6
|
authors:
|
7
7
|
- Kouji Takao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|