smalruby 0.1.8-x86-mingw32 → 0.1.9-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/.rubocop.yml +120 -15
- data/Rakefile +1 -1
- data/lib/smalruby/character.rb +5 -0
- data/lib/smalruby/hardware.rb +1 -0
- data/lib/smalruby/hardware/neo_pixel.rb +69 -0
- data/lib/smalruby/version.rb +1 -1
- data/samples/hardware_neo_pixel.rb +24 -0
- data/samples/hardware_neo_pixel2.rb +40 -0
- data/smalruby.gemspec +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d8a9c5466d5791117a27f0ee81f345874327aae
|
4
|
+
data.tar.gz: 51d80e43ded60d8a33a85f3d07daf85a4f0cc85e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d1c6bf30b3ba7d3da9867fca1afddc10f60357910fc80feca177df1446ec6aaaf512bc3cb55bac9463533549928ce7e6af9e51d77d51be65a249d112a2dc200
|
7
|
+
data.tar.gz: 7ebe348c294e7d117b58933438fb0d2872d274ad29dc1e1bbdad560a4d9bd326ba3597ecd15ba72c5d55cb95f2665fbc6b2c49ace540db875a8c725cfe38039d
|
data/.rubocop.yml
CHANGED
@@ -1,42 +1,147 @@
|
|
1
1
|
AllCops:
|
2
|
-
|
3
|
-
- tmp
|
2
|
+
Excludes:
|
3
|
+
- tmp/**/*
|
4
|
+
- vendor/**/*
|
5
|
+
- work/**/*
|
6
|
+
- samples/**/*
|
4
7
|
|
5
|
-
|
8
|
+
# Offense count: 1
|
9
|
+
# Configuration parameters: AllowSafeAssignment.
|
10
|
+
Lint/AssignmentInCondition:
|
6
11
|
Enabled: false
|
7
12
|
|
8
|
-
|
13
|
+
# Offense count: 2
|
14
|
+
Lint/HandleExceptions:
|
9
15
|
Enabled: false
|
10
16
|
|
11
|
-
|
17
|
+
# Offense count: 1
|
18
|
+
Lint/RescueException:
|
12
19
|
Enabled: false
|
13
20
|
|
14
|
-
|
21
|
+
# Offense count: 2
|
22
|
+
# Cop supports --auto-correct.
|
23
|
+
Lint/UnusedMethodArgument:
|
15
24
|
Enabled: false
|
16
25
|
|
17
|
-
|
26
|
+
# Offense count: 17
|
27
|
+
Metrics/AbcSize:
|
28
|
+
Max: 58
|
29
|
+
|
30
|
+
# Offense count: 3
|
31
|
+
# Configuration parameters: CountComments.
|
32
|
+
Metrics/ClassLength:
|
33
|
+
Max: 433
|
34
|
+
|
35
|
+
# Offense count: 3
|
36
|
+
Metrics/CyclomaticComplexity:
|
37
|
+
Max: 8
|
38
|
+
|
39
|
+
# Offense count: 4
|
40
|
+
# Configuration parameters: AllowURI, URISchemes.
|
41
|
+
Metrics/LineLength:
|
42
|
+
Max: 162
|
43
|
+
|
44
|
+
# Offense count: 22
|
45
|
+
# Configuration parameters: CountComments.
|
46
|
+
Metrics/MethodLength:
|
47
|
+
Max: 37
|
48
|
+
|
49
|
+
# Offense count: 2
|
50
|
+
# Configuration parameters: CountComments.
|
51
|
+
Metrics/ModuleLength:
|
52
|
+
Max: 170
|
53
|
+
|
54
|
+
# Offense count: 1
|
55
|
+
Metrics/PerceivedComplexity:
|
56
|
+
Max: 8
|
57
|
+
|
58
|
+
# Offense count: 1
|
59
|
+
# Cop supports --auto-correct.
|
60
|
+
Performance/ParallelAssignment:
|
61
|
+
Enabled: false
|
62
|
+
|
63
|
+
# Offense count: 1
|
64
|
+
Style/AccessorMethodName:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
# Offense count: 160
|
68
|
+
Style/AsciiComments:
|
69
|
+
Enabled: false
|
70
|
+
|
71
|
+
# Offense count: 4
|
72
|
+
# Cop supports --auto-correct.
|
73
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
74
|
+
Style/BlockDelimiters:
|
75
|
+
Enabled: false
|
76
|
+
|
77
|
+
# Offense count: 4
|
78
|
+
Style/Documentation:
|
79
|
+
Enabled: false
|
80
|
+
|
81
|
+
# Offense count: 8
|
82
|
+
# Configuration parameters: MinBodyLength.
|
83
|
+
Style/GuardClause:
|
84
|
+
Enabled: false
|
85
|
+
|
86
|
+
# Offense count: 1
|
87
|
+
# Cop supports --auto-correct.
|
88
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
|
89
|
+
Style/HashSyntax:
|
90
|
+
Enabled: false
|
91
|
+
|
92
|
+
# Offense count: 11
|
93
|
+
# Cop supports --auto-correct.
|
94
|
+
# Configuration parameters: MaxLineLength.
|
95
|
+
Style/IfUnlessModifier:
|
96
|
+
Enabled: false
|
97
|
+
|
98
|
+
# Offense count: 1
|
99
|
+
# Cop supports --auto-correct.
|
100
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
101
|
+
Style/MultilineOperationIndentation:
|
18
102
|
Enabled: false
|
19
103
|
|
20
|
-
|
104
|
+
# Offense count: 2
|
105
|
+
# Cop supports --auto-correct.
|
106
|
+
# Configuration parameters: PreferredDelimiters.
|
107
|
+
Style/PercentLiteralDelimiters:
|
21
108
|
Enabled: false
|
22
109
|
|
23
|
-
|
110
|
+
# Offense count: 1
|
111
|
+
# Cop supports --auto-correct.
|
112
|
+
Style/PerlBackrefs:
|
24
113
|
Enabled: false
|
25
114
|
|
26
|
-
|
115
|
+
# Offense count: 4
|
116
|
+
# Cop supports --auto-correct.
|
117
|
+
# Configuration parameters: AllowMultipleReturnValues.
|
118
|
+
Style/RedundantReturn:
|
27
119
|
Enabled: false
|
28
120
|
|
29
|
-
|
121
|
+
# Offense count: 2
|
122
|
+
# Cop supports --auto-correct.
|
123
|
+
Style/SpecialGlobalVars:
|
30
124
|
Enabled: false
|
31
125
|
|
32
|
-
|
126
|
+
# Offense count: 12
|
127
|
+
# Cop supports --auto-correct.
|
128
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
129
|
+
Style/StringLiterals:
|
33
130
|
Enabled: false
|
34
131
|
|
35
|
-
|
132
|
+
# Offense count: 3
|
133
|
+
# Cop supports --auto-correct.
|
134
|
+
# Configuration parameters: IgnoredMethods.
|
135
|
+
Style/SymbolProc:
|
36
136
|
Enabled: false
|
37
137
|
|
38
|
-
|
138
|
+
# Offense count: 6
|
139
|
+
# Cop supports --auto-correct.
|
140
|
+
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
|
141
|
+
Style/TrailingComma:
|
39
142
|
Enabled: false
|
40
143
|
|
41
|
-
|
144
|
+
# Offense count: 2
|
145
|
+
# Cop supports --auto-correct.
|
146
|
+
Style/UnneededPercentQ:
|
42
147
|
Enabled: false
|
data/Rakefile
CHANGED
data/lib/smalruby/character.rb
CHANGED
@@ -381,6 +381,11 @@ module Smalruby
|
|
381
381
|
Hardware.create_hardware(Hardware::RgbLedCathode, pin)
|
382
382
|
end
|
383
383
|
|
384
|
+
# マイコン内蔵RGB LED
|
385
|
+
def neo_pixel(pin)
|
386
|
+
Hardware.create_hardware(Hardware::NeoPixel, pin)
|
387
|
+
end
|
388
|
+
|
384
389
|
# サーボモーター
|
385
390
|
def servo(pin)
|
386
391
|
Hardware.create_hardware(Hardware::Servo, pin)
|
data/lib/smalruby/hardware.rb
CHANGED
@@ -0,0 +1,69 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'smalruby/hardware'
|
3
|
+
require "set"
|
4
|
+
|
5
|
+
module Smalruby
|
6
|
+
module Hardware
|
7
|
+
# Adafruit NeoPixel RGB LED class
|
8
|
+
class NeoPixel < Smalrubot::Components::BaseComponent
|
9
|
+
include Util
|
10
|
+
|
11
|
+
def initialize(options)
|
12
|
+
pin = Pin.smalruby_to_smalrubot(options[:pin])
|
13
|
+
case pin
|
14
|
+
when 3, 5, 6, 9, 10, 11
|
15
|
+
super(board: world.board, pin: pin)
|
16
|
+
else
|
17
|
+
fail "ピン番号が間違っています: {options[:pin]}"
|
18
|
+
end
|
19
|
+
@indexes = Set.new
|
20
|
+
end
|
21
|
+
|
22
|
+
# set color
|
23
|
+
def set(options)
|
24
|
+
defaults = {
|
25
|
+
index: 0,
|
26
|
+
color: "black",
|
27
|
+
show: true,
|
28
|
+
}
|
29
|
+
opts = process_options(options, defaults)
|
30
|
+
@indexes << opts[:index]
|
31
|
+
color = Color.smalruby_to_dxruby(opts[:color])
|
32
|
+
board.set_neo_pixel_color(opts[:index], *color)
|
33
|
+
if opts[:show]
|
34
|
+
show
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# apply color settings
|
39
|
+
def show
|
40
|
+
board.show_neo_pixel
|
41
|
+
end
|
42
|
+
|
43
|
+
# turn off
|
44
|
+
def turn_off
|
45
|
+
if @indexes.length > 0
|
46
|
+
@indexes.each do |i|
|
47
|
+
board.set_neo_pixel_color(i, 0, 0, 0)
|
48
|
+
end
|
49
|
+
board.show_neo_pixel
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# destruction
|
54
|
+
def stop
|
55
|
+
if @indexes.length > 0
|
56
|
+
turn_off
|
57
|
+
@indexes.clear
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def after_initialize(_ = {})
|
64
|
+
board.set_neo_pixel_pin(pin)
|
65
|
+
board.show_neo_pixel
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/smalruby/version.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
DESCRIPTION = <<EOS
|
4
|
+
マイコン内蔵RGB LEDを制御します
|
5
|
+
EOS
|
6
|
+
|
7
|
+
# デジタルの5番ピンに接続してください。
|
8
|
+
|
9
|
+
require 'smalruby'
|
10
|
+
|
11
|
+
init_hardware
|
12
|
+
|
13
|
+
stage1 = Stage.new(color: 'white')
|
14
|
+
|
15
|
+
stage1.on(:start) do
|
16
|
+
loop do
|
17
|
+
Color::NAME_TO_CODE.keys.each do |color|
|
18
|
+
draw_font(string: "#{DESCRIPTION}#{color}", color: 'black')
|
19
|
+
neo_pixel('D5').set(color: color)
|
20
|
+
sleep(1)
|
21
|
+
fill(color: 'white')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
DESCRIPTION = <<EOS
|
4
|
+
マイコン内蔵RGB LEDを制御します
|
5
|
+
EOS
|
6
|
+
|
7
|
+
# マイコン内蔵RGB LEDデジタルの5番ピンに、
|
8
|
+
# スイッチをデジタルの3・4番ピンに接続してください。
|
9
|
+
|
10
|
+
require 'smalruby'
|
11
|
+
|
12
|
+
init_hardware
|
13
|
+
|
14
|
+
stage1 = Stage.new(color: 'white')
|
15
|
+
|
16
|
+
stage1.on(:start) do
|
17
|
+
color_codes = Color::NAME_TO_CODE.keys
|
18
|
+
index = 0
|
19
|
+
loop do
|
20
|
+
fill(color: 'white')
|
21
|
+
color = color_codes[index]
|
22
|
+
draw_font(string: "#{DESCRIPTION}#{index}:#{color}", color: 'black')
|
23
|
+
neo_pixel("D5").set(color: color)
|
24
|
+
until button("D3").pressed? || button("D4").pressed?
|
25
|
+
await
|
26
|
+
end
|
27
|
+
if button("D3").pressed?
|
28
|
+
index -= 1
|
29
|
+
if index < 0
|
30
|
+
index = 0
|
31
|
+
end
|
32
|
+
end
|
33
|
+
if button("D4").pressed?
|
34
|
+
index += 1
|
35
|
+
if index >= color_codes.length
|
36
|
+
index = color_codes.length - 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/smalruby.gemspec
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.1.
|
4
|
+
version: 0.1.9
|
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: 2015-05-
|
11
|
+
date: 2015-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -198,14 +198,14 @@ dependencies:
|
|
198
198
|
requirements:
|
199
199
|
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: 0.0.
|
201
|
+
version: 0.0.6
|
202
202
|
type: :runtime
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: 0.0.
|
208
|
+
version: 0.0.6
|
209
209
|
description: smalruby is a 2D game development library. This is part of "Smalruby"
|
210
210
|
project that is a learning ruby programming environment for kids.
|
211
211
|
email:
|
@@ -259,6 +259,7 @@ files:
|
|
259
259
|
- lib/smalruby/hardware/button.rb
|
260
260
|
- lib/smalruby/hardware/led.rb
|
261
261
|
- lib/smalruby/hardware/motor_driver.rb
|
262
|
+
- lib/smalruby/hardware/neo_pixel.rb
|
262
263
|
- lib/smalruby/hardware/null_hardware.rb
|
263
264
|
- lib/smalruby/hardware/pin.rb
|
264
265
|
- lib/smalruby/hardware/rgb_led_anode.rb
|
@@ -289,6 +290,8 @@ files:
|
|
289
290
|
- samples/hardware_button.rb
|
290
291
|
- samples/hardware_led.rb
|
291
292
|
- samples/hardware_motor_driver.rb
|
293
|
+
- samples/hardware_neo_pixel.rb
|
294
|
+
- samples/hardware_neo_pixel2.rb
|
292
295
|
- samples/hardware_rgb_led_anode.rb
|
293
296
|
- samples/hardware_rgb_led_cathode.rb
|
294
297
|
- samples/hardware_sensor.rb
|