diff --git a/images/block_icon/hardware_bzr2.svg b/images/block_icon/hardware_bzr2.svg
new file mode 100644
index 0000000000..d63f19d600
--- /dev/null
+++ b/images/block_icon/hardware_bzr2.svg
@@ -0,0 +1,3385 @@
+
+
+
+
+
+
+
+
+
+
+]>
+
diff --git a/images/block_icon/hardware_dc.svg b/images/block_icon/hardware_dc.svg
new file mode 100644
index 0000000000..a9c6c752e5
--- /dev/null
+++ b/images/block_icon/hardware_dc.svg
@@ -0,0 +1,3398 @@
+
+
+
+
+
+
+
+
+
+
+]>
+
diff --git a/images/block_icon/hardware_led.svg b/images/block_icon/hardware_led.svg
new file mode 100644
index 0000000000..3013e95aa8
--- /dev/null
+++ b/images/block_icon/hardware_led.svg
@@ -0,0 +1,3406 @@
+
+
+
+
+
+
+
+
+
+
+]>
+
diff --git a/src/playground/blocks/hardware/block_iCOBOT.js b/src/playground/blocks/hardware/block_iCOBOT.js
index 062666e5b5..da1f10505b 100644
--- a/src/playground/blocks/hardware/block_iCOBOT.js
+++ b/src/playground/blocks/hardware/block_iCOBOT.js
@@ -26,10 +26,23 @@ Entry.iCOBOT = {
var keySet = Object.keys(Entry.hw.sendQueue.SET);
keySet.forEach(function(key)
{
- if(Entry.hw.sendQueue.SET[key].type === 4)
+ if(Entry.hw.sendQueue.SET[key].type === 2)
{
- Entry.hw.sendQueue.SET[key].data[0] = 0;
- Entry.hw.sendQueue.SET[key].data[1] = 0;
+ Entry.hw.sendQueue.SET[key].data = {
+ n: 0,
+ r: 0,
+ g: 0,
+ b: 0,
+ };
+ }
+ else if(Entry.hw.sendQueue.SET[key].type === 4)
+ {
+ Entry.hw.sendQueue.SET[key].data =
+ {
+ mode: 0,
+ value: 0,
+ };
+
}
else Entry.hw.sendQueue.SET[key].data = 0;
Entry.hw.sendQueue.SET[key].time = new Date().getTime();
@@ -75,102 +88,49 @@ Entry.iCOBOT = {
'11': [58, 117, 233, 466, 932, 1865, 3729, 7459],
'12': [62, 123, 247, 494, 988, 1976, 3951, 7902],
},
- monitorTemplate: {
- imgPath: 'hw/iCOBOT_Front.png',
- width: 550,
- height: 600,
- listPorts: {
- BLeft_IR: {
- name: 'Bottom Left IR',
- type: 'input',
- pos: { x: 0, y: 0 },
- },
- BMid_IR: {
- name: 'Bottom Mid IR',
- type: 'input',
- pos: { x: 0, y: 0 },
- },
- BRight_IR: {
- name: 'Bottom Right IR',
- type: 'input',
- pos: { x: 0, y: 0 },
- },
- Real_T: {
- name: 'Temperature',
- type: 'input',
- pos: { x: 0, y: 0 },
- },
- Real_H: {
- name: 'Humidity',
- type: 'input',
- pos: { x: 0, y: 0 },
- },
- Noise: {
- name: 'Sound',
- type: 'input',
- pos: { x: 0, y: 0 },
- },
- },
- ports: {
- Brightness: {
- name: 'Brightness',
- type: 'input',
- pos: { x: 295, y: 350 },
- },
- Front_IR: {
- name: 'Front IR',
- type: 'input',
- pos: { x: 250, y: 300 },
- },
- Left_IR: {
- name: 'Left IR',
- type: 'input',
- pos: { x: 20, y: 450 },
- },
- Right_IR: {
- name: 'Right IR',
- type: 'input',
- pos: { x: 525, y: 450 },
- },
- },
- mode: 'both',
- },
};
Entry.iCOBOT.blockMenuBlocks = [
- 'icobot_get_cds_value',
- 'icobot_get_sound_value',
- 'icobot_get_analog_temp_value',
- 'icobot_get_distsensor_value',
- 'icobot_get_discomfort_index_value',
- 'icobot_buzzer_onoff',
- 'icobot_set_digital_buzzer_notime',
- 'icobot_set_digital_buzzer',
- 'icobot_digital_rgbled_off',
- 'icobot_digital_rgbled_onoff',
- 'icobot_digital_set_rgbled_value',
- 'icobot_digital_rgbled_percent',
- 'icobot_digital_motor_stop',
- 'icobot_digital_set_motor_speed',
- 'icobot_digital_set_motor_direction',
- 'icobot_digital_set_motor_angle',
+ 'icobot_sensor_input_title',
+ 'icobot_get_cds_value',
+ 'icobot_get_sound_value',
+ 'icobot_get_distsensor_value',
+ 'icobot_get_analog_temp_value',
+ 'icobot_get_discomfort_index_value',
+ 'icobot_buzzer_title',
+ 'icobot_buzzer_onoff',
+ 'icobot_set_digital_buzzer_notime',
+ 'icobot_set_digital_buzzer',
+ 'icobot_led_title',
+ 'icobot_digital_rgbled_off',
+ 'icobot_digital_rgbled_onoff',
+ 'icobot_digital_set_rgbled_value',
+ 'icobot_motor_title',
+ 'icobot_digital_motor_stop',
+ 'icobot_digital_set_motor_speed',
+ 'icobot_digital_set_motor_direction',
+ 'icobot_digital_set_motor_angle',
];
Entry.iCOBOT.setLanguage = function() {
return {
ko: {
template: {
+ icobot_sensor_input_title: "▶ 아이코봇 센서 입력 값",
icobot_get_cds_value: "조도(밝기) 센서 값",
icobot_get_sound_value: "사운드(소리)감지 센서 값",
icobot_get_distsensor_value: "거리(IR) %1 센서 값",
icobot_get_analog_temp_value: "%1 센서 값",
icobot_get_discomfort_index_value: "불쾌 지수 값",
+ icobot_buzzer_title: "▶ 아이코봇 부저 출력",
icobot_buzzer_onoff: "부저 %1 %2",
icobot_set_digital_buzzer: "부저를 %1 옥타브 %2 음 %3 초 연주 %4",
icobot_set_digital_buzzer_notime: "부저를 %1 옥타브 %2 음 연주 %3",
- icobot_digital_rgbled_onoff: "RGB LED %1 색 켜기 %2",
- icobot_digital_rgbled_off: "RGB LED 끄기 %1",
- icobot_digital_set_rgbled_value: "RGB LED 빨강 %1 초록 %2 파랑 %3 으로 켜기 %4",
+ icobot_led_title: "▶ 아이코봇 RGB LED 출력",
+ icobot_digital_rgbled_onoff: "%1 RGB LED %2 색 켜기 %3",
+ icobot_digital_rgbled_off: "%1 RGB LED 끄기 %2",
+ icobot_digital_set_rgbled_value: "%1 RGB LED 빨강 %2 초록 %3 파랑 %4 으로 켜기 %5",
+ icobot_motor_title: "▶ 아이코봇 모터 출력",
icobot_digital_set_motor_direction: "%1 모터 방향을 %2 방향으로 정하기 %3",
icobot_digital_set_motor_angle: "%1 방향으로 %2 도 회전하기 %3",
icobot_digital_set_motor_speed: "%1 모터의 속도를 %2 로 정하기 %3",
@@ -194,6 +154,14 @@ Entry.iCOBOT.setLanguage = function() {
icobot_digital_motor_stop: "선택한 모터가 정지합니다.",
},
Blocks: {
+ icobot_Sound: "소리감지",
+ icobot_Brightness: "밝기(조도)",
+ monitor_ir_front: "정면 거리",
+ monitor_ir_left: "왼쪽 거리",
+ monitor_ir_right: "오른쪽 거리",
+ monitor_ir_bottom_mid: "아래중앙 거리",
+ monitor_ir_bottom_left: "아래왼쪽 거리",
+ monitor_ir_bottom_right: "아래오른쪽 거리",
icobot_Temperature: "온도(°C)",
icobot_Humidity: "습도(%)",
icobot_ir_front: "정면",
@@ -206,17 +174,22 @@ Entry.iCOBOT.setLanguage = function() {
icobot_buzzer_off: "끄기",
icobot_buzzer_silent: "무음",
icobot_buzzer_do: "도",
- icobot_buzzer_do_sharp: "도#(레b)",
+ icobot_buzzer_do_sharp: "도#(레♭)",
icobot_buzzer_re: "레",
- icobot_buzzer_re_sharp: "레#(미b)",
+ icobot_buzzer_re_sharp: "레#(미♭)",
icobot_buzzer_mi: "미",
icobot_buzzer_fa: "파",
- icobot_buzzer_fa_sharp: "파#(솔b)",
+ icobot_buzzer_fa_sharp: "파#(솔♭)",
icobot_buzzer_sol: "솔",
- icobot_buzzer_sol_sharp: "솔#(라b)",
+ icobot_buzzer_sol_sharp: "솔#(라♭)",
icobot_buzzer_la: "라",
- icobot_buzzer_la_sharp: "라#(시b)",
+ icobot_buzzer_la_sharp: "라#(시♭)",
icobot_buzzer_si: "시",
+ icobot_led_total: "모든",
+ icobot_led_left_up: "왼쪽 위",
+ icobot_led_left_down: "왼쪽 아래",
+ icobot_led_right_up: "오른쪽 위",
+ icobot_led_right_down: "오른쪽 아래",
icobot_color_white: "흰",
icobot_color_red: "빨강",
icobot_color_orange: "주황",
@@ -244,40 +217,52 @@ Entry.iCOBOT.setLanguage = function() {
},
en: {
template: {
+ icobot_sensor_input_title: "▶ i-COBOT Input Sensor Value",
icobot_get_cds_value: "CDS(Brightness) Sensor Value",
icobot_get_sound_value: "Sound Sensor Value",
icobot_get_distsensor_value: "Distance(IR) %1 Sensor Value",
icobot_get_analog_temp_value: "%1 Sensor Value",
icobot_get_discomfort_index_value: "Discomfort Index Value",
+ icobot_buzzer_title: "▶ i-COBOT Buzzer Output",
icobot_buzzer_onoff: "Buzzer %1 %2",
- icobot_set_digital_buzzer: "Play Buzzer %1 Octave %2 Note %3 Sec %4",
- icobot_set_digital_buzzer_notime: "Play Buzzer %1 Octave %2 Note %3",
- icobot_digital_rgbled_onoff: "RGB LED %1 Color Turn On %2",
- icobot_digital_rgbled_off: "RGB LED Turn Off %1",
- icobot_digital_set_rgbled_value: "Turn On RGB LED with RED %1 GREEN %2 BLUE %3 value %4",
+ icobot_set_digital_buzzer: "Play %1 Octave %2 for %3 Sec with Buzzer %4",
+ icobot_set_digital_buzzer_notime: "Play %1 Octave %2 with Buzzer %3",
+ icobot_led_title: "▶ i-COBOT RGB LED Output",
+ icobot_digital_rgbled_onoff: "Turn On %1 RGB LED as %2 Color %3",
+ icobot_digital_rgbled_off: "Turn Off %1 RGB LED %2",
+ icobot_digital_set_rgbled_value: "Set the %1 RGB LED value to RED %2 GREEN %3 BLUE %4 %5",
+ icobot_motor_title: "▶ i-COBOT Motor Output",
icobot_digital_set_motor_direction: "Set %1 Motor Direction to %2 %3",
- icobot_digital_set_motor_angle: "Rotation %2 degrees in direction %1 %3",
+ icobot_digital_set_motor_angle: "Rotate %1 by %2 degrees %3",
icobot_digital_set_motor_speed: "Set %1 Motor Speed to %2 %3",
icobot_digital_motor_stop: "Stop %1 Motor %2",
},
Helper: {
- icobot_get_cds_value: "Reads the current value of illumination(Brightness).",
+ icobot_get_cds_value: "i-COBOT reads the current value of CDS photocell.\n\n A CDS photocell(or Light Dependant Resistor / LDR) is a resistor that changes the resistance based on the amount of light.",
icobot_get_sound_value: "Senses the surrounding sound.\n The value changes minute by minute.",
icobot_get_distsensor_value: "Reads the value of selected IR sensor.\n A larger value indicates that the distance from the object is close, or that it is detecting a white color.",
icobot_get_analog_temp_value: "Reads the value of current temperature or humidity.",
icobot_get_discomfort_index_value: "Calculate the Temperature-Humidity Index(THI) using the current temperature and relative humidity values.\n\n THI = ((9/5)T)-(0.55(1-RH)((9/5)T-26))+32 \n\n T : Temperature, RH : Relative Humidity",
- icobot_buzzer_onoff: "You can turn the buzzer on or off.",
- icobot_set_digital_buzzer: "It sounds the pitch you entered until the moment you decided to.",
- icobot_set_digital_buzzer_notime: "Keep sounding the pitch you entered.",
+ icobot_buzzer_onoff: "You can turn on/off the buzzer.",
+ icobot_set_digital_buzzer: "Let i-COBOT play the pitch you entered for the seconds you entered.",
+ icobot_set_digital_buzzer_notime: "Let i-COBOT keep playing the pitch you entered.",
icobot_digital_rgbled_onoff: "Turn the LED on as the selected color.",
icobot_digital_rgbled_off: "Turns off the LED.",
icobot_digital_set_rgbled_value: "Set the R, G, and B values of the LED to the entered values and turn them on.",
- icobot_digital_set_motor_direction: "Determine the drive direction of the selected motor, and head to that.",
- icobot_digital_set_motor_angle: "The i-COBOT turns as much as you want.",
- icobot_digital_set_motor_speed: "Determine the speed of the motor and drive at that speed.",
+ icobot_digital_set_motor_direction: "Determine the driving path of the motor.",
+ icobot_digital_set_motor_angle: "Let i-COBOT rotate as much as you want.",
+ icobot_digital_set_motor_speed: "Determine the speed of the motor.",
icobot_digital_motor_stop: "The selected motor stops.",
},
Blocks: {
+ icobot_Sound: "Noise",
+ icobot_Brightness: "Brightness(CDS)",
+ monitor_ir_front: "Front Dist.",
+ monitor_ir_left: "Left Dist.",
+ monitor_ir_right: "Right Dist.",
+ monitor_ir_bottom_mid: "Bottom_Mid Dist.",
+ monitor_ir_bottom_left: "Bottom_Left Dist.",
+ monitor_ir_bottom_right: "Bottom_Right Dist.",
icobot_Temperature: "Temperature(°C)",
icobot_Humidity: "Humidity(%)",
icobot_ir_front: "Front",
@@ -289,25 +274,30 @@ Entry.iCOBOT.setLanguage = function() {
icobot_buzzer_on: "On",
icobot_buzzer_off: "Off",
icobot_buzzer_silent: "NoTone",
- icobot_buzzer_do: "Do",
- icobot_buzzer_do_sharp: "Do#(Reb)",
- icobot_buzzer_re: "Re",
- icobot_buzzer_re_sharp: "Re#(Mib)",
- icobot_buzzer_mi: "Mi",
- icobot_buzzer_fa: "Fa",
- icobot_buzzer_fa_sharp: "Fa#(Solb)",
- icobot_buzzer_sol: "Sol",
- icobot_buzzer_sol_sharp: "Sol#(Lab)",
- icobot_buzzer_la: "La",
- icobot_buzzer_la_sharp: "La#(Sib)",
- icobot_buzzer_si: "Si",
+ icobot_buzzer_do: "C",
+ icobot_buzzer_do_sharp: "C#(D♭)",
+ icobot_buzzer_re: "D",
+ icobot_buzzer_re_sharp: "D#(E♭)",
+ icobot_buzzer_mi: "E",
+ icobot_buzzer_fa: "F",
+ icobot_buzzer_fa_sharp: "F#(G♭)",
+ icobot_buzzer_sol: "G",
+ icobot_buzzer_sol_sharp: "G#(A♭)",
+ icobot_buzzer_la: "A",
+ icobot_buzzer_la_sharp: "A#(B♭)",
+ icobot_buzzer_si: "B",
+ icobot_led_total: "All",
+ icobot_led_left_up: "Left Top",
+ icobot_led_left_down: "Left Bottom",
+ icobot_led_right_up: "Right Top",
+ icobot_led_right_down: "Right Bottom",
icobot_color_white: "White",
icobot_color_red: "Red",
icobot_color_orange: "Orange",
icobot_color_yellow: "Yellow",
icobot_color_green: "Green",
icobot_color_blue: "Blue",
- icobot_color_sky_blue: "Sky_Blue",
+ icobot_color_sky_blue: "Sky Blue",
icobot_color_purple: "Purple",
icobot_motor_both_wheels: "Both",
icobot_motor_left_wheels: "Left",
@@ -329,14 +319,102 @@ Entry.iCOBOT.setLanguage = function() {
}
};
+Entry.iCOBOT.monitorTemplate = function() {
+
+ return {
+ imgPath: 'hw/iCOBOT_Front.png',
+ width: 550,
+ height: 600,
+ listPorts: {
+ BLeft_IR: {
+ name: Lang.Blocks.monitor_ir_bottom_left,
+ type: 'input',
+ pos: { x: 0, y: 0 },
+ },
+ BMid_IR: {
+ name: Lang.Blocks.monitor_ir_bottom_mid,
+ type: 'input',
+ pos: { x: 0, y: 0 },
+ },
+ BRight_IR: {
+ name: Lang.Blocks.monitor_ir_bottom_right,
+ type: 'input',
+ pos: { x: 0, y: 0 },
+ },
+ Real_T: {
+ name: Lang.Blocks.icobot_Temperature,
+ type: 'input',
+ pos: { x: 0, y: 0 },
+ },
+ Real_H: {
+ name: Lang.Blocks.icobot_Humidity,
+ type: 'input',
+ pos: { x: 0, y: 0 },
+ },
+ Sound: {
+ name: Lang.Blocks.icobot_Sound,
+ type: 'input',
+ pos: { x: 0, y: 0 },
+ },
+ },
+ ports: {
+ Brightness: {
+ name: Lang.Blocks.icobot_Brightness,
+ type: 'input',
+ pos: { x: 295, y: 350 },
+ },
+ Front_IR: {
+ name: Lang.Blocks.monitor_ir_front,
+ type: 'input',
+ pos: { x: 250, y: 300 },
+ },
+ Left_IR: {
+ name: Lang.Blocks.monitor_ir_left,
+ type: 'input',
+ pos: { x: 20, y: 450 },
+ },
+ Right_IR: {
+ name: Lang.Blocks.monitor_ir_right,
+ type: 'input',
+ pos: { x: 525, y: 450 },
+ },
+ },
+ mode: 'both',
+ };
+};
+
Entry.iCOBOT.getBlocks = function() {
return {
- //1. 센서 입력
+ //1. 센서 입력
+ icobot_sensor_input_title: {
+ color: EntryStatic.colorSet.common.TRANSPARENT,
+ fontColor: '#191970',
+ skeleton: 'basic_text',
+ skeletonOptions: {
+ contentPos: {
+ x: 5,
+ },
+ },
+ params: [
+ {
+ type: 'Text',
+ text: Lang.template.icobot_sensor_input_title,
+ color: '#191970',
+ align: 'left',
+ },
+ ],
+ def: {
+ type: 'icobot_sensor_input_title',
+ },
+ class: 'iCOBOT_ANA',
+ isNotFor: ['iCOBOT'],
+ events: {},
+ },
// 조도(밝기) - 센서 값
icobot_get_cds_value: {
color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
fontColor: '#fff',
skeleton: 'basic_string_field',
template: Lang.template.icobot_get_cds_value,
@@ -393,63 +471,32 @@ Entry.iCOBOT.getBlocks = function() {
syntax: { js: [], py: [] },
},
- icobot_analog_temp_name: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
- statements: [],
- template: '%1',
- params: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.icobot_Temperature, '8'],
- [Lang.Blocks.icobot_Humidity, '9'],
- ],
- value: '8',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- ],
- events: {},
- def: {
- params: [null],
- },
- paramsKeyMap: {
- PORT: 0,
- },
- func: function(sprite, script) {
- return script.getField('PORT');
- },
- },
-
- // 온습도 - 센서 값
icobot_get_analog_temp_value: {
color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
skeleton: 'basic_string_field',
- template: Lang.template.icobot_get_analog_temp_value,
statements: [],
params: [
{
- type: 'Block',
- accept: 'string',
- },
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.icobot_Temperature, '8'],
+ [Lang.Blocks.icobot_Humidity, '9'],
+ ],
+ value: '8',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
],
events: {},
def: {
- params: [
- {
- type: 'icobot_analog_temp_name',
- },
- ],
+ params: [null],
type: 'icobot_get_analog_temp_value',
},
paramsKeyMap: {
- PORT: 0,
+ PORT: 0,
},
class: 'iCOBOT_ANA',
isNotFor: ['iCOBOT'],
@@ -490,13 +537,12 @@ Entry.iCOBOT.getBlocks = function() {
syntax: { js: [], py: [] },
},
- icobot_analog_distsensor_list: {
+ icobot_get_distsensor_value: {
color: EntryStatic.colorSet.block.default.HARDWARE,
outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
fontColor: '#fff',
skeleton: 'basic_string_field',
statements: [],
- template: '%1',
params: [
{
type: 'Dropdown',
@@ -517,36 +563,6 @@ Entry.iCOBOT.getBlocks = function() {
events: {},
def: {
params: [null],
- },
- paramsKeyMap: {
- PORT: 0,
- },
- func: function(sprite, script) {
- return script.getField('PORT');
- },
- },
-
- // 거리 - 센서 값
- icobot_get_distsensor_value: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
- template: Lang.template.icobot_get_distsensor_value,
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- events: {},
- def: {
- params: [
- {
- type: 'icobot_analog_distsensor_list',
- },
- ],
type: 'icobot_get_distsensor_value',
},
paramsKeyMap: {
@@ -563,15 +579,38 @@ Entry.iCOBOT.getBlocks = function() {
syntax: { js: [], py: [] },
},
- //2. 부저 관련
+ //2. 부저 관련
+ icobot_buzzer_title: {
+ color: EntryStatic.colorSet.common.TRANSPARENT,
+ fontColor: '#191970',
+ skeleton: 'basic_text',
+ skeletonOptions: {
+ contentPos: {
+ x: 5,
+ },
+ },
+ params: [
+ {
+ type: 'Text',
+ text: Lang.template.icobot_buzzer_title,
+ color: '#191970',
+ align: 'left',
+ },
+ ],
+ def: {
+ type: 'icobot_buzzer_title',
+ },
+ class: 'iCOBOT_BUZ',
+ isNotFor: ['iCOBOT'],
+ events: {},
+ },
- icobot_digital_port_onoff_list: {
+ icobot_buzzer_onoff: {
color: EntryStatic.colorSet.block.default.HARDWARE,
outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
fontColor: '#fff',
- skeleton: 'basic_string_field',
+ skeleton: 'basic',
statements: [],
- template: '%1',
params: [
{
type: 'Dropdown',
@@ -584,45 +623,15 @@ Entry.iCOBOT.getBlocks = function() {
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
},
- ],
- events: {},
- def: {
- params: [null],
- },
- paramsKeyMap: {
- PORT: 0,
- },
- func: function(sprite, script) {
- return script.getField('PORT');
- },
- },
-
- // 부저 - 부저 On/Off 삐소리
- icobot_buzzer_onoff: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
{
type: 'Indicator',
- img: 'block_icon/hardware_bzr2.png', // img: 'block_icon/hardware_icon.svg',
+ img: 'block_icon/hardware_bzr2.svg',
size: 11,
},
],
events: {},
def: {
- params: [
- {
- type: 'icobot_digital_port_onoff_list',
- },
- null,
- ],
+ params: [null],
type: 'icobot_buzzer_onoff',
},
paramsKeyMap: {
@@ -648,13 +657,14 @@ Entry.iCOBOT.getBlocks = function() {
syntax: { js: [], py: [] },
},
- icobot_list_digital_octave: {
+ // 부저 - 부저 옥타브/음/초 동안 연주
+ icobot_set_digital_buzzer: {
color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
+ skeleton: 'basic',
statements: [],
- template: '%1',
+ template: Lang.template.icobot_set_digital_buzzer,
params: [
{
type: 'Dropdown',
@@ -673,28 +683,6 @@ Entry.iCOBOT.getBlocks = function() {
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
},
- ],
- events: {},
- def: {
- params: [null],
- },
- paramsKeyMap: {
- OCTAVE: 0,
- },
- func: function(sprite, script) {
- return script.getField('OCTAVE');
- },
-
- },
-
- icobot_list_digital_tone: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
- statements: [],
- template: '%1',
- params: [
{
type: 'Dropdown',
options: [
@@ -717,70 +705,36 @@ Entry.iCOBOT.getBlocks = function() {
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
},
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_bzr2.svg',
+ size: 11,
+ },
],
events: {},
def: {
- params: [null],
+ params: [
+ null,
+ null,
+ {
+ type: 'number',
+ params: ["1"],
+ },
+ null,
+ ],
+ type: 'icobot_set_digital_buzzer',
},
paramsKeyMap: {
- NOTE: 0,
+ OCTAVE: 0,
+ NOTE: 1,
+ DURATION: 2,
},
- func: function(sprite, script) {
- return script.getField('NOTE');
- },
- },
-
- // 부저 - 부저 옥타브/음/초 동안 연주
- icobot_set_digital_buzzer: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic',
- statements: [],
- template: Lang.template.icobot_set_digital_buzzer,
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Indicator',
- img: 'block_icon/hardware_bzr2.png',
- size: 11,
- },
- ],
- events: {},
- def: {
- params: [
- {
- type: 'icobot_list_digital_octave',
- },
- {
- type: 'icobot_list_digital_tone',
- },
- {
- type: 'number',
- params: ["1"],
- },
- null,
- ],
- type: 'icobot_set_digital_buzzer',
- },
- paramsKeyMap: {
- OCTAVE: 0,
- NOTE: 1,
- DURATION: 2,
- },
- class: 'iCOBOT_BUZ',
- isNotFor: ['iCOBOT'],
+ class: 'iCOBOT_BUZ',
+ isNotFor: ['iCOBOT'],
func: function(sprite, script) {
var port = 6;
var octave = script.getNumberValue('OCTAVE') - 1;
@@ -871,30 +825,53 @@ Entry.iCOBOT.getBlocks = function() {
template: Lang.template.icobot_set_digital_buzzer_notime,
params: [
{
- type: 'Block',
- accept: 'string',
+ type: 'Dropdown',
+ options: [
+ ['1', '1'],
+ ['2', '2'],
+ ['3', '3'],
+ ['4', '4'],
+ ['5', '5'],
+ ['6', '6'],
+ ['7', '7'],
+ ['8', '8'],
+ ],
+ value: '4',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
},
{
- type: 'Block',
- accept: 'string',
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.icobot_buzzer_silent, '0'],
+ [Lang.Blocks.icobot_buzzer_do, 'C'],
+ [Lang.Blocks.icobot_buzzer_do_sharp, 'CS'],
+ [Lang.Blocks.icobot_buzzer_re, 'D'],
+ [Lang.Blocks.icobot_buzzer_re_sharp, 'DS'],
+ [Lang.Blocks.icobot_buzzer_mi, 'E'],
+ [Lang.Blocks.icobot_buzzer_fa, 'F'],
+ [Lang.Blocks.icobot_buzzer_fa_sharp, 'FS'],
+ [Lang.Blocks.icobot_buzzer_sol, 'G'],
+ [Lang.Blocks.icobot_buzzer_sol_sharp, 'GS'],
+ [Lang.Blocks.icobot_buzzer_la, 'A'],
+ [Lang.Blocks.icobot_buzzer_la_sharp, 'AS'],
+ [Lang.Blocks.icobot_buzzer_si, 'B'],
+ ],
+ value: 'C',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
},
{
type: 'Indicator',
- img: 'block_icon/hardware_bzr2.png',
+ img: 'block_icon/hardware_bzr2.svg',
size: 11,
},
],
events: {},
def: {
- params: [
- {
- type: 'icobot_list_digital_octave',
- },
- {
- type: 'icobot_list_digital_tone',
- },
- null,
- ],
+ params: [null],
type: 'icobot_set_digital_buzzer_notime',
},
paramsKeyMap: {
@@ -941,15 +918,54 @@ Entry.iCOBOT.getBlocks = function() {
},
//3. LED 관련
-
- icobot_analog_rgb_color_list: {
+ icobot_led_title: {
+ color: EntryStatic.colorSet.common.TRANSPARENT,
+ fontColor: '#191970',
+ skeleton: 'basic_text',
+ skeletonOptions: {
+ contentPos: {
+ x: 5,
+ },
+ },
+ params: [
+ {
+ type: 'Text',
+ text: Lang.template.icobot_led_title,
+ color: '#191970',
+ align: 'left',
+ },
+ ],
+ def: {
+ type: 'icobot_led_title',
+ },
+ class: 'iCOBOT_RGB',
+ isNotFor: ['iCOBOT'],
+ events: {},
+ },
+
+ // RGBLED - 종류 선택 및 On/Off
+ icobot_digital_rgbled_onoff:
+ {
color: EntryStatic.colorSet.block.default.HARDWARE,
outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
+ fontColor: '#fff',
+ skeleton: 'basic',
statements: [],
- template: '%1',
params: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.icobot_led_total, '0'],
+ [Lang.Blocks.icobot_led_left_up, '1'],
+ [Lang.Blocks.icobot_led_right_up, '2'],
+ [Lang.Blocks.icobot_led_left_down, '3'],
+ [Lang.Blocks.icobot_led_right_down, '4'],
+ ],
+ value: '0',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
{
type: 'Dropdown',
options: [
@@ -967,57 +983,29 @@ Entry.iCOBOT.getBlocks = function() {
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
},
- ],
- events: {},
- def: {
- params: [null],
- },
- paramsKeyMap: {
- PORT: 0,
- },
- func: function(sprite, script) {
- return script.getField('PORT');
- },
- },
-
- // RGBLED - 종류 선택 및 On/Off
- icobot_digital_rgbled_onoff:
- {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
{
type: 'Indicator',
- img: 'block_icon/hardware_led.png',
+ img: 'block_icon/hardware_led.svg',
size: 11,
},
],
events: {},
def: {
- params: [
- {
- type: 'icobot_analog_rgb_color_list',
- },
- null,
- ],
+ params: [null],
type: 'icobot_digital_rgbled_onoff',
},
paramsKeyMap: {
- COLOR: 0,
+ NUM: 0,
+ COLOR: 1,
},
class: 'iCOBOT_RGB',
isNotFor: ['iCOBOT'],
func: function(sprite, script)
{
var port = 9;
+ var num = script.getNumberValue('NUM', script);
var color = script.getNumberValue('COLOR', script);
+ var delay_time = 0;
var rLED, gLED, bLED;
@@ -1029,7 +1017,7 @@ Entry.iCOBOT.getBlocks = function() {
break;
case 2: rLED = 255; gLED = bLED = 0; // Red
break;
- case 3: rLED = 255;gLED = 50; bLED = 0; // orange
+ case 3: rLED = 255; gLED = 50; bLED = 0; // orange
break;
case 4: rLED = gLED = 255; bLED = 0; // Yellow
break;
@@ -1042,21 +1030,43 @@ Entry.iCOBOT.getBlocks = function() {
case 8: rLED = bLED = 255; gLED = 0; // purple
break;
}
+
+ if (!script.isStart)
+ {
- if (!Entry.hw.sendQueue['SET'])
- {
- Entry.hw.sendQueue['SET'] = {};
+ if (!Entry.hw.sendQueue['SET'])
+ {
+ Entry.hw.sendQueue['SET'] = {};
+ }
+ script.isStart = true;
+ script.timeFlag = 1;
+ Entry.hw.sendQueue['SET'][port] = {
+ type: Entry.iCOBOT.sensorTypes.RGBLED,
+ data: {
+ n: num,
+ r: rLED,
+ g: gLED,
+ b: bLED,
+ },
+ time: new Date().getTime(),
+ };
+ setTimeout (function ()
+ {
+ script.timeFlag = 0;
+ }, delay_time);
+ return script;
+ }
+ else if (script .timeFlag == 1)
+ {
+ return script;
+ }
+ else
+ {
+ delete script.timeFlag;
+ delete script.isStart;
+ Entry.engine.isContinue = false;
+ return script.callReturn();
}
- Entry.hw.sendQueue['SET'][port] = {
- type: Entry.iCOBOT.sensorTypes.RGBLED,
- data: {
- r: rLED,
- g: gLED,
- b: bLED,
- },
- time: new Date().getTime(),
- };
- return script.callReturn();
},
syntax: { js: [], py: [] },
},
@@ -1070,42 +1080,79 @@ Entry.iCOBOT.getBlocks = function() {
skeleton: 'basic',
statements: [],
params: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.icobot_led_total, '0'],
+ [Lang.Blocks.icobot_led_left_up, '1'],
+ [Lang.Blocks.icobot_led_right_up, '2'],
+ [Lang.Blocks.icobot_led_left_down, '3'],
+ [Lang.Blocks.icobot_led_right_down, '4'],
+ ],
+ value: '0',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
{
type: 'Indicator',
- img: 'block_icon/hardware_led.png',
+ img: 'block_icon/hardware_led.svg',
size: 11,
},
],
events: {},
def: {
- params: [
- null,
- ],
+ params: [null],
type: 'icobot_digital_rgbled_off',
},
paramsKeyMap: {
+ NUM: 0,
},
class: 'iCOBOT_RGB',
isNotFor: ['iCOBOT'],
func: function(sprite, script)
{
var port = 9;
+ var num = script.getNumberValue('NUM', script);
var rLED = 0, gLED = 0, bLED = 0;
-
- if (!Entry.hw.sendQueue['SET'])
- {
- Entry.hw.sendQueue['SET'] = {};
+ var delay_time = 0;
+
+ if (!script.isStart)
+ {
+
+ if (!Entry.hw.sendQueue['SET'])
+ {
+ Entry.hw.sendQueue['SET'] = {};
+ }
+ script.isStart = true;
+ script.timeFlag = 1;
+ Entry.hw.sendQueue['SET'][port] = {
+ type: Entry.iCOBOT.sensorTypes.RGBLED,
+ data: {
+ n: num,
+ r: rLED,
+ g: gLED,
+ b: bLED,
+ },
+ time: new Date().getTime(),
+ };
+ setTimeout (function ()
+ {
+ script.timeFlag = 0;
+ }, delay_time);
+ return script;
+ }
+ else if (script .timeFlag == 1)
+ {
+ return script;
+ }
+ else
+ {
+ delete script.timeFlag;
+ delete script.isStart;
+ Entry.engine.isContinue = false;
+ return script.callReturn();
}
- Entry.hw.sendQueue['SET'][port] = {
- type: Entry.iCOBOT.sensorTypes.RGBLED,
- data: {
- r: rLED,
- g: gLED,
- b: bLED,
- },
- time: new Date().getTime(),
- };
- return script.callReturn();
},
syntax: { js: [], py: [] },
},
@@ -1119,6 +1166,20 @@ Entry.iCOBOT.getBlocks = function() {
skeleton: 'basic',
statements: [],
params: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.icobot_led_total, '0'],
+ [Lang.Blocks.icobot_led_left_up, '1'],
+ [Lang.Blocks.icobot_led_right_up, '2'],
+ [Lang.Blocks.icobot_led_left_down, '3'],
+ [Lang.Blocks.icobot_led_right_down, '4'],
+ ],
+ value: '0',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
{
type: 'Block',
accept: 'string',
@@ -1133,13 +1194,14 @@ Entry.iCOBOT.getBlocks = function() {
},
{
type: 'Indicator',
- img: 'block_icon/hardware_led.png',
+ img: 'block_icon/hardware_led.svg',
size: 11,
},
],
events: {},
def: {
params: [
+ null,
{
type: 'number',
params: ["0"],
@@ -1157,212 +1219,131 @@ Entry.iCOBOT.getBlocks = function() {
type: 'icobot_digital_set_rgbled_value',
},
paramsKeyMap: {
- VALUE0:0,
- VALUE1:1,
- VALUE2:2,
+ NUM: 0,
+ VALUE0:1,
+ VALUE1:2,
+ VALUE2:3,
},
class: 'iCOBOT_RGB',
isNotFor: ['iCOBOT'],
func: function(sprite, script)
{
var port = 9;
+ var num = script.getNumberValue('NUM', script);
var rLED = script.getNumberValue('VALUE0', script);
var gLED = script.getNumberValue('VALUE1', script);
var bLED = script.getNumberValue('VALUE2', script);
+ var delay_time = 0;
- if (!Entry.hw.sendQueue['SET']) {
- Entry.hw.sendQueue['SET'] = {};
- }
- Entry.hw.sendQueue['SET'][port] = {
- type: Entry.iCOBOT.sensorTypes.RGBLED,
- data: {
- r: rLED,
- g: gLED,
- b: bLED,
- },
- time: new Date().getTime(),
- };
- return script.callReturn();
- },
- syntax: { js: [], py: [] },
- },
-
- //4. 모터 관련
- icobot_digital_motor_port_list: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
- statements: [],
- template: '%1',
- params: [
+ if (!script.isStart)
{
- type: 'Dropdown',
- options: [
- [Lang.Blocks.icobot_motor_both_wheels, '2'],
- [Lang.Blocks.icobot_motor_left_wheels, '1'],
- [Lang.Blocks.icobot_motor_right_wheels, '3'],
- ],
- value: '2',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- arrowColor: EntryStatic.ARROW_COLOR_HW,
- },
- ],
- events: {},
- def: {
- params: [null],
- },
- paramsKeyMap: {
- PORT: 0,
- },
- func: function(sprite, script) {
- return script.getStringField('PORT');
+
+ if (!Entry.hw.sendQueue['SET'])
+ {
+ Entry.hw.sendQueue['SET'] = {};
+ }
+ script.isStart = true;
+ script.timeFlag = 1;
+ Entry.hw.sendQueue['SET'][port] = {
+ type: Entry.iCOBOT.sensorTypes.RGBLED,
+ data: {
+ n: num,
+ r: rLED,
+ g: gLED,
+ b: bLED,
+ },
+ time: new Date().getTime(),
+ };
+ setTimeout (function ()
+ {
+ script.timeFlag = 0;
+ }, delay_time);
+ return script;
+ }
+ else if (script .timeFlag == 1)
+ {
+ return script;
+ }
+ else
+ {
+ delete script.timeFlag;
+ delete script.isStart;
+ Entry.engine.isContinue = false;
+ return script.callReturn();
+ }
},
- },
+ syntax: { js: [], py: [] },
+ },
- icobot_motor_direction_list:
- {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
- statements: [],
- template: '%1',
+ //4. 모터 관련
+ icobot_motor_title: {
+ color: EntryStatic.colorSet.common.TRANSPARENT,
+ fontColor: '#191970',
+ skeleton: 'basic_text',
+ skeletonOptions: {
+ contentPos: {
+ x: 5,
+ },
+ },
params: [
{
- type: 'Dropdown',
- options: [
- [Lang.Blocks.icobot_motor_front_move, '0'],
- [Lang.Blocks.icobot_motor_back_move, '1'],
- ],
- value: '0',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- arrowColor: EntryStatic.ARROW_COLOR_HW,
+ type: 'Text',
+ text: Lang.template.icobot_motor_title,
+ color: '#191970',
+ align: 'left',
},
],
- events: {},
def: {
- params: [null],
+ type: 'icobot_motor_title',
},
- paramsKeyMap: {
- DIR: 0,
- },
- func: function(sprite, script) {
- return script.getStringField('DIR');
- },
- },
+ class: 'iCOBOT_DC',
+ isNotFor: ['iCOBOT'],
+ events: {},
+ },
- icobot_digital_motor_angle_port_list: {
+ // 모터 - 방향 바꾸기
+ icobot_digital_set_motor_direction:
+ {
color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
fontColor: '#fff',
- skeleton: 'basic_string_field',
+ skeleton: 'basic',
statements: [],
- template: '%1',
params: [
{
type: 'Dropdown',
options: [
- [Lang.Blocks.icobot_motor_left_turn, '1'],
- [Lang.Blocks.icobot_motor_right_turn, '3'],
+ [Lang.Blocks.icobot_motor_both_wheels, '2'],
+ [Lang.Blocks.icobot_motor_left_wheels, '1'],
+ [Lang.Blocks.icobot_motor_right_wheels, '3'],
],
- value: '1',
+ value: '2',
fontSize: 11,
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
arrowColor: EntryStatic.ARROW_COLOR_HW,
},
- ],
- events: {},
- def: {
- params: [null],
- },
- paramsKeyMap: {
- PORT: 0,
- },
- func: function(sprite, script) {
- return script.getStringField('PORT');
- },
- },
-
- icobot_motor_angle_list:
- {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
- statements: [],
- template: '%1',
- params: [
{
type: 'Dropdown',
options: [
- [Lang.Blocks.icobot_motor_30_degrees, '0'],
- [Lang.Blocks.icobot_motor_45_degrees, '1'],
- [Lang.Blocks.icobot_motor_60_degrees, '2'],
- [Lang.Blocks.icobot_motor_90_degrees, '3'],
- [Lang.Blocks.icobot_motor_120_degrees, '4'],
- [Lang.Blocks.icobot_motor_135_degrees, '5'],
- [Lang.Blocks.icobot_motor_150_degrees, '6'],
- [Lang.Blocks.icobot_motor_180_degrees, '7'],
+ [Lang.Blocks.icobot_motor_front_move, '0'],
+ [Lang.Blocks.icobot_motor_back_move, '1'],
],
value: '0',
fontSize: 11,
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
arrowColor: EntryStatic.ARROW_COLOR_HW,
- },
- ],
- events: {},
- def: {
- params: [null],
- },
- paramsKeyMap: {
- DIR: 0,
- },
- func: function(sprite, script) {
- return script.getStringField('DIR');
- },
- },
-
- // 모터 - 방향 바꾸기
- icobot_digital_set_motor_direction:
- {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Block',
- accept: 'string',
- },
+ },
{
type: 'Indicator',
- img: 'block_icon/hardware_dc.png',
+ img: 'block_icon/hardware_dc.svg',
size: 11,
},
],
events: {},
def: {
- params: [
- {
- type: 'icobot_digital_motor_port_list',
- },
- {
- type: 'icobot_motor_direction_list',
- },
- null,
- ],
+ params: [null],
type: 'icobot_digital_set_motor_direction',
},
paramsKeyMap: {
@@ -1376,21 +1357,42 @@ Entry.iCOBOT.getBlocks = function() {
var port = script.getNumberValue('PORT', script);
var dir = script.getNumberValue('DIR', script);
var mode = 1;
-
- if (!Entry.hw.sendQueue['SET']) {
- Entry.hw.sendQueue['SET'] = {};
- }
- Entry.hw.sendQueue['SET'][port] =
- {
- type: Entry.iCOBOT.sensorTypes.MOTOR,
- data:
+ var delay_time = 0;
+
+ if (!script.isStart)
+ {
+
+ if (!Entry.hw.sendQueue['SET'])
{
- mode: mode,
- value: dir,
- },
- time: new Date().getTime(),
- };
- return script.callReturn();
+ Entry.hw.sendQueue['SET'] = {};
+ }
+ script.isStart = true;
+ script.timeFlag = 1;
+ Entry.hw.sendQueue['SET'][port] = {
+ type: Entry.iCOBOT.sensorTypes.MOTOR,
+ data: {
+ mode: mode,
+ value: dir,
+ },
+ time: new Date().getTime(),
+ };
+ setTimeout (function ()
+ {
+ script.timeFlag = 0;
+ }, delay_time);
+ return script;
+ }
+ else if (script .timeFlag == 1)
+ {
+ return script;
+ }
+ else
+ {
+ delete script.timeFlag;
+ delete script.isStart;
+ Entry.engine.isContinue = false;
+ return script.callReturn();
+ }
},
syntax: { js: [], py: [] },
},
@@ -1405,30 +1407,44 @@ Entry.iCOBOT.getBlocks = function() {
statements: [],
params: [
{
- type: 'Block',
- accept: 'string',
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.icobot_motor_left_turn, '3'],
+ [Lang.Blocks.icobot_motor_right_turn, '1'],
+ ],
+ value: '3',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ arrowColor: EntryStatic.ARROW_COLOR_HW,
},
{
- type: 'Block',
- accept: 'string',
- },
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.icobot_motor_30_degrees, '0'],
+ [Lang.Blocks.icobot_motor_45_degrees, '1'],
+ [Lang.Blocks.icobot_motor_60_degrees, '2'],
+ [Lang.Blocks.icobot_motor_90_degrees, '3'],
+ [Lang.Blocks.icobot_motor_120_degrees, '4'],
+ [Lang.Blocks.icobot_motor_135_degrees, '5'],
+ [Lang.Blocks.icobot_motor_150_degrees, '6'],
+ [Lang.Blocks.icobot_motor_180_degrees, '7'],
+ ],
+ value: '0',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ arrowColor: EntryStatic.ARROW_COLOR_HW,
+ },
{
type: 'Indicator',
- img: 'block_icon/hardware_dc.png',
+ img: 'block_icon/hardware_dc.svg',
size: 11,
},
],
events: {},
def: {
- params: [
- {
- type: 'icobot_digital_motor_angle_port_list',
- },
- {
- type: 'icobot_motor_angle_list',
- },
- null,
- ],
+ params: [null],
type: 'icobot_digital_set_motor_angle',
},
paramsKeyMap: {
@@ -1442,21 +1458,42 @@ Entry.iCOBOT.getBlocks = function() {
var port = script.getNumberValue('PORT', script);
var dir = script.getNumberValue('DIR', script);
var mode = 4;
-
- if (!Entry.hw.sendQueue['SET']) {
- Entry.hw.sendQueue['SET'] = {};
- }
- Entry.hw.sendQueue['SET'][port] =
- {
- type: Entry.iCOBOT.sensorTypes.MOTOR,
- data:
+ var delay_time = 0;
+
+ if (!script.isStart)
+ {
+
+ if (!Entry.hw.sendQueue['SET'])
{
- mode: mode,
- value: dir,
- },
- time: new Date().getTime(),
- };
- return script.callReturn();
+ Entry.hw.sendQueue['SET'] = {};
+ }
+ script.isStart = true;
+ script.timeFlag = 1;
+ Entry.hw.sendQueue['SET'][port] = {
+ type: Entry.iCOBOT.sensorTypes.MOTOR,
+ data: {
+ mode: mode,
+ value: dir,
+ },
+ time: new Date().getTime(),
+ };
+ setTimeout (function ()
+ {
+ script.timeFlag = 0;
+ }, delay_time);
+ return script;
+ }
+ else if (script .timeFlag == 1)
+ {
+ return script;
+ }
+ else
+ {
+ delete script.timeFlag;
+ delete script.isStart;
+ Entry.engine.isContinue = false;
+ return script.callReturn();
+ }
},
syntax: { js: [], py: [] },
},
@@ -1471,8 +1508,17 @@ Entry.iCOBOT.getBlocks = function() {
statements: [],
params: [
{
- type: 'Block',
- accept: 'string',
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.icobot_motor_both_wheels, '2'],
+ [Lang.Blocks.icobot_motor_left_wheels, '1'],
+ [Lang.Blocks.icobot_motor_right_wheels, '3'],
+ ],
+ value: '2',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ arrowColor: EntryStatic.ARROW_COLOR_HW,
},
{
type: 'Block',
@@ -1480,16 +1526,14 @@ Entry.iCOBOT.getBlocks = function() {
},
{
type: 'Indicator',
- img: 'block_icon/hardware_dc.png',
+ img: 'block_icon/hardware_dc.svg',
size: 11,
},
],
events: {},
def: {
params: [
- {
- type: 'icobot_digital_motor_port_list',
- },
+ null,
{
type: 'number',
params: ["0"],
@@ -1511,22 +1555,44 @@ Entry.iCOBOT.getBlocks = function() {
var mode = 2;
speed = Math.min(1000, speed);
- speed = Math.max(0, speed);
-
- if (!Entry.hw.sendQueue['SET']) {
- Entry.hw.sendQueue['SET'] = {};
- }
- Entry.hw.sendQueue['SET'][port] =
- {
- type: Entry.iCOBOT.sensorTypes.MOTOR,
- data:
+ speed = Math.max(0, speed);
+
+ var delay_time = 0;
+
+ if (!script.isStart)
+ {
+
+ if (!Entry.hw.sendQueue['SET'])
{
- mode: mode,
- value: speed,
- },
- time: new Date().getTime(),
- };
- return script.callReturn();
+ Entry.hw.sendQueue['SET'] = {};
+ }
+ script.isStart = true;
+ script.timeFlag = 1;
+ Entry.hw.sendQueue['SET'][port] = {
+ type: Entry.iCOBOT.sensorTypes.MOTOR,
+ data: {
+ mode: mode,
+ value: speed,
+ },
+ time: new Date().getTime(),
+ };
+ setTimeout (function ()
+ {
+ script.timeFlag = 0;
+ }, delay_time);
+ return script;
+ }
+ else if (script .timeFlag == 1)
+ {
+ return script;
+ }
+ else
+ {
+ delete script.timeFlag;
+ delete script.isStart;
+ Entry.engine.isContinue = false;
+ return script.callReturn();
+ }
},
syntax: { js: [], py: [] },
},
@@ -1541,23 +1607,27 @@ Entry.iCOBOT.getBlocks = function() {
statements: [],
params: [
{
- type: 'Block',
- accept: 'string',
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.icobot_motor_both_wheels, '2'],
+ [Lang.Blocks.icobot_motor_left_wheels, '1'],
+ [Lang.Blocks.icobot_motor_right_wheels, '3'],
+ ],
+ value: '2',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ arrowColor: EntryStatic.ARROW_COLOR_HW,
},
{
type: 'Indicator',
- img: 'block_icon/hardware_dc.png',
+ img: 'block_icon/hardware_dc.svg',
size: 11,
},
],
events: {},
def: {
- params: [
- {
- type: 'icobot_digital_motor_port_list',
- },
- null,
- ],
+ params: [null],
type: 'icobot_digital_motor_stop',
},
paramsKeyMap: {
@@ -1570,21 +1640,42 @@ Entry.iCOBOT.getBlocks = function() {
var port = script.getNumberValue('PORT', script);
var mode = 3;
var speed = 0;
-
- if (!Entry.hw.sendQueue['SET']) {
- Entry.hw.sendQueue['SET'] = {};
- }
- Entry.hw.sendQueue['SET'][port] =
- {
- type: Entry.iCOBOT.sensorTypes.MOTOR,
- data:
+ var delay_time = 0;
+
+ if (!script.isStart)
+ {
+
+ if (!Entry.hw.sendQueue['SET'])
{
- mode: mode,
- value: speed,
- },
- time: new Date().getTime(),
- };
- return script.callReturn();
+ Entry.hw.sendQueue['SET'] = {};
+ }
+ script.isStart = true;
+ script.timeFlag = 1;
+ Entry.hw.sendQueue['SET'][port] = {
+ type: Entry.iCOBOT.sensorTypes.MOTOR,
+ data: {
+ mode: mode,
+ value: speed,
+ },
+ time: new Date().getTime(),
+ };
+ setTimeout (function ()
+ {
+ script.timeFlag = 0;
+ }, delay_time);
+ return script;
+ }
+ else if (script .timeFlag == 1)
+ {
+ return script;
+ }
+ else
+ {
+ delete script.timeFlag;
+ delete script.isStart;
+ Entry.engine.isContinue = false;
+ return script.callReturn();
+ }
},
syntax: { js: [], py: [] },
},