smalruby-editor 0.1.24 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of smalruby-editor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Guardfile +9 -0
- data/app/assets/javascripts/blocks/hardware.js.coffee.erb +147 -62
- data/app/assets/javascripts/blocks/sensing.js.coffee.erb +4 -0
- data/app/assets/javascripts/msg/en_us.js +34 -12
- data/app/assets/javascripts/msg/ja.js +35 -15
- data/app/helpers/editor_helper.rb +2 -1
- data/app/models/concerns/ruby_to_block/block/{hardware_button_down_or_up.rb → hardware_button_pressed_or_released.rb} +3 -3
- data/app/models/concerns/ruby_to_block/block/{hardware_led_on.rb → hardware_led_turn_off.rb} +2 -2
- data/app/models/concerns/ruby_to_block/block/{hardware_led_off.rb → hardware_led_turn_on.rb} +2 -2
- data/app/models/concerns/ruby_to_block/block/hardware_operation.rb +2 -0
- data/app/models/concerns/ruby_to_block/block/{hardware_rgb_led_on.rb → hardware_rgb_led_set_color.rb} +2 -2
- data/app/models/concerns/ruby_to_block/block/{hardware_rgb_led_off.rb → hardware_rgb_led_turn_off.rb} +2 -2
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_action.rb +22 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_action_with_sec.rb +24 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_led_turn_on_or_off.rb +22 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_light_sensor_value.rb +28 -0
- data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_v3_touch_sensor_pressed_or_released.rb +29 -0
- data/app/models/concerns/ruby_to_block/block/hardware_two_wheel_drive_car_commands.rb +3 -1
- data/app/views/editor/_toolbox.html.haml +30 -17
- data/app/views/layouts/application.html.erb +3 -1
- data/config/locales/en.yml +1 -0
- data/config/locales/ja.yml +1 -0
- data/lib/smalruby_editor/blockly_message_helper.rb +2 -1
- data/lib/smalruby_editor/version.rb +1 -1
- data/lib/tasks/release.rake +0 -0
- data/smalruby-editor.gemspec +1 -1
- data/spec/acceptance/block_mode/blocks/hardware/{button_down_or_up.feature → button_pressed_or_released.feature} +15 -15
- data/spec/acceptance/block_mode/blocks/hardware/led_turn_off.feature +67 -0
- data/spec/acceptance/block_mode/blocks/hardware/led_turn_on.feature +67 -0
- data/spec/acceptance/block_mode/blocks/hardware/rgb_led_set_color.feature +79 -0
- data/spec/acceptance/block_mode/blocks/hardware/{button_not_use_pullup.feature → rgb_led_turn_off.feature} +30 -18
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_action.feature +107 -0
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_action_with_sec.feature +151 -0
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_led_turn_on_or_off.feature +73 -0
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_light_sensor_value.feature +92 -0
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_motor_speed.feature +116 -0
- data/spec/acceptance/block_mode/blocks/hardware/smalrubot_v3_touch_sensor_pressed_or_released.feature +108 -0
- data/spec/models/concerns/ruby_to_block/block/hardware_spec.rb +359 -36
- data/spec/models/concerns/ruby_to_block_spec.rb +8 -8
- data/spec/steps/block_mode_steps.rb +8 -0
- metadata +43 -35
- data/app/models/concerns/ruby_to_block/block/hardware_button_not_use_pullup.rb +0 -18
- data/app/models/concerns/ruby_to_block/block/hardware_on_button_down_or_up.rb +0 -19
- data/app/models/concerns/ruby_to_block/block/hardware_on_sensor_change.rb +0 -17
- data/spec/acceptance/block_mode/blocks/hardware/led_off.feature +0 -75
- data/spec/acceptance/block_mode/blocks/hardware/led_on.feature +0 -75
- data/spec/acceptance/block_mode/blocks/hardware/on_button_down_or_up.feature +0 -87
- data/spec/acceptance/block_mode/blocks/hardware/on_sensor_change.feature +0 -81
- data/spec/acceptance/block_mode/blocks/hardware/rgb_led_off.feature +0 -81
- data/spec/acceptance/block_mode/blocks/hardware/rgb_led_on.feature +0 -87
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f9b14363d11ea6f2183f59c8457d162bb17f186
|
4
|
+
data.tar.gz: ff251621c10ae581bd696908ca3a42e9a1df5346
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f2590be9012299e533bc2654f9e422a3701a897dfaaddbc681fe54810948072d7132f4ece20f00d8b39db6ca74c34d12a4f5c750d71b10e7f1639e11eac7fd5
|
7
|
+
data.tar.gz: e43a47979a4e9613db19d3acf1cfa7bbc9334746bbaf4c9744af3a97121948a7e450f568554fa7e69c94e0a44396cef7d4a7827481ddc0f3957c74d4b0ef2964
|
data/Guardfile
CHANGED
@@ -7,13 +7,19 @@
|
|
7
7
|
## Uncomment to clear the screen before every task
|
8
8
|
# clearing :on
|
9
9
|
|
10
|
+
TEMPFILE_BY_EMACS = %r{/\.?\#[^\/]+$}
|
11
|
+
|
10
12
|
group :red_green_refactor, halt_on_fail: true do
|
11
13
|
guard :rubocop, all_on_start: false do
|
14
|
+
ignore(TEMPFILE_BY_EMACS)
|
15
|
+
|
12
16
|
watch(%r{.+\.rb$})
|
13
17
|
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
14
18
|
end
|
15
19
|
|
16
20
|
guard :rspec, cmd: 'bundle exec bin/rspec' do
|
21
|
+
ignore(TEMPFILE_BY_EMACS)
|
22
|
+
|
17
23
|
watch(%r{^spec/.+_spec\.rb$})
|
18
24
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
19
25
|
watch('spec/spec_helper.rb') { "spec" }
|
@@ -36,10 +42,13 @@ group :red_green_refactor, halt_on_fail: true do
|
|
36
42
|
end
|
37
43
|
|
38
44
|
guard 'livereload' do
|
45
|
+
ignore(TEMPFILE_BY_EMACS)
|
46
|
+
|
39
47
|
watch(%r{app/views/.+\.(erb|haml|slim)$})
|
40
48
|
watch(%r{app/helpers/.+\.rb})
|
41
49
|
watch(%r{public/.+\.(css|js|html)})
|
42
50
|
watch(%r{config/locales/.+\.yml})
|
51
|
+
|
43
52
|
# Rails Assets Pipeline
|
44
53
|
watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg))).*}) { |m| "/assets/#{m[3]}" }
|
45
54
|
end
|
@@ -12,8 +12,9 @@ pwmPinDropdown = null
|
|
12
12
|
rgbLedPinDropdown = null
|
13
13
|
aiPinDropdown = null
|
14
14
|
acDropdown = null
|
15
|
-
|
15
|
+
lorDropdown = null
|
16
16
|
twoWDPinDropdown = null
|
17
|
+
actionDropdown = null
|
17
18
|
|
18
19
|
$(document).ready ->
|
19
20
|
# ハードウェアの環境設定
|
@@ -40,13 +41,21 @@ $(document).ready ->
|
|
40
41
|
[<%= bm('.cathode') %>, 'cathode']
|
41
42
|
]
|
42
43
|
|
43
|
-
|
44
|
+
lorDropdown = [
|
44
45
|
[<%= bm('.left') %>, 'left'],
|
45
46
|
[<%= bm('.right') %>, 'right'],
|
46
47
|
]
|
47
48
|
|
48
49
|
twoWDPinDropdown = (["D#{n}", "D#{n}"] for n in [5, 6])
|
49
50
|
|
51
|
+
actionDropdown = [
|
52
|
+
[<%= bm('common.forward') %>, 'forward'],
|
53
|
+
[<%= bm('common.backward') %>, 'backward'],
|
54
|
+
[<%= bm('common.turn_left') %>, 'turn_left'],
|
55
|
+
[<%= bm('common.turn_right') %>, 'turn_right'],
|
56
|
+
[<%= bm('common.stop') %>, 'stop'],
|
57
|
+
]
|
58
|
+
|
50
59
|
# ハードウェアを準備する
|
51
60
|
<% n = "#{category}_init_hardware" %>
|
52
61
|
Blockly.Blocks['<%= n %>'] =
|
@@ -65,7 +74,7 @@ Blockly.Ruby['<%= n %>'] = (block) ->
|
|
65
74
|
# LED[▼PIN]をオンにする
|
66
75
|
# LED[▼PIN]をオフにする
|
67
76
|
<%
|
68
|
-
%w(
|
77
|
+
%w(turn_on turn_off).each do |method|
|
69
78
|
n = "#{category}_led_#{method}"
|
70
79
|
%>
|
71
80
|
|
@@ -90,12 +99,12 @@ Blockly.Ruby['<%= n %>'] = (block) ->
|
|
90
99
|
# 「RGB LED」サブジャンル
|
91
100
|
|
92
101
|
# RGB LED[▼アノード]コモン[▼PIN]を[カラー]にする
|
93
|
-
<% n = "#{category}
|
102
|
+
<% n = "#{category}_rgb_led_set_color" %>
|
94
103
|
Blockly.Blocks['<%= n %>'] =
|
95
104
|
init: ()->
|
96
105
|
@setHelpUrl('')
|
97
106
|
@setColour(<%= colors[:looks] %>)
|
98
|
-
@interpolateMsg(<%= bm('.
|
107
|
+
@interpolateMsg(<%= bm('.rgb_led_set_color') %>,
|
99
108
|
['AC', ['Dropdown', acDropdown], Blockly.ALIGN_RIGHT],
|
100
109
|
['PIN', ['Dropdown', rgbLedPinDropdown], Blockly.ALIGN_RIGHT],
|
101
110
|
['COLOUR', ['Colour', '#ff0000'], Blockly.ALIGN_RIGHT],
|
@@ -111,16 +120,16 @@ Blockly.Ruby['<%= n %>'] = (block) ->
|
|
111
120
|
red = parseInt(c[1..2], 16)
|
112
121
|
green = parseInt(c[3..4], 16)
|
113
122
|
blue = parseInt(c[5..6], 16)
|
114
|
-
Blockly.Ruby.
|
115
|
-
"
|
123
|
+
Blockly.Ruby.characterSetVariable_("rgb_led_#{ac}(#{Blockly.Ruby.quote_(pin)}).color",
|
124
|
+
"[#{red}, #{green}, #{blue}]")
|
116
125
|
|
117
126
|
# RGB LED[▼アノード]コモン[▼PIN]をオフにする
|
118
|
-
<% n = "#{category}
|
127
|
+
<% n = "#{category}_rgb_led_turn_off" %>
|
119
128
|
Blockly.Blocks['<%= n %>'] =
|
120
129
|
init: ()->
|
121
130
|
@setHelpUrl('')
|
122
131
|
@setColour(<%= colors[:looks] %>)
|
123
|
-
@interpolateMsg(<%= bm('.
|
132
|
+
@interpolateMsg(<%= bm('.rgb_led_turn_off') %>,
|
124
133
|
['AC', ['Dropdown', acDropdown], Blockly.ALIGN_RIGHT],
|
125
134
|
['PIN', ['Dropdown', rgbLedPinDropdown], Blockly.ALIGN_RIGHT],
|
126
135
|
Blockly.ALIGN_RIGHT)
|
@@ -131,7 +140,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
131
140
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
132
141
|
ac = @getFieldValue('AC')
|
133
142
|
pin = @getFieldValue('PIN')
|
134
|
-
Blockly.Ruby.characterMethodCall_("rgb_led_#{ac}(#{Blockly.Ruby.quote_(pin)}).
|
143
|
+
Blockly.Ruby.characterMethodCall_("rgb_led_#{ac}(#{Blockly.Ruby.quote_(pin)}).turn_off")
|
135
144
|
|
136
145
|
# 「7セグディスプレイ」サブジャンル
|
137
146
|
|
@@ -285,17 +294,10 @@ Blockly.Ruby['<%= n %>'] = (block) ->
|
|
285
294
|
<% n = "#{category}_#{subcategory}_commands" %>
|
286
295
|
Blockly.Blocks['<%= n %>'] =
|
287
296
|
init: ()->
|
288
|
-
commands = [
|
289
|
-
[<%= bm(".#{subcategory}_commands_forward") %>, 'forward'],
|
290
|
-
[<%= bm(".#{subcategory}_commands_backward") %>, 'backward'],
|
291
|
-
[<%= bm(".#{subcategory}_commands_turn_left") %>, 'turn_left'],
|
292
|
-
[<%= bm(".#{subcategory}_commands_turn_right") %>, 'turn_right'],
|
293
|
-
[<%= bm(".#{subcategory}_commands_stop") %>, 'stop'],
|
294
|
-
]
|
295
297
|
@setHelpUrl('')
|
296
298
|
@setColour(<%= colors[:motion] %>)
|
297
299
|
@appendDummyInput()
|
298
|
-
.appendField(new Blockly.FieldDropdown(
|
300
|
+
.appendField(new Blockly.FieldDropdown(actionDropdown), 'COMMAND')
|
299
301
|
@setOutput(true, 'String')
|
300
302
|
@setTooltip('')
|
301
303
|
|
@@ -311,7 +313,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
311
313
|
@setColour(<%= colors[:motion] %>)
|
312
314
|
@interpolateMsg(<%= bm(".#{subcategory}_set_speed") %>,
|
313
315
|
['PIN', ['Dropdown', pwmPinDropdown], Blockly.ALIGN_RIGHT],
|
314
|
-
['LOR', ['Dropdown',
|
316
|
+
['LOR', ['Dropdown', lorDropdown], Blockly.ALIGN_RIGHT],
|
315
317
|
['SPEED', ['Number'], Blockly.ALIGN_RIGHT],
|
316
318
|
Blockly.ALIGN_RIGHT)
|
317
319
|
@setInputsInline(true)
|
@@ -333,7 +335,7 @@ Blockly.Blocks['<%= n %>'] =
|
|
333
335
|
@setColour(<%= colors[:sensing] %>)
|
334
336
|
@interpolateMsg(<%= bm(".#{subcategory}_speed") %>,
|
335
337
|
['PIN', ['Dropdown', pwmPinDropdown], Blockly.ALIGN_RIGHT],
|
336
|
-
['LOR', ['Dropdown',
|
338
|
+
['LOR', ['Dropdown', lorDropdown], Blockly.ALIGN_RIGHT],
|
337
339
|
Blockly.ALIGN_RIGHT)
|
338
340
|
@setOutput(true, 'Number')
|
339
341
|
@setTooltip('')
|
@@ -413,96 +415,179 @@ Blockly.Ruby['<%= n %>'] = (block) ->
|
|
413
415
|
# 「ボタン」サブジャンル
|
414
416
|
|
415
417
|
# 条件:ボタン[▼PIN]が[▼押された]
|
416
|
-
<% n = "#{category}
|
418
|
+
<% n = "#{category}_button_pressed_or_released" %>
|
417
419
|
Blockly.Blocks['<%= n %>'] =
|
418
420
|
init: ()->
|
419
|
-
|
421
|
+
porDropdown = window.SmalrubyEditor.Sensing.PressedOrReleasedDropdown
|
420
422
|
|
421
423
|
@setHelpUrl('')
|
422
424
|
@setColour(<%= colors[:sensing] %>)
|
423
|
-
@interpolateMsg(<%= bm(".
|
425
|
+
@interpolateMsg(<%= bm(".button_pressed_or_released") %>,
|
424
426
|
['PIN', ['Dropdown', dioPinDropdown], Blockly.ALIGN_RIGHT],
|
425
|
-
['
|
427
|
+
['POR', ['Dropdown', porDropdown], Blockly.ALIGN_RIGHT],
|
426
428
|
Blockly.ALIGN_RIGHT)
|
427
429
|
@setOutput(true, 'Boolean')
|
428
430
|
@setTooltip('')
|
429
431
|
|
430
432
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
431
433
|
pin = @getFieldValue('PIN')
|
432
|
-
|
433
|
-
Blockly.Ruby.characterMethodCallInput_("button(#{Blockly.Ruby.quote_(pin)}).#{
|
434
|
+
por = @getFieldValue('POR')
|
435
|
+
Blockly.Ruby.characterMethodCallInput_("button(#{Blockly.Ruby.quote_(pin)}).#{por}?")
|
434
436
|
|
435
|
-
#
|
436
|
-
|
437
|
+
# 「センサー」サブジャンル
|
438
|
+
|
439
|
+
# センサー[▼PIN]
|
440
|
+
<% n = "#{category}_sensor_value" %>
|
437
441
|
Blockly.Blocks['<%= n %>'] =
|
438
442
|
init: ()->
|
439
|
-
douDropdown = window.SmalrubyEditor.Sensing.DownOrUpDropdown
|
440
|
-
|
441
443
|
@setHelpUrl('')
|
442
|
-
@setColour(<%= colors[:
|
443
|
-
@interpolateMsg(<%= bm('.
|
444
|
-
['PIN', ['Dropdown',
|
445
|
-
['DOU', ['Dropdown', douDropdown], Blockly.ALIGN_RIGHT],
|
444
|
+
@setColour(<%= colors[:sensing] %>)
|
445
|
+
@interpolateMsg(<%= bm('.sensor_value') %>,
|
446
|
+
['PIN', ['Dropdown', aiPinDropdown], Blockly.ALIGN_RIGHT],
|
446
447
|
Blockly.ALIGN_RIGHT)
|
447
|
-
@
|
448
|
-
@setPreviousStatement(true)
|
449
|
-
@setNextStatement(true)
|
448
|
+
@setOutput(true, 'Number')
|
450
449
|
@setTooltip('')
|
451
450
|
|
452
451
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
453
452
|
pin = @getFieldValue('PIN')
|
454
|
-
|
455
|
-
|
453
|
+
Blockly.Ruby.characterMethodCallInput_("sensor(#{Blockly.Ruby.quote_(pin)}).value")
|
454
|
+
|
455
|
+
# SmalrubotV3 sub category
|
456
|
+
<% subcategory = 'smalrubot_v3' %>
|
456
457
|
|
457
|
-
#
|
458
|
-
<% n = "#{category}
|
458
|
+
# turn on/off Smalrubot v3 red/green LED
|
459
|
+
<% n = "#{category}_#{subcategory}_led_turn_on_or_off" %>
|
459
460
|
Blockly.Blocks['<%= n %>'] =
|
460
461
|
init: ()->
|
462
|
+
colourDropdown = [
|
463
|
+
[<%= bm('colour.red') %>, 'red'],
|
464
|
+
[<%= bm('colour.green') %>, 'green'],
|
465
|
+
]
|
466
|
+
oooDropdown = [
|
467
|
+
[<%= bm('common.turn_on') %>, 'turn_on'],
|
468
|
+
[<%= bm('common.turn_off') %>, 'turn_off'],
|
469
|
+
]
|
470
|
+
|
461
471
|
@setHelpUrl('')
|
462
|
-
@setColour(<%= colors[:
|
463
|
-
@interpolateMsg(<%= bm(
|
464
|
-
['
|
472
|
+
@setColour(<%= colors[:looks] %>)
|
473
|
+
@interpolateMsg(<%= bm(".#{subcategory}_led_turn_on_or_off") %>,
|
474
|
+
['COLOUR', ['Dropdown', colourDropdown], Blockly.ALIGN_RIGHT],
|
475
|
+
['OOO', ['Dropdown', oooDropdown], Blockly.ALIGN_RIGHT],
|
465
476
|
Blockly.ALIGN_RIGHT)
|
477
|
+
@setInputsInline(true)
|
466
478
|
@setPreviousStatement(true)
|
467
479
|
@setNextStatement(true)
|
468
480
|
@setTooltip('')
|
469
481
|
|
470
482
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
471
|
-
|
472
|
-
|
483
|
+
colour = @getFieldValue('COLOUR')
|
484
|
+
ooo = @getFieldValue('OOO')
|
485
|
+
Blockly.Ruby.characterMethodCall_("<%= subcategory %>.#{colour}_led.#{ooo}")
|
473
486
|
|
474
|
-
#
|
475
|
-
|
476
|
-
# センサー[▼PIN]
|
477
|
-
<% n = "#{category}_sensor_value" %>
|
487
|
+
# Smalrubot v3 left/right motor speed
|
488
|
+
<% n = "#{category}_#{subcategory}_motor_speed" %>
|
478
489
|
Blockly.Blocks['<%= n %>'] =
|
479
490
|
init: ()->
|
480
491
|
@setHelpUrl('')
|
481
492
|
@setColour(<%= colors[:sensing] %>)
|
482
|
-
@interpolateMsg(<%= bm(
|
483
|
-
['
|
493
|
+
@interpolateMsg(<%= bm(".#{subcategory}_motor_speed") %>,
|
494
|
+
['LOR', ['Dropdown', lorDropdown], Blockly.ALIGN_RIGHT],
|
484
495
|
Blockly.ALIGN_RIGHT)
|
485
496
|
@setOutput(true, 'Number')
|
486
497
|
@setTooltip('')
|
487
498
|
|
488
499
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
489
|
-
|
490
|
-
Blockly.Ruby.characterMethodCallInput_("
|
500
|
+
lor = @getFieldValue('LOR')
|
501
|
+
Blockly.Ruby.characterMethodCallInput_("<%= subcategory %>.#{lor}_motor.speed")
|
491
502
|
|
492
|
-
#
|
493
|
-
<% n = "#{category}
|
503
|
+
# set Smalrubot v3 left/right motor speed
|
504
|
+
<% n = "#{category}_#{subcategory}_motor_set_speed" %>
|
494
505
|
Blockly.Blocks['<%= n %>'] =
|
495
506
|
init: ()->
|
496
507
|
@setHelpUrl('')
|
497
|
-
@setColour(<%= colors[:
|
498
|
-
@interpolateMsg(<%= bm(
|
499
|
-
['
|
508
|
+
@setColour(<%= colors[:motion] %>)
|
509
|
+
@interpolateMsg(<%= bm(".#{subcategory}_motor_set_speed") %>,
|
510
|
+
['LOR', ['Dropdown', lorDropdown], Blockly.ALIGN_RIGHT],
|
511
|
+
['SPEED', ['Number'], Blockly.ALIGN_RIGHT],
|
500
512
|
Blockly.ALIGN_RIGHT)
|
501
|
-
@
|
513
|
+
@setInputsInline(true)
|
502
514
|
@setPreviousStatement(true)
|
503
515
|
@setNextStatement(true)
|
504
516
|
@setTooltip('')
|
505
517
|
|
506
518
|
Blockly.Ruby['<%= n %>'] = (block) ->
|
507
|
-
|
508
|
-
Blockly.Ruby.
|
519
|
+
lor = @getFieldValue('LOR')
|
520
|
+
speed = Blockly.Ruby.valueToCode(@, 'SPEED', Blockly.Ruby.ORDER_NONE) || '100'
|
521
|
+
Blockly.Ruby.characterSetVariable_("<%= subcategory %>.#{lor}_motor.speed",
|
522
|
+
speed)
|
523
|
+
|
524
|
+
# forward/backward/turn left/turn right/stop Smalrubot v3
|
525
|
+
<% n = "#{category}_#{subcategory}_action" %>
|
526
|
+
Blockly.Blocks['<%= n %>'] =
|
527
|
+
init: ()->
|
528
|
+
@setHelpUrl('')
|
529
|
+
@setColour(<%= colors[:motion] %>)
|
530
|
+
@interpolateMsg(<%= bm(".#{subcategory}_action") %>,
|
531
|
+
['ACTION', ['Dropdown', actionDropdown], Blockly.ALIGN_RIGHT],
|
532
|
+
Blockly.ALIGN_RIGHT)
|
533
|
+
@setInputsInline(true)
|
534
|
+
@setPreviousStatement(true)
|
535
|
+
@setNextStatement(true)
|
536
|
+
@setTooltip('')
|
537
|
+
|
538
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
539
|
+
action = @getFieldValue('ACTION')
|
540
|
+
Blockly.Ruby.characterMethodCall_("<%= subcategory %>.#{action}")
|
541
|
+
|
542
|
+
# forward/backward/turn left/turn right/stop Smalrubot v3 for ( ) secs
|
543
|
+
<% n = "#{category}_#{subcategory}_action_with_sec" %>
|
544
|
+
Blockly.Blocks['<%= n %>'] =
|
545
|
+
init: ()->
|
546
|
+
@setHelpUrl('')
|
547
|
+
@setColour(<%= colors[:motion] %>)
|
548
|
+
@interpolateMsg(<%= bm(".#{subcategory}_action_with_sec") %>,
|
549
|
+
['ACTION', ['Dropdown', actionDropdown], Blockly.ALIGN_RIGHT],
|
550
|
+
['SEC', ['Number'], Blockly.ALIGN_RIGHT],
|
551
|
+
Blockly.ALIGN_RIGHT)
|
552
|
+
@setInputsInline(true)
|
553
|
+
@setPreviousStatement(true)
|
554
|
+
@setNextStatement(true)
|
555
|
+
@setTooltip('')
|
556
|
+
|
557
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
558
|
+
action = @getFieldValue('ACTION')
|
559
|
+
sec = Blockly.Ruby.valueToCode(@, 'SEC', Blockly.Ruby.ORDER_FUNCTION_CALL) || 'nil'
|
560
|
+
Blockly.Ruby.characterMethodCall_("<%= subcategory %>.#{action}(sec: #{sec})")
|
561
|
+
|
562
|
+
# Smalrubot v3 touch sensor pressed/released
|
563
|
+
<% n = "#{category}_#{subcategory}_touch_sensor_pressed_or_released" %>
|
564
|
+
Blockly.Blocks['<%= n %>'] =
|
565
|
+
init: ()->
|
566
|
+
porDropdown = window.SmalrubyEditor.Sensing.PressedOrReleasedDropdown
|
567
|
+
|
568
|
+
@setHelpUrl('')
|
569
|
+
@setColour(<%= colors[:sensing] %>)
|
570
|
+
@interpolateMsg(<%= bm(".#{subcategory}_touch_sensor_pressed_or_released") %>,
|
571
|
+
['LOR', ['Dropdown', lorDropdown], Blockly.ALIGN_RIGHT],
|
572
|
+
['POR', ['Dropdown', porDropdown], Blockly.ALIGN_RIGHT],
|
573
|
+
Blockly.ALIGN_RIGHT)
|
574
|
+
@setOutput(true, 'Boolean')
|
575
|
+
@setTooltip('')
|
576
|
+
|
577
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
578
|
+
lor = @getFieldValue('LOR')
|
579
|
+
por = @getFieldValue('POR')
|
580
|
+
Blockly.Ruby.characterMethodCallInput_("<%= subcategory %>.#{lor}_touch_sensor.#{por}?")
|
581
|
+
|
582
|
+
# Smalrubot v3 light sensor value
|
583
|
+
<% n = "#{category}_#{subcategory}_light_sensor_value" %>
|
584
|
+
Blockly.Blocks['<%= n %>'] =
|
585
|
+
init: ()->
|
586
|
+
@setHelpUrl('')
|
587
|
+
@setColour(<%= colors[:sensing] %>)
|
588
|
+
@appendDummyInput().appendField(<%= bm(".#{subcategory}_light_sensor_value") %>)
|
589
|
+
@setOutput(true, 'Number')
|
590
|
+
@setTooltip('')
|
591
|
+
|
592
|
+
Blockly.Ruby['<%= n %>'] = (block) ->
|
593
|
+
Blockly.Ruby.characterMethodCallInput_("<%= subcategory %>.light_sensor.value")
|
@@ -33,6 +33,10 @@ $(document).ready ->
|
|
33
33
|
[<%= bm('.down') %>, 'down'],
|
34
34
|
[<%= bm('.up') %>, 'up'],
|
35
35
|
]
|
36
|
+
PressedOrReleasedDropdown: [
|
37
|
+
[<%= bm('.pressed') %>, 'pressed'],
|
38
|
+
[<%= bm('.released') %>, 'released'],
|
39
|
+
]
|
36
40
|
|
37
41
|
# 条件:端に触れた
|
38
42
|
<% n = "#{category}_reach_wall" %>
|
@@ -8,6 +8,21 @@ goog.require('Blockly.Msg');
|
|
8
8
|
* to message files.
|
9
9
|
*/
|
10
10
|
|
11
|
+
// common
|
12
|
+
Blockly.Msg.COMMON_TURN_ON = 'turn on';
|
13
|
+
Blockly.Msg.COMMON_TURN_OFF = 'turn off';
|
14
|
+
Blockly.Msg.COMMON_FORWARD = 'forward';
|
15
|
+
Blockly.Msg.COMMON_BACKWARD = 'backward';
|
16
|
+
Blockly.Msg.COMMON_TURN_LEFT = 'turn left';
|
17
|
+
Blockly.Msg.COMMON_TURN_RIGHT = 'turn right';
|
18
|
+
Blockly.Msg.COMMON_STOP = 'stop';
|
19
|
+
|
20
|
+
|
21
|
+
// colour name
|
22
|
+
Blockly.Msg.COLOUR_RED = 'red';
|
23
|
+
Blockly.Msg.COLOUR_GREEN = 'green';
|
24
|
+
|
25
|
+
|
11
26
|
// views/main_menu_view.js.coffee
|
12
27
|
Blockly.Msg.VIEWS_MAIN_MENU_VIEW_COMMON_LINES = ' Lines';
|
13
28
|
Blockly.Msg.VIEWS_MAIN_MENU_VIEW_COMMON_LETTERS = ' Letters';
|
@@ -75,13 +90,16 @@ Blockly.Msg.BLOCKS_SENSING_K_DOWN = 'down arrow';
|
|
75
90
|
Blockly.Msg.BLOCKS_SENSING_K_LEFT = 'left arrow';
|
76
91
|
Blockly.Msg.BLOCKS_SENSING_K_RIGHT = 'right arrow';
|
77
92
|
Blockly.Msg.BLOCKS_SENSING_K_SPACE = 'space';
|
78
|
-
Blockly.Msg.
|
79
|
-
Blockly.Msg.
|
80
|
-
Blockly.Msg.BLOCKS_SENSING_DOWN = Blockly.Msg.
|
93
|
+
Blockly.Msg.BLOCKS_SENSING_PRESSED = 'pressed';
|
94
|
+
Blockly.Msg.BLOCKS_SENSING_PUSH = Blockly.Msg.BLOCKS_SENSING_PRESSED;
|
95
|
+
Blockly.Msg.BLOCKS_SENSING_DOWN = Blockly.Msg.BLOCKS_SENSING_PRESSED;
|
96
|
+
Blockly.Msg.BLOCKS_SENSING_HOLD_PRESSED = 'hold pressed';
|
97
|
+
Blockly.Msg.BLOCKS_SENSING_HOLD_DOWN = Blockly.Msg.BLOCKS_SENSING_HOLD_PRESSED;
|
81
98
|
Blockly.Msg.BLOCKS_SENSING_M_LBUTTON = 'left-button';
|
82
99
|
Blockly.Msg.BLOCKS_SENSING_M_MBUTTON = 'middle-button';
|
83
100
|
Blockly.Msg.BLOCKS_SENSING_M_RBUTTON = 'right-button';
|
84
|
-
Blockly.Msg.
|
101
|
+
Blockly.Msg.BLOCKS_SENSING_RELEASED = 'released';
|
102
|
+
Blockly.Msg.BLOCKS_SENSING_UP = Blockly.Msg.BLOCKS_SENSING_RELEASED;
|
85
103
|
Blockly.Msg.BLOCKS_SENSING_REACH_WALL = 'reach wall?';
|
86
104
|
Blockly.Msg.BLOCKS_SENSING_INPUT_KEY_PUSH_OR_DOWN_PREFIX = 'key ';
|
87
105
|
Blockly.Msg.BLOCKS_SENSING_INPUT_KEY_PUSH_OR_DOWN_MIDDLE = ' ';
|
@@ -154,15 +172,15 @@ Blockly.Msg.BLOCKS_LOOKS_HIDE = 'hide';
|
|
154
172
|
Blockly.Msg.BLOCKS_LOOKS_VANISH = 'vanish';
|
155
173
|
|
156
174
|
// blocks/hardware.js.coffee.erb
|
157
|
-
Blockly.Msg.
|
158
|
-
Blockly.Msg.
|
175
|
+
Blockly.Msg.BLOCKS_HARDWARE_LED_TURN_ON = 'turn on LED %1';
|
176
|
+
Blockly.Msg.BLOCKS_HARDWARE_LED_TURN_OFF = 'turn off LED %1';
|
159
177
|
Blockly.Msg.BLOCKS_HARDWARE_ANODE = 'anode';
|
160
178
|
Blockly.Msg.BLOCKS_HARDWARE_CATHODE = 'cathode';
|
161
179
|
Blockly.Msg.BLOCKS_HARDWARE_LEFT = 'left';
|
162
180
|
Blockly.Msg.BLOCKS_HARDWARE_RIGHT = 'right';
|
163
181
|
Blockly.Msg.BLOCKS_HARDWARE_INIT_HARDWARE = 'setup hardware';
|
164
|
-
Blockly.Msg.
|
165
|
-
Blockly.Msg.
|
182
|
+
Blockly.Msg.BLOCKS_HARDWARE_RGB_LED_SET_COLOR = 'set RGB LED %1 common %2 color to %3';
|
183
|
+
Blockly.Msg.BLOCKS_HARDWARE_RGB_LED_TURN_OFF = 'turn off RGB LED %1 common %2';
|
166
184
|
Blockly.Msg.BLOCKS_HARDWARE_SEVEN_SEGMENT_DISPLAY_SHOW = 'show 7 segment display %1';
|
167
185
|
Blockly.Msg.BLOCKS_HARDWARE_SEVEN_SEGMENT_DISPLAY_OFF = 'turn off 7 segment display';
|
168
186
|
Blockly.Msg.BLOCKS_HARDWARE_LCD_PUTS = 'display %1 on the LCD';
|
@@ -187,11 +205,15 @@ Blockly.Msg.BLOCKS_HARDWARE_MOTOR_DRIVER_STOP = 'stop';
|
|
187
205
|
Blockly.Msg.BLOCKS_HARDWARE_MOTOR_DRIVER = "%2 (motor driver %1's) motor";
|
188
206
|
Blockly.Msg.BLOCKS_HARDWARE_MOTOR_DRIVER_SET_SPEED = "set (motor driver %1's) motor speed to %2 %";
|
189
207
|
Blockly.Msg.BLOCKS_HARDWARE_MOTOR_DRIVER_SPEED = "(motor driver %1's) motor speed (%)";
|
190
|
-
Blockly.Msg.
|
191
|
-
Blockly.Msg.BLOCKS_HARDWARE_ON_BUTTON_DOWN_OR_UP = 'when button %1 %2';
|
192
|
-
Blockly.Msg.BLOCKS_HARDWARE_BUTTON_NOT_USE_PULLUP = "don't use button %1's pull-up resistor";
|
208
|
+
Blockly.Msg.BLOCKS_HARDWARE_BUTTON_PRESSED_OR_RELEASED = 'button %1 %2 ?';
|
193
209
|
Blockly.Msg.BLOCKS_HARDWARE_SENSOR_VALUE = 'sensor %1 value';
|
194
|
-
Blockly.Msg.
|
210
|
+
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_LED_TURN_ON_OR_OFF = '%2 Smalrubot v3 %1 LED';
|
211
|
+
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_MOTOR_SPEED = 'Smalrubot v3 %1 motor speed';
|
212
|
+
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_MOTOR_SET_SPEED = 'set Smalrubot v3 %1 motor speed to %2 %';
|
213
|
+
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_ACTION = '%1 Smalrubot v3';
|
214
|
+
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_ACTION_WITH_SEC = '%1 Smalrubot v3 for %2 secs';
|
215
|
+
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_TOUCH_SENSOR_PRESSED_OR_RELEASED = 'Smalrubot v3 %1 touch sensor %2 ?';
|
216
|
+
Blockly.Msg.BLOCKS_HARDWARE_SMALRUBOT_V3_LIGHT_SENSOR_VALUE = 'Smalrubot v3 light sensor value';
|
195
217
|
|
196
218
|
|
197
219
|
// blocks/operators.js.coffee.erb
|