diff --git a/extern/lang/code.js b/extern/lang/code.js
index 3543a1976a..6a7bec2bc3 100644
--- a/extern/lang/code.js
+++ b/extern/lang/code.js
@@ -5980,18 +5980,21 @@ Lang.template = {
"iboard_rgb_led": "RGB LED의 %1 LED %2 %3",
"iboard_set_tone": "디지털 %1 번 핀의 버저를 %2 %3 음으로 %4 초 연주하기 %5",
"iboard_toggle_led": "디지털 %1 번 핀 %2 %3",
- "bitbrick_sensor_value": "%1 값",
- "bitbrick_is_touch_pressed": "touch %1 이(가) 눌렸는가?",
- "bitbrick_turn_off_color_led": "컬러 LED 끄기 %1",
- "bitbrick_turn_on_color_led_by_rgb": "컬러 LED 켜기 R %1 G %2 B %3 %4",
- "bitbrick_turn_on_color_led_by_picker": "컬러 LED 색 %1 로 정하기 %2",
- "bitbrick_turn_on_color_led_by_value": "컬러 LED 켜기 색 %1 로 정하기 %2",
- "bitbrick_buzzer": "버저음 %1 내기 %2",
- "bitbrick_turn_off_all_motors": "모든 모터 끄기 %1",
- "bitbrick_dc_speed": "DC 모터 %1 속도 %2 %3",
- "bitbrick_dc_direction_speed": "DC 모터 %1 %2 방향 속력 %3 %4",
- "bitbrick_servomotor_angle": "서보 모터 %1 각도 %2 %3",
+ "bitbrick_when_button_pressed": "%1 버튼 %2 눌러졌을 때",
+ "bitbrick_when_sensor_get_value": "%1 %2 값 %3 %4 일 때",
+ "bitbrick_is_touch_pressed": "버튼 %1 이(가) %2 인가?",
+ "bitbrick_is_sensor_value_compare": '%1 값 %2 %3 인가?',
+ "bitbrick_sensor_value": "%1 값",
"bitbrick_convert_scale": "변환 %1 값 %2 ~ %3 에서 %4 ~ %5",
+ "bitbrick_turn_on_color_led_by_rgb": "엘이디를 빨강 %1 초록 %2 파랑 %3 %4 (으)로 켜기",
+ "bitbrick_turn_on_color_led_by_picker": "엘이디를 %1 (으)로 켜기 %2",
+ "bitbrick_turn_on_color_led_by_value": "엘이디를 %1 (으)로 켜기 %2",
+ "bitbrick_turn_off_color_led": "엘이디 끄기 %1",
+ "bitbrick_buzzer": "버저음 %1 내기 %2",
+ "bitbrick_servomotor_angle": "서보모터 %1 각도 %2 %3",
+ "bitbrick_dc_direction_speed": "디씨모터 %1 방향 %2 속력 %3 %4",
+ "bitbrick_dc_speed": "디씨모터 %1 속도 %2 %3",
+ "bitbrick_turn_off_all_motors": "모든 모터 멈추기 %1",
"start_drawing": "this.startDraw() %1",
"stop_drawing": "this.stopDraw() %1",
"set_color": "this.brush.color = %1 %2",
@@ -6791,7 +6794,8 @@ Lang.TextCoding = {
"alert_list_contains_exceed_length_value": "리스트 항목에 15자리 이상의 수가 입력되어 있으면 모드 변환을 할 수 없습니다.",
"alert_function_name_empty_text_add_change": "함수명에 공백(띄어쓰기)이 포함될 수 없습니다.",
"alert_no_save_on_error": "문법 오류가 존재하여 작품을 저장할 수 없습니다.",
- "alert_api_no_support": "작품에 확장 블록이 사용된 경우에는 엔트리파이선 모드로 변경할 수 없습니다.",
+ "alert_api_no_support":
+ '작품에 엔트리파이썬에서 지원하지 않는 \n블록이 조립되어 있습니다. \n해당 블록을 삭제하고 만들기 모드를 변경할까요?',
"warn_unnecessary_arguments": "&(calleeName)(); 는 괄호 사이에 값이 입력될 필요가 없는 명령어 입니다. (line:&(lineNumber))",
"python_code": " 오브젝트의 파이선 코드",
"eof": "줄바꿈",
diff --git a/extern/lang/ebs.js b/extern/lang/ebs.js
index 54bf2b465d..1609d88d39 100644
--- a/extern/lang/ebs.js
+++ b/extern/lang/ebs.js
@@ -575,13 +575,13 @@ Lang.Blocks = {
"blacksmith_toggle_off": "끄기",
"blacksmith_lcd_first_line": "첫 번째",
"blacksmith_lcd_seconds_line": "두 번째",
- "BITBRICK_light": "밝기센서",
- "BITBRICK_IR": "거리센서",
+ "BITBRICK_light": "밝기 센서",
+ "BITBRICK_IR": "적외선 센서",
"BITBRICK_touch": "버튼",
"BITBRICK_potentiometer": "가변저항",
- "BITBRICK_MIC": "소리감지센서",
- "BITBRICK_UserSensor": "사용자입력",
- "BITBRICK_UserInput": "사용자입력",
+ "BITBRICK_MIC": "소리 센서",
+ "BITBRICK_UserSensor": "사용자 입력",
+ "BITBRICK_UserInput": "사용자 입력",
"BITBRICK_dc_direction_ccw": "반시계",
"BITBRICK_dc_direction_cw": "시계",
"chocopi_control_event_pressed": "누를 때",
@@ -743,6 +743,7 @@ Lang.Blocks = {
"CALC_get_date_minute": "시각(분)",
"CALC_get_date_month": "월",
"CALC_get_date_second": "시각(초)",
+ "CALC_get_date_day_of_week": "요일",
"CALC_get_date_year": "연도",
"CALC_get_sound_duration_1": "",
"CALC_get_sound_duration_2": "소리의 길이",
@@ -794,10 +795,14 @@ Lang.Blocks = {
"JUDGEMENT_boolean_or": "또는",
"JUDGEMENT_false": " 거짓 ",
"JUDGEMENT_is_clicked": "마우스를 클릭했는가?",
+ "JUDGEMENT_is_object_clicked": "오브젝트를 클릭했는가?",
"JUDGEMENT_is_press_some_key_1": "",
"JUDGEMENT_is_press_some_key_2": "키가 눌러져 있는가?",
"JUDGEMENT_reach_something_1": "",
"JUDGEMENT_reach_something_2": "에 닿았는가?",
+ "JUDGEMENT_is_type_1": '(이)가',
+ "JUDGEMENT_is_type_2": '인가?',
+ "is_type_number": "숫자",
"JUDGEMENT_true": " 참 ",
"LOOKS": "생김새",
"LOOKS_change_scale_percent_1": "크기를",
@@ -1523,6 +1528,8 @@ Lang.Blocks = {
"CALC_char_at_3": "번째 글자",
"CALC_length_of_string_1": "",
"CALC_length_of_string_2": "의 글자 수",
+ "CALC_reverse_of_string_1": "",
+ "CALC_reverse_of_string_2": "을(를) 뒤집기",
"CALC_substring_1": "",
"CALC_substring_2": "의",
"CALC_substring_3": "번째 글자부터",
@@ -1537,6 +1544,8 @@ Lang.Blocks = {
"CALC_change_string_case_3": " ",
"CALC_change_string_case_sub_1": "대문자",
"CALC_change_string_case_sub_2": "소문자",
+ "CALC_count_match_string_1": "에서",
+ "CALC_count_match_string_2": "의 글자 수",
"CALC_index_of_string_1": "",
"CALC_index_of_string_2": "에서",
"CALC_index_of_string_3": "의 시작 위치",
@@ -5376,8 +5385,10 @@ Lang.Helper = {
"sound_volume_set": "작품에서 재생되는 모든 소리의 크기를 입력한 값으로 정합니다.",
"sound_silent_all": "재생 중인 모든 소리를 멈춥니다.",
"is_clicked": "마우스를 클릭한 경우 ‘참’으로 판단합니다.",
+ "is_object_clicked": "오브젝트를 클릭한 경우 ‘참’으로 판단합니다.",
"is_press_some_key": "선택한 키가 눌려져 있는 경우 ‘참’으로 판단합니다.",
"reach_something": "해당 오브젝트가 선택한 항목과 닿은 경우 ‘참’으로 판단합니다.",
+ "is_type": "입력한 값이 숫자라면 ‘참’으로 판단합니다.",
"is_included_in_list": "선택한 리스트가 입력한 값을 가진 항목을 포함하는 경우 '참'으로 판단합니다.",
"boolean_basic_operator": "입력한 두 값을 비교합니다.\n= : 왼쪽에 위치한 값과 오른쪽에 위치한 값이 같은 경우 '참'으로 판단합니다.\n> : 왼쪽에 위치한 값이 오른쪽에 위치한 값보다 큰 경우 같로 판단합니다.\n< : 왼쪽에 위치한 값이 오른쪽에 위치한 값보다 작은 경우 '참'으로 판단합니다.\n≥ : 왼쪽에 위치한 값이 오른쪽에 위치한 값보다 크거나 같은 경우 '참'으로 판단합니다.\n≤ : 왼쪽에 위치한 값이 오른쪽에 위치한 값보다 작거나 같은 경우 '참'으로 판단합니다.",
"function_create": "자주 쓰는 코드를 이 블록 아래에 조립하여 함수로 만듭니다. [함수 정의하기]의 오른쪽 빈칸에 [이름]을 조립하여 함수의 이름을 정할 수 있습니다. 함수를 실행하는 데 입력값이 필요한 경우 빈칸에 [문자/숫자값], [판단값]을 조립하여 매개변수로 사용합니다.",
@@ -5399,7 +5410,7 @@ Lang.Helper = {
"calc_share": "앞 수에서 뒤 수를 나누어 생긴 몫을 의미합니다.",
"calc_mod": "앞 수에서 뒤 수를 나누어 생긴 나머지를 의미합니다.",
"calc_operation": "입력한 수에 대한 다양한 수학식의 계산값입니다. (제곱, 루트, 사인값, 코사인값, 탄젠트값, 아크사인값, 아크코사인값, 아크탄젠트값, 로그값, 자연로그값, 소수점 부분, 소수점 버림값, 소수점 올림값, 소수점 반올림값, 펙토리얼값, 절대값)",
- "get_date": "현재 연도, 월, 일, 시각과 같이 시간에 대한 값입니다.",
+ "get_date": "현재 연도, 월, 일, 요일, 시각과 같이 시간에 대한 값입니다.",
"distance_something": "해당 오브젝트와 선택한 오브젝트 또는 마우스 포인터 간의 거릿값입니다.",
"get_sound_duration": "선택한 소리의 길이(초) 값입니다.",
"get_user_name": "작품을 실행하고 있는 사용자의 이름값입니다.",
@@ -5411,6 +5422,7 @@ Lang.Helper = {
"get_canvas_input_value": "사용자가 '대답 창'에 입력한 값입니다.",
"set_visible_answer": "대답 창'을 실행화면에서 숨기거나 보이게 합니다.",
"combine_something": "입력한 두 값을 결합한 값입니다.",
+ "reverse_of_string": "입력한 값을 뒤집은 값입니다.",
"get_variable": "선택한 변수에 저장된 값입니다.",
"change_variable": "선택한 변수에 입력한 값을 더합니다.",
"set_variable": "선택한 변수의 값을 입력한 값으로 정합니다.",
@@ -5454,6 +5466,7 @@ Lang.Helper = {
"char_at": "입력한 값에서 입력한 숫자 번째의 글자 값입니다. (공백을 포함합니다.)",
"length_of_string": "입력한 값의 공백을 포함한 글자 수입니다.",
"substring": "입력한 값에서 입력한 범위 내의 글자 값입니다. (공백을 포함합니다.)",
+ "count_match_string": "입력한 값에서 지정한 값의 글자 수이며, 영문의 경우 대문자와 소문자를 구분하여 수를 셉니다.",
"replace_string": "입력한 값에서 지정한 값을 찾아 추가로 입력한 값으로 모두 바꾼 값입니다. (영문 입력 시 대소문자를 구분합니다.)",
"index_of_string": "입력한 값에서 지정한 값이 처음으로 등장하는 위치 값입니다. (공백을 포함합니다.)",
"change_string_case": "입력한 영문의 모든 알파벳을 대문자 또는 소문자로 바꾼 값입니다.",
@@ -5980,18 +5993,21 @@ Lang.template = {
"iboard_rgb_led": "RGB LED의 %1 LED %2 %3",
"iboard_set_tone": "디지털 %1 번 핀의 버저를 %2 %3 음으로 %4 초 연주하기 %5",
"iboard_toggle_led": "디지털 %1 번 핀 %2 %3",
- "bitbrick_sensor_value": "%1 값",
- "bitbrick_is_touch_pressed": "버튼 %1 이(가) 눌렸는가?",
- "bitbrick_turn_off_color_led": "컬러 LED 끄기 %1",
- "bitbrick_turn_on_color_led_by_rgb": "컬러 LED 켜기 R %1 G %2 B %3 %4",
- "bitbrick_turn_on_color_led_by_picker": "컬러 LED 색 %1 로 정하기 %2",
- "bitbrick_turn_on_color_led_by_value": "컬러 LED 켜기 색 %1 로 정하기 %2",
- "bitbrick_buzzer": "버저음 %1 내기 %2",
- "bitbrick_turn_off_all_motors": "모든 모터 끄기 %1",
- "bitbrick_dc_speed": "DC 모터 %1 속도 %2 %3",
- "bitbrick_dc_direction_speed": "DC 모터 %1 %2 방향 속력 %3 %4",
- "bitbrick_servomotor_angle": "서보 모터 %1 각도 %2 %3",
+ "bitbrick_when_button_pressed": "%1 버튼 %2 눌러졌을 때",
+ "bitbrick_when_sensor_get_value": "%1 %2 값 %3 %4 일 때",
+ "bitbrick_is_touch_pressed": "버튼 %1 이(가) %2 인가?",
+ "bitbrick_is_sensor_value_compare": '%1 값 %2 %3 인가?',
+ "bitbrick_sensor_value": "%1 값",
"bitbrick_convert_scale": "변환 %1 값 %2 ~ %3 에서 %4 ~ %5",
+ "bitbrick_turn_on_color_led_by_rgb": "엘이디를 빨강 %1 초록 %2 파랑 %3 %4 (으)로 켜기",
+ "bitbrick_turn_on_color_led_by_picker": "엘이디를 %1 (으)로 켜기 %2",
+ "bitbrick_turn_on_color_led_by_value": "엘이디를 %1 (으)로 켜기 %2",
+ "bitbrick_turn_off_color_led": "엘이디 끄기 %1",
+ "bitbrick_buzzer": "버저음 %1 내기 %2",
+ "bitbrick_servomotor_angle": "서보모터 %1 각도 %2 %3",
+ "bitbrick_dc_direction_speed": "디씨모터 %1 방향 %2 속력 %3 %4",
+ "bitbrick_dc_speed": "디씨모터 %1 속도 %2 %3",
+ "bitbrick_turn_off_all_motors": "모든 모터 멈추기 %1",
"start_drawing": "그리기 시작하기 %1",
"stop_drawing": "그리기 멈추기 %1",
"set_color": "붓의 색을 %1 (으)로 정하기 %2",
@@ -6031,10 +6047,12 @@ Lang.template = {
"get_project_timer_value": "%1 %2",
"char_at": "%1 %2 %3 %4 %5",
"length_of_string": "%1 %2 %3",
+ "reverse_of_string": "%1 %2 %3",
"substring": "%1 %2 %3 %4 %5 %6 %7",
"replace_string": "%1 %2 %3 %4 %5 %6 %7",
"change_string_case": "%1 %2 %3 %4 %5",
"index_of_string": "%1 %2 %3 %4 %5",
+ "count_match_string": "%1 %2 %3 %4",
"combine_something": "%1 %2 %3 %4 %5",
"get_sound_volume": "%1 %2",
"quotient_and_mod": "%1 %2 %3 %4 %5 %6",
@@ -6248,8 +6266,10 @@ Lang.template = {
"turtle_turn_unit_with_radius_in_direction": "%1 으로 %2 %3 반지름 %4 cm를 %5 방향으로 돌기 %6",
"turtle_value": "%1",
"is_clicked": "%1",
+ "is_object_clicked": "%1",
"is_press_some_key": "%1 %2",
"reach_something": "%1 %2 %3",
+ "is_type": '%1 %2 %3 %4',
"boolean_comparison": "%1 %2 %3",
"boolean_equal": "%1 %2 %3",
"boolean_bigger": "%1 %2 %3",
@@ -6790,7 +6810,8 @@ Lang.TextCoding = {
"alert_list_contains_exceed_length_value": "리스트 항목에 15자리 이상의 수가 입력되어 있으면 모드 변환을 할 수 없습니다.",
"alert_function_name_empty_text_add_change": "함수명에 공백(띄어쓰기)이 포함될 수 없습니다.",
"alert_no_save_on_error": "문법 오류가 존재하여 작품을 저장할 수 없습니다.",
- "alert_api_no_support": "작품에 확장 블록이 사용된 경우에는 엔트리파이선 모드로 변경할 수 없습니다.",
+ "alert_api_no_support":
+ '작품에 엔트리파이썬에서 지원하지 않는 \n블록이 조립되어 있습니다. \n해당 블록을 삭제하고 만들기 모드를 변경할까요?',
"warn_unnecessary_arguments": "&(calleeName)(); 는 괄호 사이에 값이 입력될 필요가 없는 명령어 입니다. (line:&(lineNumber))",
"python_code": " 오브젝트의 파이선 코드",
"eof": "줄바꿈",
diff --git a/extern/lang/en.js b/extern/lang/en.js
index 4cd8e21f76..9887c9cec7 100644
--- a/extern/lang/en.js
+++ b/extern/lang/en.js
@@ -722,6 +722,8 @@ Lang.Blocks = {
"CALC_char_at_3": "",
"CALC_length_of_string_1": "length of",
"CALC_length_of_string_2": "",
+ "CALC_reverse_of_string_1": "Reverse",
+ "CALC_reverse_of_string_2": "",
"CALC_substring_1": "substring of",
"CALC_substring_2": "from",
"CALC_substring_3": "to",
@@ -736,6 +738,8 @@ Lang.Blocks = {
"CALC_change_string_case_3": " ",
"CALC_change_string_case_sub_1": "uppercase",
"CALC_change_string_case_sub_2": "lowercase",
+ "CALC_count_match_string_1": "count of",
+ "CALC_count_match_string_2": "in",
"CALC_index_of_string_1": "index of",
"CALC_index_of_string_2": "in",
"CALC_index_of_string_3": "",
@@ -1109,6 +1113,10 @@ Lang.Blocks = {
"arduino_lite_connect": "Web Connection",
"arduino_lite_disconnect": "Cancel",
"arduino_lite_guide": "• connection guide",
+ "JUDGEMENT_is_object_clicked": "Object clicked?",
+ "JUDGEMENT_is_type_1": "is",
+ "JUDGEMENT_is_type_2": "?",
+ "is_type_number": "number",
};
Lang.video_body_coord_params = {
"left_eye": "Left Eye",
@@ -4582,8 +4590,10 @@ Lang.Helper = {
"sound_volume_set": "Sets the volume of all the sounds played as much as the input percentage.",
"sound_silent_all": "Stops all sounds currently playing.",
"is_clicked": "Checks whether mouse is clicked.",
+ "is_object_clicked": "Checks whether object is clicked.",
"is_press_some_key": "Checks whether an selected key is pressed.",
"reach_something": "Checks whether the object reaches the selected point.",
+ "is_type": "Checks whether the input text is a number. If the input text is a number, it is judged as ’True’.",
"is_included_in_list": "Checks whether selected list contains the input value.",
"boolean_basic_operator": "Checks whether the value on the left is the same as the value on the right.",
"function_create": "Define a function by placing frequently used sets of blocks under this block. Place [name] next to [Define function] to give function a name. Pass on number of text values by placing [numeric/text value] block. Pass on boolean value of true or false by placing the [boolean value] block.",
@@ -4606,7 +4616,7 @@ Lang.Helper = {
"calc_share": "Reports the quotient occurring from first number divided by the second number. ",
"calc_mod": "Reports the remainder occurring from the first number divided by the second number.",
"calc_operation": "Reports calculated values of a variety of equations relating to input numbers.",
- "get_date": "Reports the values regarding the current year, month, day and time.",
+ "get_date": "Reports the values regarding the current year, month, day, day of the week and time.",
"distance_something": "Reports the distance between the object and the selected object.",
"get_sound_duration": "Reports the time length of the selected sound.",
"get_user_name": "Reports the username who runs the project.",
@@ -4619,6 +4629,7 @@ Lang.Helper = {
"get_canvas_input_value": "Reports the answer which is taken after the object asked.",
"set_visible_answer": "Hide or show the response window.",
"combine_something": "Combines two input texts.",
+ "reverse_of_string": "Reports the text that reversed input text.",
"get_variable": "Reports the value of the selected variable.",
"change_variable": "Adds the input value to the selected variable.",
"set_variable": "Sets the value of the selected variable to the input value.",
@@ -4662,6 +4673,7 @@ Lang.Helper = {
"char_at": "Reports the letter of the input text.",
"length_of_string": "Reports the length of input text including space.",
"substring": "Reports the text extracted from the input text between two specified indices. (includes space)",
+ "count_match_string": "Reports the number of letters in a specific text in the input text case sensitively.",
"replace_string": "Reports the text that replaced all the input text with another input text. (distinguishes uppercase to lowercase)",
"index_of_string": "Reports the index of first input text in second input text. (includes space)",
"change_string_case": "Reports the text that converted to uppercase or lowercase.",
@@ -5188,18 +5200,21 @@ Lang.template = {
"iboard_rgb_led": " %1 LED %2 %3",
"iboard_set_tone": "Play tone pin %1 on note %2 octave %3 beat %4 %5",
"iboard_toggle_led": "Digital %1 Pin %2 %3",
- "bitbrick_sensor_value": "Value %1",
- "bitbrick_is_touch_pressed": "Pressed %1 button? ",
- "bitbrick_turn_off_color_led": "Turn off color LED %1",
- "bitbrick_turn_on_color_led_by_rgb": "Turn on color LED R %1 G %2 B %3 %4",
- "bitbrick_turn_on_color_led_by_picker": "Select %1 for color LED %2",
- "bitbrick_turn_on_color_led_by_value": "Turn on color LED, select %1 %2",
- "bitbrick_buzzer": "Buzz for %1 secs %2",
- "bitbrick_turn_off_all_motors": "Turn off all motors %1",
- "bitbrick_dc_speed": "DC motor %1 speed %2 %3",
- "bitbrick_dc_direction_speed": "DC motor %1 %2 direction speed %3 %4",
- "bitbrick_servomotor_angle": "Servo motor %1 angle %2 %3",
- "bitbrick_convert_scale": "Convert %1 value from %2~%3 to %4~%4",
+ "bitbrick_when_button_pressed": "%1 when button %2",
+ "bitbrick_when_sensor_get_value": "%1 when %2 value %3 %4",
+ "bitbrick_is_touch_pressed": "button %1 %2?",
+ "bitbrick_is_sensor_value_compare": "%1 %2 %3?",
+ "bitbrick_sensor_value": "%1 value",
+ "bitbrick_convert_scale": "map %1 value from %2 ~ %3 to %4 ~ %5",
+ "bitbrick_turn_on_color_led_by_rgb": "set LED color to Red %1 Green %2 Blue %3 %4",
+ "bitbrick_turn_on_color_led_by_picker": "set LED color to %1 %2",
+ "bitbrick_turn_on_color_led_by_value": "set LED color %1 %2",
+ "bitbrick_turn_off_color_led": "turn off LED %1",
+ "bitbrick_buzzer": "buzz note %1 %2",
+ "bitbrick_servomotor_angle": "servo motor %1 degree %2 %3",
+ "bitbrick_dc_direction_speed": "dc motor %1 direction %2 speed %3 %4",
+ "bitbrick_dc_speed": "dc motor %1 velocity %2 %3",
+ "bitbrick_turn_off_all_motors": "stop all motors %1",
"start_drawing": "Start drawing %1",
"stop_drawing": "Stop drawing %1",
"set_color": "Set brush color to %1 %2",
@@ -5241,9 +5256,11 @@ Lang.template = {
"get_project_timer_value": "%1 %2",
"char_at": "%1 %2 %3 %4 %5",
"length_of_string": "%1 %2 %3",
+ "reverse_of_string": "%1 %2 %3",
"substring": "%1 %2 %3 %4 %5 %6 %7",
"replace_string": "%1 %2 %3 %4 %5 %6 %7",
"change_string_case": "%1 %2 %3 %4 %5",
+ "count_match_string": "%2 %3 %4 %1",
"index_of_string": "%1 %2 %3 %4 %5",
"combine_something": "%1 %2 %3 %4 %5",
"get_sound_volume": "%1 %2",
@@ -5458,8 +5475,10 @@ Lang.template = {
"turtle_turn_unit_with_radius_in_direction": "turn %1 %2 %3 with radius %4 cm in %5 direction %6",
"turtle_value": "%1",
"is_clicked": "%1",
+ "is_object_clicked": "%1",
"is_press_some_key": "%1 %2",
"reach_something": "%1 %2 %3",
+ "is_type": '%1 %2 %3 %4',
"boolean_comparison": "%1 %2 %3",
"boolean_equal": "%1 %2 %3",
"boolean_bigger": "%1 %2 %3",
@@ -6001,7 +6020,7 @@ Lang.TextCoding = {
"alert_list_contains_exceed_length_value": "You can't convert into the text mode if more than 15 digits are entered in the list item.",
"alert_function_name_empty_text_add_change": "The empty text can't be included in function name.",
"alert_no_save_on_error": "The code with an error can't save.",
- "alert_api_no_support": "You can not convert into the text mode when extension blocks are used in your project.",
+ "alert_api_no_support": "The project contains blocks \nthat are not supported by Entry-Python. \nDelete all those blocks and \nchange to Entry-Python mode?",
"warn_unnecessary_arguments": "&(calleeName)(); command doesn't require value within parentheses. (line:&(lineNumber))",
"python_code": "'s python code",
"eof": "line change",
diff --git a/extern/lang/jp.js b/extern/lang/jp.js
index 81a1f08a42..276e6c6079 100644
--- a/extern/lang/jp.js
+++ b/extern/lang/jp.js
@@ -5984,18 +5984,21 @@ Lang.template = {
"iboard_rgb_led": " %1 LED %2 %3",
"iboard_set_tone": "Play tone pin %1 on note %2 octave %3 beat %4 %5",
"iboard_toggle_led": "Digital %1 Pin %2 %3",
- "bitbrick_sensor_value": "Value %1",
- "bitbrick_is_touch_pressed": "Pressed %1 button? ",
- "bitbrick_turn_off_color_led": "Turn off color LED %1",
- "bitbrick_turn_on_color_led_by_rgb": "Turn on color LED R %1 G %2 B %3 %4",
- "bitbrick_turn_on_color_led_by_picker": "Select %1 for color LED %2",
- "bitbrick_turn_on_color_led_by_value": "Turn on color LED, select %1 %2",
- "bitbrick_buzzer": "Buzz for %1 secs %2",
- "bitbrick_turn_off_all_motors": "Turn off all motors %1",
- "bitbrick_dc_speed": "DC motor %1 speed %2 %3",
- "bitbrick_dc_direction_speed": "DC motor %1 %2 direction speed %3 %4",
- "bitbrick_servomotor_angle": "Servo motor %1 angle %2 %3",
- "bitbrick_convert_scale": "Convert %1 value from %2~%3 to %4~%4",
+ "bitbrick_when_button_pressed": "%1 when button %2",
+ "bitbrick_when_sensor_get_value": "%1 when %2 value %3 %4",
+ "bitbrick_is_touch_pressed": "button %1 %2?",
+ "bitbrick_is_sensor_value_compare": "%1 %2 %3?",
+ "bitbrick_sensor_value": "%1 value",
+ "bitbrick_convert_scale": "map %1 value from %2 ~ %3 to %4 ~ %5",
+ "bitbrick_turn_on_color_led_by_rgb": "set LED color to Red %1 Green %2 Blue %3 %4",
+ "bitbrick_turn_on_color_led_by_picker": "set LED color to %1 %2",
+ "bitbrick_turn_on_color_led_by_value": "set LED color %1 %2",
+ "bitbrick_turn_off_color_led": "turn off LED %1",
+ "bitbrick_buzzer": "buzz note %1 %2",
+ "bitbrick_servomotor_angle": "servo motor %1 degree %2 %3",
+ "bitbrick_dc_direction_speed": "dc motor %1 direction %2 speed %3 %4",
+ "bitbrick_dc_speed": "dc motor %1 velocity %2 %3",
+ "bitbrick_turn_off_all_motors": "stop all motors %1",
"start_drawing": "描きはじめる %1",
"stop_drawing": "描きおえる %1",
"set_color": "筆の色を%1にする %2",
diff --git a/extern/lang/ko.js b/extern/lang/ko.js
index 971ebb4699..b2b4bdfb0b 100644
--- a/extern/lang/ko.js
+++ b/extern/lang/ko.js
@@ -590,13 +590,13 @@ Lang.Blocks = {
blacksmith_toggle_off: '끄기',
blacksmith_lcd_first_line: '첫 번째',
blacksmith_lcd_seconds_line: '두 번째',
- BITBRICK_light: '밝기센서',
- BITBRICK_IR: '거리센서',
+ BITBRICK_light: '밝기 센서',
+ BITBRICK_IR: '적외선 센서',
BITBRICK_touch: '버튼',
BITBRICK_potentiometer: '가변저항',
- BITBRICK_MIC: '소리감지센서',
- BITBRICK_UserSensor: '사용자입력',
- BITBRICK_UserInput: '사용자입력',
+ BITBRICK_MIC: '소리 센서',
+ BITBRICK_UserSensor: '사용자 입력',
+ BITBRICK_UserInput: '사용자 입력',
BITBRICK_dc_direction_ccw: '반시계',
BITBRICK_dc_direction_cw: '시계',
chocopi_control_event_pressed: '누를 때',
@@ -756,6 +756,7 @@ Lang.Blocks = {
CALC_get_date_day: '일',
CALC_get_date_hour: '시각(시)',
CALC_get_date_minute: '시각(분)',
+ CALC_get_date_day_of_week: '요일',
CALC_get_date_month: '월',
CALC_get_date_second: '시각(초)',
CALC_get_date_year: '연도',
@@ -809,12 +810,16 @@ Lang.Blocks = {
JUDGEMENT_boolean_or: '또는',
JUDGEMENT_false: ' 거짓 ',
JUDGEMENT_is_clicked: '마우스를 클릭했는가?',
+ JUDGEMENT_is_object_clicked: '오브젝트를 클릭했는가?',
JUDGEMENT_is_press_some_key_1: '',
JUDGEMENT_is_press_some_key_2: '키가 눌러져 있는가?',
JUDGEMENT_reach_something_1: '',
JUDGEMENT_reach_something_2: '에 닿았는가?',
+ JUDGEMENT_is_type_1: '(이)가',
+ JUDGEMENT_is_type_2: '인가?',
JUDGEMENT_true: ' 참 ',
JUDGEMENT_is_boost_mode: '부스트모드가 켜져 있는가?',
+ is_type_number: '숫자',
LOOKS: '생김새',
LOOKS_change_scale_percent_1: '크기를',
LOOKS_change_scale_percent_2: '만큼 바꾸기',
@@ -1539,6 +1544,8 @@ Lang.Blocks = {
CALC_char_at_3: '번째 글자',
CALC_length_of_string_1: '',
CALC_length_of_string_2: '의 글자 수',
+ CALC_reverse_of_string_1: '',
+ CALC_reverse_of_string_2: '을(를) 뒤집기',
CALC_substring_1: '',
CALC_substring_2: '의',
CALC_substring_3: '번째 글자부터',
@@ -1553,6 +1560,8 @@ Lang.Blocks = {
CALC_change_string_case_3: ' ',
CALC_change_string_case_sub_1: '대문자',
CALC_change_string_case_sub_2: '소문자',
+ CALC_count_match_string_1: '에서',
+ CALC_count_match_string_2: '의 글자 수',
CALC_index_of_string_1: '',
CALC_index_of_string_2: '에서',
CALC_index_of_string_3: '의 시작 위치',
@@ -5907,8 +5916,10 @@ Lang.Helper = {
sound_volume_set: '작품에서 재생되는 모든 소리의 크기를 입력한 값으로 정합니다.',
sound_silent_all: '재생 중인 모든 소리를 멈춥니다.',
is_clicked: '마우스를 클릭한 경우 ‘참’으로 판단합니다.',
+ is_object_clicked: '오브젝트를 클릭한 경우 ‘참’으로 판단합니다.',
is_press_some_key: '선택한 키가 눌려져 있는 경우 ‘참’으로 판단합니다.',
reach_something: '해당 오브젝트가 선택한 항목과 닿은 경우 ‘참’으로 판단합니다.',
+ is_type: '입력한 값이 숫자라면 ‘참’으로 판단합니다.',
is_included_in_list:
"선택한 리스트가 입력한 값을 가진 항목을 포함하는 경우 '참'으로 판단합니다.",
boolean_basic_operator:
@@ -5941,7 +5952,7 @@ Lang.Helper = {
calc_mod: '앞 수에서 뒤 수를 나누어 생긴 나머지를 의미합니다.',
calc_operation:
'입력한 수에 대한 다양한 수학식의 계산값입니다. (제곱, 루트, 사인값, 코사인값, 탄젠트값, 아크사인값, 아크코사인값, 아크탄젠트값, 로그값, 자연로그값, 소수점 부분, 소수점 버림값, 소수점 올림값, 소수점 반올림값, 펙토리얼값, 절대값)',
- get_date: '현재 연도, 월, 일, 시각과 같이 시간에 대한 값입니다.',
+ get_date: '현재 연도, 월, 일, 요일, 시각과 같이 시간에 대한 값입니다.',
distance_something: '해당 오브젝트와 선택한 오브젝트 또는 마우스 포인터 간의 거릿값입니다.',
get_sound_duration: '선택한 소리의 길이(초) 값입니다.',
get_user_name: '작품을 실행하고 있는 사용자의 아이디 값입니다.',
@@ -5956,6 +5967,7 @@ Lang.Helper = {
get_canvas_input_value: "사용자가 '대답 창'에 입력한 값입니다.",
set_visible_answer: "대답 창'을 실행화면에서 숨기거나 보이게 합니다.",
combine_something: '입력한 두 값을 결합한 값입니다.',
+ reverse_of_string: '입력한 값을 뒤집은 값입니다.',
get_variable: '선택한 변수에 저장된 값입니다.',
change_variable: '선택한 변수에 입력한 값을 더합니다.',
set_variable: '선택한 변수의 값을 입력한 값으로 정합니다.',
@@ -6017,6 +6029,7 @@ Lang.Helper = {
char_at: '입력한 값에서 입력한 숫자 번째의 글자 값입니다. (공백을 포함합니다.)',
length_of_string: '입력한 값의 공백을 포함한 글자 수입니다.',
substring: '입력한 값에서 입력한 범위 내의 글자 값입니다. (공백을 포함합니다.)',
+ count_match_string: '입력한 값에서 지정한 값의 글자 수이며, 영문의 경우 대문자와 소문자를 구분하여 수를 셉니다.',
replace_string:
'입력한 값에서 지정한 값을 찾아 추가로 입력한 값으로 모두 바꾼 값입니다. (영문 입력 시 대소문자를 구분합니다.)',
index_of_string:
@@ -6490,6 +6503,7 @@ Lang.Helper = {
'비트브릭 센서를 사용할 수 있는 블록입니다. 센서값의 범위는 0 ~1023입니다. 메인보드에 연결된 센서의 종류와 포트번호를 자동으로 인식합니다. 블록 안의 화살표를 눌러 사용하려고 하는 센서를 선택하세요.',
bitbrick_convert_scale: '비트브릭 센서의 값의 범위를 바꿀 수 있습니다.',
bitbrick_is_touch_pressed: '비트브릭 센서 중 버튼을 눌렀을 경우 ‘참’으로 판단합니다.',
+ bitbrick_is_sensor_value_compare: '비트브릭 센서 중 버튼을 눌렀을 경우 ‘참’으로 판단합니다.',
bitbrick_turn_off_color_led: '비트브릭 엘이디를 끕니다.',
bitbrick_turn_on_color_led_by_rgb:
'비트브릭 엘이디를 빛의 삼원색인 빨강,초록,파랑을 혼합하여 켭니다. 값의 범위는 0 ~ 255입니다.',
@@ -6889,18 +6903,21 @@ Lang.template = {
iboard_rgb_led: 'RGB LED의 %1 LED %2 %3',
iboard_set_tone: '디지털 %1 번 핀의 버저를 %2 %3 음으로 %4 초 연주하기 %5',
iboard_toggle_led: '디지털 %1 번 핀 %2 %3',
- bitbrick_sensor_value: '%1 값',
- bitbrick_is_touch_pressed: '버튼 %1 이(가) 눌렸는가?',
- bitbrick_turn_off_color_led: '컬러 LED 끄기 %1',
- bitbrick_turn_on_color_led_by_rgb: '컬러 LED 켜기 R %1 G %2 B %3 %4',
- bitbrick_turn_on_color_led_by_picker: '컬러 LED 색 %1 로 정하기 %2',
- bitbrick_turn_on_color_led_by_value: '컬러 LED 켜기 색 %1 로 정하기 %2',
- bitbrick_buzzer: '버저음 %1 내기 %2',
- bitbrick_turn_off_all_motors: '모든 모터 끄기 %1',
- bitbrick_dc_speed: 'DC 모터 %1 속도 %2 %3',
- bitbrick_dc_direction_speed: 'DC 모터 %1 %2 방향 속력 %3 %4',
- bitbrick_servomotor_angle: '서보 모터 %1 각도 %2 %3',
+ bitbrick_when_button_pressed: '%1 버튼 %2 눌러졌을 때',
+ bitbrick_when_sensor_get_value: '%1 %2 값 %3 %4 일 때',
+ bitbrick_is_touch_pressed: '버튼 %1 이(가) %2 인가?',
+ bitbrick_is_sensor_value_compare: '%1 값 %2 %3 인가?',
+ bitbrick_sensor_value: '%1 값',
bitbrick_convert_scale: '변환 %1 값 %2 ~ %3 에서 %4 ~ %5',
+ bitbrick_turn_on_color_led_by_rgb: '엘이디를 빨강 %1 초록 %2 파랑 %3 %4 (으)로 켜기',
+ bitbrick_turn_on_color_led_by_picker: '엘이디를 %1 (으)로 켜기 %2',
+ bitbrick_turn_on_color_led_by_value: '엘이디를 %1 (으)로 켜기 %2',
+ bitbrick_turn_off_color_led: '엘이디 끄기 %1',
+ bitbrick_buzzer: '버저음 %1 내기 %2',
+ bitbrick_servomotor_angle: '서보모터 %1 각도 %2 %3',
+ bitbrick_dc_direction_speed: '디씨모터 %1 방향 %2 속력 %3 %4',
+ bitbrick_dc_speed: '디씨모터 %1 속도 %2 %3',
+ bitbrick_turn_off_all_motors: "모든 모터 멈추기 %1",
start_drawing: '그리기 시작하기 %1',
stop_drawing: '그리기 멈추기 %1',
set_color: '붓의 색을 %1 (으)로 정하기 %2',
@@ -6945,6 +6962,7 @@ Lang.template = {
substring: '%1 %2 %3 %4 %5 %6 %7',
replace_string: '%1 %2 %3 %4 %5 %6 %7',
change_string_case: '%1 %2 %3 %4 %5',
+ count_match_string: '%1 %2 %3 %4',
index_of_string: '%1 %2 %3 %4 %5',
combine_something: '%1 %2 %3 %4 %5',
get_sound_volume: '%1 %2',
@@ -7254,8 +7272,10 @@ Lang.template = {
turtle_turn_unit_with_radius_in_direction: '%1 으로 %2 %3 반지름 %4 cm를 %5 방향으로 돌기 %6',
turtle_value: '%1',
is_clicked: '%1',
+ is_object_clicked: '%1',
is_press_some_key: '%1 %2',
reach_something: '%1 %2 %3',
+ is_type: '%1 %2 %3 %4',
boolean_comparison: '%1 %2 %3',
boolean_equal: '%1 %2 %3',
boolean_bigger: '%1 %2 %3',
@@ -7821,7 +7841,7 @@ Lang.TextCoding = {
alert_function_name_empty_text_add_change: '함수명에 공백(띄어쓰기)이 포함될 수 없습니다.',
alert_no_save_on_error: '문법 오류가 존재하여 작품을 저장할 수 없습니다.',
alert_api_no_support:
- '확장, 데이터분석, 인공지능 블록이 조립된 경우에는\n엔트리파이선 모드로 변경할 수 없습니다.\n해당 블록을 모두 삭제하고 엔트리파이선 모드로 변경할까요?',
+ '작품에 엔트리파이썬에서 지원하지 않는 \n블록이 조립되어 있습니다. \n해당 블록을 삭제하고 만들기 모드를 변경할까요?',
warn_unnecessary_arguments:
'&(calleeName)(); 는 괄호 사이에 값이 입력될 필요가 없는 명령어 입니다. (line:&(lineNumber))',
python_code: ' 오브젝트의 파이선 코드',
diff --git a/extern/lang/vn.js b/extern/lang/vn.js
index 5b2a5d32bc..2986523405 100644
--- a/extern/lang/vn.js
+++ b/extern/lang/vn.js
@@ -5983,18 +5983,19 @@ Lang.template = {
"iboard_rgb_led": " %1 LED %2 %3",
"iboard_set_tone": "Play tone pin %1 on note %2 octave %3 beat %4 %5",
"iboard_toggle_led": "Digital %1 Pin %2 %3",
+ "bitbrick_is_touch_pressed": "nhấn nút %1 %2?",
+ "bitbrick_is_sensor_value_compare": "nhấn nút %1 %2 %3?",
"bitbrick_sensor_value": "giá trị %1",
- "bitbrick_is_touch_pressed": "nhấn nút %1?",
- "bitbrick_turn_off_color_led": "tắt màu LED %1",
+ "bitbrick_convert_scale": "đổi giá trị %1 từ %2~%3 đến %4~%5",
"bitbrick_turn_on_color_led_by_rgb": "mở màu LED R%1 G %2 B %3 %4",
"bitbrick_turn_on_color_led_by_picker": "chọn %1 cho màu LED %2",
"bitbrick_turn_on_color_led_by_value": "mở màu LED, chọn %1 %2",
+ "bitbrick_turn_off_color_led": "tắt màu LED %1",
"bitbrick_buzzer": "âm buzz %1 giây %2",
- "bitbrick_turn_off_all_motors": "tắt tất cả các động cơ %1",
- "bitbrick_dc_speed": "động cơ DC %1 tốc độ %2 %3",
- "bitbrick_dc_direction_speed": "động cơ DC %1 %2 tốc độ phương hướng %3 %4",
"bitbrick_servomotor_angle": "động cơ servo %1 góc độ %2 %3",
- "bitbrick_convert_scale": "đổi giá trị %1 từ %2~%3 đến %4~%4",
+ "bitbrick_dc_direction_speed": "động cơ DC %1 %2 tốc độ phương hướng %3 %4",
+ "bitbrick_dc_speed": "động cơ DC %1 tốc độ %2 %3",
+ "bitbrick_turn_off_all_motors": "tắt tất cả các động cơ %1",
"start_drawing": "bắt đầu vẽ %1",
"stop_drawing": "ngừng vẽ %1",
"set_color": "thiết lập màu cọ bằng %1 %2",
@@ -6796,7 +6797,7 @@ Lang.TextCoding = {
"alert_list_contains_exceed_length_value": "You can't convert into the text mode if more than 15 digits are entered in the list item.",
"alert_function_name_empty_text_add_change": "The empty text can't be included in function name.",
"alert_no_save_on_error": "The code with an error can't save.",
- "alert_api_no_support": "You can not convert into the text mode when extension blocks are used in your project.",
+ "alert_api_no_support": "The project contains blocks \nthat are not supported by Entry-Python. \nDelete all those blocks and \nchange to Entry-Python mode?",
"warn_unnecessary_arguments": "&(calleeName)(); command doesn't require value within parentheses. (line:&(lineNumber))",
"python_code": "'s python code",
"eof": "line change",
diff --git a/extern/util/static.js b/extern/util/static.js
index 9f77604bb6..3c7e597d2d 100644
--- a/extern/util/static.js
+++ b/extern/util/static.js
@@ -318,8 +318,10 @@ EntryStatic.getAllBlocks = function() {
category: 'judgement',
blocks: [
'is_clicked',
+ 'is_object_clicked',
'is_press_some_key',
'reach_something',
+ 'is_type',
'boolean_basic_operator',
'boolean_and_or',
'boolean_not',
@@ -345,11 +347,13 @@ EntryStatic.getAllBlocks = function() {
'get_user_name',
'get_nickname',
'length_of_string',
+ 'count_match_string',
'combine_something',
'char_at',
'substring',
'index_of_string',
'replace_string',
+ 'reverse_of_string',
'change_string_case',
'get_block_count',
],
diff --git a/images/beta_tag.svg b/images/beta_tag.svg
index 234128f399..136005fd4a 100644
--- a/images/beta_tag.svg
+++ b/images/beta_tag.svg
@@ -1,10 +1 @@
-
+
\ No newline at end of file
diff --git a/images/block_icon/hardware_bzr2.svg b/images/block_icon/hardware_bzr2.svg
index d63f19d600..0d83dad9c7 100644
--- a/images/block_icon/hardware_bzr2.svg
+++ b/images/block_icon/hardware_bzr2.svg
@@ -1,3385 +1 @@
-
-
-
-
-
-
-
-
-
-
-]>
-
+
\ No newline at end of file
diff --git a/images/block_icon/hardware_dc.svg b/images/block_icon/hardware_dc.svg
index a9c6c752e5..b282919372 100644
--- a/images/block_icon/hardware_dc.svg
+++ b/images/block_icon/hardware_dc.svg
@@ -1,3398 +1 @@
-
-
-
-
-
-
-
-
-
-
-]>
-
+
\ No newline at end of file
diff --git a/images/block_icon/hardware_led.svg b/images/block_icon/hardware_led.svg
index 3013e95aa8..acaec5f82b 100644
--- a/images/block_icon/hardware_led.svg
+++ b/images/block_icon/hardware_led.svg
@@ -1,3406 +1 @@
-
-
-
-
-
-
-
-
-
-
-]>
-
+
\ No newline at end of file
diff --git a/images/coalaboard.png b/images/coalaboard.png
new file mode 100644
index 0000000000..3226195095
Binary files /dev/null and b/images/coalaboard.png differ
diff --git a/images/hardware/KKMOO.png b/images/hardware/KKMOO.png
index facd3a8d50..426e2dcd57 100644
Binary files a/images/hardware/KKMOO.png and b/images/hardware/KKMOO.png differ
diff --git a/images/hw/bitbrick.png b/images/hw/bitbrick.png
index 22905bae53..87bba5bd06 100644
Binary files a/images/hw/bitbrick.png and b/images/hw/bitbrick.png differ
diff --git a/images/hw/coalaboard.png b/images/hw/coalaboard.png
new file mode 100644
index 0000000000..3226195095
Binary files /dev/null and b/images/hw/coalaboard.png differ
diff --git a/images/hw/iCOBOT_Front.png b/images/hw/iCOBOT_Front.png
index 7d0c6a5dd2..9dab5474fa 100644
Binary files a/images/hw/iCOBOT_Front.png and b/images/hw/iCOBOT_Front.png differ
diff --git a/scripts/deploy.sh b/scripts/deploy.sh
index eca9f70f36..578caa810f 100644
--- a/scripts/deploy.sh
+++ b/scripts/deploy.sh
@@ -25,7 +25,8 @@ then
# git push --force --quiet "https://${GH_TOKEN}@${GH_REF}" build --tags
else
echo "deploy branch's name is $deployName"
- git checkout -b "$deployName"
+ git checkout -b "$deployName"
+ echo "Entry Js deploy $deployName" > ${GITHUB_RUN_NUMBER}
# git push --delete "https://${GH_TOKEN}@${GH_REF}" "$deployName"
git add .
git commit -m "Entry Js deploy $deployName"
diff --git a/src/class/engine.js b/src/class/engine.js
index 833118753e..49b482c849 100644
--- a/src/class/engine.js
+++ b/src/class/engine.js
@@ -22,12 +22,15 @@ Entry.Engine = class Engine {
_addEventListener('canvasClick', () => this.fireEvent('mouse_clicked'));
_addEventListener('canvasClickCanceled', () => this.fireEvent('mouse_click_cancled'));
- _addEventListener('entityClick', (entity) =>
- this.fireEventOnEntity('when_object_click', entity)
- );
- _addEventListener('entityClickCanceled', (entity) =>
- this.fireEventOnEntity('when_object_click_canceled', entity)
- );
+ _addEventListener('entityClick', (entity) => {
+ const objId = entity.id;
+ Entry.stage.clickedObjectId = objId;
+ this.fireEventOnEntity('when_object_click', entity);
+ });
+ _addEventListener('entityClickCanceled', (entity) => {
+ delete Entry.stage.clickedObjectId;
+ this.fireEventOnEntity('when_object_click_canceled', entity);
+ });
if (Entry.type !== 'phone' && Entry.type !== 'playground') {
_addEventListener(
@@ -689,7 +692,7 @@ Entry.Engine = class Engine {
Entry.dispatchEvent('beforeStop');
try {
await Promise.all(this.execPromises);
- } catch (e) {}
+ } catch (e) { }
const container = Entry.container;
const variableContainer = Entry.variableContainer;
diff --git a/src/class/hw.ts b/src/class/hw.ts
index 9e96bffc51..c6f3293f83 100644
--- a/src/class/hw.ts
+++ b/src/class/hw.ts
@@ -634,17 +634,15 @@ export default class Hardware {
if (!dontShowChecked) {
const title = Lang.Msgs.hardware_need_update_title;
const content = Lang.Msgs.hardware_need_update_content;
- entrylms
- .alert(content, title, { withDontShowAgain: true })
- .one(
- 'click',
- (event: any, { dontShowChecked }: { dontShowChecked: boolean }) => {
- if (dontShowChecked) {
- localStorage.setItem('skipNoticeHWOldVersion', 'true');
- }
- resolve(null);
- }
- );
+ Entry.modal.alert(content, title, {
+ withDontShowAgain: true
+ }).then((data: { dontShowChecked: boolean }) => {
+ const { dontShowChecked } = data || {};
+ if (dontShowChecked) {
+ localStorage.setItem('skipNoticeHWOldVersion', 'true');
+ }
+ resolve(null);
+ })
} else {
resolve(null);
}
diff --git a/src/class/variable_container.js b/src/class/variable_container.js
index 9b940833a0..3d60e7ed43 100644
--- a/src/class/variable_container.js
+++ b/src/class/variable_container.js
@@ -1507,6 +1507,24 @@ Entry.VariableContainer = class VariableContainer {
this.updateList();
}
+ removeNotPythonSupportedFunction() {
+ const functions = this.functions_;
+ Object.values(functions).forEach((func) => {
+ const isNotPythonSupport = func.useLocalVariables || func.type === 'value';
+ if (isNotPythonSupport) {
+ const functionId = func.id;
+ func.destroy();
+ delete functions[functionId];
+ const functionType = `func_${functionId}`;
+ Entry.container.removeFuncBlocks(functionType);
+ for (const id in functions) {
+ functions[id].content.removeBlocksByType(functionType);
+ }
+ }
+ });
+ this.updateList();
+ }
+
checkListPosition(list, mouse) {
const pos = {
start_w: list.x_,
diff --git a/src/playground/blocks/block_calc.js b/src/playground/blocks/block_calc.js
index e41fab8102..e9896d1b4b 100644
--- a/src/playground/blocks/block_calc.js
+++ b/src/playground/blocks/block_calc.js
@@ -1396,6 +1396,7 @@ module.exports = {
[Lang.Blocks.CALC_get_date_year, 'YEAR'],
[Lang.Blocks.CALC_get_date_month, 'MONTH'],
[Lang.Blocks.CALC_get_date_day, 'DAY'],
+ [Lang.Blocks.CALC_get_date_day_of_week, 'DAY_OF_WEEK'],
[Lang.Blocks.CALC_get_date_hour, 'HOUR'],
[Lang.Blocks.CALC_get_date_minute, 'MINUTE'],
[Lang.Blocks.CALC_get_date_second, 'SECOND'],
@@ -1438,6 +1439,10 @@ module.exports = {
return dateTime.getHours();
} else if (operator === 'MINUTE') {
return dateTime.getMinutes();
+ } else if (operator === 'DAY_OF_WEEK') {
+ const daysLang = ['일', '월', '화', '수', '목', '금', '토'];
+ const dayNum = dateTime.getDay();
+ return daysLang[dayNum];
} else {
return dateTime.getSeconds();
}
@@ -1459,6 +1464,7 @@ module.exports = {
[Lang.Blocks.CALC_get_date_hour, 'HOUR'],
[Lang.Blocks.CALC_get_date_minute, 'MINUTE'],
[Lang.Blocks.CALC_get_date_second, 'SECOND'],
+ [Lang.Blocks.CALC_get_date_day_of_week, 'DAY_OF_WEEK'],
],
value: 'YEAR',
fontSize: 11,
@@ -1735,6 +1741,57 @@ module.exports = {
],
},
},
+ reverse_of_string: {
+ color: EntryStatic.colorSet.block.default.CALC,
+ outerLine: EntryStatic.colorSet.block.darken.CALC,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Text',
+ text: Lang.Blocks.CALC_reverse_of_string_1,
+ color: '#FFF',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Text',
+ text: Lang.Blocks.CALC_reverse_of_string_2,
+ color: '#FFF',
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ {
+ type: 'text',
+ params: [Lang.Blocks.entry],
+ },
+ null,
+ ],
+ type: 'reverse_of_string',
+ },
+ paramsKeyMap: {
+ STRING: 1,
+ },
+ class: 'calc_string',
+ isNotFor: ['python_disable'],
+ func(sprite, script) {
+ const originStr = script.getStringValue('STRING', script);
+ const reversedStr = originStr
+ .split('')
+ .reverse()
+ .join('');
+ return reversedStr;
+ },
+ syntax: {
+ js: [],
+ py: [],
+ },
+ },
combine_something: {
color: EntryStatic.colorSet.block.default.CALC,
outerLine: EntryStatic.colorSet.block.darken.CALC,
@@ -2070,6 +2127,70 @@ module.exports = {
],
},
},
+ count_match_string: {
+ color: EntryStatic.colorSet.block.default.CALC,
+ outerLine: EntryStatic.colorSet.block.darken.CALC,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Text',
+ text: Lang.Blocks.CALC_count_match_string_1,
+ color: '#FFF',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Text',
+ text: Lang.Blocks.CALC_count_match_string_2,
+ color: '#FFF',
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'text',
+ params: [Lang.Blocks.hi_entry_en],
+ },
+ null,
+ {
+ type: 'text',
+ params: ['e'],
+ },
+ null,
+ ],
+ type: 'count_match_string',
+ },
+ paramsKeyMap: {
+ STRING: 0,
+ TARGET: 2,
+ },
+ class: 'calc_string',
+ isNotFor: ['python_disable'],
+ func(sprite, script) {
+ const originStr = script.getStringValue('STRING', script);
+ const targetStr = script.getStringValue('TARGET', script);
+
+ if (originStr.length > 0 && targetStr.length > 0) {
+ const result = originStr.match(new RegExp(targetStr, 'g'));
+ if (result) {
+ return result.length;
+ }
+ }
+ return 0;
+ },
+ syntax: {
+ js: [],
+ py: [],
+ },
+ },
index_of_string: {
color: EntryStatic.colorSet.block.default.CALC,
outerLine: EntryStatic.colorSet.block.darken.CALC,
diff --git a/src/playground/blocks/block_judgement.js b/src/playground/blocks/block_judgement.js
index 52752f04eb..1090a217d8 100644
--- a/src/playground/blocks/block_judgement.js
+++ b/src/playground/blocks/block_judgement.js
@@ -36,6 +36,34 @@ module.exports = {
],
},
},
+ is_object_clicked: {
+ color: EntryStatic.colorSet.block.default.JUDGE,
+ outerLine: EntryStatic.colorSet.block.darken.JUDGE,
+ skeleton: 'basic_boolean_field',
+ statements: [],
+ params: [
+ {
+ type: 'Text',
+ text: Lang.Blocks.JUDGEMENT_is_object_clicked,
+ color: '#FFF',
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ type: 'is_object_clicked',
+ },
+ class: 'boolean_input',
+ isNotFor: ['python_disable'],
+ func(sprite, script) {
+ const objId = sprite.id;
+ if (Entry.stage.clickedObjectId == objId) {
+ return true;
+ }
+ return false;
+ },
+ syntax: { js: [], py: [] },
+ },
is_press_some_key: {
color: EntryStatic.colorSet.block.default.JUDGE,
outerLine: EntryStatic.colorSet.block.darken.JUDGE,
@@ -229,6 +257,62 @@ module.exports = {
],
},
},
+ is_type: {
+ color: EntryStatic.colorSet.block.default.JUDGE,
+ outerLine: EntryStatic.colorSet.block.darken.JUDGE,
+ skeleton: 'basic_boolean_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Text',
+ text: Lang.Blocks.JUDGEMENT_is_type_1,
+ color: '#FFF',
+ },
+ {
+ type: 'Dropdown',
+ options: [[Lang.Blocks.is_type_number, 'number']],
+ value: 'number',
+ fontSize: 10,
+ bgColor: EntryStatic.colorSet.block.darken.JUDGE,
+ },
+ {
+ type: 'Text',
+ text: Lang.Blocks.JUDGEMENT_is_type_2,
+ color: '#FFF',
+ },
+ ],
+ events: {},
+ def: {
+ params: ['10', null, 'number', null],
+ type: 'is_type',
+ },
+ paramsKeyMap: {
+ VALUE: 0,
+ TYPE: 2,
+ },
+ class: 'boolean_type',
+ isNotFor: ['python_disable'],
+ func(sprite, script) {
+ const value = script.getStringValue('VALUE', script);
+ const type = script.getField('TYPE', script);
+
+ if (type === 'number') {
+ const numCheckRegex = /^-?\d+$/;
+ if (numCheckRegex.test(value)) {
+ return true;
+ }
+ }
+ return false;
+ },
+ syntax: {
+ js: [],
+ py: [],
+ },
+ },
boolean_basic_operator: {
color: EntryStatic.colorSet.block.default.JUDGE,
outerLine: EntryStatic.colorSet.block.darken.JUDGE,
diff --git a/src/playground/blocks/hardware/block_bitbrick.js b/src/playground/blocks/hardware/block_bitbrick.js
index f4391d5f2c..61b7a12021 100644
--- a/src/playground/blocks/hardware/block_bitbrick.js
+++ b/src/playground/blocks/hardware/block_bitbrick.js
@@ -130,26 +130,6 @@ Entry.Bitbrick = {
type: 'input',
pos: { x: 0, y: 0 },
},
- A: {
- name: Lang.Hw.port_en + ' A ' + Lang.Hw.port_ko,
- type: 'input',
- pos: { x: 0, y: 0 },
- },
- B: {
- name: Lang.Hw.port_en + ' B ' + Lang.Hw.port_ko,
- type: 'input',
- pos: { x: 0, y: 0 },
- },
- C: {
- name: Lang.Hw.port_en + ' C ' + Lang.Hw.port_ko,
- type: 'input',
- pos: { x: 0, y: 0 },
- },
- D: {
- name: Lang.Hw.port_en + ' D ' + Lang.Hw.port_ko,
- type: 'input',
- pos: { x: 0, y: 0 },
- },
},
// },
// ports : {
@@ -206,21 +186,27 @@ Entry.Bitbrick = {
Entry.Bitbrick.blockMenuBlocks = [
'bitbrick_when_button_pressed',
'bitbrick_when_sensor_get_value',
+ 'bitbrick_is_touch_pressed',
+ 'bitbrick_is_sensor_value_compare',
'bitbrick_sensor_value',
'bitbrick_convert_scale',
- 'bitbrick_is_touch_pressed',
- 'bitbrick_turn_off_color_led',
'bitbrick_turn_on_color_led_by_rgb',
'bitbrick_turn_on_color_led_by_picker',
'bitbrick_turn_on_color_led_by_value',
- 'bitbrick_buzzer',
- 'bitbrick_turn_off_all_motors',
- 'bitbrick_dc_speed',
- 'bitbrick_dc_direction_speed',
+ 'bitbrick_turn_off_color_led',
+ 'bitbrick_buzzer',
'bitbrick_servomotor_angle',
+ 'bitbrick_dc_direction_speed',
+ 'bitbrick_dc_speed',
+ 'bitbrick_turn_off_all_motors',
];
Entry.Bitbrick.getBlocks = function() {
+ let options_BITBRICK_button2 =
+ [
+ [Lang.Blocks.BITBRICK_button_pressed, 'pressed'],
+ [Lang.Blocks.BITBRICK_button_released, 'released'],
+ ];
return {
//region bitbrick 비트브릭
bitbrick_when_button_pressed: {
@@ -230,15 +216,6 @@ Entry.Bitbrick.getBlocks = function() {
skeleton: 'basic_event',
statements: [],
params: [
- // {
- // type: 'Indicator',
- // img: 'block_icon/start_icon_play.svg',
- // size: 14,
- // position: {
- // x: 0,
- // y: -2,
- // },
- // },
{
type: 'Indicator',
img: 'block_icon/hardware_icon.svg',
@@ -273,10 +250,13 @@ Entry.Bitbrick.getBlocks = function() {
if( script.values.length > 0 ) {
let selectedSensor = script.values[ 1 ];
let port = script.getStringField('PORT');
- let type = Entry.hw.portData[port].type;
- let val = Entry.hw.portData[port].value;
- if( selectedSensor == port && val == 0 ) {
- return script.callReturn();
+ let val = Entry.hw.portData[port].value; // 0이면 누름, 1023이면 누르지 않음
+ if( selectedSensor == port ) {
+ if (val == 0) {
+ return script.callReturn();
+ } else {
+ return this.die();
+ }
} else {
return this.die();
}
@@ -316,7 +296,7 @@ Entry.Bitbrick.getBlocks = function() {
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
options: Entry.Bitbrick.INEQ_SIGN,
- value: '<',
+ value: '>',
},
{
type: 'Block',
@@ -331,7 +311,7 @@ Entry.Bitbrick.getBlocks = function() {
null,
{
type: 'text',
- params: ['50'],
+ params: ['100'],
}
],
type: 'bitbrick_when_sensor_get_value',
@@ -441,7 +421,7 @@ Entry.Bitbrick.getBlocks = function() {
},
{
type: 'number',
- params: ['-100'],
+ params: ['0'],
},
{
type: 'number',
@@ -501,21 +481,105 @@ Entry.Bitbrick.getBlocks = function() {
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
},
+ {
+ type: 'Dropdown',
+ options: options_BITBRICK_button2,
+ value: 'pressed',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
],
events: {},
def: {
- params: [null],
+ params: [null, null],
type: 'bitbrick_is_touch_pressed',
},
paramsKeyMap: {
PORT: 0,
+ PRESSED: 1
},
class: 'button',
isNotFor: ['bitbrick'],
func: function(sprite, script) {
- return Entry.hw.portData[script.getStringField('PORT')].value === 0;
+ console.info("bitbrick_is_touch_pressed");
+ let port = script.getStringField('PORT');
+ let val = Entry.hw.portData[port].value;
+ let pressed = script.getStringField('PRESSED');
+ if ((pressed == 'pressed') && (val == 0)) {
+ return true;
+ } else if ((pressed == 'released') && (val == 1023)) {
+ return true;
+ } else {
+ return false;
+ }
},
- syntax: { js: [], py: ['Bitbrick.is_touch_pressed(%1)'] },
+ syntax: { js: [], py: ['Bitbrick.is_touch_pressed(%1, %2)'] },
+ },
+ bitbrick_is_sensor_value_compare: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
+ skeleton: 'basic_boolean_field',
+ statements: [],
+ params: [
+ {
+ type: 'DropdownDynamic',
+ value: null,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ menuName: Entry.Bitbrick.sensorList,
+ },
+ {
+ type: 'Dropdown',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ options: Entry.Bitbrick.INEQ_SIGN,
+ value: '>',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ null,
+ {
+ type: 'text',
+ params: ['100'],
+ }
+ ],
+ type: 'bitbrick_is_sensor_value_compare',
+ },
+ paramsKeyMap: {
+ PORT: 0,
+ INEQ_SIGN: 1,
+ VALUE: 2
+ },
+ class: 'button',
+ isNotFor: ['bitbrick'],
+ func: function(sprite, script) {
+ let selectedPort = script.values[ 0 ];
+ let ineqSign = script.values[ 1 ];
+ let value = script.values[ 2 ];
+ let port = script.getStringField('PORT');
+ let val = Entry.hw.portData[port].value;
+ if( selectedPort == port && ineqSign == '<' && val < value ) {
+ return true;
+ } else if( selectedPort == port && ineqSign == '>' && val > value ) {
+ return true;
+ } else if( selectedPort == port && ineqSign == '=' && val == value ) {
+ return true;
+ } else {
+ return false;
+ }
+ },
+ syntax: { js: [], py: ['Bitbrick.is_sensor_value_compare(%1,%2,%3)'] },
},
bitbrick_turn_off_color_led: {
color: EntryStatic.colorSet.block.default.HARDWARE,
@@ -964,29 +1028,32 @@ Entry.Bitbrick.setLanguage = function() {
template: {
bitbrick_when_button_pressed: '%1 버튼 %2 눌러졌을 때',
bitbrick_when_sensor_get_value: '%1 %2 값 %3 %4 일 때',
- bitbrick_sensor_value: '%1 값',
- bitbrick_is_touch_pressed: '버튼 %1 이(가) 눌렸는가?',
- bitbrick_turn_off_color_led: '엘이디 끄기 %1',
- bitbrick_turn_on_color_led_by_rgb: '엘이디 빨강 %1 초록 %2 파랑 %3 %4',
- bitbrick_turn_on_color_led_by_picker: '엘이디 색 %1 로 정하기 %2',
- bitbrick_turn_on_color_led_by_value: '엘이디 색 %1 로 정하기 %2',
- bitbrick_buzzer: '버저음 %1 내기 %2',
- bitbrick_turn_off_all_motors: '모든 모터 끄기 %1',
- bitbrick_dc_speed: '디씨모터 %1 속도 %2 %3',
- bitbrick_dc_direction_speed: '디씨모터 %1 %2 방향 속력 %3 %4',
- bitbrick_servomotor_angle: '서보모터 %1 각도 %2 %3',
+ bitbrick_is_touch_pressed: '버튼 %1 이(가) %2 인가?',
+ bitbrick_is_sensor_value_compare: '%1 값 %2 %3 인가?',
+ bitbrick_sensor_value: '%1 값',
bitbrick_convert_scale: '변환 %1 값 %2 ~ %3 에서 %4 ~ %5',
+ bitbrick_turn_on_color_led_by_rgb: '엘이디를 빨강 %1 초록 %2 파랑 %3 %4 (으)로 켜기',
+ bitbrick_turn_on_color_led_by_picker: '엘이디를 %1 (으)로 켜기 %2',
+ bitbrick_turn_on_color_led_by_value: '엘이디를 %1 (으)로 켜기 %2',
+ bitbrick_turn_off_color_led: '엘이디 끄기 %1',
+ bitbrick_buzzer: '버저음 %1 내기 %2',
+ bitbrick_servomotor_angle: '서보모터 %1 각도 %2 %3',
+ bitbrick_dc_direction_speed: '디씨모터 %1 방향 %2 속력 %3 %4',
+ bitbrick_dc_speed: '디씨모터 %1 속도 %2 %3',
+ bitbrick_turn_off_all_motors: '모든 모터 멈추기 %1',
},
Blocks: {
- BITBRICK_light: '밝기센서',
- BITBRICK_IR: '거리센서',
+ BITBRICK_button_pressed: '누름',
+ BITBRICK_button_released: '누르지 않음',
+ BITBRICK_light: '밝기 센서',
+ BITBRICK_IR: '적외선 센서',
BITBRICK_touch: '버튼',
BITBRICK_ultrasonicSensor: '초음파센서',
- BITBRICK_vibrationSensor: '진동센서',
+ BITBRICK_vibrationSensor: '진동 센서',
BITBRICK_potentiometer: '가변저항',
- BITBRICK_MIC: '소리센서',
- BITBRICK_UserSensor: '사용자입력',
- BITBRICK_UserInput: '사용자입력',
+ BITBRICK_MIC: '소리 센서',
+ BITBRICK_UserSensor: '사용자 입력',
+ BITBRICK_UserInput: '사용자 입력',
BITBRICK_dc_direction_ccw: '반시계',
BITBRICK_dc_direction_cw: '시계',
},
@@ -1000,22 +1067,25 @@ Entry.Bitbrick.setLanguage = function() {
en: {
// en.js에 작성하던 내용
template: {
- bitbrick_when_button_pressed: '%1 When button %2 pressed',
- bitbrick_when_sensor_get_value: '%1 When %2 value %3 %4',
- bitbrick_sensor_value: 'Value %1',
- bitbrick_is_touch_pressed: 'Pressed %1 button? ',
- bitbrick_turn_off_color_led: 'Turn off color LED %1',
- bitbrick_turn_on_color_led_by_rgb: 'Color LED R %1 G %2 B %3 %4',
- bitbrick_turn_on_color_led_by_picker: 'Select %1 for color LED %2',
- bitbrick_turn_on_color_led_by_value: 'Color LED, select %1 %2',
- bitbrick_buzzer: 'Buzz for %1 secs %2',
- bitbrick_turn_off_all_motors: 'Turn off all motors %1',
- bitbrick_dc_speed: 'DC motor %1 speed %2 %3',
- bitbrick_dc_direction_speed: 'DC motor %1 %2 direction speed %3 %4',
- bitbrick_servomotor_angle: 'Servo motor %1 angle %2 %3',
- bitbrick_convert_scale: 'Convert %1 value from %2~%3 to %4~%4',
+ bitbrick_when_button_pressed: '%1 when button %2',
+ bitbrick_when_sensor_get_value: '%1 when %2 value %3 %4',
+ bitbrick_is_touch_pressed: 'button %1 %2?',
+ bitbrick_is_sensor_value_compare: '%1 %2 %3? ',
+ bitbrick_sensor_value: '%1 value',
+ bitbrick_convert_scale: 'map %1 value from %2 ~ %3 to %4 ~ %5',
+ bitbrick_turn_on_color_led_by_rgb: 'set LED color to Red %1 Green %2 Blue %3 %4',
+ bitbrick_turn_on_color_led_by_picker: 'set LED color to %1 %2',
+ bitbrick_turn_on_color_led_by_value: 'set LED color %1 %2',
+ bitbrick_turn_off_color_led: 'turn off LED %1',
+ bitbrick_buzzer: 'buzz note %1 %2',
+ bitbrick_servomotor_angle: 'servo motor %1 degree %2 %3',
+ bitbrick_dc_direction_speed: 'dc motor %1 direction %2 speed %3 %4',
+ bitbrick_dc_speed: 'dc motor %1 velocity %2 %3',
+ bitbrick_turn_off_all_motors: 'stop all motors %1',
},
Blocks: {
+ BITBRICK_button_pressed: 'pressed',
+ BITBRICK_button_released: 'released',
BITBRICK_light: 'light',
BITBRICK_IR: 'IR',
BITBRICK_touch: 'touch',
diff --git a/src/playground/blocks/hardware/block_coalaboard.js b/src/playground/blocks/hardware/block_coalaboard.js
new file mode 100644
index 0000000000..b29e9ad34d
--- /dev/null
+++ b/src/playground/blocks/hardware/block_coalaboard.js
@@ -0,0 +1,1129 @@
+'use strict';
+
+Entry.Coalaboard = {
+ SENSOR_MAP: {
+ 1: 'light',
+ 2: 'IR',
+ 3: 'touch',
+ 4: 'potentiometer',
+ 5: 'MIC',
+ 6: 'ultrasonicSensor',
+ 7: 'temperature',
+ 10: 'vibrationSensor',
+ 21: 'UserSensor',
+ 11: 'UserInput',
+ 20: 'LED',
+ 19: 'SERVO',
+ 18: 'DC',
+ },
+ PORT_MAP: {
+ buzzer: 2,
+ '5': 4,
+ '6': 6,
+ '7': 8,
+ '8': 10,
+ LEDR: 12,
+ LEDG: 14,
+ LEDB: 16,
+ },
+ INEQ_SIGN: [
+ ["<", "<"],
+ [">", ">"],
+ ["=", "="]
+ ],
+ sensorList: function() {
+ var list = [];
+ var portData = Entry.hw.portData;
+ for (var i = 1; i < 5; i++) {
+ var data = portData[i];
+ if (data && (data.value || data.value === 0)) {
+ list.push([i + ' - ' + Lang.Blocks['COALABOARD_' + data.type], i.toString()]);
+ }
+ }
+
+ if (list.length == 0) return [[Lang.Blocks.no_target, 'null']];
+ return list;
+ },
+ touchList: function() {
+ var list = [];
+ var portData = Entry.hw.portData;
+ for (var i = 1; i < 5; i++) {
+ var data = portData[i];
+ if (data && data.type === 'touch') list.push([i.toString(), i.toString()]);
+ }
+ if (list.length == 0) return [[Lang.Blocks.no_target, 'null']];
+ return list;
+ },
+ servoList: function() {
+ var list = [];
+ var portData = Entry.hw.portData;
+ for (var i = 5; i < 9; i++) {
+ var data = portData[i];
+ if (data && data.type === 'SERVO') list.push(['ABCD'[i - 5], i.toString()]);
+ }
+ if (list.length == 0) return [[Lang.Blocks.no_target, 'null']];
+ return list;
+ },
+ dcList: function() {
+ var list = [];
+ var portData = Entry.hw.portData;
+ for (var i = 5; i < 9; i++) {
+ var data = portData[i];
+ if (data && data.type === 'DC') list.push(['ABCD'[i - 5], i.toString()]);
+ }
+ if (list.length == 0) return [[Lang.Blocks.no_target, 'null']];
+ return list;
+ },
+ /**
+ * 엔트리가 중지 되면 호출된다.
+ */
+ setZero: function() {
+ let sq = Entry.hw.sendQueue;
+ for (let port in Entry.Coalaboard.PORT_MAP) {
+ let portData = Entry.hw.portData[port];
+ if( portData != null ) {
+ if( portData.type == Entry.Coalaboard.SENSOR_MAP[18] ) { // DC모터 인 경우, 129로 세팅하여 바로 멈추기
+ sq[port] = 129;
+ } else {
+ sq[port] = 0;
+ }
+ } else {
+ sq[port] = 0;
+ }
+ }
+ Entry.hw.update();
+ },
+ id: '3.3',
+ name: 'coalaboard',
+ url: 'http://www.bitbrick.cc/',
+ imageName: 'coalaboard.png',
+ title: {
+ ko: '코알라보드',
+ en: 'coalaboard',
+ },
+ servoMaxValue: 181,
+ servoMinValue: 1,
+ dcMaxValue: 100,
+ dcMinValue: -100,
+ monitorTemplate: {
+ keys: ['value'],
+ imgPath: 'hw/coalaboard.png',
+ width: 400,
+ height: 400,
+ listPorts: {
+ 'UserInput': {
+ name: Lang.Blocks.COALABOARD_UserInput,
+ type: 'input',
+ pos: { x: 0, y: 0 },
+ },
+ 'potentiometer': {
+ name: Lang.Blocks.COALABOARD_potentiometer,
+ type: 'input',
+ pos: { x: 0, y: 0 },
+ },
+ 'MIC': {
+ name: Lang.Blocks.COALABOARD_MIC,
+ type: 'input',
+ pos: { x: 0, y: 0 },
+ },
+ 'IR': {
+ name: Lang.Blocks.COALABOARD_IR,
+ type: 'input',
+ pos: { x: 0, y: 0 },
+ },
+ 'temperature': {
+ name: Lang.Blocks.COALABOARD_temperature,
+ type: 'input',
+ pos: { x: 0, y: 0 },
+ },
+ 'light': {
+ name: Lang.Blocks.COALABOARD_light,
+ type: 'input',
+ pos: { x: 0, y: 0 },
+ },
+ 'touch': {
+ name: Lang.Blocks.COALABOARD_touch,
+ type: 'input',
+ pos: { x: 0, y: 0 },
+ },
+ },
+ mode: 'both',
+ },
+ /**
+ * 콜백 함수. 계속해서 센서 데이터를 받는다.
+ * @param {*} pd
+ */
+ afterReceive(pd) {
+ for( let i = 1; i < 5; i++ ) { // 오직 센서만 받기
+ let obj = pd[ i ]; // ex) null or { type: "touch", value: 1023 }
+ if( obj != null ) {
+ if( obj.type == 'touch' && obj.value == 0 ) {
+ Entry.engine.fireEvent('coalaboardButtonEventReceive');
+ }
+ Entry.engine.fireEvent('coalaboardSensorGetValueEventReceive');
+ }
+ }
+ },
+ calculateDCMotorValue: function( value ) {
+ let val = 0;
+ if ( value > 0 ) {
+ val = Math.floor( ( value * 0.8 ) + 16 );
+ } else if ( value < 0 ) {
+ val = Math.ceil( ( value * 0.8 ) - 19 );
+ } else {
+ val = 0;
+ }
+ // DC_MOTOR_ADJUSTMENT 128
+ val = 128 + val;
+ if ( val == 128 ) {
+ val = 129;
+ }
+ return val;
+ }
+};
+
+Entry.Coalaboard.blockMenuBlocks = [
+ 'coalaboard_when_button_pressed',
+ 'coalaboard_when_sensor_get_value',
+ 'coalaboard_is_touch_pressed',
+ 'coalaboard_is_sensor_value_compare',
+ 'coalaboard_sensor_value',
+ 'coalaboard_convert_scale',
+ 'coalaboard_turn_on_color_led_by_rgb',
+ 'coalaboard_turn_on_color_led_by_picker',
+ 'coalaboard_turn_on_color_led_by_value',
+ 'coalaboard_turn_off_color_led',
+ 'coalaboard_buzzer',
+ 'coalaboard_servomotor_angle',
+ 'coalaboard_dc_direction_speed',
+ 'coalaboard_dc_speed',
+ 'coalaboard_turn_off_all_motors',
+];
+
+Entry.Coalaboard.getBlocks = function() {
+ let options_COALABOARD_button2 =
+ [
+ [Lang.Blocks.COALABOARD_button_pressed, 'pressed'],
+ [Lang.Blocks.COALABOARD_button_released, 'released'],
+ ];
+ return {
+ //region coalaboard 코알라보드
+ coalaboard_when_button_pressed: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
+ skeleton: 'basic_event',
+ statements: [],
+ params: [
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ position: {
+ x: 0,
+ y: 0
+ }
+ },
+ {
+ type: 'DropdownDynamic',
+ value: null,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ menuName: Entry.Coalaboard.touchList,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null, null],
+ type: 'coalaboard_when_button_pressed',
+ },
+ paramsKeyMap: {
+ DUMMY: 0,
+ PORT: 1
+ },
+ class: 'event',
+ isNotFor: ['coalaboard'],
+ event: 'coalaboardButtonEventReceive',
+ func: function(sprite, script) {
+ let selectedSensor = script.values[ 1 ];
+ let port = script.getStringField('PORT');
+ let type = Entry.hw.portData[port].type;
+ let val = Entry.hw.portData[port].value; // 0이면 누름, 1023이면 누르지 않음
+ if( selectedSensor == port ) {
+ if (val == 0) {
+ return script.callReturn();
+ } else {
+ return this.die();
+ }
+ } else {
+ return this.die();
+ }
+ },
+ syntax: { js: [], py: ['Coalaboard.when_button_pressed(%2, %3)'] },
+ },
+ coalaboard_when_sensor_get_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
+ skeleton: 'basic_event',
+ statements: [],
+ params: [
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ position: {
+ x: 0,
+ y: 0
+ }
+ },
+ {
+ type: 'DropdownDynamic',
+ value: null,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ menuName: Entry.Coalaboard.sensorList,
+ },
+ {
+ type: 'Dropdown',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ options: Entry.Coalaboard.INEQ_SIGN,
+ value: '>',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ null,
+ null,
+ {
+ type: 'text',
+ params: ['100'],
+ }
+ ],
+ type: 'coalaboard_when_sensor_get_value',
+ },
+ paramsKeyMap: {
+ DUMMY: 0,
+ PORT: 1,
+ INEQ_SIGN: 2,
+ VALUE: 3
+ },
+ class: 'event',
+ isNotFor: ['coalaboard'],
+ event: 'coalaboardSensorGetValueEventReceive',
+ func: function(sprite, script) {
+ let selectedPort = script.values[ 1 ];
+ let ineqSign = script.values[ 2 ];
+ let value = script.values[ 3 ];
+ let port = script.getStringField('PORT');
+ let val = Entry.hw.portData[port].value;
+ if( selectedPort == port && ineqSign == '<' && val < value ) {
+ return script.callReturn();
+ } else if( selectedPort == port && ineqSign == '>' && val > value ) {
+ return script.callReturn();
+ } else if( selectedPort == port && ineqSign == '=' && val == value ) {
+ return script.callReturn();
+ } else {
+ return this.die();
+ }
+ },
+ syntax: { js: [], py: ['Coalaboard.when_sensor_get_value(%2,%3,%4)'] },
+ },
+ coalaboard_sensor_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'DropdownDynamic',
+ value: null,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ menuName: Entry.Coalaboard.sensorList,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ type: 'coalaboard_sensor_value',
+ },
+ paramsKeyMap: {
+ PORT: 0,
+ },
+ class: 'button',
+ isNotFor: ['coalaboard'],
+ func: function(sprite, script) {
+ var port = script.getStringField('PORT');
+ return Entry.hw.portData[port].value;
+ },
+ syntax: { js: [], py: ['Coalaboard.sensor_value(%1)'] },
+ },
+ coalaboard_convert_scale: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'DropdownDynamic',
+ value: null,
+ fontSize: 11,
+ menuName: Entry.Coalaboard.sensorList,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'number',
+ params: ['1023'],
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'number',
+ params: ['100'],
+ },
+ ],
+ type: 'coalaboard_convert_scale',
+ },
+ paramsKeyMap: {
+ PORT: 0,
+ VALUE2: 1,
+ VALUE3: 2,
+ VALUE4: 3,
+ VALUE5: 4,
+ },
+ class: 'button',
+ isNotFor: ['coalaboard'],
+ func: function(sprite, script) {
+ var port = script.getNumberField('PORT');
+ var value1 = Entry.hw.portData[port].value;
+ var value2 = script.getNumberValue('VALUE2', script);
+ var value3 = script.getNumberValue('VALUE3', script);
+ var value4 = script.getNumberValue('VALUE4', script);
+ var value5 = script.getNumberValue('VALUE5', script);
+ var result = value1;
+
+ if (value4 > value5) {
+ var swap = value4;
+ value4 = value5;
+ value5 = swap;
+ }
+
+ result -= value2;
+ result = result * ((value5 - value4) / (value3 - value2));
+ result += value4;
+ result = Math.min(value5, result);
+ result = Math.max(value4, result);
+ return Math.round(result);
+ },
+ syntax: {
+ js: [],
+ py: ['Coalaboard.convert_scale(%1, %2, %3, %4, %5)'],
+ },
+ },
+ coalaboard_is_touch_pressed: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
+ skeleton: 'basic_boolean_field',
+ statements: [],
+ params: [
+ {
+ type: 'DropdownDynamic',
+ value: null,
+ fontSize: 11,
+ menuName: Entry.Coalaboard.touchList,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Dropdown',
+ options: options_COALABOARD_button2,
+ value: 'pressed',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null, null],
+ type: 'coalaboard_is_touch_pressed',
+ },
+ paramsKeyMap: {
+ PORT: 0,
+ PRESSED: 1
+ },
+ class: 'button',
+ isNotFor: ['coalaboard'],
+ func: function(sprite, script) {
+ let port = script.getStringField('PORT');
+ let val = Entry.hw.portData[port].value;
+ let pressed = script.getStringField('PRESSED');
+ if ((pressed == 'pressed') && (val == 0)) {
+ return true;
+ } else if ((pressed == 'released') && (val == 1023)) {
+ return true;
+ } else {
+ return false;
+ }
+ },
+ syntax: { js: [], py: ['Coalaboard.is_touch_pressed(%1, %2)'] },
+ },
+ coalaboard_is_sensor_value_compare: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
+ skeleton: 'basic_boolean_field',
+ statements: [],
+ params: [
+ {
+ type: 'DropdownDynamic',
+ value: null,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ menuName: Entry.Coalaboard.sensorList,
+ },
+ {
+ type: 'Dropdown',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ options: Entry.Coalaboard.INEQ_SIGN,
+ value: '>',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ null,
+ {
+ type: 'text',
+ params: ['100'],
+ }
+ ],
+ type: 'coalaboard_is_sensor_value_compare',
+ },
+ paramsKeyMap: {
+ PORT: 0,
+ INEQ_SIGN: 1,
+ VALUE: 2
+ },
+ class: 'button',
+ isNotFor: ['coalaboard'],
+ func: function(sprite, script) {
+ let selectedPort = script.values[ 0 ];
+ let ineqSign = script.values[ 1 ];
+ let value = script.values[ 2 ];
+ let port = script.getStringField('PORT');
+ let val = Entry.hw.portData[port].value;
+ if( selectedPort == port && ineqSign == '<' && val < value ) {
+ return true;
+ } else if( selectedPort == port && ineqSign == '>' && val > value ) {
+ return true;
+ } else if( selectedPort == port && ineqSign == '=' && val == value ) {
+ return true;
+ } else {
+ return false;
+ }
+ },
+ syntax: { js: [], py: ['Bitbrick.is_sensor_value_compare(%1,%2,%3)'] },
+ },
+ coalaboard_turn_off_color_led: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ type: 'coalaboard_turn_off_color_led',
+ id: 'i3je',
+ },
+ class: 'led',
+ isNotFor: ['coalaboard'],
+ func: function(sprite, script) {
+ Entry.hw.sendQueue['LEDR'] = 0;
+ Entry.hw.sendQueue['LEDG'] = 0;
+ Entry.hw.sendQueue['LEDB'] = 0;
+ return script.callReturn();
+ },
+ syntax: { js: [], py: ['Coalaboard.turn_off_color_led()'] },
+ },
+ coalaboard_turn_on_color_led_by_rgb: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'text',
+ params: ['255'],
+ },
+ {
+ type: 'text',
+ params: ['255'],
+ },
+ {
+ type: 'text',
+ params: ['255'],
+ },
+ null,
+ ],
+ type: 'coalaboard_turn_on_color_led_by_rgb',
+ },
+ paramsKeyMap: {
+ rValue: 0,
+ gValue: 1,
+ bValue: 2,
+ },
+ class: 'led',
+ isNotFor: ['coalaboard'],
+ func: function(sprite, script) {
+ var red = script.getNumberValue('rValue'),
+ green = script.getNumberValue('gValue'),
+ blue = script.getNumberValue('bValue'),
+ min = 0,
+ max = 255,
+ adjustor = Entry.adjustValueWithMaxMin,
+ sq = Entry.hw.sendQueue;
+
+ sq['LEDR'] = adjustor(red, min, max);
+ sq['LEDG'] = adjustor(green, min, max);
+ sq['LEDB'] = adjustor(blue, min, max);
+ return script.callReturn();
+ },
+ syntax: { js: [], py: ['Coalaboard.color_led_by_rgb(%1, %2, %3)'] },
+ },
+ coalaboard_turn_on_color_led_by_picker: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Color',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ type: 'coalaboard_turn_on_color_led_by_picker',
+ },
+ paramsKeyMap: {
+ VALUE: 0,
+ },
+ class: 'led',
+ isNotFor: ['coalaboard'],
+ func: function(sprite, script) {
+ var port = script.getStringField('VALUE');
+ Entry.hw.sendQueue['LEDR'] = parseInt(port.substr(1, 2), 16);
+ Entry.hw.sendQueue['LEDG'] = parseInt(port.substr(3, 2), 16);
+ Entry.hw.sendQueue['LEDB'] = parseInt(port.substr(5, 2), 16);
+ return script.callReturn();
+ },
+ syntax: { js: [], py: ['Coalaboard.color_led_by_picker(%1)'] },
+ },
+ coalaboard_turn_on_color_led_by_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'text',
+ params: ['0'],
+ },
+ null,
+ ],
+ type: 'coalaboard_turn_on_color_led_by_value',
+ },
+ paramsKeyMap: {
+ VALUE: 0,
+ },
+ class: 'led',
+ isNotFor: ['coalaboard'],
+ func: function(sprite, script) {
+ var value = script.getNumberValue('VALUE');
+ var red, green, blue;
+ value = value % 200;
+ if (value < 67) {
+ red = 200 - value * 3;
+ green = value * 3;
+ blue = 0;
+ } else if (value < 134) {
+ value = value - 67;
+ red = 0;
+ green = 200 - value * 3;
+ blue = value * 3;
+ } else if (value < 201) {
+ value = value - 134;
+ red = value * 3;
+ green = 0;
+ blue = 200 - value * 3;
+ }
+ Entry.hw.sendQueue['LEDR'] = red;
+ Entry.hw.sendQueue['LEDG'] = green;
+ Entry.hw.sendQueue['LEDB'] = blue;
+ return script.callReturn();
+ },
+ syntax: { js: [], py: ['Coalaboard.color_led_by_value(%1)'] },
+ },
+ coalaboard_buzzer: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'text',
+ params: ['60'],
+ },
+ null,
+ ],
+ type: 'coalaboard_buzzer',
+ },
+ paramsKeyMap: {
+ VALUE: 0,
+ },
+ class: 'buzzer',
+ isNotFor: ['coalaboard'],
+ func: function(sprite, script) {
+ if (!script.isStart) {
+ var value = script.getNumberValue('VALUE');
+ Entry.hw.sendQueue['buzzer'] = value;
+ script.isStart = true;
+ return script;
+ } else {
+ Entry.hw.sendQueue['buzzer'] = 0;
+ delete script.isStart;
+ return script.callReturn();
+ }
+ },
+ syntax: { js: [], py: ['Coalaboard.buzzer(%1)'] },
+ },
+ coalaboard_turn_off_all_motors: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ type: 'coalaboard_turn_off_all_motors',
+ },
+ class: 'motor',
+ isNotFor: ['coalaboard'],
+ func: function(sprite, script) {
+ var sq = Entry.hw.sendQueue;
+ var coalaboard = Entry.Coalaboard;
+ coalaboard.servoList().map(function(servo) {
+ sq[servo[1]] = 0;
+ });
+ coalaboard.dcList().map(function(dc) {
+ sq[dc[1]] = 129;
+ });
+ return script.callReturn();
+ },
+ syntax: { js: [], py: ['Coalaboard.turn_off_all_motors()'] },
+ },
+ coalaboard_dc_speed: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'DropdownDynamic',
+ value: null,
+ fontSize: 11,
+ menuName: Entry.Coalaboard.dcList,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ {
+ type: 'text',
+ params: ['100'],
+ },
+ null,
+ ],
+ type: 'coalaboard_dc_speed',
+ },
+ paramsKeyMap: {
+ PORT: 0,
+ VALUE: 1,
+ },
+ class: 'motor',
+ isNotFor: ['coalaboard'],
+ func: function(sprite, script) {
+ var value = script.getNumberValue('VALUE');
+ value = Math.min(value, Entry.Coalaboard.dcMaxValue);
+ value = Math.max(value, Entry.Coalaboard.dcMinValue);
+ let val = Entry.Coalaboard.calculateDCMotorValue( value );
+ Entry.hw.sendQueue[script.getStringField('PORT')] = val;
+ return script.callReturn();
+ },
+ syntax: { js: [], py: ['Coalaboard.dc_speed(%1, %2)'] },
+ },
+ coalaboard_dc_direction_speed: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'DropdownDynamic',
+ value: null,
+ fontSize: 11,
+ menuName: Entry.Coalaboard.dcList,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.COALABOARD_dc_direction_cw, 'CW'],
+ [Lang.Blocks.COALABOARD_dc_direction_ccw, 'CCW'],
+ ],
+ value: 'CW',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ null,
+ {
+ type: 'text',
+ params: ['100'],
+ },
+ null,
+ ],
+ type: 'coalaboard_dc_direction_speed',
+ },
+ paramsKeyMap: {
+ PORT: 0,
+ DIRECTION: 1,
+ VALUE: 2,
+ },
+ class: 'motor',
+ isNotFor: ['coalaboard'],
+ func: function(sprite, script) {
+ let isFront = script.getStringField('DIRECTION') === 'CW';
+ let value = script.getNumberValue('VALUE');
+ value = Math.min(value, Entry.Coalaboard.dcMaxValue);
+ value = Math.max(value, 0);
+ if ( !isFront ) {
+ value = -1 * value;
+ }
+ let val = Entry.Coalaboard.calculateDCMotorValue( value );
+ Entry.hw.sendQueue[script.getStringField('PORT')] = val;
+ return script.callReturn();
+ },
+ syntax: { js: [], py: ['Coalaboard.dc_direction_speed(%1, %2, %3)'] },
+ },
+ coalaboard_servomotor_angle: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'DropdownDynamic',
+ value: null,
+ fontSize: 11,
+ menuName: Entry.Coalaboard.servoList,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ {
+ type: 'text',
+ params: ['0'],
+ },
+ null,
+ ],
+ type: 'coalaboard_servomotor_angle',
+ },
+ paramsKeyMap: {
+ PORT: 0,
+ VALUE: 1,
+ },
+ class: 'motor',
+ isNotFor: ['coalaboard'],
+ func: function(sprite, script) {
+ var value = Entry.Coalaboard.servoMaxValue - (script.getNumberValue('VALUE') + 1);
+ value = Math.min(value, Entry.Coalaboard.servoMaxValue);
+ value = Math.max(value, Entry.Coalaboard.servoMinValue);
+ Entry.hw.sendQueue[script.getStringField('PORT')] = value;
+ return script.callReturn();
+ },
+ syntax: { js: [], py: ['Coalaboard.servomotor_angle(%1, %2)'] },
+ },
+ //endregion coalaboard 코알라보드
+ };
+};
+// 언어 적용
+Entry.Coalaboard.setLanguage = function() {
+ return {
+ ko: {
+ // ko.js에 작성하던 내용
+ template: {
+ coalaboard_when_button_pressed: '%1 버튼 %2 눌러졌을 때',
+ coalaboard_when_sensor_get_value: '%1 %2 값 %3 %4 일 때',
+ coalaboard_is_touch_pressed: '버튼 %1 이(가) %2 인가?',
+ coalaboard_is_sensor_value_compare: '%1 값 %2 %3 인가?',
+ coalaboard_sensor_value: '%1 값',
+ coalaboard_convert_scale: '변환 %1 값 %2 ~ %3 에서 %4 ~ %5',
+ coalaboard_turn_on_color_led_by_rgb: '엘이디를 빨강 %1 초록 %2 파랑 %3 %4 (으)로 켜기',
+ coalaboard_turn_on_color_led_by_picker: '엘이디를 %1 (으)로 켜기 %2',
+ coalaboard_turn_on_color_led_by_value: '엘이디를 %1 (으)로 켜기 %2',
+ coalaboard_turn_off_color_led: '엘이디 끄기 %1',
+ coalaboard_buzzer: '버저음 %1 내기 %2',
+ coalaboard_servomotor_angle: '서보모터 %1 각도 %2 %3',
+ coalaboard_dc_direction_speed: '디씨모터 %1 방향 %2 속력 %3 %4',
+ coalaboard_dc_speed: '디씨모터 %1 속도 %2 %3',
+ coalaboard_turn_off_all_motors: '모든 모터 멈추기 %1',
+ },
+ Blocks: {
+ COALABOARD_button_pressed: '누름',
+ COALABOARD_button_released: '누르지 않음',
+ COALABOARD_light: '밝기 센서',
+ COALABOARD_IR: '적외선 센서',
+ COALABOARD_touch: '버튼',
+ COALABOARD_temperature: '온도 센서',
+ COALABOARD_ultrasonicSensor: '초음파 센서',
+ COALABOARD_vibrationSensor: '진동 센서',
+ COALABOARD_potentiometer: '가변저항',
+ COALABOARD_MIC: '소리 센서',
+ COALABOARD_UserSensor: '사용자 입력',
+ COALABOARD_UserInput: '사용자 입력',
+ COALABOARD_dc_direction_ccw: '반시계',
+ COALABOARD_dc_direction_cw: '시계',
+ },
+ Menus: {
+ coalaboard: '코알라보드',
+ },
+ Device: {
+ coalaboard: '코알라보드',
+ },
+ Helper: {
+ coalaboard_when_button_pressed: '비트브릭 버튼을 누르면 아래에 연결된 블록들을 실행합니다.',
+ coalaboard_when_sensor_get_value:
+ '비트브릭 센서의 값과 오른쪽에 입력한 값을 비교합니다.\n< : 센서 값이 오른쪽에 위치한 값보다 작은 경우 ‘참’으로 판단합니다.\n> : 센서 값이 오른쪽에 위치한 값보다 큰 경우 ‘참으로 판단합니다.\n= : 센서 값이 오른쪽에 위치한 값과 같은 경우 ‘참으로 판단합니다.',
+ coalaboard_sensor_value:
+ '비트브릭 센서를 사용할 수 있는 블록입니다. 센서값의 범위는 0 ~1023입니다. 메인보드에 연결된 센서의 종류와 포트번호를 자동으로 인식합니다. 블록 안의 화살표를 눌러 사용하려고 하는 센서를 선택하세요.',
+ coalaboard_convert_scale: '비트브릭 센서의 값의 범위를 바꿀 수 있습니다.',
+ coalaboard_is_touch_pressed: '비트브릭 센서 중 버튼을 눌렀을 경우 ‘참’으로 판단합니다.',
+ coalaboard_turn_off_color_led: '비트브릭 엘이디를 끕니다.',
+ coalaboard_turn_on_color_led_by_rgb:
+ '비트브릭 엘이디를 빛의 삼원색인 빨강,초록,파랑을 혼합하여 켭니다. 값의 범위는 0 ~ 255입니다.',
+ coalaboard_turn_on_color_led_by_picker: '비트브릭 엘이디를 색상 창을 사용해 켭니다.',
+ coalaboard_turn_on_color_led_by_value:
+ '비트브릭 엘이디를 색상 값으로 켭니다. 값의 범위는 0 ~ 199입니다.',
+ coalaboard_buzzer:
+ '비트브릭 버저를 사용하여 소리를 냅니다. 값의 범위는 0 ~ 96입니다. 값이 0일 때는 버저 소리를 끕니다.',
+ coalaboard_turn_off_all_motors: '비트브릭 모터를 모두 끕니다.',
+ coalaboard_dc_speed:
+ '비트브릭 디씨모터의 속도를 제어합니다. 속도 값의 범위는 –100 ~ 100입니다. 음수(-)일 때는 반시계방향으로 회전합니다. 양수(+)일 때는 시계방향으로 회전합니다. 속도가 0일 때는 회전을 멈춥니다.',
+ coalaboard_dc_direction_speed:
+ '비트브릭 디씨모터의 방향과 속력을 제어합니다. 방향은 시계방향과 반시계방향을 선택할 수 있습니다. 속력 값의 범위는 0 ~ 100입니다. 속력이 0일 때는 회전을 멈춥니다.',
+ coalaboard_servomotor_angle:
+ '비트브릭 서보모터의 각도를 제어합니다. 각도 값의 범위는 0 ~ 180입니다.'
+ }
+ },
+ en: {
+ // en.js에 작성하던 내용
+ template: {
+ coalaboard_when_button_pressed: '%1 when button %2',
+ coalaboard_when_sensor_get_value: '%1 when %2 value %3 %4',
+ coalaboard_is_touch_pressed: 'button %1 %2?',
+ coalaboard_is_sensor_value_compare: '%1 %2 %3? ',
+ coalaboard_sensor_value: '%1 value',
+ coalaboard_convert_scale: 'map %1 value from %2 ~ %3 to %4 ~ %5',
+ coalaboard_turn_on_color_led_by_rgb: 'set LED color to Red %1 Green %2 Blue %3 %4',
+ coalaboard_turn_on_color_led_by_picker: 'set LED color to %1 %2',
+ coalaboard_turn_on_color_led_by_value: 'set LED color %1 %2',
+ coalaboard_turn_off_color_led: 'turn off LED %1',
+ coalaboard_buzzer: 'buzz note %1 %2',
+ coalaboard_servomotor_angle: 'servo motor %1 degree %2 %3',
+ coalaboard_dc_direction_speed: 'dc motor %1 direction %2 speed %3 %4',
+ coalaboard_dc_speed: 'dc motor %1 velocity %2 %3',
+ coalaboard_turn_off_all_motors: 'stop all motors %1',
+ },
+ Blocks: {
+ COALABOARD_button_pressed: 'pressed',
+ COALABOARD_button_released: 'released',
+ COALABOARD_light: 'light',
+ COALABOARD_IR: 'IR',
+ COALABOARD_touch: 'touch',
+ COALABOARD_temperature: 'temperature',
+ COALABOARD_ultrasonicSensor: 'ultrasonicSenso',
+ COALABOARD_vibrationSensor: 'vibrationSensor',
+ COALABOARD_potentiometer: 'potentiometer',
+ COALABOARD_MIC: 'MIC',
+ COALABOARD_UserSensor: 'UserSensor',
+ COALABOARD_UserInput: 'UserInput',
+ COALABOARD_dc_direction_ccw: 'CCW',
+ COALABOARD_dc_direction_cw: 'CW',
+ },
+ Menus: {
+ coalaboard: 'coalaboard',
+ },
+ },
+ };
+};
+
+module.exports = Entry.Coalaboard;
diff --git a/src/playground/blocks/hardware/block_roborobo.js b/src/playground/blocks/hardware/block_roborobo.js
deleted file mode 100644
index c86c6a69c7..0000000000
--- a/src/playground/blocks/hardware/block_roborobo.js
+++ /dev/null
@@ -1,4654 +0,0 @@
-'use strict';
-
-Entry.Roborobo_Roduino = {
- id: '10.1',
- name: 'roborobo_roduino',
- url: 'http://www.roborobo.co.kr',
- imageName: 'roborobo_roduino.png',
- title: {
- ko: '로두이노',
- en: 'Roduino',
- },
- INSTRUCTION: {
- INPUT: 0,
- OUTPUT: 1,
- ANALOG: 2,
- PWM: 3,
- SERVO: 4,
- SONAR: 11,
- },
- setZero: function() {
- Entry.hw.sendQueue.colorPin = 0;
- Entry.hw.sendQueue.digitalPinMode = [];
- Entry.hw.sendQueue.preDigitalPinMode = [];
- Entry.hw.sendQueue.stopSend = false;
-
- for (var port = 0; port < 14; port++) {
- Entry.hw.sendQueue[port] = 0;
- Entry.hw.sendQueue.preDigitalPinMode[port] = -2;
- Entry.hw.sendQueue.digitalPinMode[port] = -1;
- }
- this.ColorPin = [0, 0, 0];
- Entry.hw.update();
- },
- ColorPin: [0, 0, 0],
-
- monitorTemplate: {
- imgPath: 'hw/roborobo_roduino.png',
- keys: ['value'],
- width: 256,
- height: 256,
- listPorts: {
- a0: {
- name: 'A0',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- a1: {
- name: 'A1',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- a2: {
- name: 'A2',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- a3: {
- name: 'A3',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- a4: {
- name: 'A4',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- a5: {
- name: 'A5',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- 2: {
- name: 'D2',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- 3: {
- name: 'D3',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- 4: {
- name: 'D4',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- 5: {
- name: 'D5',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- 6: {
- name: 'D6',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- 7: {
- name: 'D7',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- 8: {
- name: 'D8',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- 9: {
- name: 'D9',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- 10: {
- name: 'D10',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- },
- mode: 'both',
- },
-};
-
-Entry.Roborobo_Roduino.setLanguage = function() {
- return {
- ko: {
- template: {
- roduino_get_analog_number: '%1 ',
- roduino_get_port_number: '%1 ',
- roduino_get_analog_value: '아날로그 %1 번 센서값 ',
- roduino_get_digital_value: '디지털 %1 번 센서값 ',
- roduino_set_digital: '디지털 %1 번 핀 %2 %3',
- roduino_motor: '%1 %2 %3',
- roduino_set_color_pin: '컬러센서 R : %1, G : %2, B : %3 %4',
- roduino_get_color: '컬러센서 %1 감지',
- roduino_on_block: ' On ',
- roduino_off_block: ' Off ',
- roduino_set_servo_value: '서보모터 %1 번 핀 %2˚ %3',
- roduino_set_pwm_value: 'PWM %1 번 핀 %2으로 전류조절 %3',
- roduino_get_sensor_analog_value: '아날로그 %1 %2 번 핀 값',
- roduino_get_sensor_digital_value: '디지털 %1 %2 번 핀 값',
- },
- Blocks: {
- roborobo_get_temperutre: '온도센서',
- roborobo_get_joystick_x: '조이스틱X',
- roborobo_get_joystick_y: '조이스틱Y',
- roborobo_get_light: '빛센서',
- roborobo_get_dial: '다이얼',
- roborobo_get_keypad_a: 'A키패트(키번호)',
- roborobo_get_ultrasonic: '초음파센서[cm]',
- roborobo_num_analog_value_1: '아날로그',
- roborobo_num_analog_value_2: '번 센서값',
- roborobo_get_digital_value_1: '디지털',
- roborobo_num_pin_1: '디지털',
- roborobo_num_pin_2: '번 핀',
- roborobo_on: '켜기',
- roborobo_off: '끄기',
- roborobo_motor1: '모터1',
- roborobo_motor2: '모터2',
- roborobo_motor_CW: '정회전',
- roborobo_motor_CCW: '역회전',
- roborobo_motor_stop: '정지',
- roborobo_input_mode: '입력',
- roborobo_output_mode: '출력',
- roborobo_pwm_mode: '전류조절(pwm)',
- roborobo_servo_mode: '서보모터',
- roborobo_color: '컬러센서',
- roborobo_color_red: ' 빨간색 ',
- roborobo_color_green: ' 녹색 ',
- roborobo_color_blue: ' 파란색 ',
- roborobo_color_yellow: ' 노란색 ',
- roborobo_color_detected: ' 감지 ',
- roborobo_degree: ' ˚',
- },
- },
- en: {
- template: {
- roduino_get_analog_number: '%1 ',
- roduino_get_port_number: '%1 ',
- roduino_get_analog_value: 'Analog %1 Sensor value ',
- roduino_get_digital_value: 'Digital %1 Sensor value ',
- roduino_set_digital: 'Digital %1 Pin %2 %3',
- roduino_motor: '%1 %2 %3',
- roduino_set_color_pin: 'Color Sensor R : %1, G : %2, B : %3 %4',
- roduino_get_color: 'Color Sensor %1 Detected ',
- roduino_on_block: ' On ',
- roduino_off_block: ' Off ',
- roduino_set_servo_value: 'Servo %1 Pin %2˚ %3',
- roduino_set_pwm_value: 'PWM Set pin %1 to %2',
- roduino_get_sensor_analog_value: 'analog %1 Pin %2 value',
- roduino_get_sensor_digital_value: 'digital %1 %2 번 핀 값',
- },
- Blocks: {
- roborobo_num_analog_value_1: 'Analog',
- roborobo_num_analog_value_2: 'Sensor Value',
- roborobo_get_digital_value_1: 'Digital',
- roborobo_num_pin_1: 'Digital',
- roborobo_num_pin_2: 'Pin',
- roborobo_on: 'On',
- roborobo_off: 'Off',
- roborobo_motor1: 'motor1',
- roborobo_motor2: 'motor2',
- roborobo_motor_CW: 'ClockWise',
- roborobo_motor_CCW: 'CounterClockWise',
- roborobo_motor_stop: 'Stop',
- roborobo_input_mode: 'Input',
- roborobo_output_mode: 'Output',
- roborobo_pwm_mode: 'PWM',
- roborobo_servo_mode: 'Servo',
- roborobo_color: 'Color Sensor ',
- roborobo_color_red: ' Red ',
- roborobo_color_green: ' Green ',
- roborobo_color_blue: ' Blue ',
- roborobo_color_yellow: ' Yellow ',
- roborobo_color_detected: ' Detected ',
- roborobo_degree: ' ˚',
- roborobo_get_temperutre: 'Temperature Sensor',
- roborobo_get_joystick_x: 'JoystickX',
- roborobo_get_joystick_y: 'JoystickY',
- roborobo_get_light: 'Light Sensor',
- roborobo_get_dial: 'Dial',
- roborobo_get_keypad_a: 'A Keypad(key number)',
- roborobo_get_ultrasonic: 'Ultrasonic Sensor[cm]',
- },
- },
- };
-};
-
-Entry.Roborobo_SchoolKit = {
- hasPracticalCourse: true,
- id: '10.2',
- name: 'roborobo_schoolkit',
- url: 'http://www.roborobo.co.kr',
- imageName: 'roborobo_schoolkit.png',
- title: {
- ko: '스쿨키트',
- en: 'School Kit',
- },
- pinMode: {
- INPUT: 0,
- OUTPUT: 1,
- ANALOG: 2,
- PWM: 3,
- SERVO: 4,
- },
- inputPort: {
- ir: 7,
- sound: 8,
- contact: 9,
- cds: 10,
- },
- setZero: function() {
- Entry.hw.sendQueue.digitalPinMode = [];
- Entry.hw.sendQueue.previousValue = [];
-
- for (var port = 0; port < 14; port++) {
- Entry.hw.sendQueue[port] = 0;
- Entry.hw.sendQueue.digitalPinMode[port] = 0;
- Entry.hw.sendQueue.previousValue[port] = -1;
- }
- Entry.hw.update();
- },
- monitorTemplate: {
- imgPath: 'hw/roborobo_schoolkit.png',
- keys: ['value'],
- width: 256,
- height: 256,
- listPorts: {
- '0': {
- name: 'D1',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- '1': {
- name: 'D2',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- '2': {
- name: 'D3',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- '3': {
- name: 'D4',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- '4': {
- name: 'D5',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- '5': {
- name: 'D6',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- '6': {
- name: 'D7',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- },
- mode: 'both',
- },
-};
-
-Entry.Roborobo_RoE = {
- id: '48.1',
- name: 'roborobo_roe',
- url: 'http://www.roborobo.co.kr',
- imageName: 'roborobo_roe.png',
- title: {
- ko: '로이',
- en: 'Ro-E',
- },
- setZero: function() {
- Entry.hw.sendQueue['LED'] = 0;
- Entry.hw.sendQueue['Melody'] = [0, 0, 0]; //[octave, note, duration]
- Entry.hw.sendQueue['LeftMotor'] = [0, 0]; //[direction, value]
- Entry.hw.sendQueue['RightMotor'] = [0, 0]; //[direction, value]
- Entry.hw.update();
- },
- motorDiretion: {
- STOP: 0,
- CW: 1,
- CCW: 2
- },
- monitorTemplate: {
- imgPath: 'hw/roborobo_roe.png',
- keys: ['value'],
- width: 256,
- height: 256,
- listPorts: {
- lColor: {
- name: 'Color Sensor(Left)',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- rColor: {
- name: 'Color Sensor(Right)',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- ir: {
- name: 'IR Sensor',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- switch: {
- name: 'Switch Sensor',
- type: 'input',
- pos: {
- x: 0,
- y: 0,
- },
- },
- },
- mode: 'both',
- },
-};
-
-Entry.Roborobo_Roduino.blockMenuBlocks = [
- 'roduino_on_block',
- 'roduino_off_block',
- 'roduino_get_sensor_analog_value',
- 'roduino_get_sensor_digital_value',
- 'roduino_get_analog_value',
- 'roduino_get_digital_value',
- 'roduino_get_color',
- 'roduino_set_digital',
- 'roduino_motor',
- 'roduino_set_color_pin',
- 'roduino_set_servo_value',
- 'roduino_set_pwm_value',
-];
-
-Entry.Roborobo_Roduino.getBlocks = function() {
- return {
- //region roduino 로두이노
- roduino_on_block: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- events: {},
- def: {
- params: [null],
- type: 'roduino_on_block',
- },
- paramsKeyMap: {},
- class: 'roduino_value',
- isNotFor: ['roborobo_roduino'],
- func: function(sprite, script) {
- return '1';
- },
- syntax: {
- js: [],
- py: ['Roborobo_roduino.roduino_on_block()'],
- },
- },
- roduino_off_block: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- events: {},
- def: {
- params: [null],
- type: 'roduino_off_block',
- },
- paramsKeyMap: {},
- class: 'roduino_value',
- isNotFor: ['roborobo_roduino'],
- func: function(sprite, script) {
- return '0';
- },
- syntax: {
- js: [],
- py: ['Roborobo_roduino.roduino_off_block()'],
- },
- },
- roduino_get_analog_number: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [
- ['0', '0'],
- ['1', '1'],
- ['2', '2'],
- ['3', '3'],
- ['4', '4'],
- ['5', '5'],
- ],
- value: '0',
- 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.getStringField('PORT');
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: '%1',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- ['0', '0'],
- ['1', '1'],
- ['2', '2'],
- ['3', '3'],
- ['4', '4'],
- ['5', '5'],
- ],
- value: '0',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- ],
- keyOption: 'roduino_get_analog_number',
- },
- ],
- },
- },
- roduino_get_port_number: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [
- ['2', '2'],
- ['3', '3'],
- ['4', '4'],
- ['5', '5'],
- ['6', '6'],
- ['7', '7'],
- ['8', '8'],
- ],
- value: '2',
- 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.getStringField('PORT');
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: '%1',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- ['2', '2'],
- ['3', '3'],
- ['4', '4'],
- ['5', '5'],
- ['6', '6'],
- ['7', '7'],
- ['8', '8'],
- ],
- value: '2',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- ],
- keyOption: 'roduino_get_port_number',
- },
- ],
- },
- },
- roduino_get_analog_value: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- events: {},
- def: {
- params: [
- {
- type: 'roduino_get_analog_number',
- },
- ],
- type: 'roduino_get_analog_value',
- },
- paramsKeyMap: {
- VALUE: 0,
- },
- class: 'roduino_value',
- isNotFor: ['roborobo_roduino'],
- func: function(sprite, script) {
- var signal = script.getValue('VALUE', script);
- return Entry.hw.getAnalogPortValue(signal);
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: 'Roborobo_roduino.read_analog(%1)',
- blockType: 'param',
- textParams: [
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- },
- ],
- },
- },
- roduino_get_digital_value: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- events: {},
- def: {
- params: [
- {
- type: 'roduino_get_port_number',
- },
- ],
- type: 'roduino_get_digital_value',
- },
- paramsKeyMap: {
- VALUE: 0,
- },
- class: 'roduino_value',
- isNotFor: ['roborobo_roduino'],
- func: function(sprite, script) {
- var signal = script.getNumberValue('VALUE', script);
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = [
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- ];
- }
- Entry.hw.sendQueue.digitalPinMode[signal] =
- Entry.Roborobo_Roduino.INSTRUCTION.INPUT;
- Entry.hw.update();
- return Entry.hw.getDigitalPortValue(signal);
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: 'Roborobo_roduino.read_digital(%1)',
- blockType: 'param',
- textParams: [
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- },
- ],
- },
- },
- roduino_get_color: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roborobo_color_red, 'red'],
- [Lang.Blocks.roborobo_color_green, 'green'],
- [Lang.Blocks.roborobo_color_blue, 'blue'],
- [Lang.Blocks.roborobo_color_yellow, 'yellow'],
- ],
- value: 'red',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- ],
- events: {},
- def: {
- params: [null],
- type: 'roduino_get_color',
- },
- paramsKeyMap: {
- VALUE: 0,
- },
- class: 'roduino_value',
- isNotFor: ['roborobo_roduino'],
- func: function(sprite, script) {
- var flag = 0;
- var signal = script.getField('VALUE', script);
- var value = [
- Entry.hw.portData[Entry.Roborobo_Roduino.ColorPin[0]],
- Entry.hw.portData[Entry.Roborobo_Roduino.ColorPin[1]],
- Entry.hw.portData[Entry.Roborobo_Roduino.ColorPin[2]],
- ];
-
- switch (signal) {
- case 'red':
- if (value[0] == 1 && value[1] == 0 && value[2] == 0) {
- flag = 1;
- }
- break;
- case 'green':
- if (value[0] == 0 && value[1] == 1 && value[2] == 0) {
- flag = 1;
- }
- break;
- case 'blue':
- if (value[0] == 0 && value[1] == 0 && value[2] == 1) {
- flag = 1;
- }
- break;
- case 'yellow':
- if (value[0] == 1 && value[1] == 1 && value[2] == 1) {
- flag = 1;
- }
- break;
- }
- return flag;
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: 'Roborobo_roduino.read_color(%1)',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roborobo_color_red, 'red'],
- [Lang.Blocks.roborobo_color_green, 'green'],
- [Lang.Blocks.roborobo_color_blue, 'blue'],
- [Lang.Blocks.roborobo_color_yellow, 'yellow'],
- ],
- value: 'red',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- ],
- },
- ],
- },
- },
- roduino_get_sensor_analog_value: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roborobo_get_temperutre, 'temperature'],
- [Lang.Blocks.roborobo_get_joystick_x, 'joystickX'],
- [Lang.Blocks.roborobo_get_joystick_y, 'joystickY'],
- [Lang.Blocks.roborobo_get_light, 'light'],
- [Lang.Blocks.roborobo_get_dial, 'dial'],
- [Lang.Blocks.roborobo_get_keypad_a, 'keypad'],
- ],
- value: 'temperature',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- events: {},
- def: {
- params: [
- null,
- {
- type: 'roduino_get_analog_number',
- },
- ],
- type: 'roduino_get_sensor_analog_value',
- },
- paramsKeyMap: {
- SENSOR: 0,
- VALUE: 1,
- },
- class: 'roduino_value',
- isNotFor: ['roborobo_roduino'],
- func: function(sprite, script) {
- var sensor = script.getField('SENSOR');
- var signal = script.getNumberValue('VALUE');
- var readData = Entry.hw.getAnalogPortValue(signal);
- var data = 0;
- switch (sensor) {
- case 'temperature':
- // var data = 5 / 51.0 * readData - 22;
- data = readData;
- break;
- case 'joystickX':
- readData = readData >> 6;
- if (readData > 14) data = 2;
- else if (readData > 9) data = 1;
- else if (readData > 5) data = 0;
- else if (readData > 1) data = -1;
- else data = -2;
- break;
- case 'joystickY':
- readData = readData >> 6;
- if (readData > 14) data = 2;
- else if (readData > 9) data = 1;
- else if (readData > 5) data = 0;
- else if (readData > 1) data = -1;
- else data = -2;
- break;
- case 'light':
- data = Math.round(readData / 10) * 10;
- break;
- case 'dial':
- data = Math.round(readData / 10);
- break;
- case 'keypad':
- if (readData >= 450) data = 1;
- else if (readData >= 390) data = 2;
- else if (readData >= 310) data = 3;
- else if (readData >= 200) data = 4;
- else if (readData >= 100) data = 5;
- else data = 0;
- break;
- }
- return data;
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: 'Roborobo_roduino.read_analog_sensor(%1, %2)',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roborobo_get_temperutre, 'temperature'],
- [Lang.Blocks.roborobo_get_joystick_x, 'joystickX'],
- [Lang.Blocks.roborobo_get_joystick_y, 'joystickY'],
- [Lang.Blocks.roborobo_get_light, 'light'],
- [Lang.Blocks.roborobo_get_dial, 'dial'],
- [Lang.Blocks.roborobo_get_keypad_a, 'keypad'],
- ],
- value: 'temperature',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- },
- ],
- },
- },
- roduino_get_sensor_digital_value: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [[Lang.Blocks.roborobo_get_ultrasonic, 'ultrasonic']],
- value: 'ultrasonic',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- events: {},
- def: {
- params: [
- null,
- {
- type: 'roduino_get_port_number',
- },
- ],
- type: 'roduino_get_sensor_digital_value',
- },
- paramsKeyMap: {
- SENSOR: 0,
- VALUE: 1,
- },
- class: 'roduino_value',
- isNotFor: ['roborobo_roduino'],
- func: function(sprite, script) {
- var sensor = script.getField('SENSOR');
- var signal = script.getNumberValue('VALUE', script);
- switch (sensor) {
- case 'ultrasonic':
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = [
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- ];
- }
- Entry.hw.sendQueue.digitalPinMode[signal] =
- Entry.Roborobo_Roduino.INSTRUCTION.SONAR;
- Entry.hw.update();
- break;
- }
- return Entry.hw.getDigitalPortValue(signal);
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: 'Roborobo_roduino.read_digital_sensor(%1, %2)',
- textParams: [
- {
- type: 'Dropdown',
- options: [[Lang.Blocks.roborobo_get_ultrasonic, 'ultrasonic']],
- value: 'ultrasonic',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- },
- ],
- },
- },
- roduino_set_digital: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roborobo_on, 'on'],
- [Lang.Blocks.roborobo_off, 'off'],
- ],
- value: 'on',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- {
- type: 'Indicator',
- img: 'block_icon/hardware_icon.svg',
- size: 12,
- },
- ],
- events: {},
- def: {
- params: [
- {
- type: 'roduino_get_port_number',
- },
- null,
- null,
- ],
- type: 'roduino_set_digital',
- },
- paramsKeyMap: {
- VALUE: 0,
- OPERATOR: 1,
- },
- class: 'roduino_set',
- isNotFor: ['roborobo_roduino'],
- func: function(sprite, script) {
- var pin = script.getNumberValue('VALUE', script);
- var operator = script.getField('OPERATOR');
- var value = operator == 'on' ? 1 : 0;
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = [
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- ];
- }
- Entry.hw.sendQueue.digitalPinMode[pin] = Entry.Roborobo_Roduino.INSTRUCTION.OUTPUT;
-
- Entry.hw.setDigitalPortValue(pin, value);
- return script.callReturn();
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: 'Roborobo_roduino.wirte_digital(%1, %2)',
- textParams: [
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roborobo_on, 'on'],
- [Lang.Blocks.roborobo_off, 'off'],
- ],
- value: 'on',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- ],
- },
- ],
- },
- },
- roduino_get_pwm_port_number: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic_string_field',
- statements: [],
- template: '%1',
- params: [
- {
- type: 'Dropdown',
- options: [
- ['3', 3],
- ['5', 5],
- ['6', 6],
- ],
- value: 3,
- 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.getNumberField('PORT');
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: '%1',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- ['3', 3],
- ['5', 5],
- ['6', 6],
- ],
- value: 3,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- ],
- keyOption: 'roduino_get_pwm_port_number',
- },
- ],
- },
- },
- roduino_get_pwm_output_value: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic_string_field',
- statements: [],
- template: '%1',
- params: [
- {
- type: 'Dropdown',
- options: [
- ['0', '0'],
- ['1', '1'],
- ['2', '2'],
- ['3', '3'],
- ['4', '4'],
- ['5', '5'],
- ['6', '6'],
- ['7', '7'],
- ['8', '8'],
- ['9', '9'],
- ['10', '10'],
- ['11', '11'],
- ['12', '12'],
- ['13', '13'],
- ['14', '14'],
- ['15', '15'],
- ],
- value: '0',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- ],
- events: {},
- def: {
- params: [null],
- },
- paramsKeyMap: {
- VALUE: '0',
- },
- func: function(sprite, script) {
- return script.getNumberField('VALUE');
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: '%1',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- ['0', '0'],
- ['1', '1'],
- ['2', '2'],
- ['3', '3'],
- ['4', '4'],
- ['5', '5'],
- ['6', '6'],
- ['7', '7'],
- ['8', '8'],
- ['9', '9'],
- ['10', '10'],
- ['11', '11'],
- ['12', '12'],
- ['13', '13'],
- ['14', '14'],
- ['15', '15'],
- ],
- value: '0',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- ],
- keyOption: 'roduino_get_pwm_output_value',
- },
- ],
- },
- },
- roduino_set_pwm_value: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Indicator',
- img: 'block_icon/hardware_icon.svg',
- size: 12,
- },
- ],
- events: {},
- def: {
- params: [
- {
- type: 'roduino_get_pwm_port_number',
- },
- {
- type: 'roduino_get_pwm_output_value',
- },
- null,
- ],
- type: 'roduino_set_pwm_value',
- },
- paramsKeyMap: {
- PIN: 0,
- VALUE: 1,
- },
- class: 'roduino_set',
- isNotFor: ['roborobo_roduino'],
- func: function(sprite, script) {
- var pin = script.getNumberValue('PIN', script);
- var value = script.getNumberValue('VALUE');
-
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = [
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- ];
- }
-
- Entry.hw.sendQueue.digitalPinMode[pin] = Entry.Roborobo_Roduino.INSTRUCTION.PWM;
-
- Entry.hw.setDigitalPortValue(pin, value);
- return script.callReturn();
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: 'Roborobo_roduino.write_analog(%1, %2)',
- textParams: [
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- },
- ],
- },
- },
- roduino_get_servo_port_number: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic_string_field',
- statements: [],
- template: '%1',
- params: [
- {
- type: 'Dropdown',
- options: [
- ['3', 3],
- ['5', 5],
- ['6', 6],
- ],
- value: 3,
- 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.getNumberField('PORT');
- },
-
- syntax: {
- js: [],
- py: [
- {
- syntax: '%1',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- ['3', 3],
- ['5', 5],
- ['6', 6],
- ],
- value: 3,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- ],
- keyOption: 'roduino_get_servo_port_number',
- },
- ],
- },
- },
- roduino_set_servo_value: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Indicator',
- img: 'block_icon/hardware_icon.svg',
- size: 12,
- },
- ],
- events: {},
- def: {
- params: [
- {
- type: 'roduino_get_servo_port_number',
- },
- {
- type: 'number',
- params: ['90'],
- },
- null,
- ],
- type: 'roduino_set_servo_value',
- },
- paramsKeyMap: {
- PIN: 0,
- VALUE: 1,
- },
- class: 'roduino_set',
- isNotFor: ['roborobo_roduino'],
- func: function(sprite, script) {
- var pin = script.getNumberValue('PIN', script);
- var value = script.getNumberValue('VALUE');
-
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = [
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- ];
- }
-
- Entry.hw.sendQueue.digitalPinMode[pin] = Entry.Roborobo_Roduino.INSTRUCTION.SERVO;
-
- if (value < 0) {
- value = 0;
- } else if (value > 180) {
- value = 180;
- }
-
- Entry.hw.setDigitalPortValue(pin, value);
- return script.callReturn();
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: 'Roborobo_roduino.move_servo(%1, %2)',
- textParams: [
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- },
- ],
- },
- },
- roduino_motor: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roborobo_motor1, 'motor1'],
- [Lang.Blocks.roborobo_motor2, 'motor2'],
- ],
- value: 'motor1',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roborobo_motor_CW, 'cw'],
- [Lang.Blocks.roborobo_motor_CCW, 'ccw'],
- [Lang.Blocks.roborobo_motor_stop, 'stop'],
- ],
- value: 'cw',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- {
- type: 'Indicator',
- img: 'block_icon/hardware_icon.svg',
- size: 12,
- },
- ],
- events: {},
- def: {
- params: [null, null, null],
- type: 'roduino_motor',
- },
- paramsKeyMap: {
- MODE: 0,
- OPERATOR: 1,
- },
- class: 'roduino_set',
- isNotFor: ['roborobo_roduino'],
- func: function(sprite, script) {
- var pin1 = 0;
- var pin2 = 0;
- var value1 = 0;
- var value2 = 0;
- var mode = script.getField('MODE');
- var operator = script.getField('OPERATOR');
-
- if (mode == 'motor1') {
- pin1 = 9;
- pin2 = 10;
- } else {
- pin1 = 11;
- pin2 = 12;
- }
-
- if (operator == 'cw') {
- value1 = 1;
- value2 = 0;
- } else if (operator == 'ccw') {
- value1 = 0;
- value2 = 1;
- } else {
- value1 = 0;
- value2 = 0;
- }
-
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = [
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- ];
- }
- Entry.hw.sendQueue.digitalPinMode[pin1] = Entry.Roborobo_Roduino.INSTRUCTION.OUTPUT;
- Entry.hw.sendQueue.digitalPinMode[pin2] = Entry.Roborobo_Roduino.INSTRUCTION.OUTPUT;
-
- Entry.hw.setDigitalPortValue(pin1, value1);
- Entry.hw.setDigitalPortValue(pin2, value2);
- Entry.hw.update();
- return script.callReturn();
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: 'Roborobo_roduino.move_motor(%1, %2)',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roborobo_motor1, 'motor1'],
- [Lang.Blocks.roborobo_motor2, 'motor2'],
- ],
- value: 'motor1',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roborobo_motor_CW, 'cw'],
- [Lang.Blocks.roborobo_motor_CCW, 'ccw'],
- [Lang.Blocks.roborobo_motor_stop, 'stop'],
- ],
- value: 'cw',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- ],
- },
- ],
- },
- },
- roduino_set_color_pin: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Indicator',
- img: 'block_icon/hardware_icon.svg',
- size: 12,
- },
- ],
- events: {},
- def: {
- params: [
- {
- type: 'number',
- params: ['2'],
- },
- {
- type: 'number',
- params: ['3'],
- },
- {
- type: 'number',
- params: ['4'],
- },
- null,
- ],
- type: 'roduino_set_color_pin',
- },
- paramsKeyMap: {
- RED: 0,
- GREEN: 1,
- BLUE: 2,
- },
- class: 'roduino_set',
- isNotFor: ['roborobo_roduino'],
- func: function(sprite, script) {
- var redPin = script.getNumberValue('RED', script);
- var greenPin = script.getNumberValue('GREEN', script);
- var bluePin = script.getNumberValue('BLUE', script);
-
- Entry.Roborobo_Roduino.ColorPin = [redPin, greenPin, bluePin];
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = [
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- -1,
- ];
- }
- Entry.hw.sendQueue.digitalPinMode[redPin] =
- Entry.Roborobo_Roduino.INSTRUCTION.INPUT;
- Entry.hw.sendQueue.digitalPinMode[greenPin] =
- Entry.Roborobo_Roduino.INSTRUCTION.INPUT;
- Entry.hw.sendQueue.digitalPinMode[bluePin] =
- Entry.Roborobo_Roduino.INSTRUCTION.INPUT;
- Entry.hw.update();
- return script.callReturn();
- },
- syntax: {
- js: [],
- py: ['Roborobo_roduino.set_color_pin_mode(%1, %2, %3)'],
- },
- },
- //endregion roduino 로두이노
- };
-};
-
-Entry.Roborobo_SchoolKit.setLanguage = function() {
- return {
- ko: {
- template: {
- schoolkit_get_in_port_number: '%1 ',
- schoolkit_get_out_port_number: '%1 ',
- schoolkit_get_servo_port_number: '%1 ',
- schoolkit_get_input_value: '디지털 %1 번 센서값 ',
- schoolkit_set_output: '디지털 %1 번 핀 %2 %3',
- schoolkit_motor: '%1 속도 %2(으)로 %3 %4',
- schoolkit_set_servo_value: '서보모터 %1 번 핀 %2˚ %3',
- schoolkit_on_block: ' On ',
- schoolkit_off_block: ' Off ',
- },
- },
- en: {
- template: {
- schoolkit_get_in_port_number: '%1 ',
- schoolkit_get_out_port_number: '%1 ',
- schoolkit_get_servo_port_number: '%1 ',
- schoolkit_get_input_value: 'Digital %1 Sensor value ',
- schoolkit_set_output: 'Digital %1 Pin %2 %3',
- schoolkit_motor: '%1 Speed %2 %3 %4',
- schoolkit_set_servo_value: 'Servo %1 Pin %2˚ %3',
- schoolkit_on_block: ' On ',
- schoolkit_off_block: ' Off ',
- },
- },
- };
-};
-
-Entry.Roborobo_SchoolKit.blockMenuBlocks = [
- 'schoolkit_on_block',
- 'schoolkit_off_block',
- 'schoolkit_get_input_value',
- 'schoolkit_set_output',
- 'schoolkit_motor',
- 'schoolkit_set_servo_value',
-];
-
-Entry.Roborobo_SchoolKit.practicalBlockMenuBlocks = {
- hw_motor: [
- // 'roborobo_motor_speed',
- 'roborobo_move_for_secs',
- 'roborobo_move_for',
- 'roborobo_turn_for',
- 'roborobo_stop_for',
- ],
- hw_melody: [
-
- ],
- hw_sensor: [
- 'roborobo_touch_value',
- 'roborobo_touch_value_boolean',
- 'roborobo_light_value',
- 'roborobo_light_value_boolean',
- 'roborobo_sound_value',
- 'roborobo_sound_value_boolean',
- 'roborobo_irs_value',
- 'roborobo_irs_value_boolean',
- ],
- hw_led: [
- 'roborobo_diode_secs_toggle',
- 'roborobo_diode_toggle',
- 'roborobo_diode_inout_toggle',
- 'roborobo_diode_set_output',
- 'roborobo_diode_input_value',
- ],
-}
-
-Entry.Roborobo_SchoolKit.getBlocks = function() {
- return {
- //region schoolkit 스쿨키트
- schoolkit_on_block: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- events: {},
- def: {
- params: [null],
- type: 'schoolkit_on_block',
- },
- paramsKeyMap: {},
- class: 'schoolkit_value',
- isNotFor: ['roborobo_schoolkit'],
- func: function(sprite, script) {
- return '1';
- },
- syntax: {
- js: [],
- py: ['Roborobo_SchoolKit.schoolkit_on_block()'],
- },
- },
- schoolkit_off_block: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- events: {},
- def: {
- params: [null],
- type: 'schoolkit_off_block',
- },
- paramsKeyMap: {},
- class: 'schoolkit_value',
- isNotFor: ['roborobo_schoolkit'],
- func: function(sprite, script) {
- return '0';
- },
- syntax: {
- js: [],
- py: ['Roborobo_SchoolKit.schoolkit_off_block()'],
- },
- },
- schoolkit_get_out_port_number: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [
- ['OUT1', 2],
- ['OUT2', 3],
- ['OUT3', 4],
- ['OUT4', 5],
- ['OUT5', 6],
- ],
- value: 2,
- 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.getNumberField('PORT');
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: '%1',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- ['OUT1', 2],
- ['OUT2', 3],
- ['OUT3', 4],
- ['OUT4', 5],
- ['OUT5', 6],
- ],
- value: 2,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- ],
- keyOption: 'schoolkit_get_out_port_number',
- },
- ],
- },
- },
- schoolkit_get_servo_port_number: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [
- ['OUT1', 2],
- ['OUT2', 3],
- ['OUT3', 4],
- ],
- value: 2,
- 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.getNumberField('PORT');
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: '%1',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- ['OUT1', 2],
- ['OUT2', 3],
- ['OUT3', 4],
- ],
- value: 2,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- ],
- keyOption: 'schoolkit_get_servo_port_number',
- },
- ],
- },
- },
- schoolkit_get_in_port_number: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [
- ['IN1', 7],
- ['IN2', 8],
- ['IN3', 9],
- ['IN4', 10],
- ['IN5', 11],
- ['IN6', 12],
- ['IN7', 13],
- ],
- value: 7,
- 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.getNumberField('PORT');
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: '%1',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- ['IN1', 7],
- ['IN2', 8],
- ['IN3', 9],
- ['IN4', 10],
- ['IN5', 11],
- ['IN6', 12],
- ['IN7', 13],
- ],
- value: 7,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- ],
- keyOption: 'schoolkit_get_in_port_number',
- },
- ],
- },
- },
- schoolkit_set_output: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roborobo_on, 'on'],
- [Lang.Blocks.roborobo_off, 'off'],
- ],
- value: 'on',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- {
- type: 'Indicator',
- img: 'block_icon/hardware_icon.svg',
- size: 12,
- },
- ],
- events: {},
- def: {
- params: [
- {
- type: 'schoolkit_get_out_port_number',
- },
- null,
- null,
- ],
- type: 'schoolkit_set_output',
- },
- paramsKeyMap: {
- VALUE: 0,
- OPERATOR: 1,
- },
- class: 'schoolkit_set',
- isNotFor: ['roborobo_schoolkit'],
- func: function(sprite, script) {
- var pin = script.getNumberValue('VALUE', script);
- var operator = script.getField('OPERATOR');
- var value = operator == 'on' ? 1 : 0;
-
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = {};
- }
-
- Entry.hw.sendQueue.digitalPinMode[pin] = Entry.Roborobo_SchoolKit.pinMode.OUTPUT;
- Entry.hw.sendQueue[pin] = value;
- return script.callReturn();
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: 'Roborobo_schoolkit.wirte_digital(%1, %2)',
- textParams: [
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roborobo_on, 'on'],
- [Lang.Blocks.roborobo_off, 'off'],
- ],
- value: 'on',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- ],
- },
- ],
- },
- },
- schoolkit_get_input_value: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- events: {},
- def: {
- params: [
- {
- type: 'schoolkit_get_in_port_number',
- },
- ],
- type: 'schoolkit_get_input_value',
- },
- paramsKeyMap: {
- VALUE: 0,
- },
- class: 'schoolkit_value',
- isNotFor: ['roborobo_schoolkit'],
- func: function(sprite, script) {
- var signal = script.getNumberValue('VALUE', script);
- return Entry.hw.portData[signal - 7];
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: 'Roborobo_schoolkit.read_digital(%1)',
- textParams: [
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- },
- ],
- },
- },
- schoolkit_motor: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roborobo_motor1, 'motor1'],
- [Lang.Blocks.roborobo_motor2, 'motor2'],
- ],
- value: 'motor1',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- {
- type: 'Dropdown',
- options: [
- ['0', '45'],
- ['1', '59'],
- ['2', '73'],
- ['3', '87'],
- ['4', '101'],
- ['5', '115'],
- ['6', '129'],
- ['7', '143'],
- ['8', '157'],
- ['9', '171'],
- ['10', '185'],
- ['11', '199'],
- ['12', '213'],
- ['13', '227'],
- ['14', '241'],
- ['15', '255'],
- ],
- value: '45',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roborobo_motor_CW, 'cw'],
- [Lang.Blocks.roborobo_motor_CCW, 'ccw'],
- [Lang.Blocks.roborobo_motor_stop, 'stop'],
- ],
- value: 'cw',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- {
- type: 'Indicator',
- img: 'block_icon/hardware_icon.svg',
- size: 12,
- },
- ],
- events: {},
- def: {
- params: [null, null, null, null],
- type: 'schoolkit_motor',
- },
- paramsKeyMap: {
- MODE: 0,
- VALUE: 1,
- OPERATOR: 2,
- },
- class: 'schoolkit_set',
- isNotFor: ['roborobo_schoolkit'],
- func: function(sprite, script) {
- var mode = script.getField('MODE');
- var pin = 0;
- var operator = script.getField('OPERATOR');
- var value = script.getField('VALUE');
-
- if (mode == 'motor1') {
- pin = 0;
- } else {
- pin = 1;
- }
-
- if (value > 255) {
- value = 255;
- } else if (value < 0) {
- value = 0;
- }
-
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = {};
- }
-
- Entry.hw.sendQueue.digitalPinMode[pin] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[pin + 7] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- if (operator == 'cw') {
- Entry.hw.sendQueue[pin] = value;
- } else if (operator == 'ccw') {
- Entry.hw.sendQueue[pin] = -value;
- } else if (operator == 'stop') {
- Entry.hw.sendQueue[pin] = 0x00;
- }
- return script.callReturn();
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: 'Roborobo_schoolkit.move_motor_speed(%1, %2, %3)',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roborobo_motor1, 'motor1'],
- [Lang.Blocks.roborobo_motor2, 'motor2'],
- ],
- value: 'motor1',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- {
- type: 'Dropdown',
- options: [
- ['0', '45'],
- ['1', '59'],
- ['2', '73'],
- ['3', '87'],
- ['4', '101'],
- ['5', '115'],
- ['6', '129'],
- ['7', '143'],
- ['8', '157'],
- ['9', '171'],
- ['10', '185'],
- ['11', '199'],
- ['12', '213'],
- ['13', '227'],
- ['14', '241'],
- ['15', '255'],
- ],
- value: '45',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roborobo_motor_CW, 'cw'],
- [Lang.Blocks.roborobo_motor_CCW, 'ccw'],
- [Lang.Blocks.roborobo_motor_stop, 'stop'],
- ],
- value: 'cw',
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- ],
- },
- ],
- },
- },
- schoolkit_set_servo_value: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Indicator',
- img: 'block_icon/hardware_icon.svg',
- size: 12,
- },
- ],
- events: {},
- def: {
- params: [
- {
- type: 'schoolkit_get_servo_port_number',
- },
- {
- type: 'number',
- params: ['0'],
- },
- null,
- ],
- type: 'schoolkit_set_servo_value',
- },
- paramsKeyMap: {
- PIN: 0,
- VALUE: 1,
- },
- class: 'schoolkit_set',
- isNotFor: ['roborobo_schoolkit'],
- func: function(sprite, script) {
- var pin = script.getNumberValue('PIN', script);
- var value = script.getNumberValue('VALUE');
-
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = {};
- }
- Entry.hw.sendQueue.digitalPinMode[pin] = Entry.Roborobo_SchoolKit.pinMode.SERVO;
-
- if (value < 0) {
- value = 0;
- } else if (value > 180) {
- value = 180;
- }
- Entry.hw.sendQueue[pin] = value;
- return script.callReturn();
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: 'Roborobo_schoolkit.move_servo(%1, %2)',
- textParams: [
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- },
- ],
- },
- },
- //endregion schoolkit 스쿨키트
- };
-};
-
-Entry.Roborobo_SchoolKit.getPracticalBlocks = function() {
- return {
- // roborobo_mini
- roborobo_motor_speed: {
- color: '#00B200',
- outerLine: '#019101',
- skeleton: 'basic_string_field',
- statements: [],
- isNotFor: ['roborobo_schoolkit'],
- template: '%1',
- params: [
- {
- type: 'Dropdown',
- options: [
- ['1', '52'],
- ['2', '66'],
- ['3', '80'],
- ['4', '94'],
- ['5', '107'],
- ['6', '120'],
- ['7', '134'],
- ['8', '148'],
- ['9', '162'],
- ['10', '176'],
- ['11', '190'],
- ['12', '204'],
- ['13', '218'],
- ['14', '232'],
- ['15', '255'],
- ],
- value: '255',
- fontSize: 11,
- bgColor: '#019101',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- ],
- events: {},
- def: {
- params: [null],
- },
- paramsKeyMap: {
- VALUE: 0,
- },
- func(sprite, script) {
- return script.getStringField('VALUE');
- },
- },
- roborobo_move_for_secs: {
- color: '#00B200',
- outerLine: '#019101',
- skeleton: 'basic',
- fontColor: '#fff',
- statements: [],
- isNotFor: ['roborobo_schoolkit'],
- template: '%1모터를 %2 %3의 속도로 %4초 동안 회전 %5',
- params: [
- {
- type: 'Dropdown',
- options: [
- ['양쪽', '1'],
- ['오른쪽', '2'],
- ['왼쪽', '3'],
- ],
- value: '1',
- fontSize: 11,
- bgColor: '#019101',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- {
- type: 'Dropdown',
- options: [
- ['앞으로', '1'],
- ['뒤로', '2'],
- ],
- value: '1',
- fontSize: 11,
- bgColor: '#019101',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Indicator',
- img: 'block_icon/practical_course/dcmotor.png',
- size: 12,
- },
- ],
- events: {},
- def: {
- params: [
- null,
- null,
- {
- type: 'roborobo_motor_speed',
- },
- {
- type: 'number',
- params: ['2'],
- },
- null,
- ],
- type: 'roborobo_move_for_secs',
- },
- paramsKeyMap: {
- WHEEL: 0,
- DIRECTION: 1,
- SPEED: 2,
- DURATION: 3,
- },
- class: 'roborobo_motor',
- func(sprite, script) {
- const motor1 = 0;
- const motor2 = 1;
- const wheel = script.getNumberField('WHEEL');
- const speed = script.getNumberValue('SPEED');
- const direction = script.getNumberField('DIRECTION');
- const duration = script.getNumberValue('DURATION');
-
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = {};
- }
-
- if (!script.isStart) {
- if (wheel == 1) {
- Entry.hw.sendQueue.digitalPinMode[7] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[0] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[8] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[1] = Entry.Roborobo_SchoolKit.pinMode.PWM;
-
- if (direction == 1) {
- Entry.hw.sendQueue[motor1] = speed;
- Entry.hw.sendQueue[motor2] = speed;
- } else if (direction == 2) {
- Entry.hw.sendQueue[motor1] = -speed;
- Entry.hw.sendQueue[motor2] = -speed;
- }
- } else if (wheel == 2) {
- Entry.hw.sendQueue.digitalPinMode[8] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[1] = Entry.Roborobo_SchoolKit.pinMode.PWM;
-
- if (direction == 1) {
- Entry.hw.sendQueue[motor1] = 0x00;
- Entry.hw.sendQueue[motor2] = speed;
- } else if (direction == 2) {
- Entry.hw.sendQueue[motor1] = 0x00;
- Entry.hw.sendQueue[motor2] = -speed;
- }
- } else if (wheel == 3) {
- Entry.hw.sendQueue.digitalPinMode[7] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[0] = Entry.Roborobo_SchoolKit.pinMode.PWM;
-
- if (direction == 1) {
- Entry.hw.sendQueue[motor1] = speed;
- Entry.hw.sendQueue[motor2] = 0x00;
- } else if (direction == 2) {
- Entry.hw.sendQueue[motor1] = -speed;
- Entry.hw.sendQueue[motor2] = 0x00;
- }
- }
-
- script.wheelMode = wheel;
- script.isStart = true;
- script.timeFlag = 1;
- setTimeout(() => {
- script.timeFlag = 0;
- }, duration * 1000);
- return script;
- } else if (script.timeFlag == 1) {
- return script;
- } else {
- Entry.hw.sendQueue[motor1] = 0x00;
- Entry.hw.sendQueue[motor2] = 0x00;
-
- delete script.timeFlag;
- delete script.isStart;
- delete script.wheelMode;
- Entry.engine.isContinue = false;
- return script.callReturn();
- }
- },
- },
- roborobo_move_for: {
- color: '#00B200',
- outerLine: '#019101',
- skeleton: 'basic',
- fontColor: '#fff',
- statements: [],
- isNotFor: ['roborobo_schoolkit'],
- template: '%1모터를 %2 %3의 속도로 계속 회전 %4',
- params: [
- {
- type: 'Dropdown',
- options: [
- ['양쪽', '1'],
- ['오른쪽', '2'],
- ['왼쪽', '3'],
- ],
- value: '1',
- fontSize: 11,
- bgColor: '#019101',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- {
- type: 'Dropdown',
- options: [
- ['앞으로', '1'],
- ['뒤로', '2'],
- ],
- value: '1',
- fontSize: 11,
- bgColor: '#019101',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Indicator',
- img: 'block_icon/practical_course/dcmotor.png',
- size: 12,
- },
- ],
- events: {},
- def: {
- params: [
- null,
- null,
- {
- type: 'roborobo_motor_speed',
- },
- null,
- ],
- type: 'roborobo_move_for',
- },
- paramsKeyMap: {
- WHEEL: 0,
- DIRECTION: 1,
- SPEED: 2,
- },
- class: 'roborobo_motor',
- //'isNotFor': ['mini'],
- func(sprite, script) {
- const motor1 = 0;
- const motor2 = 1;
- const wheel = script.getNumberField('WHEEL');
- const speed = script.getNumberValue('SPEED');
- const direction = script.getNumberField('DIRECTION');
-
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = {};
- }
-
- if (wheel == 1) {
- Entry.hw.sendQueue.digitalPinMode[7] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[0] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[8] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[1] = Entry.Roborobo_SchoolKit.pinMode.PWM;
-
- if (direction == 1) {
- Entry.hw.sendQueue[motor1] = speed;
- Entry.hw.sendQueue[motor2] = speed;
- } else if (direction == 2) {
- Entry.hw.sendQueue[motor1] = -speed;
- Entry.hw.sendQueue[motor2] = -speed;
- }
- } else if (wheel == 2) {
- Entry.hw.sendQueue.digitalPinMode[8] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[1] = Entry.Roborobo_SchoolKit.pinMode.PWM;
-
- if (direction == 1) {
- Entry.hw.sendQueue[motor1] = 0x00;
- Entry.hw.sendQueue[motor2] = speed;
- } else if (direction == 2) {
- Entry.hw.sendQueue[motor1] = 0x00;
- Entry.hw.sendQueue[motor2] = -speed;
- }
- } else if (wheel == 3) {
- Entry.hw.sendQueue.digitalPinMode[7] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[0] = Entry.Roborobo_SchoolKit.pinMode.PWM;
-
- if (direction == 1) {
- Entry.hw.sendQueue[motor1] = speed;
- Entry.hw.sendQueue[motor2] = 0x00;
- } else if (direction == 2) {
- Entry.hw.sendQueue[motor1] = -speed;
- //Entry.hw.sendQueue[motor2] = 0x00;
- }
- }
-
- return script.callReturn();
- },
- },
- roborobo_turn_for: {
- color: '#00B200',
- outerLine: '#019101',
- skeleton: 'basic',
- fontColor: '#fff',
- statements: [],
- isNotFor: ['roborobo_schoolkit'],
- template: '오른쪽 모터를 %1 %2, 왼쪽 모터를 %3 %4의 속도로 계속 회전 %5',
- params: [
- {
- type: 'Dropdown',
- options: [
- ['앞으로', '1'],
- ['뒤로', '2'],
- ],
- value: '1',
- fontSize: 11,
- bgColor: '#019101',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Dropdown',
- options: [
- ['앞으로', '1'],
- ['뒤로', '2'],
- ],
- value: '1',
- fontSize: 11,
- bgColor: '#019101',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Indicator',
- img: 'block_icon/practical_course/dcmotor.png',
- size: 12,
- },
- ],
- events: {},
- def: {
- params: [
- null,
- { type: 'roborobo_motor_speed' },
- null,
- { type: 'roborobo_motor_speed' },
- null,
- ],
- type: 'roborobo_turn_for',
- },
- paramsKeyMap: {
- RDIR: 0,
- RSPEED: 1,
- LDIR: 2,
- LSPEED: 3,
- },
- class: 'roborobo_motor',
- //'isNotFor': ['mini'],
- func(sprite, script) {
- const motor1 = 0;
- const motor2 = 1;
-
- const rightDir = script.getNumberField('RDIR');
- const rightSpeed = script.getNumberValue('RSPEED');
- const leftDir = script.getNumberField('LDIR');
- const leftSpeed = script.getNumberValue('LSPEED');
-
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = {};
- }
-
- Entry.hw.sendQueue.digitalPinMode[7] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[0] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[8] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[1] = Entry.Roborobo_SchoolKit.pinMode.PWM;
-
- if (leftDir == 1) {
- Entry.hw.sendQueue[motor1] = leftSpeed;
- } else {
- Entry.hw.sendQueue[motor1] = -leftSpeed;
- }
-
- if (rightDir == 1) {
- Entry.hw.sendQueue[motor2] = rightSpeed;
- } else {
- Entry.hw.sendQueue[motor2] = -rightSpeed;
- }
-
- return script.callReturn();
- },
- },
- roborobo_stop_for: {
- color: '#00B200',
- outerLine: '#019101',
- skeleton: 'basic',
- fontColor: '#fff',
- statements: [],
- isNotFor: ['roborobo_schoolkit'],
- template: '%1모터를 정지 %2',
- params: [
- {
- type: 'Dropdown',
- options: [
- ['양쪽', '1'],
- ['오른쪽', '2'],
- ['왼쪽', '3'],
- ],
- value: '1',
- fontSize: 11,
- bgColor: '#019101',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- {
- type: 'Indicator',
- img: 'block_icon/practical_course/dcmotor.png',
- size: 12,
- },
- ],
- events: {},
- def: {
- params: [null, null],
- type: 'roborobo_stop_for',
- },
- paramsKeyMap: {
- WHEEL: 0,
- },
- class: 'roborobo_motor',
- func(sprite, script) {
- const motor1 = 0;
- const motor2 = 1;
- const wheel = script.getNumberField('WHEEL');
-
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = {};
- }
-
- if (wheel == 1) {
- Entry.hw.sendQueue.digitalPinMode[7] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[0] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[8] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[1] = Entry.Roborobo_SchoolKit.pinMode.PWM;
-
- Entry.hw.sendQueue[motor1] = 0x00;
- Entry.hw.sendQueue[motor2] = 0x00;
- } else if (wheel == 2) {
- Entry.hw.sendQueue.digitalPinMode[8] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[1] = Entry.Roborobo_SchoolKit.pinMode.PWM;
-
- Entry.hw.sendQueue[motor2] = 0x00;
- } else if (wheel == 3) {
- Entry.hw.sendQueue.digitalPinMode[7] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue.digitalPinMode[0] = Entry.Roborobo_SchoolKit.pinMode.PWM;
-
- Entry.hw.sendQueue[motor1] = 0x00;
- }
-
- return script.callReturn();
- },
- },
- roborobo_touch_value: {
- color: '#2AB4D3',
- outerLine: '#0e93b1',
- skeleton: 'basic_string_field',
- fontColor: '#fff',
- statements: [],
- isNotFor: ['roborobo_schoolkit'],
- template: '접촉 센서 값',
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- events: {},
- def: {
- params: [null],
- type: 'roborobo_touch_value',
- },
- paramsKeyMap: {},
- class: 'roborobo_touch',
- func(sprite, script) {
- const port = Entry.Roborobo_SchoolKit.inputPort.contact;
- Entry.hw.sendQueue.digitalPinMode[port] = Entry.Roborobo_SchoolKit.pinMode.INPUT;
- Entry.hw.update();
- return Entry.hw.portData[port - 7];
- },
- },
- roborobo_touch_value_boolean: {
- color: '#2AB4D3',
- outerLine: '#0e93b1',
- skeleton: 'basic_boolean_field',
- fontColor: '#fff',
- isNotFor: ['roborobo_schoolkit'],
- template: '접촉 센서가 %1',
- params: [
- {
- type: 'Dropdown',
- options: [
- ['접촉 되면', '1'],
- ['접촉 안되면', '0'],
- ],
- value: '1',
- fontSize: 11,
- bgColor: '#0e93b1',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- ],
- def: {
- params: [null],
- type: 'roborobo_touch_value_boolean',
- },
- paramsKeyMap: {
- TOUCH: 0,
- },
- class: 'roborobo_touch',
- func(sprite, script) {
- const port = Entry.Roborobo_SchoolKit.inputPort.contact;
- const touch = script.getNumberField('TOUCH', script);
-
- Entry.hw.sendQueue.digitalPinMode[port] = Entry.Roborobo_SchoolKit.pinMode.INPUT;
- Entry.hw.update();
-
- const value = Entry.hw.portData[port - 7];
- const isTouch = touch == value;
-
- return isTouch;
- },
- },
- roborobo_light_value: {
- color: '#ff8d0f',
- outerLine: '#e37100',
- skeleton: 'basic_string_field',
- fontColor: '#fff',
- statements: [],
- isNotFor: ['roborobo_schoolkit'],
- template: 'CDS 센서 값',
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- events: {},
- def: {
- params: [null],
- type: 'roborobo_light_value',
- },
- paramsKeyMap: {},
- class: 'roborobo_light',
- func(sprite, script) {
- const port = Entry.Roborobo_SchoolKit.inputPort.cds;
- return Entry.hw.portData[port - 7];
- },
- },
- roborobo_light_value_boolean: {
- color: '#ff8d0f',
- outerLine: '#e37100',
- skeleton: 'basic_boolean_field',
- fontColor: '#fff',
- isNotFor: ['roborobo_schoolkit'],
- template: 'CDS 센서 값 %1 %2',
- params: [
- {
- type: 'Dropdown',
- options: [
- ['=', 'EQUAL'],
- ['>', 'GREATER'],
- ['<', 'LESS'],
- ['≥', 'GREATER_OR_EQUAL'],
- ['≤', 'LESS_OR_EQUAL'],
- ],
- value: 'LESS',
- fontSize: 11,
- bgColor: '#e37100',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- noaRrow: true,
- },
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- def: {
- params: [
- null,
- {
- type: 'number',
- params: ['512'],
- },
- ],
- type: 'roborobo_light_value_boolean',
- },
- paramsKeyMap: {
- OPERATOR: 0,
- RIGHTVALUE: 1,
- },
- class: 'roborobo_light',
- func(sprite, script) {
- const port = Entry.Roborobo_SchoolKit.inputPort.cds;
- const operator = script.getField('OPERATOR', script);
- let rightValue = script.getNumberValue('RIGHTVALUE', script);
- const leftValue = Entry.hw.portData[port - 7];
- let isCheck = false;
-
- if (rightValue < 0) {
- rightValue = 0;
- } else if (rightValue > 1023) {
- rightValue = 1023;
- }
- switch (operator) {
- case 'EQUAL':
- isCheck = leftValue == rightValue;
- break;
- case 'GREATER':
- isCheck = Number(leftValue) > Number(rightValue);
- break;
- case 'LESS':
- isCheck = Number(leftValue) < Number(rightValue);
- break;
- case 'GREATER_OR_EQUAL':
- isCheck = Number(leftValue) >= Number(rightValue);
- break;
- case 'LESS_OR_EQUAL':
- isCheck = Number(leftValue) <= Number(rightValue);
- break;
- }
- return isCheck;
- },
- },
- roborobo_sound_value: {
- color: '#01d67f',
- outerLine: '#00b36a',
- skeleton: 'basic_string_field',
- fontColor: '#fff',
- statements: [],
- isNotFor: ['roborobo_schoolkit'],
- template: '소리 센서에 감지되는 소리 값',
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- events: {},
- def: {
- params: [null],
- type: 'roborobo_sound_value',
- },
- paramsKeyMap: {},
- class: 'roborobo_sound',
- func(sprite, script) {
- const port = Entry.Roborobo_SchoolKit.inputPort.sound;
- return Entry.hw.portData[port - 7];
- },
- },
- roborobo_sound_value_boolean: {
- color: '#01d67f',
- outerLine: '#00b36a',
- skeleton: 'basic_boolean_field',
- fontColor: '#fff',
- isNotFor: ['roborobo_schoolkit'],
- template: '소리 센서에 감지되는 소리 값 %1 %2',
- params: [
- {
- type: 'Dropdown',
- options: [
- ['=', 'EQUAL'],
- ['>', 'GREATER'],
- ['<', 'LESS'],
- ['≥', 'GREATER_OR_EQUAL'],
- ['≤', 'LESS_OR_EQUAL'],
- ],
- value: 'LESS',
- fontSize: 11,
- bgColor: '#00b36a',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- noaRrow: true,
- },
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- def: {
- params: [
- null,
- {
- type: 'number',
- params: ['512'],
- },
- ],
- type: 'roborobo_sound_value_boolean',
- },
- paramsKeyMap: {
- OPERATOR: 0,
- RIGHTVALUE: 1,
- },
- class: 'roborobo_sound',
- func(sprite, script) {
- const port = Entry.Roborobo_SchoolKit.inputPort.sound;
- const operator = script.getField('OPERATOR', script);
- let rightValue = script.getNumberValue('RIGHTVALUE', script);
- const leftValue = Entry.hw.portData[port - 7];
- let isCheck = false;
-
- if (rightValue < 0) {
- rightValue = 0;
- } else if (rightValue > 1023) {
- rightValue = 1023;
- }
-
- switch (operator) {
- case 'EQUAL':
- isCheck = leftValue == rightValue;
- break;
- case 'GREATER':
- isCheck = Number(leftValue) > Number(rightValue);
- break;
- case 'LESS':
- isCheck = Number(leftValue) < Number(rightValue);
- break;
- case 'GREATER_OR_EQUAL':
- isCheck = Number(leftValue) >= Number(rightValue);
- break;
- case 'LESS_OR_EQUAL':
- isCheck = Number(leftValue) <= Number(rightValue);
- break;
- }
-
- return isCheck;
- },
- },
- roborobo_irs_value: {
- color: '#C4065C',
- outerLine: '#9a0045',
- skeleton: 'basic_string_field',
- fontColor: '#fff',
- statements: [],
- isNotFor: ['roborobo_schoolkit'],
- template: '적외선 센서 값',
- params: [
- {
- type: 'Block',
- accept: 'string',
- },
- ],
- events: {},
- def: {
- params: [null],
- type: 'roborobo_irs_value',
- },
- paramsKeyMap: {},
- class: 'roborobo_irs',
- //'isNotFor': ['mini'],
- func(sprite, script) {
- const port = Entry.Roborobo_SchoolKit.inputPort.ir;
- const value =
- Entry.hw.portData[port - 7] == undefined ? 0 : Entry.hw.portData[port - 7];
- return value;
- },
- },
- roborobo_irs_value_boolean: {
- color: '#C4065C',
- outerLine: '#9a0045',
- skeleton: 'basic_boolean_field',
- fontColor: '#fff',
- isNotFor: ['roborobo_schoolkit'],
- template: '적외선 센서가 %1',
- params: [
- {
- type: 'Dropdown',
- options: [
- ['감지 되면', '1'],
- ['감지 안되면', '0'],
- ],
- value: '1',
- fontSize: 11,
- bgColor: '#9a0045',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- ],
- def: {
- params: [null],
- type: 'roborobo_irs_value_boolean',
- },
- paramsKeyMap: {
- DETECT: 0,
- },
- class: 'roborobo_irs',
- //'isNotFor': ['mini'],
- func(sprite, script) {
- const port = Entry.Roborobo_SchoolKit.inputPort.ir;
- const detect = script.getNumberField('DETECT', script);
-
- Entry.hw.sendQueue.digitalPinMode[port] = Entry.Roborobo_SchoolKit.pinMode.INPUT;
- Entry.hw.update();
-
- const value = Entry.hw.portData[port - 7];
- const isDetect = detect == value;
-
- return isDetect;
- },
- },
- roborobo_diode_secs_toggle: {
- color: '#ff8d0f',
- outerLine: '#e37100',
- skeleton: 'basic',
- fontColor: '#fff',
- statements: [],
- isNotFor: ['roborobo_schoolkit'],
- template: '%1번 포트의 발광다이오드를 %2초 동안 %3 %4',
- params: [
- {
- type: 'Dropdown',
- options: [
- ['LED 1', '5'],
- ['LED 2', '4'],
- ['R - A', '3'],
- ['R - B', '2'],
- ],
- value: '5',
- fontSize: 11,
- bgColor: '#e37100',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Dropdown',
- options: [
- ['켜기', '255'],
- ['끄기', '0'],
- ],
- value: '255',
- fontSize: 11,
- bgColor: '#e37100',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- {
- type: 'Indicator',
- img: 'block_icon/practical_course/diode.png',
- size: 12,
- },
- ],
- events: {},
- def: {
- params: [
- null,
- {
- type: 'number',
- params: ['2'],
- },
- null,
- null,
- ],
- type: 'roborobo_diode_secs_toggle',
- },
- paramsKeyMap: {
- PORT: 0,
- DURATION: 1,
- VALUE: 2,
- },
- class: 'roborobo_diode',
- func(sprite, script) {
- const port = script.getNumberField('PORT');
- const duration = script.getNumberValue('DURATION');
- const value = script.getNumberField('VALUE');
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = {};
- }
- Entry.hw.sendQueue.digitalPinMode[port] = Entry.Roborobo_SchoolKit.pinMode.PWM;
-
- if (!script.isStart) {
- script.isStart = true;
- script.timeFlag = 1;
- Entry.hw.sendQueue[port] = value;
-
- setTimeout(() => {
- script.timeFlag = 0;
- }, duration * 1000);
- return script;
- } else if (script.timeFlag == 1) {
- return script;
- } else {
- Entry.hw.sendQueue[port] = 0;
- delete script.timeFlag;
- delete script.isStart;
- Entry.engine.isContinue = false;
- return script.callReturn();
- }
- },
- },
- roborobo_diode_toggle: {
- color: '#ff8d0f',
- outerLine: '#e37100',
- skeleton: 'basic',
- fontColor: '#fff',
- statements: [],
- isNotFor: ['roborobo_schoolkit'],
- template: '%1번 포트의 발광다이오드를 %2 %3',
- params: [
- {
- type: 'Dropdown',
- options: [
- ['LED 1', '5'],
- ['LED 2', '4'],
- ['R - A', '3'],
- ['R - B', '2'],
- ],
- value: '5',
- fontSize: 11,
- bgColor: '#e37100',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- {
- type: 'Dropdown',
- options: [
- ['켜기', '255'],
- ['끄기', '0'],
- ],
- value: '255',
- fontSize: 11,
- bgColor: '#e37100',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- {
- type: 'Indicator',
- img: 'block_icon/practical_course/diode.png',
- size: 12,
- },
- ],
- events: {},
- def: {
- params: [null, null, null],
- type: 'roborobo_diode_toggle',
- },
- paramsKeyMap: {
- PORT: 0,
- VALUE: 1,
- },
- class: 'roborobo_diode',
- //'isNotFor': ['mini'],
- func(sprite, script) {
- const port = script.getNumberField('PORT');
- const value = script.getNumberField('VALUE');
-
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = {};
- }
-
- Entry.hw.sendQueue.digitalPinMode[port] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue[port] = value;
-
- return script.callReturn();
- },
- },
- roborobo_diode_inout_toggle: {
- color: '#ff8d0f',
- outerLine: '#e37100',
- skeleton: 'basic',
- fontColor: '#fff',
- statements: [],
- isNotFor: ['roborobo_schoolkit'],
- template: '%1번 포트의 발광다이오드를 %2번 포트의 %3~%4의 범위로 켜기%5',
- params: [
- {
- type: 'Dropdown',
- options: [
- ['LED 1', '5'],
- ['LED 2', '4'],
- ['R - A', '3'],
- ['R - B', '2'],
- ],
- value: '5',
- fontSize: 11,
- bgColor: '#e37100',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- {
- type: 'Dropdown',
- options: [
- ['소 리', '8'],
- ['CDS', '10'],
- ],
- value: '8',
- fontSize: 11,
- bgColor: '#e37100',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Indicator',
- img: 'block_icon/practical_course/diode.png',
- size: 12,
- },
- ],
- events: {},
- def: {
- params: [
- null,
- null,
- { type: 'number', params: ['0'] },
- { type: 'number', params: ['255'] },
- null,
- ],
- type: 'roborobo_diode_inout_toggle',
- },
- paramsKeyMap: {
- OUTPUT: 0,
- INPUT: 1,
- MIN: 2,
- MAX: 3,
- },
- class: 'roborobo_diode',
- //'isNotFor': ['mini'],
- func(sprite, script) {
- const outputPort = script.getNumberField('OUTPUT');
- const inputPort = script.getNumberField('INPUT');
-
- const oMin = script.getNumberValue('MIN');
- const oMax = script.getNumberValue('MAX');
- const nMin = 0;
- const nMax = 255;
- const x = Entry.hw.portData[inputPort - 7] / 4;
- const percent = (x - oMin) / (oMax - oMin);
- let result = percent * (nMax - nMin) + nMin;
- if (result > nMax) {
- result = nMax;
- }
- if (result < nMin) {
- result = nMin;
- }
-
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = {};
- }
-
- Entry.hw.sendQueue.digitalPinMode[outputPort] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue[outputPort] = result;
-
- return script.callReturn();
- },
- },
- roborobo_diode_set_output: {
- color: '#ff8d0f',
- outerLine: '#e37100',
- skeleton: 'basic',
- statements: [],
- isNotFor: ['roborobo_schoolkit'],
- template: '%1번 포트의 발광다이오드를 %2의 밝기로 켜기 %3',
- params: [
- {
- type: 'Dropdown',
- options: [
- ['LED 1', '5'],
- ['LED 2', '4'],
- ['R - A', '3'],
- ['R - B', '2'],
- ],
- value: '5',
- fontSize: 11,
- bgColor: '#e37100',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- {
- type: 'Block',
- accept: 'string',
- },
- {
- type: 'Indicator',
- img: 'block_icon/practical_course/diode.png',
- size: 12,
- },
- ],
- events: {},
- def: {
- params: [
- null,
- {
- type: 'number',
- params: ['255'],
- },
- null,
- ],
- type: 'roborobo_diode_set_output',
- },
- paramsKeyMap: {
- PORT: 0,
- VALUE: 1,
- },
- class: 'roborobo_diode',
- //'isNotFor': ['mini'],
- func(sprite, script) {
- const port = script.getStringField('PORT', script);
- let value = script.getNumberValue('VALUE', script);
-
- if (value < 0) {
- value = 0;
- } else if (value > 255) {
- value = 255;
- }
- if (!Entry.hw.sendQueue.digitalPinMode) {
- Entry.hw.sendQueue.digitalPinMode = {};
- }
- Entry.hw.sendQueue.digitalPinMode[port] = Entry.Roborobo_SchoolKit.pinMode.PWM;
- Entry.hw.sendQueue[port] = value;
-
- return script.callReturn();
- },
- },
- roborobo_diode_input_value: {
- color: '#ff8d0f',
- outerLine: '#e37100',
- skeleton: 'basic_string_field',
- fontColor: '#fff',
- statements: [],
- isNotFor: ['roborobo_schoolkit'],
- template: '%1 포트의 값',
- params: [
- {
- type: 'Dropdown',
- options: [
- ['적외선', '7'],
- ['소 리', '8'],
- ['접 촉', '9'],
- ['CDS', '10'],
- ],
- value: '8',
- fontSize: 11,
- bgColor: '#e37100',
- arrowColor: EntryStatic.colorSet.common.WHITE,
- },
- ],
- events: {},
- def: {
- params: [null],
- type: 'roborobo_diode_input_value',
- },
- paramsKeyMap: {
- PORT: 0,
- },
- class: 'roborobo_diode',
- func(sprite, script) {
- const port = script.getNumberField('PORT');
- return Entry.hw.portData[port - 7];
- },
- },
- }
-}
-
-Entry.Roborobo_RoE.setLanguage = function() {
- return {
- ko: {
- template: {
- roe_set_led: '%1 LED 켜기 %2',
- roe_set_led_off: 'LED 끄기 %1',
- roe_set_motor: '로이 %1 %2',
- roe_set_motor_value: '%1 모터 : %2 만큼 %3 %4',
- roe_set_melody: '%1 옥타브 %2 을(를) %3 초 연주 %4',
- roe_get_input_switch: '접촉센서가 %1 ?',
- roe_get_input_ir: '적외선 센서가 %1 ?',
- roe_get_input_color: '%1 컬러센서 값이 %2 인가?',
- roe_led_color_dropdown: '%1',
- roe_melody_dropdown: '%1',
- roe_motor_dropdown: '%1',
- roe_movement_dropdown: '%1',
- roe_detect_dropdown: '%1',
- roe_color_select_dropdown: '%1',
- roe_color_color_dropdown: '%1',
- },
- Blocks: {
- roe_color_sensor_left: '왼쪽',
- roe_color_sensor_right: '오른쪽',
- roe_color_sensor_both: '양쪽',
- roe_color_red: '빨간색',
- roe_color_orange: '주황색',
- roe_color_yellow: '노란색',
- roe_color_yellowgreen: '연두색',
- roe_color_green: '초록색',
- roe_color_skyblue: '하늘색',
- roe_color_blue: '파란색',
- roe_color_purple: '보라색',
- roe_color_pink: '분홍색',
- roe_color_white: '흰색',
- roe_color_black: '검정색',
- roe_color_random: '무작위 색',
- roe_color_none: '미감지',
- roe_motor_both: '양쪽',
- roe_motor_left: '왼쪽',
- roe_motor_right: '오른쪽',
- roe_move_forward: '전진',
- roe_move_backward: '후진',
- roe_move_turnleft: '좌회전',
- roe_move_turnright: '우회전',
- roe_move_stop: '정지',
- roe_detected: '감지되었는가',
- roe_undetected: '감지되지 않았는가',
- roe_melody_do: '도',
- roe_melody_doS: '도#',
- roe_melody_re: '레',
- roe_melody_miF: '미b',
- roe_melody_mi: '미',
- roe_melody_pa: '파',
- roe_melody_paS: '파#',
- roe_melody_sol: '솔',
- roe_melody_solS: '솔#',
- roe_melody_la: '라',
- roe_melody_siF: '시b',
- roe_melody_si: '시',
- }
- },
- en: {
- template: {
- roe_set_led: 'Turn on %1 LED %2',
- roe_set_led_off: 'Turn off LED %1',
- roe_set_motor: 'Ro-E %1 %2',
- roe_set_motor_value: '%1 motor(s) : Move %3 by %2 %4',
- roe_set_melody: 'Play %1 octave %2 tone for %3 second(s) %4',
- roe_get_input_switch: 'Is the switch sensor %1 ?',
- roe_get_input_ir: 'Is the IR sensor %1 ?',
- roe_get_input_color: 'Is %1 color sensor value %2 ?',
- roe_led_color_dropdown: '%1',
- roe_melody_dropdown: '%1',
- roe_motor_dropdown: '%1',
- roe_movement_dropdown: '%1',
- roe_detect_dropdown: '%1',
- roe_color_select_dropdown: '%1',
- roe_color_color_dropdown: '%1',
- },
- Blocks: {
- roe_color_sensor_left: 'left',
- roe_color_sensor_right: 'right',
- roe_color_sensor_both: 'both',
- roe_color_red: 'Red',
- roe_color_orange: 'Orange',
- roe_color_yellow: 'Yellow',
- roe_color_yellowgreen: 'Yellow Green',
- roe_color_green: 'Green',
- roe_color_skyblue: 'Sky Blue',
- roe_color_blue: 'Blue',
- roe_color_purple: 'Purple',
- roe_color_pink: 'Pink',
- roe_color_white: 'White',
- roe_color_black: 'Black',
- roe_color_random: 'Random',
- roe_color_none: 'Undetected',
- roe_motor_both: 'Both',
- roe_motor_left: 'Left',
- roe_motor_right: 'Right',
- roe_move_forward: 'forward',
- roe_move_backward: 'backward',
- roe_move_turnleft: 'turn left',
- roe_move_turnright: 'turn right',
- roe_move_stop: 'stop',
- roe_detected: 'detected',
- roe_undetected: 'undetected',
- roe_melody_do: 'C',
- roe_melody_doS: 'C#',
- roe_melody_re: 'D',
- roe_melody_miF: 'Eb',
- roe_melody_mi: 'E',
- roe_melody_pa: 'F',
- roe_melody_paS: 'F#',
- roe_melody_sol: 'G',
- roe_melody_solS: 'G#',
- roe_melody_la: 'A',
- roe_melody_siF: 'Bb',
- roe_melody_si: 'B',
- },
- },
- };
-};
-
-Entry.Roborobo_RoE.blockMenuBlocks = [
- 'roe_set_led',
- 'roe_set_led_off',
- 'roe_set_motor',
- 'roe_set_motor_value',
- 'roe_set_melody',
- 'roe_get_input_switch',
- 'roe_get_input_ir',
- 'roe_get_input_color',
-];
-
-Entry.Roborobo_RoE.getBlocks = function() {
- return {
- //region roe 로이
- roe_led_color_dropdown: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roe_color_red, 1],
- [Lang.Blocks.roe_color_orange, 2],
- [Lang.Blocks.roe_color_yellow, 3],
- [Lang.Blocks.roe_color_yellowgreen, 4],
- [Lang.Blocks.roe_color_green, 5],
- [Lang.Blocks.roe_color_skyblue, 6],
- [Lang.Blocks.roe_color_blue, 7],
- [Lang.Blocks.roe_color_purple, 8],
- [Lang.Blocks.roe_color_pink, 9],
- [Lang.Blocks.roe_color_white, 10]
- ],
- value: 1,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- ],
- events: {},
- def: {
- params: [null],
- },
- paramsKeyMap: {
- VALUE: 0,
- },
- func: function(sprite, script) {
- return script.getNumberField('VALUE');
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: '%1',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roe_color_red, 1],
- [Lang.Blocks.roe_color_orange, 2],
- [Lang.Blocks.roe_color_yellow, 3],
- [Lang.Blocks.roe_color_yellowgreen, 4],
- [Lang.Blocks.roe_color_green, 5],
- [Lang.Blocks.roe_color_skyblue, 6],
- [Lang.Blocks.roe_color_blue, 7],
- [Lang.Blocks.roe_color_purple, 8],
- [Lang.Blocks.roe_color_pink, 9],
- [Lang.Blocks.roe_color_white, 10]
- ],
- value: 1,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- ],
- keyOption: 'roe_led_color_dropdown',
- },
- ],
- },
- },
- roe_melody_dropdown: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roe_melody_do, 1],
- [Lang.Blocks.roe_melody_re, 2],
- [Lang.Blocks.roe_melody_mi, 3],
- [Lang.Blocks.roe_melody_pa, 4],
- [Lang.Blocks.roe_melody_sol, 5],
- [Lang.Blocks.roe_melody_la, 6],
- [Lang.Blocks.roe_melody_si, 7],
- ],
- value: 1,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- ],
- events: {},
- def: {
- params: [null],
- },
- paramsKeyMap: {
- VALUE: 0,
- },
- func: function(sprite, script) {
- return script.getNumberField('VALUE', script);
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: '%1',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roe_melody_do, 1],
- [Lang.Blocks.roe_melody_re, 2],
- [Lang.Blocks.roe_melody_mi, 3],
- [Lang.Blocks.roe_melody_pa, 4],
- [Lang.Blocks.roe_melody_sol, 5],
- [Lang.Blocks.roe_melody_la, 6],
- [Lang.Blocks.roe_melody_si, 7],
- ],
- value: 1,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- ],
- keyOption: 'roe_melody_dropdown',
- },
- ],
- },
- },
- roe_motor_dropdown: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roe_motor_both, 1],
- [Lang.Blocks.roe_motor_left, 2],
- [Lang.Blocks.roe_motor_right, 3],
- ],
- value: 1,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- ],
- events: {},
- def: {
- params: [null],
- },
- paramsKeyMap: {
- VALUE: 0,
- },
- func: function(sprite, script) {
- return script.getNumberField('VALUE');
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: '%1',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roe_motor_both, 1],
- [Lang.Blocks.roe_motor_left, 2],
- [Lang.Blocks.roe_motor_right, 3],
- ],
- value: 1,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- ],
- keyOption: 'roe_motor_dropdown',
- },
- ],
- },
- },
- roe_movement_dropdown: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roe_move_forward, 1],
- [Lang.Blocks.roe_move_backward, 2],
- [Lang.Blocks.roe_move_turnleft, 3],
- [Lang.Blocks.roe_move_turnright, 4],
- [Lang.Blocks.roe_move_stop, 5],
- ],
- value: 1,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- ],
- events: {},
- def: {
- params: [null],
- },
- paramsKeyMap: {
- VALUE: 0,
- },
- func: function(sprite, script) {
- return script.getNumberField('VALUE');
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: '%1',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roe_move_forward, 1],
- [Lang.Blocks.roe_move_backward, 2],
- [Lang.Blocks.roe_move_turnleft, 3],
- [Lang.Blocks.roe_move_turnright, 4],
- [Lang.Blocks.roe_move_stop, 5],
- ],
- value: 1,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- ],
- keyOption: 'roe_movement_dropdown',
- },
- ],
- },
- },
- roe_detect_dropdown: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roe_detected, 1],
- [Lang.Blocks.roe_undetected, 0],
- ],
- value: 1,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- ],
- events: {},
- def: {
- params: [null],
- },
- paramsKeyMap: {
- VALUE: 0,
- },
- func: function(sprite, script) {
- return script.getNumberField('VALUE');
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: '%1',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roe_detected, 1],
- [Lang.Blocks.roe_undetected, 2],
- ],
- value: 1,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- ],
- keyOption: 'roe_detect_dropdown',
- },
- ],
- },
- },
- roe_color_select_dropdown: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roe_color_sensor_both, 1],
- [Lang.Blocks.roe_color_sensor_left, 2],
- [Lang.Blocks.roe_color_sensor_right, 3],
- ],
- value: 1,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- ],
- events: {},
- def: {
- params: [null],
- },
- paramsKeyMap: {
- VALUE: 0,
- },
- func: function(sprite, script) {
- return script.getNumberField('VALUE');
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: '%1',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roe_color_sensor_both, 1],
- [Lang.Blocks.roe_color_sensor_left, 2],
- [Lang.Blocks.roe_color_sensor_right, 3],
- ],
- value: 1,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- ],
- keyOption: 'roe_color_select_dropdown',
- },
- ],
- },
- },
- roe_color_color_dropdown: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic_string_field',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roe_color_red, 1],
- [Lang.Blocks.roe_color_orange, 2],
- [Lang.Blocks.roe_color_yellow, 3],
- [Lang.Blocks.roe_color_yellowgreen, 7],
- [Lang.Blocks.roe_color_green, 4],
- [Lang.Blocks.roe_color_skyblue, 8],
- [Lang.Blocks.roe_color_blue, 5],
- [Lang.Blocks.roe_color_purple, 6],
- [Lang.Blocks.roe_color_pink, 9],
- [Lang.Blocks.roe_color_black, 10],
- [Lang.Blocks.roe_color_white, 11],
- [Lang.Blocks.roe_color_none, 127],
- ],
- value: 1,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- ],
- events: {},
- def: {
- params: [null],
- },
- paramsKeyMap: {
- VALUE: 0,
- },
- func: function(sprite, script) {
- return script.getNumberField('VALUE');
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: '%1',
- textParams: [
- {
- type: 'Dropdown',
- options: [
- [Lang.Blocks.roe_color_red, 1],
- [Lang.Blocks.roe_color_orange, 2],
- [Lang.Blocks.roe_color_yellow, 3],
- [Lang.Blocks.roe_color_yellowgreen, 7],
- [Lang.Blocks.roe_color_green, 4],
- [Lang.Blocks.roe_color_skyblue, 8],
- [Lang.Blocks.roe_color_blue, 5],
- [Lang.Blocks.roe_color_purple, 6],
- [Lang.Blocks.roe_color_pink, 9],
- [Lang.Blocks.roe_color_black, 10],
- [Lang.Blocks.roe_color_white, 11],
- [Lang.Blocks.roe_color_none, 127],
- ],
- value: 1,
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- converter: Entry.block.converters.returnStringValue,
- },
- ],
- keyOption: 'roe_color_color_dropdown',
- },
- ],
- },
- },
- roe_set_led: {
- 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_icon.svg',
- size: 12
- }
- ],
- events: {},
- def: {
- params: [
- {
- type: 'roe_led_color_dropdown',
- },
- null
- ],
- type: 'roe_set_led',
- },
- paramsKeyMap: {
- VALUE: 0,
- },
- class: 'roe_set',
- isNotFor: ['roborobo_roe'],
- func: function(sprite, script) {
- var color = script.getNumberValue('VALUE', script);
- Entry.hw.sendQueue['LED'] = color;
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: 'Roborobo_roe.roe_set_led(%1)',
- textParams: [
- {
- type: "Block",
- accept: "string"
- },
- {
- type: 'roe_led_color_dropdown'
- }
- ],
- },
- ],
- },
- },
- roe_set_led_off: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic',
- statements: [],
- params: [
- {
- type: "Indicator",
- img: "block_icon/hardware_icon.svg",
- size: 12
- }
- ],
- events: {},
- def: {
- params: [
- null
- ],
- type: 'roe_set_led_off'
- },
- paramsKeyMap: {},
- class: 'roe_set',
- isNotFor: ['roborobo_roe'],
- func: function(sprite, script) {
- Entry.hw.sendQueue['LED'] = 0;
- },
- syntax: {
- js: [],
- py: ['Roborobo_roe.roe_set_led_off()'],
- },
- },
- roe_set_melody: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic',
- statements: [],
- params: [
- {
- type: 'Dropdown',
- options: [
- ['4', '4'],
- ['5', '5'],
- ['6', '6'],
- ['7', '7'],
- ],
- fontSize: 11,
- bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
- arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
- },
- {
- type: 'Block',
- accept: 'string'
- },
- {
- type: 'Block',
- accept: 'string'
- },
- {
- type: "Indicator",
- img: "block_icon/hardware_icon.svg",
- size: 12
- }
- ],
- events: {},
- def: {
- params: [
- '4',
- {
- type: 'roe_melody_dropdown',
- },
- '1',
- null
- ],
- type: 'roe_set_melody',
- },
- paramsKeyMap: {
- OCTAVE: 0,
- NOTE: 1,
- DURATION: 2
- },
- class: 'roe_set',
- isNotFor: ['roborobo_roe'],
- func: function(sprite, script) {
- if (!script.isStart) {
- var octave = script.getNumberValue('OCTAVE', script);
- var note = script.getNumberValue('NOTE', script);
- var duration = script.getNumberValue('DURATION', script);
-
- if(octave < 4) {
- octave = 4;
- } else if (octave > 7) {
- octave = 7;
- }
-
- if(note < 1) {
- note = 1;
- } else if (note > 7) {
- note = 7;
- }
- duration = duration < 0 ? 0 : duration;
- duration = duration * 1000;
-
- script.isStart = true;
- script.timeFlag = 1;
-
- Entry.hw.sendQueue['Melody'] = [octave, note, duration];
-
- setTimeout(function() {
- script.timeFlag = 0;
- }, duration);
- return script;
- } else if (script.timeFlag == 1) {
- return script;
- } else {
- delete script.timeFlag;
- delete script.isStart;
- }
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: 'Roborobo_roe.roe_set_melody(%1 %2 %3)',
- textParams: [
- '4',
- {
- type: 'roe_melody_dropdown',
- },
- '1',
- ],
- },
- ],
- },
- },
- roe_set_motor: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic',
- statements: [],
- params: [
- {
- type: "Block",
- accept: "string"
- },
- {
- type: "Indicator",
- img: "block_icon/hardware_icon.svg",
- size: 12
- }
- ],
- events: {},
- def: {
- params: [
- {
- type: 'roe_movement_dropdown'
- },
- null
- ],
- type: 'roe_set_motor'
- },
- paramsKeyMap: {
- OPERATOR: 0,
- },
- class: 'roe_set',
- isNotFor: ['roborobo_roe'],
- func: function(sprite, script) {
- var op = script.getNumberValue('OPERATOR', script);
- if(op == 1) {
- Entry.hw.sendQueue['LeftMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CCW, 0 ];
- Entry.hw.sendQueue['RightMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CW, 0 ];
- } else if (op == 2) {
- Entry.hw.sendQueue['LeftMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CW, 0] ;
- Entry.hw.sendQueue['RightMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CCW, 0 ];
- } else if (op == 3) {
- Entry.hw.sendQueue['LeftMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CW, 0 ];
- Entry.hw.sendQueue['RightMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CW, 0 ];
- } else if (op == 4) {
- Entry.hw.sendQueue['LeftMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CCW, 0 ];
- Entry.hw.sendQueue['RightMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CCW, 0 ];
- } else if (op == 5) {
- Entry.hw.sendQueue['LeftMotor'] = [ Entry.Roborobo_RoE.motorDiretion.STOP, 0 ];
- Entry.hw.sendQueue['RightMotor'] = [ Entry.Roborobo_RoE.motorDiretion.STOP,0 ];
- }
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: 'Roborobo_roe.roe_set_motor(%1)',
- textParams: [
- {
- type: 'roe_movement_dropdown'
- },
- ],
- },
- ],
- },
- },
- roe_set_motor_value: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- skeleton: 'basic',
- statements: [],
- params: [
- {
- type: "Block",
- accept: "string"
- },
- {
- type: "Block",
- accept: "string"
- },
- {
- type: "Block",
- accept: "string"
- },
- {
- type: "Indicator",
- img: "block_icon/hardware_icon.svg",
- size: 12
- }
- ],
- events: {},
- def: {
- params: [
- {
- type: 'roe_motor_dropdown'
- },
- '100',
- {
- type: 'roe_movement_dropdown'
- },
- null
- ],
- type: 'roe_set_motor_value'
- },
- paramsKeyMap: {
- MOTOR: 0,
- VALUE: 1,
- OPERATOR: 2,
- },
- class: 'roe_set',
- isNotFor: ['roborobo_roe'],
- func: function(sprite, script) {
- var motor = script.getNumberValue('MOTOR', script);
- var value = script.getNumberValue('VALUE', script);
- var op = script.getNumberValue('OPERATOR', script);
-
- if(value < 0) {
- value = 0;
- } else if(value > 100) {
- value = 100;
- }
-
- if(motor == 1) {
- if(op == 1) {
- Entry.hw.sendQueue['LeftMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CCW, value ];
- Entry.hw.sendQueue['RightMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CW, value ];
- } else if (op == 2) {
- Entry.hw.sendQueue['LeftMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CW, value ] ;
- Entry.hw.sendQueue['RightMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CCW, value ];
- } else if (op == 3) {
- Entry.hw.sendQueue['LeftMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CW, value ];
- Entry.hw.sendQueue['RightMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CW, value ];
- } else if (op == 4) {
- Entry.hw.sendQueue['LeftMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CCW, value ];
- Entry.hw.sendQueue['RightMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CCW, value ];
- } else if (op == 5) {
- Entry.hw.sendQueue['LeftMotor'] = [ Entry.Roborobo_RoE.motorDiretion.STOP, value ];
- Entry.hw.sendQueue['RightMotor'] = [ Entry.Roborobo_RoE.motorDiretion.STOP, value ];
- }
- } else if (motor == 2) {
- if(op == 1) {
- Entry.hw.sendQueue['LeftMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CCW, value ];
- } else if (op == 2) {
- Entry.hw.sendQueue['LeftMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CW, value ] ;
- } else if (op == 3) {
- Entry.hw.sendQueue['LeftMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CW, value ];
- } else if (op == 4) {
- Entry.hw.sendQueue['LeftMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CCW, value ];
- } else if (op == 5) {
- Entry.hw.sendQueue['LeftMotor'] = [ Entry.Roborobo_RoE.motorDiretion.STOP, value ];
- }
- } else if (motor == 3) {
- if(op == 1) {
- Entry.hw.sendQueue['RightMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CW, value ];
- } else if (op == 2) {
- Entry.hw.sendQueue['RightMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CCW, value ];
- } else if (op == 3) {
- Entry.hw.sendQueue['RightMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CW, value ];
- } else if (op == 4) {
- Entry.hw.sendQueue['RightMotor'] = [ Entry.Roborobo_RoE.motorDiretion.CCW, value ];
- } else if (op == 5) {
- Entry.hw.sendQueue['RightMotor'] = [ Entry.Roborobo_RoE.motorDiretion.STOP, value ];
- }
- }
- },
- syntax: {
- js: [],
- py: [
- {
- syntax: 'Roborobo_roe.roe_set_motor_value(%1 %2 %3)',
- textParams: [
- {
- type: 'roe_motor_dropdown'
- },
- '100',
- {
- type: 'roe_movement_dropdown'
- },
- ],
- },
- ],
- },
- },
- roe_get_input_switch: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_boolean_field',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string'
- },
- {
- type: "Indicator",
- img: "block_icon/hardware_icon.svg",
- size: 12
- }
- ],
- events: {},
- def: {
- params: [
- {
- type: 'roe_detect_dropdown',
- },
- null
- ],
- type: 'roe_get_input_switch'
- },
- paramsKeyMap: {
- DETECT: 0
- },
- class: 'roe_get',
- isNotFor: ['roborobo_roe'],
- func: function(sprite, script) {
- var detect = script.getNumberValue('DETECT', script);
- var value = Entry.hw.portData['Switch'];
- // console.log('Switch Value : ' + value);
- return detect == value ? true : false;
- },
- syntax: {
- js: [],
- py: ['Roborobo_roe.roe_get_input_switch()'],
- },
- },
- roe_get_input_ir: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_boolean_field',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string'
- },
- {
- type: "Indicator",
- img: "block_icon/hardware_icon.svg",
- size: 12
- }
- ],
- events: {},
- def: {
- params: [
- {
- type: 'roe_detect_dropdown',
- },
- null
- ],
- type: 'roe_get_input_ir'
- },
- paramsKeyMap: {
- DETECT: 0
- },
- class: 'roe_get',
- isNotFor: ['roborobo_roe'],
- func: function(sprite, script) {
- var detect = script.getNumberValue('DETECT', script);
- var value = Entry.hw.portData['IR'];
- // console.log('IR Value : ' + value);
- return detect == value ? true : false;
- },
- syntax: {
- js: [],
- py: ['Roborobo_roe.roe_get_input_ir()'],
- },
- },
- roe_get_input_color: {
- color: EntryStatic.colorSet.block.default.HARDWARE,
- outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
- fontColor: '#fff',
- skeleton: 'basic_boolean_field',
- statements: [],
- params: [
- {
- type: 'Block',
- accept: 'string'
- },
- {
- type: 'Block',
- accept: 'string'
- },
- {
- type: "Indicator",
- img: "block_icon/hardware_icon.svg",
- size: 12
- }
- ],
- events: {},
- def: {
- params: [
- {
- type: 'roe_color_select_dropdown',
- },
- {
- type: 'roe_color_color_dropdown',
- },
- null
- ],
- type: 'roe_get_input_color'
- },
- paramsKeyMap: {
- SENSOR: 0,
- COLOR: 1
- },
- class: 'roe_get',
- isNotFor: ['roborobo_roe'],
- func: function(sprite, script) {
- var result = false;
- var sensor = script.getNumberValue('SENSOR', script);
- var color = script.getNumberValue('COLOR', script);
- var left = Entry.hw.portData['LeftColor'];
- var right = Entry.hw.portData['RightColor'];
-
- if(sensor == 1) {
- if(left == color && right == color) {
- result = true;
- }
- } else if (sensor == 2) {
- result = left == color ? true : false;
- } else if (sensor == 3) {
- result = right == color ? true : false;
- }
- return result;
- },
- syntax: {
- js: [],
- py: ['Roborobo_roe.roe_get_input_color()'],
- },
- },
- //endregion roe 로이
- };
-};
-
-module.exports = [Entry.Roborobo_Roduino, Entry.Roborobo_SchoolKit, Entry.Roborobo_RoE];
diff --git a/src/playground/blocks/hardware/block_roborobo_base.js b/src/playground/blocks/hardware/block_roborobo_base.js
new file mode 100644
index 0000000000..620d6843e2
--- /dev/null
+++ b/src/playground/blocks/hardware/block_roborobo_base.js
@@ -0,0 +1,422 @@
+'use strict';
+
+const PinMode = {
+ INPUT: 0x00,
+ OUTPUT: 0x01,
+ ANALOG: 0x02,
+ I2C: 0x06,
+}
+
+class ArduinoBase {
+ constructor () {
+ this.resetState();
+ }
+
+ setLanguage () {throw new Error('재정의 필요');}
+ getBlocks () {throw new Error('재정의 필요');}
+
+ setZero () {
+ this.resetState();
+ this.request('reset', null, null, true);
+ }
+
+ afterReceive = function (data) {
+ const keys = data.state ? Object.keys(data.state) : [];
+ keys.forEach(key => this.state[key] = data.state[key]);
+ }
+
+ afterSend = function () {
+ Entry.hw.sendQueue = {};
+ }
+
+ request (func, subkey, value, updateNow = false) {
+ if (!Entry.hw.sendQueue[func]) Entry.hw.sendQueue[func] = {};
+
+ if (subkey) {
+ Entry.hw.sendQueue[func][subkey.toString()] = value;
+ } else {
+ Entry.hw.sendQueue[func] = value;
+ }
+
+ if (updateNow) Entry.hw.update();
+ }
+
+ resetState () {
+ this.state = {
+ pin: [],
+ rx: {}
+ };
+ }
+
+ pinToNumber (pin) {
+ if (pin === undefined || pin === null) return 0;
+ if (typeof pin === 'number') {
+ if (Number.isNaN(pin)) return 0;
+ return pin;
+ }
+
+ const pinStr = pin.toString().toLowerCase();
+ switch (pinStr) {
+ case 'd2': return 2;
+ case 'd3': return 3;
+ case 'd4': return 4;
+ case 'd5': return 5;
+ case 'd6': return 6;
+ case 'd7': return 7;
+ case 'd8': return 8;
+ case 'd9': return 9;
+ case 'd10': return 10;
+ case 'd11': return 11;
+ case 'd12': return 12;
+ case 'd13': return 13;
+ case 'a0': return 14;
+ case 'a1': return 15;
+ case 'a2': return 16;
+ case 'a3': return 17;
+ case 'a4': return 18;
+ case 'a5': return 19;
+ default: {
+ const n = Number(pin);
+ if (Number.isNaN(n)) return 0;
+ return n;
+ }
+ }
+ }
+
+ isEqualsPinMode (pin, mode) {
+ return typeof pin === 'number' && this.state.pin[pin] && this.state.pin[pin].mode == mode;
+ }
+
+ isDigitalPin (pin) {
+ return typeof pin === 'number' && 2 <= pin && pin <= 15;
+ }
+
+ isAnalogPin (pin) {
+ return typeof pin === 'number' && 14 <= pin && pin <= 19;
+ }
+
+ measureAnalogPin (pin) {
+ const analogPin = pin - 14;
+ return Math.min(5, Math.max(0, analogPin));
+ }
+
+ getDigitalValue (pin) {
+ if (!this.isDigitalPin(pin)) return 0;
+
+ if (!this.isEqualsPinMode(pin, PinMode.INPUT)) {
+ this.request('enableDigitalInput', pin, {pin}, true);
+ }
+
+ return this.state.rx.digital && typeof this.state.rx.digital[pin] === 'number'
+ ? this.state.rx.digital[pin]
+ : 0;
+ }
+
+ getAnalogValue (pin, defValue = 0) {
+ if (!this.isAnalogPin(pin)) return defValue;
+
+ if (!this.isEqualsPinMode(pin, PinMode.ANALOG)) {
+ this.request('enableAnalogInput', pin, {pin}, true);
+ }
+
+ const analogPin = this.measureAnalogPin(pin);
+ return this.state.rx.analog && typeof this.state.rx.analog[analogPin] === 'number'
+ ? this.state.rx.analog[analogPin]
+ : defValue;
+ }
+
+ set_digital (sprite, script) {
+ const pin = this.pinToNumber(script.getStringValue('PIN'));
+ const value = script.getNumberValue('VALUE');
+
+ this.request('setDigital', pin, {pin, value});
+ return script.callReturn();
+ }
+
+ set_motor (sprite, script) {
+ const motor = script.getNumberValue('MOTOR');
+ const speed = script.getNumberValue('SPEED');
+ const state = script.getStringValue('STATE');
+
+ let stateNum = 0;
+ if (state == 'cw') stateNum = 1;
+ else if (state == 'ccw') stateNum = 2;
+
+ this.request('setMotor', motor, {motor, speed, state: stateNum});
+ return script.callReturn();
+ }
+
+ set_motors (sprite, script) {
+ const motors = script.getNumberValue('MOTORS');
+ const speed1 = script.getNumberValue('SPEED1');
+ const speed2 = script.getNumberValue('SPEED2');
+ const state = script.getStringValue('STATE');
+
+ const speed = [speed1, speed2];
+ let motor = []
+ if (motors == 12) {
+ motor = [1, 2];
+ } else if (motors == 34) {
+ motor = [3, 4];
+ }
+
+ let stateNum = [0, 0];
+ switch (state) {
+ case 'forward':
+ stateNum = [2, 1];
+ break;
+ case 'turn-left':
+ stateNum = [1, 1];
+ break;
+ case 'backward':
+ stateNum = [1, 2];
+ break;
+ case 'turn-right':
+ stateNum = [2, 2];
+ break;
+ }
+
+ for (let i = 0; i < 2; i++) {
+ this.request('setMotor', i + 1, {motor: motor[i], speed: speed[i], state: stateNum[i]});
+ }
+ return script.callReturn();
+ }
+
+ set_servo_angle (sprite, script) {
+ const pin = this.pinToNumber(script.getStringValue('PIN'));
+ const angle = script.getNumberValue('ANGLE');
+
+ this.request('setServo', pin, {pin, angle});
+ return script.callReturn();
+ }
+
+ set_rgbled_color (sprite, script) {
+ const pin = this.pinToNumber(script.getStringValue('PIN'));
+ let colorString = script.getStringValue('COLOR');
+
+ let color;
+ if (typeof colorString === 'string' && colorString.substring(0, 1) === '#') {
+ const shorThandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
+ colorString = colorString.replace(shorThandRegex, (m, r, g, b) => r + r + g + g + b + b);
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(colorString);
+ color = result ? {
+ r: parseInt(result[1], 16),
+ g: parseInt(result[2], 16),
+ b: parseInt(result[3], 16)
+ } : null;
+ }
+ if (!color) color = {r: 0, g: 0, b: 0};
+
+ this.request('setRgbLedColor', pin, {pin, color});
+ return script.callReturn();
+
+ }
+
+ change_rgbled_brightness_by (sprite, script) {
+ const pin = this.pinToNumber(script.getStringValue('PIN'));
+ const brightness = script.getNumberValue('BRIGHTNESS');
+
+ this.request('changeRgbLedBrightnessBy', pin, {pin, brightness});
+ return script.callReturn();
+ }
+
+ set_rgbled_brightness_to (sprite, script) {
+ const pin = this.pinToNumber(script.getStringValue('PIN'));
+ const brightness = script.getNumberValue('BRIGHTNESS');
+
+ this.request('setRgbLedBrightnessTo', pin, {pin, brightness});
+ return script.callReturn();
+ }
+
+ play_piezobuzzer (sprite, script) {
+ const pin = this.pinToNumber(script.getStringValue('PIN'));
+ const octave = script.getNumberValue('OCTAVE');
+ const duration = script.getNumberValue('DURATION');
+ let note = script.getNumberValue('NOTE');
+ note = (octave - 1) * 12 + note;
+
+ this.request('setPiezoBuzzer', pin, {pin, note, duration});
+ return script.callReturn();
+ }
+
+ play_piezobuzzer_until_done (sprite, script) {
+ const duration = script.getNumberValue('DURATION');
+ this.play_piezobuzzer(sprite, script);
+ return new Promise(resolve => setTimeout(() => resolve(), duration * 1000));
+ }
+
+ get_digital_value (sprite, script) {
+ const pin = this.pinToNumber(script.getStringValue('PIN'));
+ return this.getDigitalValue(pin);
+ }
+
+ is_digital_detected (sprite, script) {
+ return this.get_digital_value(sprite, script) == 1;
+ }
+
+ get_analog_value (sprite, script) {
+ const pin = this.pinToNumber(script.getStringValue('PIN'));
+ return this.getAnalogValue(pin);
+ }
+
+ compare_analog_value (sprite, script) {
+ const value1 = this.get_analog_value(sprite, script);
+ const symbol = script.getStringValue('SYMBOL');
+ const value2 = script.getStringValue('VALUE');
+
+ return this._compare(value1, value2, symbol);
+ }
+
+ _compare (v1, v2, symbol) {
+ switch (symbol) {
+ case 'greater-than':
+ return v1 > v2;
+ case 'equal':
+ return v1 == v2;
+ case 'less-than':
+ return v1 < v2;
+ default: return false;
+ }
+ }
+
+ get_sensor_value (sprite, script) {
+ const pin = this.pinToNumber(script.getStringValue('PIN'));
+ const sensor = script.getStringValue('SENSOR');
+
+ if (sensor == 'ultrasonic') {
+ if (!this.isEqualsPinMode(pin, PinMode.INPUT)) {
+ this.request('enableSonarSensor', pin, {pin}, true);
+ }
+ return this.state.rx.digital[pin];
+ }
+
+ if (!this.isEqualsPinMode(pin, PinMode.ANALOG)) {
+ this.request('enableAnalogInput', pin, {pin}, true);
+ }
+ const analogPin = this.measureAnalogPin(pin);
+ switch (sensor) {
+ case "joystickx":
+ case "joysticky": {
+ const analogValue = this.getAnalogValue(pin, 512);
+ const value = analogValue >> 6;
+
+ if (value > 14) return 2;
+ else if (value > 9) return 1;
+ else if (value > 5) return 0;
+ else if (value > 1) return -1;
+ else return -2;
+ }
+ case "light": {
+ const analogValue = this.getAnalogValue(pin);
+ return parseInt(Math.round(analogValue * 0.1));
+ }
+ case "dial": {
+ const analogValue = this.getAnalogValue(pin);
+ return Math.round(analogValue * 0.1);
+ }
+ case "akeypad": {
+ const analogValue = this.getAnalogValue(pin);
+ if (analogValue >= 450) return 1;
+ else if (analogValue >= 390) return 2;
+ else if (analogValue >= 310) return 3;
+ else if (analogValue >= 200) return 4;
+ else if (analogValue >= 100) return 5;
+ else return 0;
+ }
+ case 'temperature': {
+ if (!this.state.rx.temperature[analogPin] || !this.state.rx.temperature[analogPin].enable) {
+ this.request('enableTemperatureSensor', pin, {pin}, true);
+ }
+
+ if (this.state.rx.temperature[analogPin] && this.state.rx.temperature[analogPin].value) {
+ return this.state.rx.temperature[analogPin].value;
+ }
+ } break;
+ case 'magnetic': {
+ const analogValue = this.getAnalogValue(pin, 512);
+
+ const zero = 512;
+ const zeroGap = 32;
+ const startS = zero + zeroGap;
+ const startN = zero - zeroGap;
+ const maxArea = 64;
+
+ let value = 0;
+ if (analogValue > startS) {
+ value = (analogValue > 1024 - maxArea) ? 1024 - maxArea : analogValue;
+ value = Math.min(10, parseInt(Math.round((value - startS) / 32)));
+ } else if (analogValue < startN) {
+ value = (analogValue < maxArea) ? maxArea : analogValue;
+ value = Math.min(10, parseInt(Math.round((startN - value) / 32))) * -1;
+ }
+ return value;
+ }
+ case 'rotaryposition': {
+ if (!this.state.rx.rotaryPosition[analogPin] || !this.state.rx.rotaryPosition[analogPin].enable) {
+ this.request('enableRotaryPositionSensor', pin, {pin}, true);
+ }
+
+ if (this.state.rx.rotaryPosition[analogPin] && this.state.rx.rotaryPosition[analogPin].rotation) {
+ return this.state.rx.rotaryPosition[analogPin].originAngle;
+ }
+ } break;
+ }
+ return 0;
+ }
+
+ compare_sensor_value (sprite, script) {
+ const value1 = this.get_sensor_value(sprite, script);
+ const symbol = script.getStringValue('SYMBOL');
+ const value2 = script.getStringValue('VALUE');
+
+ return this._compare(value1, value2, symbol);
+ }
+
+ get_rotary_position_sensor_value (sprite, script) {
+ const pin = this.pinToNumber(script.getStringValue('PIN'));
+ const analogPin = this.measureAnalogPin(pin);
+ const type = script.getStringValue('PROPERTY');
+
+ if (!this.state.rx.rotaryPosition[analogPin] || !this.state.rx.rotaryPosition[analogPin].enable) {
+ this.request('enableRotaryPositionSensor', pin, {pin}, true);
+ }
+
+ if (!this.state.rx.rotaryPosition[analogPin] || !this.state.rx.rotaryPosition[analogPin].rotation) return 0;
+
+ const obj = this.state.rx.rotaryPosition[analogPin];
+ let value = 0;
+ switch (type) {
+ case 'rotation': {
+ if (obj.isIntegerRotation) {
+ value = parseInt(obj.rotation);
+ } else {
+ value = obj.rotation;
+ }
+ } break;
+ case 'position': {
+ if (obj.isIntegerPosition) {
+ value = parseInt(Math.round(obj.position));
+ } else {
+ value = obj.position;
+ }
+ } break;
+ case 'angle': {
+ value = obj.angle;
+ } break;
+ case 'angle-origin': {
+ value = obj.originAngle;
+ } break;
+ }
+ return value;
+ }
+
+ reset_rotary_position_sensor (sprite, script) {
+ const pin = this.pinToNumber(script.getStringValue('PIN'));
+ const type = script.getStringValue('PROPERTY');
+ const value = script.getNumberValue('VALUE');
+
+ this.request('resetRotaryPositionSensor', pin, {pin, type, value});
+ }
+}
+
+module.exports = {ArduinoBase, PinMode};
diff --git a/src/playground/blocks/hardware/block_roborobo_robokit_rs.js b/src/playground/blocks/hardware/block_roborobo_robokit_rs.js
new file mode 100644
index 0000000000..5366dad99a
--- /dev/null
+++ b/src/playground/blocks/hardware/block_roborobo_robokit_rs.js
@@ -0,0 +1,2152 @@
+'use strict';
+const {ArduinoBase, PinMode} = require('./block_roborobo_base.js');
+
+class RobokitRS extends ArduinoBase {
+ constructor () {
+ super();
+
+ this.id = '10.3';
+ this.name = 'roborobo_robokit_rs';
+ this.url = 'http://www.roborobo.co.kr';
+ this.imageName = 'roborobo_robokit_rs.png';
+ this.title = {
+ ko: '로보키트 RS',
+ en: 'Robokit RS',
+ }
+ this.blockMenuBlocks = this.getBlockMenuBlocks();
+ }
+
+ /**
+ * 언어 번역 사용을 위해 함수 형태로 유지
+ */
+ monitorTemplate () {
+ return {
+ //imgPath: 'hw/~~.png',
+ //width: 256,
+ //height: 256,
+ // 모니터 화면 상단에 차례대로 나열하는 값
+ listPorts: {
+ digital_2: {name: (Lang.Blocks.monitor_digital + ': 2'), type: 'input', pos: {x: 0, y: 0, }},
+ digital_3: {name: (Lang.Blocks.monitor_digital + ': 3'), type: 'input', pos: {x: 0, y: 0, }},
+ digital_4: {name: (Lang.Blocks.monitor_digital + ': 4'), type: 'input', pos: {x: 0, y: 0, }},
+ digital_5: {name: (Lang.Blocks.monitor_digital + ': 5'), type: 'input', pos: {x: 0, y: 0, }},
+ digital_6: {name: (Lang.Blocks.monitor_digital + ': 6'), type: 'input', pos: {x: 0, y: 0, }},
+ digital_7: {name: (Lang.Blocks.monitor_digital + ': 7'), type: 'input', pos: {x: 0, y: 0, }},
+ digital_8: {name: (Lang.Blocks.monitor_digital + ': 8'), type: 'input', pos: {x: 0, y: 0, }},
+ digital_9: {name: (Lang.Blocks.monitor_digital + ': 9'), type: 'input', pos: {x: 0, y: 0, }},
+ digital_10: {name: (Lang.Blocks.monitor_digital + ': 10'), type: 'input', pos: {x: 0, y: 0, }},
+ digital_11: {name: (Lang.Blocks.monitor_digital + ': 11'), type: 'input', pos: {x: 0, y: 0, }},
+ digital_12: {name: (Lang.Blocks.monitor_digital + ': 12'), type: 'input', pos: {x: 0, y: 0, }},
+ digital_13: {name: (Lang.Blocks.monitor_digital + ': 13'), type: 'input', pos: {x: 0, y: 0, }},
+ analog_0: {name: (Lang.Blocks.monitor_analog + ': A0'), type: 'input', pos: {x: 0, y: 0, }},
+ analog_1: {name: (Lang.Blocks.monitor_analog + ': A1'), type: 'input', pos: {x: 0, y: 0, }},
+ analog_2: {name: (Lang.Blocks.monitor_analog + ': A2'), type: 'input', pos: {x: 0, y: 0, }},
+ analog_3: {name: (Lang.Blocks.monitor_analog + ': A3'), type: 'input', pos: {x: 0, y: 0, }},
+ analog_4: {name: (Lang.Blocks.monitor_analog + ': A4'), type: 'input', pos: {x: 0, y: 0, }},
+ analog_5: {name: (Lang.Blocks.monitor_analog + ': A5'), type: 'input', pos: {x: 0, y: 0, }},
+ sensor_gyroscope_angle_x: {name: Lang.Blocks.monitor_gyroscope_angle_x, type: 'input', pos: {x: 0, y: 0, }},
+ sensor_gyroscope_angle_y: {name: Lang.Blocks.monitor_gyroscope_angle_y, type: 'input', pos: {x: 0, y: 0, }},
+ sensor_gyroscope_angle_z: {name: Lang.Blocks.monitor_gyroscope_angle_z, type: 'input', pos: {x: 0, y: 0, }},
+ sensor_gyroscope_gyro_x: {name: Lang.Blocks.monitor_gyroscope_x, type: 'input', pos: {x: 0, y: 0, }},
+ sensor_gyroscope_gyro_y: {name: Lang.Blocks.monitor_gyroscope_y, type: 'input', pos: {x: 0, y: 0, }},
+ sensor_gyroscope_gyro_z: {name: Lang.Blocks.monitor_gyroscope_z, type: 'input', pos: {x: 0, y: 0, }},
+ sensor_gyroscope_shake: {name: Lang.Blocks.monitor_gyroscope_shake, type: 'input', pos: {x: 0, y: 0, }},
+ },
+ // 모니터 화면 지정 위치와 선으로 연결하여 표시하는 값
+ ports: {},
+ mode: 'both',
+ }
+ }
+
+ getBlockMenuBlocks () {
+ return [
+ 'robokit_rs_menu_digital_pin',
+ 'robokit_rs_menu_analog_pin',
+ 'robokit_rs_menu_pin',
+ 'robokit_rs_menu_digital_value',
+ 'robokit_rs_menu_motor_number',
+
+ 'robokit_rs_set_digital',
+ 'robokit_rs_set_motor',
+ 'robokit_rs_set_motors',
+ 'robokit_rs_set_mecanumwheels',
+ 'robokit_rs_set_servo_angle',
+ 'robokit_rs_set_rgbled_color',
+ 'robokit_rs_change_rgbled_brightness_by',
+ 'robokit_rs_set_rgbled_brightness_to',
+ 'robokit_rs_set_dot_state_of_dotmatrix',
+ 'robokit_rs_set_dotmatrix_row',
+ 'robokit_rs_set_dotmatrix',
+ 'robokit_rs_clear_dotmatrix',
+ 'robokit_rs_play_piezobuzzer',
+ 'robokit_rs_play_piezobuzzer_until_done',
+ 'robokit_rs_get_digital_value',
+ 'robokit_rs_get_analog_value',
+ 'robokit_rs_get_sensor_value',
+ 'robokit_rs_is_digital_detected',
+ 'robokit_rs_compare_analog_value',
+ 'robokit_rs_compare_sensor_value',
+ 'robokit_rs_get_gyro_sensor_value',
+ 'robokit_rs_is_shaken_gyro_sensor',
+ 'robokit_rs_reset_gyro_sensor',
+ 'robokit_rs_get_rotary_position_sensor_value',
+ 'robokit_rs_reset_rotary_position_sensor',
+ ];
+ }
+
+ setLanguage () {
+ return {
+ ko: {
+ template: {
+ robokit_rs_menu_digital_pin: '%1',
+ robokit_rs_menu_analog_pin: '%1',
+ robokit_rs_menu_pin: '%1',
+ robokit_rs_menu_digital_value: '%1',
+ robokit_rs_menu_motor_number: '%1',
+
+ robokit_rs_set_digital: '%1 번 핀 디지털 값을 %2 (으)로 정하기 %3',
+ robokit_rs_set_motor: '%1 번 모터를 속도 %2 (으)로 %3 %4',
+ robokit_rs_set_motors: '%1 번 모터, 속도 %2, %3 (으)로 로봇을 %4 %5',
+ robokit_rs_set_mecanumwheels: '메카넘 휠 로봇을 속도 %1 (으)로 %2 %3',
+ robokit_rs_set_servo_angle: '%1 번 핀 서보 모터를 %2 도로 회전하기 %3',
+ robokit_rs_set_rgbled_color: '%1 번 핀 RGB LED 색상을 %2 색으로 정하기 %3',
+ robokit_rs_change_rgbled_brightness_by: '%1 번 핀 RGB LED 밝기를 %2 만큼 바꾸기 %3',
+ robokit_rs_set_rgbled_brightness_to: '%1 번 핀 RGB LED 밝기를 %2 %로 정하기 %3',
+ robokit_rs_set_dot_state_of_dotmatrix: '도트 매트릭스 x: %1 y: %2 좌표를 %3 (으)로 정하기 %4',
+ robokit_rs_set_dotmatrix_row: '도트 매트릭스 y: %1 행에 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16 그리기 %17',
+ robokit_rs_set_dotmatrix: '도트 매트릭스에 %1 그리기 %2',
+ robokit_rs_clear_dotmatrix: '도트 매트릭스 모두 지우기 %1',
+ robokit_rs_play_piezobuzzer: '%1 번 핀 피에조 버저로 %2 옥타브 %3 음을 %4 초 소리내기 %5',
+ robokit_rs_play_piezobuzzer_until_done: '%1 번 핀 피에조 버저로 %2 옥타브 %3 음을 %4 초 소리내며 기다리기 %5',
+ robokit_rs_get_digital_value: '%1 번 핀 디지털 값',
+ robokit_rs_get_analog_value: '%1 번 핀 아날로그 값',
+ robokit_rs_get_sensor_value: '%1 번 핀 %2 값',
+ robokit_rs_is_digital_detected: '%1 번 핀이 감지되었는가?',
+ robokit_rs_compare_analog_value: '%1 번 핀 아날로그 값 %2 %3',
+ robokit_rs_compare_sensor_value: '%1 번 핀 %2 값 %3 %4',
+ robokit_rs_get_gyro_sensor_value: '자이로 센서 %1 값',
+ robokit_rs_is_shaken_gyro_sensor: '자이로 센서를 흔들었는가?',
+ robokit_rs_reset_gyro_sensor: '자이로 센서 기본 자세의 방향을 %1 정하기 %2',
+ robokit_rs_get_rotary_position_sensor_value: '%1 번 핀 회전 위치 센서 %2 값',
+ robokit_rs_reset_rotary_position_sensor: '%1 번 핀 회전 위치 센서 %2 값을 %3 (으)로 정하기 %4'
+ },
+ Blocks: {
+ monitor_digital: '디지털',
+ monitor_analog: '아날로그',
+ monitor_gyroscope_angle_x: '자이로 센서 : 기울기 x',
+ monitor_gyroscope_angle_y: '자이로 센서 : 기울기 y',
+ monitor_gyroscope_angle_z: '자이로 센서 : 기울기 z',
+ monitor_gyroscope_x: '자이로 센서 : 각속도 x',
+ monitor_gyroscope_y: '자이로 센서 : 각속도 y',
+ monitor_gyroscope_z: '자이로 센서 : 각속도 z',
+ monitor_gyroscope_shake: '자이로 센서 : 흔들림',
+
+ robokit_rs_motor_state_cw: '시계 방향 회전',
+ robokit_rs_motor_state_ccw: '시계 반대 방향 회전',
+ robokit_rs_motor_state_stop: '정지',
+
+ robokit_rs_motors_state_forward: '앞으로 이동',
+ robokit_rs_motors_state_backward: '뒤로 이동',
+ robokit_rs_motors_state_turn_left: '왼쪽으로 회전',
+ robokit_rs_motors_state_turn_right: '오른쪽으로 회전',
+ robokit_rs_motors_state_stop: '정지',
+
+ robokit_rs_mecanumwheels_state_0: '앞으로 이동',
+ robokit_rs_mecanumwheels_state_180: '뒤로 이동',
+ robokit_rs_mecanumwheels_state_270: '왼쪽으로 이동',
+ robokit_rs_mecanumwheels_state_90: '오른쪽으로 이동',
+ robokit_rs_mecanumwheels_state_45: '45도 방향으로 이동',
+ robokit_rs_mecanumwheels_state_135: '135도 방향으로 이동',
+ robokit_rs_mecanumwheels_state_315: '-45도 방향으로 이동',
+ robokit_rs_mecanumwheels_state_225: '-135도 방향으로 이동',
+ robokit_rs_mecanumwheels_state_cw: '시계 방향 회전',
+ robokit_rs_mecanumwheels_state_ccw: '시계 반대 방향 회전',
+ robokit_rs_mecanumwheels_state_stop: '정지',
+
+ robokit_rs_dotmatrix_example_eighth_note: '8분 음표',
+ robokit_rs_dotmatrix_example_sixteenth_note: '16분 음표',
+ robokit_rs_dotmatrix_example_square: '네모',
+ robokit_rs_dotmatrix_example_triangle: '세모',
+ robokit_rs_dotmatrix_example_circle: '동그라미',
+ robokit_rs_dotmatrix_example_heart: '하트',
+ robokit_rs_dotmatrix_example_ga: '가',
+ robokit_rs_dotmatrix_example_na: '나',
+ robokit_rs_dotmatrix_example_speech_bubble: '말풍선',
+ robokit_rs_dotmatrix_example_looking_at_top_right: '오른쪽 위 보기',
+ robokit_rs_dotmatrix_example_looking_at_bottom_right: '오른쪽 아래 보기',
+ robokit_rs_dotmatrix_example_looking_at_top_left: '왼쪽 위 보기',
+ robokit_rs_dotmatrix_example_looking_at_bottom_left: '왼쪽 아래 보기',
+ robokit_rs_dotmatrix_example_square_basic: '네모 기본',
+ robokit_rs_dotmatrix_example_square_basic_2: '네모 기본2',
+ robokit_rs_dotmatrix_example_square_square_eyes: '네모 네모 눈',
+ robokit_rs_dotmatrix_example_square_surprised_mouth: '네모 놀란 입',
+ robokit_rs_dotmatrix_example_big_round_eyes: '크고 둥근 눈',
+ robokit_rs_dotmatrix_example_small_round_eyes: '작고 둥근 눈',
+ robokit_rs_dotmatrix_example_wink_right_eye: '오른쪽 윙크',
+ robokit_rs_dotmatrix_example_wink_left_eye: '왼쪽 윙크',
+ robokit_rs_dotmatrix_example_eyebrow_eye_right: '오른쪽 눈썹 눈',
+ robokit_rs_dotmatrix_example_eyebrow_eye_left: '왼쪽 눈썹 눈',
+ robokit_rs_dotmatrix_example_expressionless: '무표정',
+ robokit_rs_dotmatrix_example_cutie: '귀요미',
+ robokit_rs_dotmatrix_example_cute: '깜찍이',
+ robokit_rs_dotmatrix_example_small_eyes_smile: '작은 눈 웃는 표정',
+ robokit_rs_dotmatrix_example_half_moon_shape_eyes: '반달 눈',
+ robokit_rs_dotmatrix_example_half_moon_shape_eyes_smiling: '반달 눈 웃기',
+ robokit_rs_dotmatrix_example_half_moon_shape_eyes_closed: '반달 눈 감기',
+ robokit_rs_dotmatrix_example_sad_expression: '슬픈 표정',
+ robokit_rs_dotmatrix_example_sullen: '시무룩',
+ robokit_rs_dotmatrix_example_crying_eyes: '우는 눈',
+ robokit_rs_dotmatrix_example_melancholy_look: '우울한 표정',
+ robokit_rs_dotmatrix_example_angry_eyes: '화난 눈',
+ robokit_rs_dotmatrix_example_o_shape_mouth: '오모양 입',
+ robokit_rs_dotmatrix_example_yo_shape_mouth: '요모양 입',
+
+ robokit_rs_piezobuzzer_tone_c: '도',
+ robokit_rs_piezobuzzer_tone_c_sharp: '도♯(레♭)',
+ robokit_rs_piezobuzzer_tone_d: '레',
+ robokit_rs_piezobuzzer_tone_d_sharp: '레♯(미♭)',
+ robokit_rs_piezobuzzer_tone_e: '미',
+ robokit_rs_piezobuzzer_tone_f: '파',
+ robokit_rs_piezobuzzer_tone_f_sharp: '파♯(솔♭)',
+ robokit_rs_piezobuzzer_tone_g: '솔',
+ robokit_rs_piezobuzzer_tone_g_sharp: '솔♯(라♭)',
+ robokit_rs_piezobuzzer_tone_a: '라',
+ robokit_rs_piezobuzzer_tone_a_sharp: '라♯(시♭)',
+ robokit_rs_piezobuzzer_tone_b: '시',
+
+ robokit_rs_sensor_temperutre: '온도 센서',
+ robokit_rs_sensor_joystick_x: '조이스틱 x',
+ robokit_rs_sensor_joystick_y: '조이스틱 y',
+ robokit_rs_sensor_light: '빛 센서',
+ robokit_rs_sensor_dial: '다이얼',
+ robokit_rs_sensor_a_keypad: 'A 키패드',
+ robokit_rs_sensor_rotaryposition: '회전 위치 센서',
+ robokit_rs_sensor_magnetic: '자기 센서',
+ robokit_rs_sensor_ultrasonic: '초음파 센서',
+
+ robokit_rs_sensor_gyroscope_angle_x: '기울기 x',
+ robokit_rs_sensor_gyroscope_angle_y: '기울기 y',
+ robokit_rs_sensor_gyroscope_angle_z: '기울기 z',
+ robokit_rs_sensor_gyroscope_x: '각속도 x',
+ robokit_rs_sensor_gyroscope_y: '각속도 y',
+ robokit_rs_sensor_gyroscope_z: '각속도 z',
+ robokit_rs_sensor_gyroscope_shake: '흔들림',
+
+ robokit_rs_sensor_gyroscope_direction_up: '위로',
+ robokit_rs_sensor_gyroscope_direction_forward: '앞으로',
+ robokit_rs_sensor_gyroscope_direction_right: '오른쪽으로',
+ robokit_rs_sensor_gyroscope_direction_backward: '뒤로',
+ robokit_rs_sensor_gyroscope_direction_left: '왼쪽으로',
+
+ robokit_rs_sensor_rotaryposition_rotation: '회전',
+ robokit_rs_sensor_rotaryposition_position: '위치',
+ robokit_rs_sensor_rotaryposition_angle: '각도',
+ },
+ },
+ en: {
+ template: {
+ robokit_rs_menu_digital_pin: '%1',
+ robokit_rs_menu_analog_pin: '%1',
+ robokit_rs_menu_pin: '%1',
+ robokit_rs_menu_digital_value: '%1',
+ robokit_rs_menu_motor_number: '%1',
+
+ robokit_rs_set_digital: 'set pin %1 digital value to %2 %3',
+ robokit_rs_set_motor: 'set motor %1 speed to %2 %3 %4',
+ robokit_rs_set_motors: '%4 a robot with motor %1 at speed %2 %3 %5',
+ robokit_rs_set_mecanumwheels: 'mecanum wheel robot %1 at speed %2 %3',
+ robokit_rs_set_servo_angle: 'rotate pin %1 servo motor to %2 degree %3',
+ robokit_rs_set_rgbled_color: 'set %1 pin RGB LED color to the %2 color %3',
+ robokit_rs_change_rgbled_brightness_by: 'change pin %1 RGB LED brightness by %2 %3',
+ robokit_rs_set_rgbled_brightness_to: 'set pin %1 RGB LED brightness to %2 % %3',
+ robokit_rs_set_dot_state_of_dotmatrix: 'Set dot matrix X: %1 Y: %2 to %3 %4',
+ robokit_rs_set_dotmatrix_row: 'Draw %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16 on dot matrix y:%1 column %17',
+ robokit_rs_set_dotmatrix: 'draw %1 on dotmatrix %2',
+ robokit_rs_clear_dotmatrix: 'Clear all dot matrix %1',
+ robokit_rs_play_piezobuzzer: 'Play pin %1 peizo buzzer with %2 otave %3 note for %4 sec %5',
+ robokit_rs_play_piezobuzzer_until_done: 'Play pin %1 peizo buzzer with %2 otave %3 note for %4 sec and wait %5',
+ robokit_rs_get_digital_value: 'pin %1 digital value',
+ robokit_rs_get_analog_value: 'pin %1 analog value',
+ robokit_rs_get_sensor_value: 'pin %1 %2 value',
+ robokit_rs_is_digital_detected: 'pin %1 detected?',
+ robokit_rs_compare_analog_value: 'pin %1 analog value %2 %3',
+ robokit_rs_compare_sensor_value: 'pin %1 %2 value %3 %4',
+ robokit_rs_get_gyro_sensor_value: '%1 value of gyrosensor',
+ robokit_rs_is_shaken_gyro_sensor: 'is gyrosensor shaken?',
+ robokit_rs_reset_gyro_sensor: 'set basic position of gyrosensor %1 %2',
+ robokit_rs_get_rotary_position_sensor_value: 'rotary position sensor of pin %1 %2 value',
+ robokit_rs_reset_rotary_position_sensor: 'rotary position sensor of pin %1 set %2 value to %3 %4'
+ },
+ Blocks: {
+ monitor_digital: 'Digital',
+ monitor_analog: 'Analog',
+ monitor_gyroscope_angle_x: 'Gyroscope sensor : angle x',
+ monitor_gyroscope_angle_y: 'Gyroscope sensor : angle y',
+ monitor_gyroscope_angle_z: 'Gyroscope sensor : angle z',
+ monitor_gyroscope_x: 'Gyroscope sensor : angular velocity x',
+ monitor_gyroscope_y: 'Gyroscope sensor : angular velocity y',
+ monitor_gyroscope_z: 'Gyroscope sensor : angular velocity z',
+ monitor_gyroscope_shake: 'Gyroscope sensor : shake',
+
+ robokit_rs_motor_state_cw: 'rotate clockwise',
+ robokit_rs_motor_state_ccw: 'rotate counterclockwise',
+ robokit_rs_motor_state_stop: 'stop',
+
+ robokit_rs_motors_state_forward: 'move forward',
+ robokit_rs_motors_state_backward: 'move backword',
+ robokit_rs_motors_state_turn_left: 'turn left',
+ robokit_rs_motors_state_turn_right: 'turn right',
+ robokit_rs_motors_state_stop: 'stop',
+
+ robokit_rs_mecanumwheels_state_0: 'move forward',
+ robokit_rs_mecanumwheels_state_180: 'move backward',
+ robokit_rs_mecanumwheels_state_270: 'move left',
+ robokit_rs_mecanumwheels_state_90: 'move right',
+ robokit_rs_mecanumwheels_state_45: 'move 45 degree',
+ robokit_rs_mecanumwheels_state_135: 'move 135 degree',
+ robokit_rs_mecanumwheels_state_315: 'move -45 degree',
+ robokit_rs_mecanumwheels_state_225: 'move -135 degree',
+ robokit_rs_mecanumwheels_state_cw: 'rotate clockwise',
+ robokit_rs_mecanumwheels_state_ccw: 'rotate counterclockwise',
+ robokit_rs_mecanumwheels_state_stop: 'stop',
+
+ robokit_rs_dotmatrix_example_eighth_note: 'eighth note',
+ robokit_rs_dotmatrix_example_sixteenth_note: 'sixteenth note',
+ robokit_rs_dotmatrix_example_square: 'square',
+ robokit_rs_dotmatrix_example_triangle: 'triangle',
+ robokit_rs_dotmatrix_example_circle: 'circle',
+ robokit_rs_dotmatrix_example_heart: 'heart',
+ robokit_rs_dotmatrix_example_ga: 'ga',
+ robokit_rs_dotmatrix_example_ga: 'na',
+ robokit_rs_dotmatrix_example_speech_bubble: 'speech bubble',
+ robokit_rs_dotmatrix_example_looking_at_top_right: 'looking at top right',
+ robokit_rs_dotmatrix_example_looking_at_bottom_right: 'looking at bottom right',
+ robokit_rs_dotmatrix_example_looking_at_top_left: 'looking at top left',
+ robokit_rs_dotmatrix_example_looking_at_bottom_left: 'looking at bottom left',
+ robokit_rs_dotmatrix_example_square_basic: 'square basic',
+ robokit_rs_dotmatrix_example_square_basic_2: 'square basic2',
+ robokit_rs_dotmatrix_example_square_square_eyes: 'square square eyes',
+ robokit_rs_dotmatrix_example_square_surprised_mouth: 'square surprised mouth',
+ robokit_rs_dotmatrix_example_big_round_eyes: 'big round eyes',
+ robokit_rs_dotmatrix_example_small_round_eyes: 'small round eyes',
+ robokit_rs_dotmatrix_example_wink_right_eye: 'wink right eye',
+ robokit_rs_dotmatrix_example_wink_left_eye: 'wink left eye',
+ robokit_rs_dotmatrix_example_eyebrow_eye_right: 'eyebrow eye to the right',
+ robokit_rs_dotmatrix_example_eyebrow_eye_left: 'eyebrow eye to the left',
+ robokit_rs_dotmatrix_example_expressionless: 'expressionless',
+ robokit_rs_dotmatrix_example_cutie: 'cutie',
+ robokit_rs_dotmatrix_example_cute: 'cute',
+ robokit_rs_dotmatrix_example_small_eyes_smile: 'small eyes smile',
+ robokit_rs_dotmatrix_example_half_moon_shape_eyes: 'half moon shape eyes',
+ robokit_rs_dotmatrix_example_half_moon_shape_eyes_smiling: 'half moon shape eyes smiling',
+ robokit_rs_dotmatrix_example_half_moon_shape_eyes_closed: 'half moon shape eyes closed',
+ robokit_rs_dotmatrix_example_sad_expression: 'sad expression',
+ robokit_rs_dotmatrix_example_sullen: 'sullen',
+ robokit_rs_dotmatrix_example_crying_eyes: 'crying eyes',
+ robokit_rs_dotmatrix_example_melancholy_look: 'melancholy look',
+ robokit_rs_dotmatrix_example_angry_eyes: 'angry eyes',
+ robokit_rs_dotmatrix_example_o_shape_mouth: 'o shape mouth',
+ robokit_rs_dotmatrix_example_yo_shape_mouth: 'yo shape mouth',
+
+ robokit_rs_piezobuzzer_tone_c: 'C',
+ robokit_rs_piezobuzzer_tone_c_sharp: 'C♯(D♭)',
+ robokit_rs_piezobuzzer_tone_d: 'D',
+ robokit_rs_piezobuzzer_tone_d_sharp: 'D♯(E♭)',
+ robokit_rs_piezobuzzer_tone_e: 'E',
+ robokit_rs_piezobuzzer_tone_f: 'F',
+ robokit_rs_piezobuzzer_tone_f_sharp: 'F♯(G♭)',
+ robokit_rs_piezobuzzer_tone_g: 'G',
+ robokit_rs_piezobuzzer_tone_g_sharp: 'G♯(A♭)',
+ robokit_rs_piezobuzzer_tone_a: 'A',
+ robokit_rs_piezobuzzer_tone_a_sharp: 'A♯(B♭)',
+ robokit_rs_piezobuzzer_tone_b: 'B',
+
+ robokit_rs_sensor_temperutre: 'temperature sensor',
+ robokit_rs_sensor_joystick_x: 'joystick x',
+ robokit_rs_sensor_joystick_y: 'joystick y',
+ robokit_rs_sensor_light: 'light sensor',
+ robokit_rs_sensor_dial: 'dial',
+ robokit_rs_sensor_a_keypad: 'A keypad',
+ robokit_rs_sensor_rotaryposition: 'rotary position sensor',
+ robokit_rs_sensor_magnetic: 'magnetic sensor',
+ robokit_rs_sensor_ultrasonic: 'ultrasonic sensor',
+
+ robokit_rs_sensor_gyroscope_angle_x: 'angle x',
+ robokit_rs_sensor_gyroscope_angle_y: 'angle y',
+ robokit_rs_sensor_gyroscope_angle_z: 'angle z',
+ robokit_rs_sensor_gyroscope_x: 'angular velocity x',
+ robokit_rs_sensor_gyroscope_y: 'angular velocity y',
+ robokit_rs_sensor_gyroscope_z: 'angular velocity z',
+ robokit_rs_sensor_gyroscope_shake: 'shake',
+
+ robokit_rs_sensor_gyroscope_direction_up: 'up',
+ robokit_rs_sensor_gyroscope_direction_forward: 'forward',
+ robokit_rs_sensor_gyroscope_direction_right: 'right',
+ robokit_rs_sensor_gyroscope_direction_backward: 'backward',
+ robokit_rs_sensor_gyroscope_direction_left: 'left',
+
+ robokit_rs_sensor_rotaryposition_rotation: 'rotation',
+ robokit_rs_sensor_rotaryposition_position: 'position',
+ robokit_rs_sensor_rotaryposition_angle: 'angle',
+ },
+ },
+ };
+ };
+
+ getBlocks () {
+ return {
+ robokit_rs_menu_digital_pin: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['2', '2'],
+ ['3', '3'],
+ ['4', '4'],
+ ['5', '5'],
+ ['6', '6'],
+ ['7', '7'],
+ ['8', '8'],
+ ['9', '9'],
+ ['10', '10'],
+ ['11', '11'],
+ ['12', '12'],
+ ['13', '13']
+ ],
+ value: '2',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ },
+ func: (sprite, script) => {
+ return script.getStringField('PIN');
+ },
+ },
+ robokit_rs_menu_analog_pin: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['A0', '14'],
+ ['A1', '15'],
+ ['A2', '16'],
+ ['A3', '17'],
+ ['A4', '18'],
+ ['A5', '19'],
+ ],
+ value: '14',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ },
+ func: (sprite, script) => {
+ return script.getStringField('PIN');
+ },
+ },
+ robokit_rs_menu_pin: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['A0', '14'],
+ ['A1', '15'],
+ ['A2', '16'],
+ ['A3', '17'],
+ ['A4', '18'],
+ ['A5', '19'],
+ ['2', '2'],
+ ['3', '3'],
+ ['4', '4'],
+ ['5', '5'],
+ ['6', '6'],
+ ['7', '7'],
+ ['8', '8'],
+ ['9', '9'],
+ ['10', '10'],
+ ['11', '11'],
+ ['12', '12'],
+ ['13', '13'],
+ ],
+ value: '14',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ },
+ func: (sprite, script) => {
+ return script.getStringField('PIN');
+ },
+ },
+ robokit_rs_menu_digital_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['0', '0'],
+ ['1', '1'],
+ ],
+ value: '1',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ NUM: 0,
+ },
+ func: (sprite, script) => {
+ return script.getStringField('NUM');
+ },
+ },
+ robokit_rs_menu_motor_number: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['1', '1'],
+ ['2', '2'],
+ ['3', '3'],
+ ['4', '4'],
+ ],
+ value: '1',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ NUM: 0,
+ },
+ func: (sprite, script) => {
+ return script.getStringField('NUM');
+ },
+ },
+ robokit_rs_set_digital: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ }
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'robokit_rs_menu_digital_pin',
+ },
+ {
+ type: 'robokit_rs_menu_digital_value',
+ },
+ null,
+ ],
+ type: 'robokit_rs_set_digital',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ VALUE: 1,
+ },
+ class: 'motion',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.set_digital(sprite, script),
+ },
+ robokit_rs_set_motor: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.robokit_rs_motor_state_cw, 'cw'],
+ [Lang.Blocks.robokit_rs_motor_state_ccw, 'ccw'],
+ [Lang.Blocks.robokit_rs_motor_state_stop, 'stop'],
+ ],
+ value: 'cw',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'robokit_rs_menu_motor_number'
+ },
+ {
+ type: 'number',
+ params: ['15'],
+ },
+ null,
+ null,
+
+ ],
+ type: 'robokit_rs_set_motor',
+ },
+ paramsKeyMap: {
+ MOTOR: 0,
+ SPEED: 1,
+ STATE: 2,
+ },
+ class: 'motion',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.set_motor(sprite, script)
+ },
+ robokit_rs_set_motors: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['1, 2', '12'],
+ ['3, 4', '34']
+ ],
+ value: '12',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.robokit_rs_motors_state_forward, 'forward'],
+ [Lang.Blocks.robokit_rs_motors_state_backward, 'backward'],
+ [Lang.Blocks.robokit_rs_motors_state_turn_left, 'turn-left'],
+ [Lang.Blocks.robokit_rs_motors_state_turn_right, 'turn-right'],
+ [Lang.Blocks.robokit_rs_motors_state_stop, 'stop'],
+ ],
+ value: 'forward',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ {
+ type: 'number',
+ params: ['15'],
+ },
+ {
+ type: 'number',
+ params: ['15'],
+ },
+ null,
+ null,
+
+ ],
+ type: 'robokit_rs_set_motors',
+ },
+ paramsKeyMap: {
+ MOTORS: 0,
+ SPEED1: 1,
+ SPEED2: 2,
+ STATE: 3,
+ },
+ class: 'motion',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.set_motors(sprite, script)
+ },
+ robokit_rs_set_mecanumwheels: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.robokit_rs_mecanumwheels_state_0, '0'],
+ [Lang.Blocks.robokit_rs_mecanumwheels_state_180, '180'],
+ [Lang.Blocks.robokit_rs_mecanumwheels_state_270, '270'],
+ [Lang.Blocks.robokit_rs_mecanumwheels_state_90, '90'],
+ [Lang.Blocks.robokit_rs_mecanumwheels_state_45, '45'],
+ [Lang.Blocks.robokit_rs_mecanumwheels_state_135, '135'],
+ [Lang.Blocks.robokit_rs_mecanumwheels_state_315, '315'],
+ [Lang.Blocks.robokit_rs_mecanumwheels_state_225, '225'],
+ [Lang.Blocks.robokit_rs_mecanumwheels_state_cw, 'cw'],
+ [Lang.Blocks.robokit_rs_mecanumwheels_state_ccw, 'ccw'],
+ [Lang.Blocks.robokit_rs_mecanumwheels_state_stop, 'stop'],
+ ],
+ value: '0',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'number',
+ params: ['15'],
+ },
+ null,
+ null,
+
+ ],
+ type: 'robokit_rs_set_mecanumwheels',
+ },
+ paramsKeyMap: {
+ SPEED: 0,
+ STATE: 1,
+ },
+ class: 'motion',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.set_mecanumwheels(sprite, script)
+ },
+ robokit_rs_set_servo_angle: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'robokit_rs_menu_digital_pin'
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ null,
+
+ ],
+ type: 'robokit_rs_set_servo_angle',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ ANGLE: 1,
+ },
+ class: 'motion',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.set_servo_angle(sprite, script)
+ },
+ robokit_rs_set_rgbled_color: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Color',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'robokit_rs_menu_digital_pin'
+ },
+ null,
+ null,
+
+ ],
+ type: 'robokit_rs_set_rgbled_color',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ COLOR: 1,
+ },
+ class: 'looks',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.set_rgbled_color(sprite, script)
+ },
+ robokit_rs_change_rgbled_brightness_by: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'robokit_rs_menu_digital_pin'
+ },
+ {
+ type: 'number',
+ params: ['10'],
+ },
+ null,
+
+ ],
+ type: 'robokit_rs_change_rgbled_brightness_by',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ BRIGHTNESS: 1,
+ },
+ class: 'looks',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.change_rgbled_brightness_by(sprite, script)
+ },
+ robokit_rs_set_rgbled_brightness_to: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'robokit_rs_menu_digital_pin'
+ },
+ {
+ type: 'number',
+ params: ['100'],
+ },
+ null,
+
+ ],
+ type: 'robokit_rs_set_rgbled_brightness_to',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ BRIGHTNESS: 1,
+ },
+ class: 'looks',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.set_rgbled_brightness_to(sprite, script)
+ },
+ robokit_rs_set_dot_state_of_dotmatrix: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'robokit_rs_menu_digital_value',
+ },
+ null,
+ ],
+ type: 'robokit_rs_set_dot_state_of_dotmatrix',
+ },
+ paramsKeyMap: {
+ X: 0,
+ Y: 1,
+ STATE: 2,
+ },
+ class: 'looks_dot_matrix',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.set_dot_state_of_dotmatrix(sprite, script)
+ },
+ robokit_rs_set_dotmatrix_row: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['0', '0'],
+ ['1', '1'],
+ ['2', '2'],
+ ['3', '3'],
+ ['4', '4'],
+ ['5', '5'],
+ ['6', '6'],
+ ],
+ value: '0',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ null,
+
+ ],
+ type: 'robokit_rs_set_dotmatrix_row',
+ },
+ paramsKeyMap: {
+ Y: 0,
+ X0: 1, X1: 2, X2: 3, X3: 4, X4: 5, X5: 6, X6: 7, X7: 8, X8: 9, X9: 10, X10: 11, X11: 12, X12: 13, X13: 14, X14: 15, X15: 16,
+ },
+ class: 'looks_dot_matrix',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.set_dotmatrix_row(sprite, script)
+ },
+ robokit_rs_set_dotmatrix: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.robokit_rs_dotmatrix_example_eighth_note, '000000000000000000000011000000000000010100000000000010100000000001110100000000011110000000000001100000000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_sixteenth_note, '000000001111000000000011001000000000010001000000000010011000000001110111000000011110111000000001100000000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_square, '000111111111000000111111111000000110000011000000110000011000000110000011000000111111111000000111111111000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_triangle, '000000010000000000000111000000000001101100000000011000110000000110000011000001100000001100001111111111100'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_circle, '000001111100000000011000110000000110000011000000100000001000000110000011000000011000110000000001111100000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_heart, '000011000110000000111101111000001111111111100001111111111100000111111111000000001111100000000000010000000'],
+ ['X', '000110000011000000011000110000000001111100000000000111000000000001111100000000011000110000000110000011000'],
+ ['A', '000000111000000000001000100000000001000100000000001111100000000001000100000000001000100000000001000100000'],
+ ['B', '000001111000000000001000100000000001000100000000001111100000000001000100000000001000100000000001111000000'],
+ ['C', '000000111000000000001000100000000001000000000000001000000000000001000000000000001000100000000000111000000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_ga, '000000000000000000011101000000000000101000000000000101100000000001001000000000000001000000000000000000000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_na, '000000000000000000010001000000000010001000000000010001100000000011101000000000000001000000000000000000000'],
+ ['!', '000000010000000000000010000000000000010000000000000010000000000000010000000000000000000000000000010000000'],
+ ['?', '000000111000000000001000100000000000000100000000000001000000000000010000000000000000000000000000010000000'],
+ ['0', '000001111100000000001000100000000001000100000000001000100000000001000100000000001000100000000001111100000'],
+ ['1', '000000010000000000000110000000000001010000000000000010000000000000010000000000000010000000000001111100000'],
+ ['2', '000001111100000000000000100000000000000100000000001111100000000001000000000000001000000000000001111100000'],
+ ['3', '000001111100000000000000100000000000000100000000001111100000000000000100000000000000100000000001111100000'],
+ ['4', '000001000100000000001000100000000001000100000000001000100000000001111110000000000000100000000000000100000'],
+ ['5', '000001111100000000001000000000000001000000000000001111100000000000000100000000000000100000000001111100000'],
+ ['6', '000001111100000000001000000000000001000000000000001111100000000001000100000000001000100000000001111100000'],
+ ['7', '000001111100000000001000100000000001000100000000000000100000000000000100000000000000100000000000000100000'],
+ ['8', '000001111100000000001000100000000001000100000000001111100000000001000100000000001000100000000001111100000'],
+ ['9', '000001111100000000001000100000000001000100000000001111100000000000000100000000000000100000000001111100000'],
+ ['10', '000010001111100000110001000100001010001000100000010001000100000010001000100000010001000100001111101111100'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_speech_bubble, '111111111111111100000000000001100111111111001100000000000001111110011111111000010100000000000011000000000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_looking_at_top_right, '011111000111110111100101111001111100101111001111111101111111111111101111111111111101111111011111000111110'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_looking_at_bottom_right, '011111000111110111111101111111111111101111111111111101111111111100101111001111100101111001011111000111110'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_looking_at_top_left, '011111000111110100111101001111100111101001111111111101111111111111101111111111111101111111011111000111110'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_looking_at_bottom_left, '011111000111110111111101111111111111101111111111111101111111100111101001111100111101001111011111000111110'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_square_basic, '111111111111111100000000000001100100000001001100000000000001100111111111001100000000000001111111111111111'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_square_basic_2, '111111111111111100000000000001101111000111101100110000011001100110010011001100000000000001111111111111111'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_square_square_eyes, '111111111111111100000000000001101111000111101101001000100101101111010111101100000000000001111111111111111'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_square_surprised_mouth, '111111111111111100000000000001100100111001001100000101000001100000101000001100000111000001111111111111111'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_big_round_eyes, '001111000111100011111101111110011111101111110011111101111110011111101111110011111101111110001111000111100'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_small_round_eyes, '000000000000000001111000111100011111101111110011111101111110011111101111110001111000111100000000000000000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_wink_right_eye, '000000000000000001111000000000011111100000000011111100111100011111101111110001111000111100000000000000000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_wink_left_eye, '000000000000000000000000111100000000001111110001111001111110011111101111110001111000111100000000000000000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_eyebrow_eye_right, '111111000111111000000000000000111111000111111011101000111010011111000111110011110000011110000000000000000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_eyebrow_eye_left, '111111000111111000000000000000111111000111111010111000101110011111000111110011110000011110000000000000000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_expressionless, '000000000000000011111000111110000000000000000000111000111000000111000111000000111000111000000111000111000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_cutie, '000000000000000001110000011100001110000011100001010010010100001110010011100000000101000000000011000110000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_cute, '001000000000100000100000001000000010000010000000100000001000001000010000100000000000000000000111111111000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_small_eyes_smile, '000000000000000000100000001000000100000001000000000000000000001111111111100001111111111100000111111111000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_half_moon_shape_eyes, '000000000000000001111000111100011111101111110010000101000010000000000000000000000000000000000000000000000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_half_moon_shape_eyes_smiling, '001111000111100011111101111110010000101000010000000000000000001100000001100000110000011000000011111110000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_half_moon_shape_eyes_closed, '000000000000000000000000000000000000000000000010000101000010011111101111110001111000111100000000000000000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_sad_expression, '000000000000000000010000010000000100000001000001000000000100010110000011010000110000011000000110000011000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_sullen, '000000000000000001100000001100011110000011110011110000011110001100111001100000001111100000000011000110000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_crying_eyes, '000000000000000000000000000000011111000111110001010000010100001010000010100001010000010100000000000000000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_melancholy_look, '011111000111110001100000001100001100000001100000001111100000000011000110000000110000011000000100000001000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_angry_eyes, '100000000000001010000000000010001000000000100000100000001000011010000010110011001000100110011000000000110'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_o_shape_mouth, '000000000000000001100000001100011010000011010011110000011110001100010001100000000010000000000001111100000'],
+ [Lang.Blocks.robokit_rs_dotmatrix_example_yo_shape_mouth, '000000000000000010001000100010010001000100010001110000011100000000000000000000000101000000000000111000000'],
+ ['↑', '000000010000000000000111000000000001010100000000000010000000000000010000000000000010000000000000010000000'],
+ ['↗', '000000011110000000000000110000000000001010000000000010010000000000100000000000001000000000000010000000000'],
+ ['→', '000000000000000000000001000000000000000100000000011111110000000000000100000000000001000000000000000000000'],
+ ['↘', '000010000000000000001000000000000000100000000000000010010000000000001010000000000000110000000000011110000'],
+ ['↓', '000000010000000000000010000000000000010000000000000010000000000001010100000000000111000000000000010000000'],
+ ['↙', '000000000010000000000000100000000000001000000000010010000000000010100000000000011000000000000011110000000'],
+ ['←', '000000000000000000000100000000000001000000000000011111110000000001000000000000000100000000000000000000000'],
+ ['↖', '000011110000000000011000000000000010100000000000010010000000000000001000000000000000100000000000000010000'],
+ ],
+ value: '000000000000000000000011000000000000010100000000000010100000000001110100000000011110000000000001100000000',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ null,
+ ],
+ type: 'robokit_rs_set_dotmatrix',
+ },
+ paramsKeyMap: {
+ MATRIX: 0
+ },
+ class: 'looks_dot_matrix',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.set_dotmatrix(sprite, script)
+ },
+ robokit_rs_clear_dotmatrix: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ ],
+ type: 'robokit_rs_clear_dotmatrix',
+ },
+ paramsKeyMap: {},
+ class: 'looks_dot_matrix',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.clear_dotmatrix(sprite, script)
+ },
+ robokit_rs_play_piezobuzzer: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ 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: 'Dropdown',
+ options: [
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_c, '0'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_c_sharp, '1'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_d, '2'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_d_sharp, '3'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_e, '4'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_f, '5'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_f_sharp, '6'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_g, '7'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_g_sharp, '8'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_a, '9'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_a_sharp, '10'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_b, '11'],
+ ],
+ value: '0',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'robokit_rs_menu_digital_pin'
+ },
+ null,
+ null,
+ {
+ type: 'number',
+ params: ['0.5'],
+ },
+ null,
+
+ ],
+ type: 'robokit_rs_play_piezobuzzer',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ OCTAVE: 1,
+ NOTE: 2,
+ DURATION: 3,
+ },
+ class: 'sound',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.play_piezobuzzer(sprite, script)
+ },
+ robokit_rs_play_piezobuzzer_until_done: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ 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: 'Dropdown',
+ options: [
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_c, '0'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_c_sharp, '1'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_d, '2'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_d_sharp, '3'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_e, '4'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_f, '5'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_f_sharp, '6'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_g, '7'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_g_sharp, '8'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_a, '9'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_a_sharp, '10'],
+ [Lang.Blocks.robokit_rs_piezobuzzer_tone_b, '11'],
+ ],
+ value: '0',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'robokit_rs_menu_digital_pin'
+ },
+ null,
+ null,
+ {
+ type: 'number',
+ params: ['0.5'],
+ },
+ null,
+
+ ],
+ type: 'robokit_rs_play_piezobuzzer_until_done',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ OCTAVE: 1,
+ NOTE: 2,
+ DURATION: 3,
+ },
+ class: 'sound',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.play_piezobuzzer_until_done(sprite, script)
+ },
+ robokit_rs_get_digital_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'robokit_rs_menu_digital_pin',
+ },
+ ],
+ type: 'robokit_rs_get_digital_value',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ },
+ class: 'sensing',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.get_digital_value(sprite, script),
+ },
+ robokit_rs_get_analog_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'robokit_rs_menu_analog_pin',
+ },
+ ],
+ type: 'robokit_rs_get_analog_value',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ },
+ class: 'sensing',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.get_analog_value(sprite, script),
+ },
+ robokit_rs_get_sensor_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.robokit_rs_sensor_temperutre, 'temperature'],
+ [Lang.Blocks.robokit_rs_sensor_joystick_x, 'joystickx'],
+ [Lang.Blocks.robokit_rs_sensor_joystick_y, 'joysticky'],
+ [Lang.Blocks.robokit_rs_sensor_light, 'light'],
+ [Lang.Blocks.robokit_rs_sensor_dial, 'dial'],
+ [Lang.Blocks.robokit_rs_sensor_a_keypad, 'akeypad'],
+ [Lang.Blocks.robokit_rs_sensor_rotaryposition, 'rotaryposition'],
+ [Lang.Blocks.robokit_rs_sensor_magnetic, 'magnetic'],
+ [Lang.Blocks.robokit_rs_sensor_ultrasonic, 'ultrasonic'],
+ ],
+ value: 'temperature',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'robokit_rs_menu_pin',
+ },
+ null,
+ ],
+ type: 'robokit_rs_get_sensor_value',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ SENSOR: 1,
+ },
+ class: 'sensing',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.get_sensor_value(sprite, script)
+ },
+ robokit_rs_is_digital_detected: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_boolean_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'robokit_rs_menu_digital_pin',
+ },
+ ],
+ type: 'robokit_rs_is_digital_detected',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ },
+ class: 'sensing',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.is_digital_detected(sprite, script),
+ },
+ robokit_rs_compare_analog_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_boolean_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ ['>', 'greater-than'],
+ ['=', 'equal'],
+ ['<', 'less-than'],
+ ],
+ value: 'greater-than',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'robokit_rs_menu_analog_pin',
+ },
+ null,
+ {
+ type: 'number',
+ params: ['512'],
+ },
+ ],
+ type: 'robokit_rs_compare_analog_value',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ SYMBOL: 1,
+ VALUE: 2,
+ },
+ class: 'sensing',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.compare_analog_value(sprite, script),
+ },
+ robokit_rs_compare_sensor_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_boolean_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.robokit_rs_sensor_temperutre, 'temperature'],
+ [Lang.Blocks.robokit_rs_sensor_joystick_x, 'joystickx'],
+ [Lang.Blocks.robokit_rs_sensor_joystick_y, 'joysticky'],
+ [Lang.Blocks.robokit_rs_sensor_light, 'light'],
+ [Lang.Blocks.robokit_rs_sensor_dial, 'dial'],
+ [Lang.Blocks.robokit_rs_sensor_a_keypad, 'akeypad'],
+ [Lang.Blocks.robokit_rs_sensor_rotaryposition, 'rotaryposition'],
+ [Lang.Blocks.robokit_rs_sensor_magnetic, 'magnetic'],
+ [Lang.Blocks.robokit_rs_sensor_ultrasonic, 'ultrasonic'],
+ ],
+ value: 'temperature',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ ['>', 'greater-than'],
+ ['=', 'equal'],
+ ['<', 'less-than'],
+ ],
+ value: 'greater-than',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'robokit_rs_menu_pin',
+ },
+ null,
+ null,
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ ],
+ type: 'robokit_rs_compare_sensor_value',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ SENSOR: 1,
+ SYMBOL: 2,
+ VALUE: 3,
+ },
+ class: 'sensing',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.compare_sensor_value(sprite, script),
+ },
+ robokit_rs_get_gyro_sensor_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.robokit_rs_sensor_gyroscope_angle_x, "anglex"],
+ [Lang.Blocks.robokit_rs_sensor_gyroscope_angle_y, "angley"],
+ [Lang.Blocks.robokit_rs_sensor_gyroscope_angle_z, "anglez"],
+ [Lang.Blocks.robokit_rs_sensor_gyroscope_x, "gyrox"],
+ [Lang.Blocks.robokit_rs_sensor_gyroscope_y, "gyroy"],
+ [Lang.Blocks.robokit_rs_sensor_gyroscope_z, "gyroz"],
+ [Lang.Blocks.robokit_rs_sensor_gyroscope_shake, "shake"]
+ ],
+ value: 'anglex',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ null,
+ ],
+ type: 'robokit_rs_get_gyro_sensor_value',
+ },
+ paramsKeyMap: {
+ PROPERTY: 0,
+ },
+ class: 'sensing_gyro_sensor',
+ isNotFor: ['roborobo_robokit_rs'],
+
+ func: (sprite, script) => this.get_gyro_sensor_value(sprite, script),
+ },
+ robokit_rs_is_shaken_gyro_sensor: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_boolean_field',
+ statements: [],
+ params: [],
+ events: {},
+ def: {
+ params: [],
+ type: 'robokit_rs_is_shaken_gyro_sensor',
+ },
+ paramsKeyMap: {},
+ class: 'sensing_gyro_sensor',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.is_shaken_gyro_sensor(sprite, script)
+ },
+ robokit_rs_reset_gyro_sensor: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.robokit_rs_sensor_gyroscope_direction_up, 'up'],
+ [Lang.Blocks.robokit_rs_sensor_gyroscope_direction_forward, 'forward'],
+ [Lang.Blocks.robokit_rs_sensor_gyroscope_direction_right, 'right'],
+ [Lang.Blocks.robokit_rs_sensor_gyroscope_direction_backward, 'backward'],
+ [Lang.Blocks.robokit_rs_sensor_gyroscope_direction_left, 'left']
+ ],
+ value: 'up',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ null,
+ ],
+ type: 'robokit_rs_reset_gyro_sensor',
+ },
+ paramsKeyMap: {
+ DIRECTION: 0,
+ },
+ class: 'sensing_gyro_sensor',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.reset_gyro_sensor(sprite, script)
+ },
+
+ robokit_rs_get_rotary_position_sensor_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.robokit_rs_sensor_rotaryposition_rotation, 'rotation'],
+ [Lang.Blocks.robokit_rs_sensor_rotaryposition_position, 'position'],
+ [Lang.Blocks.robokit_rs_sensor_rotaryposition_angle, 'angle']
+ ],
+ value: 'rotation',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'robokit_rs_menu_analog_pin',
+ },
+ null,
+ ],
+ type: 'robokit_rs_get_rotary_position_sensor_value',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ PROPERTY: 1,
+ },
+ class: 'sensing_rotary_position_sensor',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.get_rotary_position_sensor_value(sprite, script)
+ },
+
+ robokit_rs_reset_rotary_position_sensor: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.robokit_rs_sensor_rotaryposition_rotation, 'rotation'],
+ [Lang.Blocks.robokit_rs_sensor_rotaryposition_position, 'position'],
+ [Lang.Blocks.robokit_rs_sensor_rotaryposition_angle, 'angle']
+ ],
+ value: 'rotation',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'robokit_rs_menu_analog_pin',
+ },
+ null,
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ null,
+ ],
+ type: 'robokit_rs_reset_rotary_position_sensor',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ PROPERTY: 1,
+ VALUE: 2,
+ },
+ class: 'sensing_rotary_position_sensor',
+ isNotFor: ['roborobo_robokit_rs'],
+ func: (sprite, script) => this.reset_rotary_position_sensor(sprite, script)
+ },
+ };
+ };
+
+ setZero () {
+ super.setZero();
+ }
+
+ afterReceive (data) {
+ super.afterReceive(data);
+ }
+
+ afterSend () {
+ super.afterSend();
+ }
+
+ request (func, subkey, value, updateNow = false) {
+ super.request(func, subkey, value, updateNow);
+ }
+
+ /**
+ * -----------------------------------block execute-----------------------------------
+ * 공통 사용 함수를 제외한 나머지 블록 동작을 작성
+ * -----------------------------------------------------------------------------------
+ */
+
+ set_mecanumwheels (sprite, script) {
+ const speed = script.getNumberValue('SPEED');
+ const state = script.getStringValue('STATE');
+
+ let data = []
+ for (let i = 0; i < 4; i++) {
+ data[i] = {motor: i + 1, speed: speed, state: 0}
+ }
+
+ switch (state) {
+ case '0': {
+ data[0].state = 2;
+ data[1].state = 1;
+ data[2].state = 2;
+ data[3].state = 1;
+ }
+ break;
+ case '45': {
+ data[0].state = 2;
+ data[3].state = 1;
+ }
+ break;
+ case '90': {
+ data[0].state = 2;
+ data[1].state = 2;
+ data[2].state = 1;
+ data[3].state = 1;
+ }
+ break;
+ case '135': {
+ data[1].state = 2;
+ data[2].state = 1;
+ }
+ break;
+ case '180': {
+ data[0].state = 1;
+ data[1].state = 2;
+ data[2].state = 1;
+ data[3].state = 2;
+ }
+ break;
+ case '225': {
+ data[0].state = 1;
+ data[3].state = 2;
+ }
+ break;
+ case '270': {
+ data[0].state = 1;
+ data[1].state = 1;
+ data[2].state = 2;
+ data[3].state = 2;
+ }
+ break;
+ case '315': {
+ data[1].state = 1;
+ data[2].state = 2;
+ }
+ break;
+ case 'cw': {
+ data[0].state = 2;
+ data[1].state = 2;
+ data[2].state = 2;
+ data[3].state = 2;
+ }
+ break;
+ case 'ccw': {
+ data[0].state = 1;
+ data[1].state = 1;
+ data[2].state = 1;
+ data[3].state = 1;
+ }
+ break;
+ case 'stop':
+ break;
+ }
+
+ for (let i = 0; i < 4; i++) {
+ this.request('setMotor', i + 1, data[i]);
+ }
+ return script.callReturn();
+ }
+
+ set_dot_state_of_dotmatrix (sprite, script) {
+ const x = script.getNumberValue('X');
+ const y = script.getNumberValue('Y');
+ const state = script.getNumberValue('STATE');
+ if (x < 0 || x > 14 || y < 0 || y > 6) return script.callReturn();
+
+ this.request('setDotMatrix', null, {type: 'dot', x, y, dot: Math.min(1, Math.max(0, state)).toString()}, true);
+ return script.callReturn();
+ }
+
+ set_dotmatrix_row (sprite, script) {
+ const y = script.getNumberValue('Y');
+ let dots = '';
+ for (let i = 0; i < 16; i++) {
+ const value = script.getNumberValue('X' + i);
+ dots += Math.max(0, Math.min(1, value)).toString();
+ }
+
+ this.request('setDotMatrix', null, {type: 'row', y, dots}, true);
+ return script.callReturn();
+ }
+
+ set_dotmatrix (sprite, script) {
+ const example = script.getStringValue('MATRIX')
+ this.request('setDotMatrix', null, {type: 'all', dots: example}, true);
+ return script.callReturn();
+ }
+
+ clear_dotmatrix (sprite, script) {
+ const length = 15 * 7;
+ let dots = '';
+ for (let i = 0; i < length; i++) {dots += 0;}
+
+ this.request('setDotMatrix', null, {type: 'all', dots});
+ return script.callReturn();
+ }
+
+ get_gyro_sensor_value (sprite, script) {
+ const type = script.getStringValue('PROPERTY');
+
+ const obj = this.state.rx.gyro;
+ if (!this.isEqualsPinMode(18, PinMode.I2C) || !this.isEqualsPinMode(19, PinMode.I2C) || !obj || !obj.enable) {
+ this.request('enableGyroSensor', null, null, true);
+ }
+
+ if (!obj) return 0;
+ switch (type) {
+ case 'anglex': return obj.angle.x;
+ case 'angley': return obj.angle.y;
+ case 'anglez': return obj.angle.z;
+ case 'gyrox': return obj.gyro.x;
+ case 'gyroy': return obj.gyro.y;
+ case 'gyroz': return obj.gyro.z;
+ case 'shake': return obj.shake;
+ default: return 0;
+ }
+ }
+
+ is_shaken_gyro_sensor (sprite, script) {
+ const obj = this.state.rx.gyro;
+
+ if (!this.isEqualsPinMode(18, PinMode.I2C) || !this.isEqualsPinMode(19, PinMode.I2C) || !obj || !obj.enable) {
+ this.request('enableGyroSensor', null, null, true);
+ }
+
+ return obj ? obj.shake == 1 : false;
+ }
+
+ reset_gyro_sensor (sprite, script) {
+ const dir = script.getStringValue('DIRECTION');
+ let dirNum = 0;
+ switch (dir) {
+ case 'up':
+ dirNum = 0;
+ break;
+ case 'forward':
+ dirNum = 1;
+ break;
+ case 'right':
+ dirNum = 2;
+ break;
+ case 'backward':
+ dirNum = 3;
+ break;
+ case 'left':
+ dirNum = 4;
+ break;
+ }
+ this.request('resetGyroSensor', null, {direction: dirNum}, true);
+ return new Promise(resolve => setTimeout(() => resolve(), 500));
+ }
+}
+
+module.exports = new RobokitRS();
\ No newline at end of file
diff --git a/src/playground/blocks/hardware/block_roborobo_roduino.js b/src/playground/blocks/hardware/block_roborobo_roduino.js
new file mode 100644
index 0000000000..034c6e2bad
--- /dev/null
+++ b/src/playground/blocks/hardware/block_roborobo_roduino.js
@@ -0,0 +1,1340 @@
+'use strict';
+const {ArduinoBase} = require('./block_roborobo_base.js');
+
+class Roduino extends ArduinoBase {
+ constructor () {
+ super();
+
+ this.id = '10.1';
+ this.name = 'roborobo_roduino';
+ this.url = 'http://www.roborobo.co.kr';
+ this.imageName = 'roborobo_roduino.png';
+ this.title = {
+ ko: '로두이노',
+ en: 'Roduino',
+ }
+ this.blockMenuBlocks = this.getBlockMenuBlocks();
+ }
+
+ /**
+ * 언어 번역 사용을 위해 함수 형태로 유지
+ */
+ monitorTemplate () {
+ return {
+ //imgPath: 'hw/~~.png',
+ //width: 256,
+ //height: 256,
+ // 모니터 화면 상단에 차례대로 나열하는 값
+ listPorts: {
+ digital_2: {name: (Lang.Blocks.monitor_digital + ': 2'), type: 'input', pos: {x: 0, y: 0, }},
+ digital_3: {name: (Lang.Blocks.monitor_digital + ': 3'), type: 'input', pos: {x: 0, y: 0, }},
+ digital_4: {name: (Lang.Blocks.monitor_digital + ': 4'), type: 'input', pos: {x: 0, y: 0, }},
+ digital_5: {name: (Lang.Blocks.monitor_digital + ': 5'), type: 'input', pos: {x: 0, y: 0, }},
+ digital_6: {name: (Lang.Blocks.monitor_digital + ': 6'), type: 'input', pos: {x: 0, y: 0, }},
+ digital_7: {name: (Lang.Blocks.monitor_digital + ': 7'), type: 'input', pos: {x: 0, y: 0, }},
+ digital_8: {name: (Lang.Blocks.monitor_digital + ': 8'), type: 'input', pos: {x: 0, y: 0, }},
+ analog_0: {name: (Lang.Blocks.monitor_analog + ': A0'), type: 'input', pos: {x: 0, y: 0, }},
+ analog_1: {name: (Lang.Blocks.monitor_analog + ': A1'), type: 'input', pos: {x: 0, y: 0, }},
+ analog_2: {name: (Lang.Blocks.monitor_analog + ': A2'), type: 'input', pos: {x: 0, y: 0, }},
+ analog_3: {name: (Lang.Blocks.monitor_analog + ': A3'), type: 'input', pos: {x: 0, y: 0, }},
+ analog_4: {name: (Lang.Blocks.monitor_analog + ': A4'), type: 'input', pos: {x: 0, y: 0, }},
+ analog_5: {name: (Lang.Blocks.monitor_analog + ': A5'), type: 'input', pos: {x: 0, y: 0, }},
+ },
+ // 모니터 화면 지정 위치와 선으로 연결하여 표시하는 값
+ ports: {},
+ mode: 'both',
+ }
+ }
+
+ getBlockMenuBlocks () {
+ return [
+ 'roduino_menu_digital_pin',
+ 'roduino_menu_analog_pin',
+ 'roduino_menu_pin',
+ 'roduino_menu_digital_value',
+ 'roduino_menu_motor_number',
+
+ 'roduino_set_digital',
+ 'roduino_set_motor_rotation',
+ 'roduino_set_rgbled_color',
+ 'roduino_change_rgbled_brightness_by',
+ 'roduino_set_rgbled_brightness_to',
+ 'roduino_play_piezobuzzer',
+ 'roduino_play_piezobuzzer_until_done',
+ 'roduino_get_digital_value',
+ 'roduino_get_analog_value',
+ 'roduino_get_sensor_value',
+ 'roduino_is_digital_detected',
+ 'roduino_compare_analog_value',
+ 'roduino_compare_sensor_value',
+ 'roduino_get_rotary_position_sensor_value',
+ 'roduino_reset_rotary_position_sensor',
+ 'roduino_get_color_sensor_detected_value',
+ 'roduino_is_color_sensor_detected',
+ 'roduino_set_color_sensor_pins',
+ ];
+ }
+
+ setLanguage () {
+ return {
+ ko: {
+ template: {
+ roduino_menu_digital_pin: '%1',
+ roduino_menu_analog_pin: '%1',
+ roduino_menu_pin: '%1',
+ roduino_menu_digital_value: '%1',
+ roduino_menu_motor_number: '%1',
+
+ roduino_set_digital: '%1 번 핀 디지털 값을 %2 (으)로 정하기 %3',
+ roduino_set_motor_rotation: '%1 번 모터를 %2 하기 %3',
+ roduino_set_rgbled_color: '%1 번 핀 RGB LED 색상을 %2 색으로 정하기 %3',
+ roduino_change_rgbled_brightness_by: '%1 번 핀 RGB LED 밝기를 %2 만큼 바꾸기 %3',
+ roduino_set_rgbled_brightness_to: '%1 번 핀 RGB LED 밝기를 %2 %로 정하기 %3',
+ roduino_play_piezobuzzer: '%1 번 핀 피에조 버저로 %2 옥타브 %3 음을 %4 초 소리내기 %5',
+ roduino_play_piezobuzzer_until_done: '%1 번 핀 피에조 버저로 %2 옥타브 %3 음을 %4 초 소리내며 기다리기 %5',
+ roduino_get_digital_value: '%1 번 핀 디지털 값',
+ roduino_get_analog_value: '%1 번 핀 아날로그 값',
+ roduino_get_sensor_value: '%1 번 핀 %2 값',
+ roduino_is_digital_detected: '%1 번 핀이 감지되었는가?',
+ roduino_compare_analog_value: '%1 번 핀 아날로그 값 %2 %3',
+ roduino_compare_sensor_value: '%1 번 핀 %2 값 %3 %4',
+ roduino_get_rotary_position_sensor_value: '%1 번 핀 회전 위치 센서 %2 값',
+ roduino_reset_rotary_position_sensor: '%1 번 핀 회전 위치 센서 %2 값을 %3 (으)로 정하기 %4',
+ roduino_get_color_sensor_detected_value: '%1 감지 값',
+ roduino_is_color_sensor_detected: '%1 이 감지되었는가?',
+ roduino_set_color_sensor_pins: '컬러 센서 핀을 R: %1 G: %2 B: %3 번으로 정하기 %4',
+ },
+ Blocks: {
+ monitor_digital: '디지털',
+ monitor_analog: '아날로그',
+
+ roduino_motor_state_cw: '시계 방향 회전',
+ roduino_motor_state_ccw: '시계 반대 방향 회전',
+ roduino_motor_state_stop: '정지',
+
+ roduino_piezobuzzer_tone_c: '도',
+ roduino_piezobuzzer_tone_c_sharp: '도♯(레♭)',
+ roduino_piezobuzzer_tone_d: '레',
+ roduino_piezobuzzer_tone_d_sharp: '레♯(미♭)',
+ roduino_piezobuzzer_tone_e: '미',
+ roduino_piezobuzzer_tone_f: '파',
+ roduino_piezobuzzer_tone_f_sharp: '파♯(솔♭)',
+ roduino_piezobuzzer_tone_g: '솔',
+ roduino_piezobuzzer_tone_g_sharp: '솔♯(라♭)',
+ roduino_piezobuzzer_tone_a: '라',
+ roduino_piezobuzzer_tone_a_sharp: '라♯(시♭)',
+ roduino_piezobuzzer_tone_b: '시',
+
+ roduino_sensor_temperutre: '온도 센서',
+ roduino_sensor_joystick_x: '조이스틱 x',
+ roduino_sensor_joystick_y: '조이스틱 y',
+ roduino_sensor_light: '빛 센서',
+ roduino_sensor_dial: '다이얼',
+ roduino_sensor_a_keypad: 'A 키패드',
+ roduino_sensor_rotaryposition: '회전 위치 센서',
+ roduino_sensor_magnetic: '자기 센서',
+ roduino_sensor_ultrasonic: '초음파 센서',
+
+ roduino_sensor_rotaryposition_rotation: '회전',
+ roduino_sensor_rotaryposition_position: '위치',
+ roduino_sensor_rotaryposition_angle: '각도',
+
+ roduino_sensor_color_red: '빨간색',
+ roduino_sensor_color_yellow: '노란색',
+ roduino_sensor_color_green: '초록색',
+ roduino_sensor_color_blue: '파란색',
+ },
+ },
+ en: {
+ template: {
+ roduino_menu_digital_pin: '%1',
+ roduino_menu_analog_pin: '%1',
+ roduino_menu_pin: '%1',
+ roduino_menu_digital_value: '%1',
+ roduino_menu_motor_number: '%1',
+
+ roduino_set_digital: 'set pin %1 digital value to %2 %3',
+ roduino_set_motor_rotation: 'set %1 the %2 motor %3',
+ roduino_set_rgbled_color: 'set %1 pin RGB LED color to the %2 color %3',
+ roduino_change_rgbled_brightness_by: 'change pin %1 RGB LED brightness by %2 %3',
+ roduino_set_rgbled_brightness_to: 'set pin %1 RGB LED brightness to %2 % %3',
+ roduino_play_piezobuzzer: 'Play pin %1 peizo buzzer with %2 otave %3 note for %4 sec %5',
+ roduino_play_piezobuzzer_until_done: 'Play pin %1 peizo buzzer with %2 otave %3 note for %4 sec and wait %5',
+ roduino_get_digital_value: 'pin %1 digital value',
+ roduino_get_analog_value: 'pin %1 analog value',
+ roduino_get_sensor_value: 'pin %1 %2 value',
+ roduino_is_digital_detected: 'pin %1 detected?',
+ roduino_compare_analog_value: 'pin %1 analog value %2 %3',
+ roduino_compare_sensor_value: 'pin %1 %2 value %3 %4',
+ roduino_get_rotary_position_sensor_value: 'rotary position sensor of pin %1 %2 value',
+ roduino_reset_rotary_position_sensor: 'rotary position sensor of pin %1 set %2 value to %3 %4',
+ roduino_get_color_sensor_detected_value: '%1 detection value',
+ roduino_is_color_sensor_detected: 'is %1 detected?',
+ roduino_set_color_sensor_pins: 'set color sensor pins to R: %1 G: %2 B: %3 %4',
+ },
+ Blocks: {
+ monitor_digital: 'Digital',
+ monitor_analog: 'Analog',
+
+ roduino_motor_state_cw: 'rotate clockwise',
+ roduino_motor_state_ccw: 'rotate counterclockwise',
+ roduino_motor_state_stop: 'stop',
+
+ roduino_piezobuzzer_tone_c: 'C',
+ roduino_piezobuzzer_tone_c_sharp: 'C♯(D♭)',
+ roduino_piezobuzzer_tone_d: 'D',
+ roduino_piezobuzzer_tone_d_sharp: 'D♯(E♭)',
+ roduino_piezobuzzer_tone_e: 'E',
+ roduino_piezobuzzer_tone_f: 'F',
+ roduino_piezobuzzer_tone_f_sharp: 'F♯(G♭)',
+ roduino_piezobuzzer_tone_g: 'G',
+ roduino_piezobuzzer_tone_g_sharp: 'G♯(A♭)',
+ roduino_piezobuzzer_tone_a: 'A',
+ roduino_piezobuzzer_tone_a_sharp: 'A♯(B♭)',
+ roduino_piezobuzzer_tone_b: 'B',
+
+ roduino_sensor_temperutre: 'temperature sensor',
+ roduino_sensor_joystick_x: 'joystick x',
+ roduino_sensor_joystick_y: 'joystick y',
+ roduino_sensor_light: 'light sensor',
+ roduino_sensor_dial: 'dial',
+ roduino_sensor_a_keypad: 'A keypad',
+ roduino_sensor_rotaryposition: 'rotary position sensor',
+ roduino_sensor_magnetic: 'magnetic sensor',
+ roduino_sensor_ultrasonic: 'ultrasonic sensor',
+
+ roduino_sensor_rotaryposition_rotation: 'rotation',
+ roduino_sensor_rotaryposition_position: 'position',
+ roduino_sensor_rotaryposition_angle: 'angle',
+
+ roduino_sensor_color_red: 'red',
+ roduino_sensor_color_yellow: 'yellow',
+ roduino_sensor_color_green: 'green',
+ roduino_sensor_color_blue: 'blue',
+ },
+ },
+ };
+ };
+
+ getBlocks () {
+ return {
+ roduino_menu_digital_pin: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['2', '2'],
+ ['3', '3'],
+ ['4', '4'],
+ ['5', '5'],
+ ['6', '6'],
+ ['7', '7'],
+ ['8', '8'],
+ ],
+ value: '2',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ },
+ func: (sprite, script) => {
+ return script.getStringField('PIN');
+ },
+ },
+ roduino_menu_analog_pin: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['A0', '14'],
+ ['A1', '15'],
+ ['A2', '16'],
+ ['A3', '17'],
+ ['A4', '18'],
+ ['A5', '19'],
+ ],
+ value: '14',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ },
+ func: (sprite, script) => {
+ return script.getStringField('PIN');
+ },
+ },
+ roduino_menu_pin: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['A0', '14'],
+ ['A1', '15'],
+ ['A2', '16'],
+ ['A3', '17'],
+ ['A4', '18'],
+ ['A5', '19'],
+ ['2', '2'],
+ ['3', '3'],
+ ['4', '4'],
+ ['5', '5'],
+ ['6', '6'],
+ ['7', '7'],
+ ['8', '8'],
+ ],
+ value: '14',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ },
+ func: (sprite, script) => {
+ return script.getStringField('PIN');
+ },
+ },
+ roduino_menu_digital_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['0', '0'],
+ ['1', '1'],
+ ],
+ value: '1',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ NUM: 0,
+ },
+ func: (sprite, script) => {
+ return script.getStringField('NUM');
+ },
+ },
+ roduino_menu_motor_number: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['1', '1'],
+ ['2', '2']
+ ],
+ value: '1',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ NUM: 0,
+ },
+ func: (sprite, script) => {
+ return script.getStringField('NUM');
+ },
+ },
+ roduino_set_digital: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ }
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roduino_menu_digital_pin',
+ },
+ {
+ type: 'roduino_menu_digital_value',
+ },
+ null,
+ ],
+ type: 'roduino_set_digital',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ VALUE: 1,
+ },
+ class: 'motion',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.set_digital(sprite, script),
+ },
+ roduino_set_motor_rotation: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roduino_motor_state_cw, 'cw'],
+ [Lang.Blocks.roduino_motor_state_ccw, 'ccw'],
+ [Lang.Blocks.roduino_motor_state_stop, 'stop'],
+ ],
+ value: 'cw',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roduino_menu_motor_number'
+ },
+ null,
+ null,
+
+ ],
+ type: 'roduino_set_motor_rotation',
+ },
+ paramsKeyMap: {
+ MOTOR: 0,
+ STATE: 1,
+ },
+ class: 'motion',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.set_motor_rotation(sprite, script)
+ },
+ roduino_set_rgbled_color: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Color',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roduino_menu_digital_pin'
+ },
+ null,
+ null,
+
+ ],
+ type: 'roduino_set_rgbled_color',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ COLOR: 1,
+ },
+ class: 'looks',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.set_rgbled_color(sprite, script)
+ },
+ roduino_change_rgbled_brightness_by: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roduino_menu_digital_pin'
+ },
+ {
+ type: 'number',
+ params: ['10'],
+ },
+ null,
+
+ ],
+ type: 'roduino_change_rgbled_brightness_by',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ BRIGHTNESS: 1,
+ },
+ class: 'looks',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.change_rgbled_brightness_by(sprite, script)
+ },
+ roduino_set_rgbled_brightness_to: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roduino_menu_digital_pin'
+ },
+ {
+ type: 'number',
+ params: ['100'],
+ },
+ null,
+
+ ],
+ type: 'roduino_set_rgbled_brightness_to',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ BRIGHTNESS: 1,
+ },
+ class: 'looks',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.set_rgbled_brightness_to(sprite, script)
+ },
+ roduino_play_piezobuzzer: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ 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: 'Dropdown',
+ options: [
+ [Lang.Blocks.roduino_piezobuzzer_tone_c, '0'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_c_sharp, '1'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_d, '2'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_d_sharp, '3'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_e, '4'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_f, '5'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_f_sharp, '6'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_g, '7'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_g_sharp, '8'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_a, '9'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_a_sharp, '10'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_b, '11'],
+ ],
+ value: '0',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roduino_menu_digital_pin'
+ },
+ null,
+ null,
+ {
+ type: 'number',
+ params: ['0.5'],
+ },
+ null,
+
+ ],
+ type: 'roduino_play_piezobuzzer',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ OCTAVE: 1,
+ NOTE: 2,
+ DURATION: 3,
+ },
+ class: 'sound',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.play_piezobuzzer(sprite, script)
+ },
+ roduino_play_piezobuzzer_until_done: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ 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: 'Dropdown',
+ options: [
+ [Lang.Blocks.roduino_piezobuzzer_tone_c, '0'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_c_sharp, '1'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_d, '2'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_d_sharp, '3'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_e, '4'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_f, '5'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_f_sharp, '6'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_g, '7'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_g_sharp, '8'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_a, '9'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_a_sharp, '10'],
+ [Lang.Blocks.roduino_piezobuzzer_tone_b, '11'],
+ ],
+ value: '0',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roduino_menu_digital_pin'
+ },
+ null,
+ null,
+ {
+ type: 'number',
+ params: ['0.5'],
+ },
+ null,
+
+ ],
+ type: 'roduino_play_piezobuzzer_until_done',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ OCTAVE: 1,
+ NOTE: 2,
+ DURATION: 3,
+ },
+ class: 'sound',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.play_piezobuzzer_until_done(sprite, script)
+ },
+ roduino_get_digital_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roduino_menu_digital_pin',
+ },
+ ],
+ type: 'roduino_get_digital_value',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ },
+ class: 'sensing',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.get_digital_value(sprite, script),
+ },
+ roduino_get_analog_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roduino_menu_analog_pin',
+ },
+ ],
+ type: 'roduino_get_analog_value',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ },
+ class: 'sensing',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.get_analog_value(sprite, script),
+ },
+ roduino_get_sensor_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roduino_sensor_temperutre, 'temperature'],
+ [Lang.Blocks.roduino_sensor_joystick_x, 'joystickx'],
+ [Lang.Blocks.roduino_sensor_joystick_y, 'joysticky'],
+ [Lang.Blocks.roduino_sensor_light, 'light'],
+ [Lang.Blocks.roduino_sensor_dial, 'dial'],
+ [Lang.Blocks.roduino_sensor_a_keypad, 'akeypad'],
+ [Lang.Blocks.roduino_sensor_rotaryposition, 'rotaryposition'],
+ [Lang.Blocks.roduino_sensor_magnetic, 'magnetic'],
+ [Lang.Blocks.roduino_sensor_ultrasonic, 'ultrasonic'],
+ ],
+ value: 'temperature',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roduino_menu_pin',
+ },
+ null,
+ ],
+ type: 'roduino_get_sensor_value',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ SENSOR: 1,
+ },
+ class: 'sensing',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.get_sensor_value(sprite, script)
+ },
+ roduino_is_digital_detected: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_boolean_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roduino_menu_digital_pin',
+ },
+ ],
+ type: 'roduino_is_digital_detected',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ },
+ class: 'sensing',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.is_digital_detected(sprite, script),
+ },
+ roduino_compare_analog_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_boolean_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ ['>', 'greater-than'],
+ ['=', 'equal'],
+ ['<', 'less-than'],
+ ],
+ value: 'greater-than',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roduino_menu_analog_pin',
+ },
+ null,
+ {
+ type: 'number',
+ params: ['512'],
+ },
+ ],
+ type: 'roduino_compare_analog_value',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ SYMBOL: 1,
+ VALUE: 2,
+ },
+ class: 'sensing',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.compare_analog_value(sprite, script),
+ },
+ roduino_compare_sensor_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_boolean_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roduino_sensor_temperutre, 'temperature'],
+ [Lang.Blocks.roduino_sensor_joystick_x, 'joystickx'],
+ [Lang.Blocks.roduino_sensor_joystick_y, 'joysticky'],
+ [Lang.Blocks.roduino_sensor_light, 'light'],
+ [Lang.Blocks.roduino_sensor_dial, 'dial'],
+ [Lang.Blocks.roduino_sensor_a_keypad, 'akeypad'],
+ [Lang.Blocks.roduino_sensor_rotaryposition, 'rotaryposition'],
+ [Lang.Blocks.roduino_sensor_magnetic, 'magnetic'],
+ [Lang.Blocks.roduino_sensor_ultrasonic, 'ultrasonic'],
+ ],
+ value: 'temperature',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ ['>', 'greater-than'],
+ ['=', 'equal'],
+ ['<', 'less-than'],
+ ],
+ value: 'greater-than',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roduino_menu_pin',
+ },
+ null,
+ null,
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ ],
+ type: 'roduino_compare_sensor_value',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ SENSOR: 1,
+ SYMBOL: 2,
+ VALUE: 3,
+ },
+ class: 'sensing',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.compare_sensor_value(sprite, script),
+ },
+
+ roduino_get_rotary_position_sensor_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roduino_sensor_rotaryposition_rotation, 'rotation'],
+ [Lang.Blocks.roduino_sensor_rotaryposition_position, 'position'],
+ [Lang.Blocks.roduino_sensor_rotaryposition_angle, 'angle']
+ ],
+ value: 'rotation',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roduino_menu_analog_pin',
+ },
+ null,
+ ],
+ type: 'roduino_get_rotary_position_sensor_value',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ PROPERTY: 1,
+ },
+ class: 'sensing_rotary_position_sensor',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.get_rotary_position_sensor_value(sprite, script)
+ },
+
+ roduino_reset_rotary_position_sensor: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roduino_sensor_rotaryposition_rotation, 'rotation'],
+ [Lang.Blocks.roduino_sensor_rotaryposition_position, 'position'],
+ [Lang.Blocks.roduino_sensor_rotaryposition_angle, 'angle']
+ ],
+ value: 'rotation',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ defualtType: 'number',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roduino_menu_analog_pin',
+ },
+ null,
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ null,
+ ],
+ type: 'roduino_reset_rotary_position_sensor',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ PROPERTY: 1,
+ VALUE: 2,
+ },
+ class: 'sensing_rotary_position_sensor',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.reset_rotary_position_sensor(sprite, script)
+ },
+ roduino_get_color_sensor_detected_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roduino_sensor_color_red, '#FF0000'],
+ [Lang.Blocks.roduino_sensor_color_yellow, '#FFEE00'],
+ [Lang.Blocks.roduino_sensor_color_green, '#00AA00'],
+ [Lang.Blocks.roduino_sensor_color_blue, '#0055FF'],
+ ],
+ value: '#FF0000',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ ],
+ type: 'roduino_get_color_sensor_detected_value',
+ },
+ paramsKeyMap: {
+ COLOR: 0,
+ },
+ class: 'sensing_color_sensor',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.get_color_sensor_detected_value(sprite, script)
+ },
+ roduino_is_color_sensor_detected: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_boolean_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roduino_sensor_color_red, '#FF0000'],
+ [Lang.Blocks.roduino_sensor_color_yellow, '#FFEE00'],
+ [Lang.Blocks.roduino_sensor_color_green, '#00AA00'],
+ [Lang.Blocks.roduino_sensor_color_blue, '#0055FF'],
+ ],
+ value: '#FF0000',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ ],
+ type: 'roduino_is_color_sensor_detected',
+ },
+ paramsKeyMap: {
+ COLOR: 0,
+ },
+ class: 'sensing_color_sensor',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.is_color_sensor_detected(sprite, script)
+ },
+ roduino_set_color_sensor_pins: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roduino_menu_digital_pin',
+ params: ['6'],
+ },
+ {
+ type: 'roduino_menu_digital_pin',
+ params: ['7'],
+ },
+ {
+ type: 'roduino_menu_digital_pin',
+ params: ['8'],
+ },
+ null,
+ ],
+ type: 'roduino_set_color_sensor_pins',
+ },
+ paramsKeyMap: {
+ RED: 0,
+ GREEN: 1,
+ BLUE: 2,
+ },
+ class: 'sensing_color_sensor',
+ isNotFor: ['roborobo_roduino'],
+ func: (sprite, script) => this.set_color_sensor_pins(sprite, script)
+ },
+ };
+ };
+
+ setZero () {
+ super.setZero();
+ }
+
+ afterReceive (data) {
+ super.afterReceive(data);
+ }
+
+ afterSend () {
+ super.afterSend();
+ }
+
+ request (func, subkey, value, updateNow = false) {
+ super.request(func, subkey, value, updateNow);
+ }
+
+ resetState () {
+ super.resetState();
+ this.state.tx = {color: {pins: {r: -1, g: -1, b: -1}}};
+ }
+
+ /**
+ * -----------------------------------block execute-----------------------------------
+ * 공통 사용 함수를 제외한 나머지 블록 동작을 작성
+ * -----------------------------------------------------------------------------------
+ */
+
+ set_motor_rotation (sprite, script) {
+ const motor = script.getNumberValue('MOTOR');
+ const state = script.getStringValue('STATE');
+
+ let stateNum = 0;
+ if (state == 'cw') stateNum = 1;
+ else if (state == 'ccw') stateNum = 2;
+
+ this.request('setMotor', motor, {motor, speed: 0, state: stateNum});
+ return script.callReturn();
+ }
+
+ get_color_sensor_detected_value (sprite, script) {
+ const color = script.getStringValue('COLOR');
+ return this._isColorSensorDetected(color) ? 1 : 0;
+ }
+
+ is_color_sensor_detected (sprite, script) {
+ const color = script.getStringValue('COLOR');
+ return this._isColorSensorDetected(color);
+ }
+
+ _isColorSensorDetected (color) {
+ const pins = this.state.tx.color.pins;
+ if (!pins || !this.isDigitalPin(pins.r) || !this.isDigitalPin(pins.g) || !this.isDigitalPin(pins.b)) return false;
+
+ const r = this.getDigitalValue(pins.r);
+ const g = this.getDigitalValue(pins.g);
+ const b = this.getDigitalValue(pins.b);
+
+ switch (color) {
+ case '#FF0000':
+ return r == 1 && g == 0 && b == 0;
+ case '#00AA00':
+ return r == 0 && g == 1 && b == 0;
+ case '#0055FF':
+ return r == 0 && g == 0 && b == 1;
+ case '#FFEE00':
+ return r == 1 && g == 1 && b == 1;
+ }
+ return false;
+ }
+
+ set_color_sensor_pins (sprite, script) {
+ const r = this.pinToNumber(script.getStringValue('RED'));
+ const g = this.pinToNumber(script.getStringValue('GREEN'));
+ const b = this.pinToNumber(script.getStringValue('BLUE'));
+
+ const colorPins = this.state.tx.color.pins;
+ if (!colorPins) return;
+
+ if (colorPins.r != r) {
+ this.request('enableDigitalInput', r, {pin: r});
+ colorPins.r = r;
+ }
+ if (colorPins.g != g) {
+ this.request('enableDigitalInput', g, {pin: g});
+ colorPins.g = g;
+ }
+ if (colorPins.b != b) {
+ this.request('enableDigitalInput', b, {pin: b}, true);
+ colorPins.b = b;
+ }
+ }
+}
+
+module.exports = new Roduino();
\ No newline at end of file
diff --git a/src/playground/blocks/hardware/block_roborobo_roe.js b/src/playground/blocks/hardware/block_roborobo_roe.js
new file mode 100644
index 0000000000..4ec189e542
--- /dev/null
+++ b/src/playground/blocks/hardware/block_roborobo_roe.js
@@ -0,0 +1,1146 @@
+'use strict';
+
+Entry.Roborobo_RoE = {
+ id: '48.1',
+ name: 'roborobo_roe',
+ url: 'http://www.roborobo.co.kr',
+ imageName: 'roborobo_roe.png',
+ title: {
+ ko: '로이',
+ en: 'Ro-E',
+ },
+ setZero: function () {
+ Entry.hw.sendQueue['LED'] = 0;
+ Entry.hw.sendQueue['Melody'] = [0, 0, 0]; //[octave, note, duration]
+ Entry.hw.sendQueue['LeftMotor'] = [0, 0]; //[direction, value]
+ Entry.hw.sendQueue['RightMotor'] = [0, 0]; //[direction, value]
+ Entry.hw.update();
+ },
+ motorDiretion: {
+ STOP: 0,
+ CW: 1,
+ CCW: 2
+ },
+ monitorTemplate: {
+ imgPath: 'hw/roborobo_roe.png',
+ keys: ['value'],
+ width: 256,
+ height: 256,
+ listPorts: {
+ lColor: {
+ name: 'Color Sensor(Left)',
+ type: 'input',
+ pos: {
+ x: 0,
+ y: 0,
+ },
+ },
+ rColor: {
+ name: 'Color Sensor(Right)',
+ type: 'input',
+ pos: {
+ x: 0,
+ y: 0,
+ },
+ },
+ ir: {
+ name: 'IR Sensor',
+ type: 'input',
+ pos: {
+ x: 0,
+ y: 0,
+ },
+ },
+ switch: {
+ name: 'Switch Sensor',
+ type: 'input',
+ pos: {
+ x: 0,
+ y: 0,
+ },
+ },
+ },
+ mode: 'both',
+ },
+};
+
+Entry.Roborobo_RoE.setLanguage = function () {
+ return {
+ ko: {
+ template: {
+ roe_set_led: '%1 LED 켜기 %2',
+ roe_set_led_off: 'LED 끄기 %1',
+ roe_set_motor: '로이 %1 %2',
+ roe_set_motor_value: '%1 모터 : %2 만큼 %3 %4',
+ roe_set_melody: '%1 옥타브 %2 을(를) %3 초 연주 %4',
+ roe_get_input_switch: '접촉센서가 %1 ?',
+ roe_get_input_ir: '적외선 센서가 %1 ?',
+ roe_get_input_color: '%1 컬러센서 값이 %2 인가?',
+ roe_led_color_dropdown: '%1',
+ roe_melody_dropdown: '%1',
+ roe_motor_dropdown: '%1',
+ roe_movement_dropdown: '%1',
+ roe_detect_dropdown: '%1',
+ roe_color_select_dropdown: '%1',
+ roe_color_color_dropdown: '%1',
+ },
+ Blocks: {
+ roe_color_sensor_left: '왼쪽',
+ roe_color_sensor_right: '오른쪽',
+ roe_color_sensor_both: '양쪽',
+ roe_color_red: '빨간색',
+ roe_color_orange: '주황색',
+ roe_color_yellow: '노란색',
+ roe_color_yellowgreen: '연두색',
+ roe_color_green: '초록색',
+ roe_color_skyblue: '하늘색',
+ roe_color_blue: '파란색',
+ roe_color_purple: '보라색',
+ roe_color_pink: '분홍색',
+ roe_color_white: '흰색',
+ roe_color_black: '검정색',
+ roe_color_random: '무작위 색',
+ roe_color_none: '미감지',
+ roe_motor_both: '양쪽',
+ roe_motor_left: '왼쪽',
+ roe_motor_right: '오른쪽',
+ roe_move_forward: '전진',
+ roe_move_backward: '후진',
+ roe_move_turnleft: '좌회전',
+ roe_move_turnright: '우회전',
+ roe_move_stop: '정지',
+ roe_detected: '감지되었는가',
+ roe_undetected: '감지되지 않았는가',
+ roe_melody_do: '도',
+ roe_melody_doS: '도#',
+ roe_melody_re: '레',
+ roe_melody_miF: '미b',
+ roe_melody_mi: '미',
+ roe_melody_pa: '파',
+ roe_melody_paS: '파#',
+ roe_melody_sol: '솔',
+ roe_melody_solS: '솔#',
+ roe_melody_la: '라',
+ roe_melody_siF: '시b',
+ roe_melody_si: '시',
+ }
+ },
+ en: {
+ template: {
+ roe_set_led: 'Turn on %1 LED %2',
+ roe_set_led_off: 'Turn off LED %1',
+ roe_set_motor: 'Ro-E %1 %2',
+ roe_set_motor_value: '%1 motor(s) : Move %3 by %2 %4',
+ roe_set_melody: 'Play %1 octave %2 tone for %3 second(s) %4',
+ roe_get_input_switch: 'Is the switch sensor %1 ?',
+ roe_get_input_ir: 'Is the IR sensor %1 ?',
+ roe_get_input_color: 'Is %1 color sensor value %2 ?',
+ roe_led_color_dropdown: '%1',
+ roe_melody_dropdown: '%1',
+ roe_motor_dropdown: '%1',
+ roe_movement_dropdown: '%1',
+ roe_detect_dropdown: '%1',
+ roe_color_select_dropdown: '%1',
+ roe_color_color_dropdown: '%1',
+ },
+ Blocks: {
+ roe_color_sensor_left: 'left',
+ roe_color_sensor_right: 'right',
+ roe_color_sensor_both: 'both',
+ roe_color_red: 'Red',
+ roe_color_orange: 'Orange',
+ roe_color_yellow: 'Yellow',
+ roe_color_yellowgreen: 'Yellow Green',
+ roe_color_green: 'Green',
+ roe_color_skyblue: 'Sky Blue',
+ roe_color_blue: 'Blue',
+ roe_color_purple: 'Purple',
+ roe_color_pink: 'Pink',
+ roe_color_white: 'White',
+ roe_color_black: 'Black',
+ roe_color_random: 'Random',
+ roe_color_none: 'Undetected',
+ roe_motor_both: 'Both',
+ roe_motor_left: 'Left',
+ roe_motor_right: 'Right',
+ roe_move_forward: 'forward',
+ roe_move_backward: 'backward',
+ roe_move_turnleft: 'turn left',
+ roe_move_turnright: 'turn right',
+ roe_move_stop: 'stop',
+ roe_detected: 'detected',
+ roe_undetected: 'undetected',
+ roe_melody_do: 'C',
+ roe_melody_doS: 'C#',
+ roe_melody_re: 'D',
+ roe_melody_miF: 'Eb',
+ roe_melody_mi: 'E',
+ roe_melody_pa: 'F',
+ roe_melody_paS: 'F#',
+ roe_melody_sol: 'G',
+ roe_melody_solS: 'G#',
+ roe_melody_la: 'A',
+ roe_melody_siF: 'Bb',
+ roe_melody_si: 'B',
+ },
+ },
+ };
+};
+
+Entry.Roborobo_RoE.blockMenuBlocks = [
+ 'roe_set_led',
+ 'roe_set_led_off',
+ 'roe_set_motor',
+ 'roe_set_motor_value',
+ 'roe_set_melody',
+ 'roe_get_input_switch',
+ 'roe_get_input_ir',
+ 'roe_get_input_color',
+];
+
+Entry.Roborobo_RoE.getBlocks = function () {
+ return {
+ //region roe 로이
+ roe_led_color_dropdown: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roe_color_red, 1],
+ [Lang.Blocks.roe_color_orange, 2],
+ [Lang.Blocks.roe_color_yellow, 3],
+ [Lang.Blocks.roe_color_yellowgreen, 4],
+ [Lang.Blocks.roe_color_green, 5],
+ [Lang.Blocks.roe_color_skyblue, 6],
+ [Lang.Blocks.roe_color_blue, 7],
+ [Lang.Blocks.roe_color_purple, 8],
+ [Lang.Blocks.roe_color_pink, 9],
+ [Lang.Blocks.roe_color_white, 10]
+ ],
+ value: 1,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ VALUE: 0,
+ },
+ func: function (sprite, script) {
+ return script.getNumberField('VALUE');
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: '%1',
+ textParams: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roe_color_red, 1],
+ [Lang.Blocks.roe_color_orange, 2],
+ [Lang.Blocks.roe_color_yellow, 3],
+ [Lang.Blocks.roe_color_yellowgreen, 4],
+ [Lang.Blocks.roe_color_green, 5],
+ [Lang.Blocks.roe_color_skyblue, 6],
+ [Lang.Blocks.roe_color_blue, 7],
+ [Lang.Blocks.roe_color_purple, 8],
+ [Lang.Blocks.roe_color_pink, 9],
+ [Lang.Blocks.roe_color_white, 10]
+ ],
+ value: 1,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ converter: Entry.block.converters.returnStringValue,
+ },
+ ],
+ keyOption: 'roe_led_color_dropdown',
+ },
+ ],
+ },
+ },
+ roe_melody_dropdown: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roe_melody_do, 1],
+ [Lang.Blocks.roe_melody_re, 2],
+ [Lang.Blocks.roe_melody_mi, 3],
+ [Lang.Blocks.roe_melody_pa, 4],
+ [Lang.Blocks.roe_melody_sol, 5],
+ [Lang.Blocks.roe_melody_la, 6],
+ [Lang.Blocks.roe_melody_si, 7],
+ ],
+ value: 1,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ VALUE: 0,
+ },
+ func: function (sprite, script) {
+ return script.getNumberField('VALUE', script);
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: '%1',
+ textParams: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roe_melody_do, 1],
+ [Lang.Blocks.roe_melody_re, 2],
+ [Lang.Blocks.roe_melody_mi, 3],
+ [Lang.Blocks.roe_melody_pa, 4],
+ [Lang.Blocks.roe_melody_sol, 5],
+ [Lang.Blocks.roe_melody_la, 6],
+ [Lang.Blocks.roe_melody_si, 7],
+ ],
+ value: 1,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ keyOption: 'roe_melody_dropdown',
+ },
+ ],
+ },
+ },
+ roe_motor_dropdown: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roe_motor_both, 1],
+ [Lang.Blocks.roe_motor_left, 2],
+ [Lang.Blocks.roe_motor_right, 3],
+ ],
+ value: 1,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ VALUE: 0,
+ },
+ func: function (sprite, script) {
+ return script.getNumberField('VALUE');
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: '%1',
+ textParams: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roe_motor_both, 1],
+ [Lang.Blocks.roe_motor_left, 2],
+ [Lang.Blocks.roe_motor_right, 3],
+ ],
+ value: 1,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ converter: Entry.block.converters.returnStringValue,
+ },
+ ],
+ keyOption: 'roe_motor_dropdown',
+ },
+ ],
+ },
+ },
+ roe_movement_dropdown: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roe_move_forward, 1],
+ [Lang.Blocks.roe_move_backward, 2],
+ [Lang.Blocks.roe_move_turnleft, 3],
+ [Lang.Blocks.roe_move_turnright, 4],
+ [Lang.Blocks.roe_move_stop, 5],
+ ],
+ value: 1,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ VALUE: 0,
+ },
+ func: function (sprite, script) {
+ return script.getNumberField('VALUE');
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: '%1',
+ textParams: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roe_move_forward, 1],
+ [Lang.Blocks.roe_move_backward, 2],
+ [Lang.Blocks.roe_move_turnleft, 3],
+ [Lang.Blocks.roe_move_turnright, 4],
+ [Lang.Blocks.roe_move_stop, 5],
+ ],
+ value: 1,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ converter: Entry.block.converters.returnStringValue,
+ },
+ ],
+ keyOption: 'roe_movement_dropdown',
+ },
+ ],
+ },
+ },
+ roe_detect_dropdown: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roe_detected, 1],
+ [Lang.Blocks.roe_undetected, 0],
+ ],
+ value: 1,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ VALUE: 0,
+ },
+ func: function (sprite, script) {
+ return script.getNumberField('VALUE');
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: '%1',
+ textParams: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roe_detected, 1],
+ [Lang.Blocks.roe_undetected, 2],
+ ],
+ value: 1,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ converter: Entry.block.converters.returnStringValue,
+ },
+ ],
+ keyOption: 'roe_detect_dropdown',
+ },
+ ],
+ },
+ },
+ roe_color_select_dropdown: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roe_color_sensor_both, 1],
+ [Lang.Blocks.roe_color_sensor_left, 2],
+ [Lang.Blocks.roe_color_sensor_right, 3],
+ ],
+ value: 1,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ VALUE: 0,
+ },
+ func: function (sprite, script) {
+ return script.getNumberField('VALUE');
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: '%1',
+ textParams: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roe_color_sensor_both, 1],
+ [Lang.Blocks.roe_color_sensor_left, 2],
+ [Lang.Blocks.roe_color_sensor_right, 3],
+ ],
+ value: 1,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ converter: Entry.block.converters.returnStringValue,
+ },
+ ],
+ keyOption: 'roe_color_select_dropdown',
+ },
+ ],
+ },
+ },
+ roe_color_color_dropdown: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roe_color_red, 1],
+ [Lang.Blocks.roe_color_orange, 2],
+ [Lang.Blocks.roe_color_yellow, 3],
+ [Lang.Blocks.roe_color_yellowgreen, 7],
+ [Lang.Blocks.roe_color_green, 4],
+ [Lang.Blocks.roe_color_skyblue, 8],
+ [Lang.Blocks.roe_color_blue, 5],
+ [Lang.Blocks.roe_color_purple, 6],
+ [Lang.Blocks.roe_color_pink, 9],
+ [Lang.Blocks.roe_color_black, 10],
+ [Lang.Blocks.roe_color_white, 11],
+ [Lang.Blocks.roe_color_none, 127],
+ ],
+ value: 1,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ VALUE: 0,
+ },
+ func: function (sprite, script) {
+ return script.getNumberField('VALUE');
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: '%1',
+ textParams: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roe_color_red, 1],
+ [Lang.Blocks.roe_color_orange, 2],
+ [Lang.Blocks.roe_color_yellow, 3],
+ [Lang.Blocks.roe_color_yellowgreen, 7],
+ [Lang.Blocks.roe_color_green, 4],
+ [Lang.Blocks.roe_color_skyblue, 8],
+ [Lang.Blocks.roe_color_blue, 5],
+ [Lang.Blocks.roe_color_purple, 6],
+ [Lang.Blocks.roe_color_pink, 9],
+ [Lang.Blocks.roe_color_black, 10],
+ [Lang.Blocks.roe_color_white, 11],
+ [Lang.Blocks.roe_color_none, 127],
+ ],
+ value: 1,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ converter: Entry.block.converters.returnStringValue,
+ },
+ ],
+ keyOption: 'roe_color_color_dropdown',
+ },
+ ],
+ },
+ },
+ roe_set_led: {
+ 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_icon.svg',
+ size: 12
+ }
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roe_led_color_dropdown',
+ },
+ null
+ ],
+ type: 'roe_set_led',
+ },
+ paramsKeyMap: {
+ VALUE: 0,
+ },
+ class: 'roe_set',
+ isNotFor: ['roborobo_roe'],
+ func: function (sprite, script) {
+ var color = script.getNumberValue('VALUE', script);
+ Entry.hw.sendQueue['LED'] = color;
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: 'Roborobo_roe.roe_set_led(%1)',
+ textParams: [
+ {
+ type: "Block",
+ accept: "string"
+ },
+ {
+ type: 'roe_led_color_dropdown'
+ }
+ ],
+ },
+ ],
+ },
+ },
+ roe_set_led_off: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: "Indicator",
+ img: "block_icon/hardware_icon.svg",
+ size: 12
+ }
+ ],
+ events: {},
+ def: {
+ params: [
+ null
+ ],
+ type: 'roe_set_led_off'
+ },
+ paramsKeyMap: {},
+ class: 'roe_set',
+ isNotFor: ['roborobo_roe'],
+ func: function (sprite, script) {
+ Entry.hw.sendQueue['LED'] = 0;
+ },
+ syntax: {
+ js: [],
+ py: ['Roborobo_roe.roe_set_led_off()'],
+ },
+ },
+ roe_set_melody: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['4', '4'],
+ ['5', '5'],
+ ['6', '6'],
+ ['7', '7'],
+ ],
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Block',
+ accept: 'string'
+ },
+ {
+ type: 'Block',
+ accept: 'string'
+ },
+ {
+ type: "Indicator",
+ img: "block_icon/hardware_icon.svg",
+ size: 12
+ }
+ ],
+ events: {},
+ def: {
+ params: [
+ '4',
+ {
+ type: 'roe_melody_dropdown',
+ },
+ '1',
+ null
+ ],
+ type: 'roe_set_melody',
+ },
+ paramsKeyMap: {
+ OCTAVE: 0,
+ NOTE: 1,
+ DURATION: 2
+ },
+ class: 'roe_set',
+ isNotFor: ['roborobo_roe'],
+ func: function (sprite, script) {
+ if (!script.isStart) {
+ var octave = script.getNumberValue('OCTAVE', script);
+ var note = script.getNumberValue('NOTE', script);
+ var duration = script.getNumberValue('DURATION', script);
+
+ if (octave < 4) {
+ octave = 4;
+ } else if (octave > 7) {
+ octave = 7;
+ }
+
+ if (note < 1) {
+ note = 1;
+ } else if (note > 7) {
+ note = 7;
+ }
+ duration = duration < 0 ? 0 : duration;
+ duration = duration * 1000;
+
+ script.isStart = true;
+ script.timeFlag = 1;
+
+ Entry.hw.sendQueue['Melody'] = [octave, note, duration];
+
+ setTimeout(function () {
+ script.timeFlag = 0;
+ }, duration);
+ return script;
+ } else if (script.timeFlag == 1) {
+ return script;
+ } else {
+ delete script.timeFlag;
+ delete script.isStart;
+ }
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: 'Roborobo_roe.roe_set_melody(%1 %2 %3)',
+ textParams: [
+ '4',
+ {
+ type: 'roe_melody_dropdown',
+ },
+ '1',
+ ],
+ },
+ ],
+ },
+ },
+ roe_set_motor: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: "Block",
+ accept: "string"
+ },
+ {
+ type: "Indicator",
+ img: "block_icon/hardware_icon.svg",
+ size: 12
+ }
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roe_movement_dropdown'
+ },
+ null
+ ],
+ type: 'roe_set_motor'
+ },
+ paramsKeyMap: {
+ OPERATOR: 0,
+ },
+ class: 'roe_set',
+ isNotFor: ['roborobo_roe'],
+ func: function (sprite, script) {
+ var op = script.getNumberValue('OPERATOR', script);
+ if (op == 1) {
+ Entry.hw.sendQueue['LeftMotor'] = [Entry.Roborobo_RoE.motorDiretion.CCW, 0];
+ Entry.hw.sendQueue['RightMotor'] = [Entry.Roborobo_RoE.motorDiretion.CW, 0];
+ } else if (op == 2) {
+ Entry.hw.sendQueue['LeftMotor'] = [Entry.Roborobo_RoE.motorDiretion.CW, 0];
+ Entry.hw.sendQueue['RightMotor'] = [Entry.Roborobo_RoE.motorDiretion.CCW, 0];
+ } else if (op == 3) {
+ Entry.hw.sendQueue['LeftMotor'] = [Entry.Roborobo_RoE.motorDiretion.CW, 0];
+ Entry.hw.sendQueue['RightMotor'] = [Entry.Roborobo_RoE.motorDiretion.CW, 0];
+ } else if (op == 4) {
+ Entry.hw.sendQueue['LeftMotor'] = [Entry.Roborobo_RoE.motorDiretion.CCW, 0];
+ Entry.hw.sendQueue['RightMotor'] = [Entry.Roborobo_RoE.motorDiretion.CCW, 0];
+ } else if (op == 5) {
+ Entry.hw.sendQueue['LeftMotor'] = [Entry.Roborobo_RoE.motorDiretion.STOP, 0];
+ Entry.hw.sendQueue['RightMotor'] = [Entry.Roborobo_RoE.motorDiretion.STOP, 0];
+ }
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: 'Roborobo_roe.roe_set_motor(%1)',
+ textParams: [
+ {
+ type: 'roe_movement_dropdown'
+ },
+ ],
+ },
+ ],
+ },
+ },
+ roe_set_motor_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: "Block",
+ accept: "string"
+ },
+ {
+ type: "Block",
+ accept: "string"
+ },
+ {
+ type: "Block",
+ accept: "string"
+ },
+ {
+ type: "Indicator",
+ img: "block_icon/hardware_icon.svg",
+ size: 12
+ }
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roe_motor_dropdown'
+ },
+ '100',
+ {
+ type: 'roe_movement_dropdown'
+ },
+ null
+ ],
+ type: 'roe_set_motor_value'
+ },
+ paramsKeyMap: {
+ MOTOR: 0,
+ VALUE: 1,
+ OPERATOR: 2,
+ },
+ class: 'roe_set',
+ isNotFor: ['roborobo_roe'],
+ func: function (sprite, script) {
+ var motor = script.getNumberValue('MOTOR', script);
+ var value = script.getNumberValue('VALUE', script);
+ var op = script.getNumberValue('OPERATOR', script);
+
+ if (value < 0) {
+ value = 0;
+ } else if (value > 100) {
+ value = 100;
+ }
+
+ if (motor == 1) {
+ if (op == 1) {
+ Entry.hw.sendQueue['LeftMotor'] = [Entry.Roborobo_RoE.motorDiretion.CCW, value];
+ Entry.hw.sendQueue['RightMotor'] = [Entry.Roborobo_RoE.motorDiretion.CW, value];
+ } else if (op == 2) {
+ Entry.hw.sendQueue['LeftMotor'] = [Entry.Roborobo_RoE.motorDiretion.CW, value];
+ Entry.hw.sendQueue['RightMotor'] = [Entry.Roborobo_RoE.motorDiretion.CCW, value];
+ } else if (op == 3) {
+ Entry.hw.sendQueue['LeftMotor'] = [Entry.Roborobo_RoE.motorDiretion.CW, value];
+ Entry.hw.sendQueue['RightMotor'] = [Entry.Roborobo_RoE.motorDiretion.CW, value];
+ } else if (op == 4) {
+ Entry.hw.sendQueue['LeftMotor'] = [Entry.Roborobo_RoE.motorDiretion.CCW, value];
+ Entry.hw.sendQueue['RightMotor'] = [Entry.Roborobo_RoE.motorDiretion.CCW, value];
+ } else if (op == 5) {
+ Entry.hw.sendQueue['LeftMotor'] = [Entry.Roborobo_RoE.motorDiretion.STOP, value];
+ Entry.hw.sendQueue['RightMotor'] = [Entry.Roborobo_RoE.motorDiretion.STOP, value];
+ }
+ } else if (motor == 2) {
+ if (op == 1) {
+ Entry.hw.sendQueue['LeftMotor'] = [Entry.Roborobo_RoE.motorDiretion.CCW, value];
+ } else if (op == 2) {
+ Entry.hw.sendQueue['LeftMotor'] = [Entry.Roborobo_RoE.motorDiretion.CW, value];
+ } else if (op == 3) {
+ Entry.hw.sendQueue['LeftMotor'] = [Entry.Roborobo_RoE.motorDiretion.CW, value];
+ } else if (op == 4) {
+ Entry.hw.sendQueue['LeftMotor'] = [Entry.Roborobo_RoE.motorDiretion.CCW, value];
+ } else if (op == 5) {
+ Entry.hw.sendQueue['LeftMotor'] = [Entry.Roborobo_RoE.motorDiretion.STOP, value];
+ }
+ } else if (motor == 3) {
+ if (op == 1) {
+ Entry.hw.sendQueue['RightMotor'] = [Entry.Roborobo_RoE.motorDiretion.CW, value];
+ } else if (op == 2) {
+ Entry.hw.sendQueue['RightMotor'] = [Entry.Roborobo_RoE.motorDiretion.CCW, value];
+ } else if (op == 3) {
+ Entry.hw.sendQueue['RightMotor'] = [Entry.Roborobo_RoE.motorDiretion.CW, value];
+ } else if (op == 4) {
+ Entry.hw.sendQueue['RightMotor'] = [Entry.Roborobo_RoE.motorDiretion.CCW, value];
+ } else if (op == 5) {
+ Entry.hw.sendQueue['RightMotor'] = [Entry.Roborobo_RoE.motorDiretion.STOP, value];
+ }
+ }
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: 'Roborobo_roe.roe_set_motor_value(%1 %2 %3)',
+ textParams: [
+ {
+ type: 'roe_motor_dropdown'
+ },
+ '100',
+ {
+ type: 'roe_movement_dropdown'
+ },
+ ],
+ },
+ ],
+ },
+ },
+ roe_get_input_switch: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
+ skeleton: 'basic_boolean_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string'
+ },
+ {
+ type: "Indicator",
+ img: "block_icon/hardware_icon.svg",
+ size: 12
+ }
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roe_detect_dropdown',
+ },
+ null
+ ],
+ type: 'roe_get_input_switch'
+ },
+ paramsKeyMap: {
+ DETECT: 0
+ },
+ class: 'roe_get',
+ isNotFor: ['roborobo_roe'],
+ func: function (sprite, script) {
+ var detect = script.getNumberValue('DETECT', script);
+ var value = Entry.hw.portData['Switch'];
+ // console.log('Switch Value : ' + value);
+ return detect == value ? true : false;
+ },
+ syntax: {
+ js: [],
+ py: ['Roborobo_roe.roe_get_input_switch()'],
+ },
+ },
+ roe_get_input_ir: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
+ skeleton: 'basic_boolean_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string'
+ },
+ {
+ type: "Indicator",
+ img: "block_icon/hardware_icon.svg",
+ size: 12
+ }
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roe_detect_dropdown',
+ },
+ null
+ ],
+ type: 'roe_get_input_ir'
+ },
+ paramsKeyMap: {
+ DETECT: 0
+ },
+ class: 'roe_get',
+ isNotFor: ['roborobo_roe'],
+ func: function (sprite, script) {
+ var detect = script.getNumberValue('DETECT', script);
+ var value = Entry.hw.portData['IR'];
+ // console.log('IR Value : ' + value);
+ return detect == value ? true : false;
+ },
+ syntax: {
+ js: [],
+ py: ['Roborobo_roe.roe_get_input_ir()'],
+ },
+ },
+ roe_get_input_color: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
+ skeleton: 'basic_boolean_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string'
+ },
+ {
+ type: 'Block',
+ accept: 'string'
+ },
+ {
+ type: "Indicator",
+ img: "block_icon/hardware_icon.svg",
+ size: 12
+ }
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'roe_color_select_dropdown',
+ },
+ {
+ type: 'roe_color_color_dropdown',
+ },
+ null
+ ],
+ type: 'roe_get_input_color'
+ },
+ paramsKeyMap: {
+ SENSOR: 0,
+ COLOR: 1
+ },
+ class: 'roe_get',
+ isNotFor: ['roborobo_roe'],
+ func: function (sprite, script) {
+ var result = false;
+ var sensor = script.getNumberValue('SENSOR', script);
+ var color = script.getNumberValue('COLOR', script);
+ var left = Entry.hw.portData['LeftColor'];
+ var right = Entry.hw.portData['RightColor'];
+
+ if (sensor == 1) {
+ if (left == color && right == color) {
+ result = true;
+ }
+ } else if (sensor == 2) {
+ result = left == color ? true : false;
+ } else if (sensor == 3) {
+ result = right == color ? true : false;
+ }
+ return result;
+ },
+ syntax: {
+ js: [],
+ py: ['Roborobo_roe.roe_get_input_color()'],
+ },
+ },
+ //endregion roe 로이
+ };
+};
+
+module.exports = Entry.Roborobo_RoE;
diff --git a/src/playground/blocks/hardware/block_roborobo_schoolkit.js b/src/playground/blocks/hardware/block_roborobo_schoolkit.js
new file mode 100644
index 0000000000..fd91dadfda
--- /dev/null
+++ b/src/playground/blocks/hardware/block_roborobo_schoolkit.js
@@ -0,0 +1,1946 @@
+'use strict';
+
+Entry.Roborobo_SchoolKit = {
+ hasPracticalCourse: true,
+ id: '10.2',
+ name: 'roborobo_schoolkit',
+ url: 'http://www.roborobo.co.kr',
+ imageName: 'roborobo_schoolkit.png',
+ title: {
+ ko: '스쿨키트',
+ en: 'School Kit',
+ },
+ pinMode: {
+ INPUT: 0,
+ OUTPUT: 1,
+ ANALOG: 2,
+ PWM: 3,
+ SERVO: 4,
+ },
+ inputPort: {
+ ir: 7,
+ sound: 8,
+ contact: 9,
+ cds: 10,
+ },
+ setZero: function () {
+ Entry.hw.sendQueue.digitalPinMode = [];
+ Entry.hw.sendQueue.previousValue = [];
+
+ for (var port = 0; port < 14; port++) {
+ Entry.hw.sendQueue[port] = 0;
+ Entry.hw.sendQueue.digitalPinMode[port] = 0;
+ Entry.hw.sendQueue.previousValue[port] = -1;
+ }
+ Entry.hw.update();
+ },
+ monitorTemplate: {
+ imgPath: 'hw/roborobo_schoolkit.png',
+ keys: ['value'],
+ width: 256,
+ height: 256,
+ listPorts: {
+ '0': {
+ name: 'D1',
+ type: 'input',
+ pos: {
+ x: 0,
+ y: 0,
+ },
+ },
+ '1': {
+ name: 'D2',
+ type: 'input',
+ pos: {
+ x: 0,
+ y: 0,
+ },
+ },
+ '2': {
+ name: 'D3',
+ type: 'input',
+ pos: {
+ x: 0,
+ y: 0,
+ },
+ },
+ '3': {
+ name: 'D4',
+ type: 'input',
+ pos: {
+ x: 0,
+ y: 0,
+ },
+ },
+ '4': {
+ name: 'D5',
+ type: 'input',
+ pos: {
+ x: 0,
+ y: 0,
+ },
+ },
+ '5': {
+ name: 'D6',
+ type: 'input',
+ pos: {
+ x: 0,
+ y: 0,
+ },
+ },
+ '6': {
+ name: 'D7',
+ type: 'input',
+ pos: {
+ x: 0,
+ y: 0,
+ },
+ },
+ },
+ mode: 'both',
+ },
+};
+
+Entry.Roborobo_SchoolKit.setLanguage = function () {
+ return {
+ ko: {
+ template: {
+ schoolkit_get_in_port_number: '%1 ',
+ schoolkit_get_out_port_number: '%1 ',
+ schoolkit_get_servo_port_number: '%1 ',
+ schoolkit_get_input_value: '디지털 %1 번 센서값 ',
+ schoolkit_set_output: '디지털 %1 번 핀 %2 %3',
+ schoolkit_motor: '%1 속도 %2(으)로 %3 %4',
+ schoolkit_set_servo_value: '서보모터 %1 번 핀 %2˚ %3',
+ schoolkit_on_block: ' On ',
+ schoolkit_off_block: ' Off ',
+ },
+ },
+ en: {
+ template: {
+ schoolkit_get_in_port_number: '%1 ',
+ schoolkit_get_out_port_number: '%1 ',
+ schoolkit_get_servo_port_number: '%1 ',
+ schoolkit_get_input_value: 'Digital %1 Sensor value ',
+ schoolkit_set_output: 'Digital %1 Pin %2 %3',
+ schoolkit_motor: '%1 Speed %2 %3 %4',
+ schoolkit_set_servo_value: 'Servo %1 Pin %2˚ %3',
+ schoolkit_on_block: ' On ',
+ schoolkit_off_block: ' Off ',
+ },
+ },
+ };
+};
+
+Entry.Roborobo_SchoolKit.blockMenuBlocks = [
+ 'schoolkit_on_block',
+ 'schoolkit_off_block',
+ 'schoolkit_get_input_value',
+ 'schoolkit_set_output',
+ 'schoolkit_motor',
+ 'schoolkit_set_servo_value',
+];
+
+Entry.Roborobo_SchoolKit.practicalBlockMenuBlocks = {
+ hw_motor: [
+ // 'roborobo_motor_speed',
+ 'roborobo_move_for_secs',
+ 'roborobo_move_for',
+ 'roborobo_turn_for',
+ 'roborobo_stop_for',
+ ],
+ hw_melody: [
+
+ ],
+ hw_sensor: [
+ 'roborobo_touch_value',
+ 'roborobo_touch_value_boolean',
+ 'roborobo_light_value',
+ 'roborobo_light_value_boolean',
+ 'roborobo_sound_value',
+ 'roborobo_sound_value_boolean',
+ 'roborobo_irs_value',
+ 'roborobo_irs_value_boolean',
+ ],
+ hw_led: [
+ 'roborobo_diode_secs_toggle',
+ 'roborobo_diode_toggle',
+ 'roborobo_diode_inout_toggle',
+ 'roborobo_diode_set_output',
+ 'roborobo_diode_input_value',
+ ],
+}
+
+Entry.Roborobo_SchoolKit.getBlocks = function () {
+ return {
+ //region schoolkit 스쿨키트
+ schoolkit_on_block: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ type: 'schoolkit_on_block',
+ },
+ paramsKeyMap: {},
+ class: 'schoolkit_value',
+ isNotFor: ['roborobo_schoolkit'],
+ func: function (sprite, script) {
+ return '1';
+ },
+ syntax: {
+ js: [],
+ py: ['Roborobo_SchoolKit.schoolkit_on_block()'],
+ },
+ },
+ schoolkit_off_block: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ type: 'schoolkit_off_block',
+ },
+ paramsKeyMap: {},
+ class: 'schoolkit_value',
+ isNotFor: ['roborobo_schoolkit'],
+ func: function (sprite, script) {
+ return '0';
+ },
+ syntax: {
+ js: [],
+ py: ['Roborobo_SchoolKit.schoolkit_off_block()'],
+ },
+ },
+ schoolkit_get_out_port_number: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['OUT1', 2],
+ ['OUT2', 3],
+ ['OUT3', 4],
+ ['OUT4', 5],
+ ['OUT5', 6],
+ ],
+ value: 2,
+ 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.getNumberField('PORT');
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: '%1',
+ textParams: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['OUT1', 2],
+ ['OUT2', 3],
+ ['OUT3', 4],
+ ['OUT4', 5],
+ ['OUT5', 6],
+ ],
+ value: 2,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ converter: Entry.block.converters.returnStringValue,
+ },
+ ],
+ keyOption: 'schoolkit_get_out_port_number',
+ },
+ ],
+ },
+ },
+ schoolkit_get_servo_port_number: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['OUT1', 2],
+ ['OUT2', 3],
+ ['OUT3', 4],
+ ],
+ value: 2,
+ 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.getNumberField('PORT');
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: '%1',
+ textParams: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['OUT1', 2],
+ ['OUT2', 3],
+ ['OUT3', 4],
+ ],
+ value: 2,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ converter: Entry.block.converters.returnStringValue,
+ },
+ ],
+ keyOption: 'schoolkit_get_servo_port_number',
+ },
+ ],
+ },
+ },
+ schoolkit_get_in_port_number: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['IN1', 7],
+ ['IN2', 8],
+ ['IN3', 9],
+ ['IN4', 10],
+ ['IN5', 11],
+ ['IN6', 12],
+ ['IN7', 13],
+ ],
+ value: 7,
+ 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.getNumberField('PORT');
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: '%1',
+ textParams: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['IN1', 7],
+ ['IN2', 8],
+ ['IN3', 9],
+ ['IN4', 10],
+ ['IN5', 11],
+ ['IN6', 12],
+ ['IN7', 13],
+ ],
+ value: 7,
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ converter: Entry.block.converters.returnStringValue,
+ },
+ ],
+ keyOption: 'schoolkit_get_in_port_number',
+ },
+ ],
+ },
+ },
+ schoolkit_set_output: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roborobo_on, 'on'],
+ [Lang.Blocks.roborobo_off, 'off'],
+ ],
+ value: 'on',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'schoolkit_get_out_port_number',
+ },
+ null,
+ null,
+ ],
+ type: 'schoolkit_set_output',
+ },
+ paramsKeyMap: {
+ VALUE: 0,
+ OPERATOR: 1,
+ },
+ class: 'schoolkit_set',
+ isNotFor: ['roborobo_schoolkit'],
+ func: function (sprite, script) {
+ var pin = script.getNumberValue('VALUE', script);
+ var operator = script.getField('OPERATOR');
+ var value = operator == 'on' ? 1 : 0;
+
+ if (!Entry.hw.sendQueue.digitalPinMode) {
+ Entry.hw.sendQueue.digitalPinMode = {};
+ }
+
+ Entry.hw.sendQueue.digitalPinMode[pin] = Entry.Roborobo_SchoolKit.pinMode.OUTPUT;
+ Entry.hw.sendQueue[pin] = value;
+ return script.callReturn();
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: 'Roborobo_schoolkit.wirte_digital(%1, %2)',
+ textParams: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roborobo_on, 'on'],
+ [Lang.Blocks.roborobo_off, 'off'],
+ ],
+ value: 'on',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ converter: Entry.block.converters.returnStringValue,
+ },
+ ],
+ },
+ ],
+ },
+ },
+ schoolkit_get_input_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
+ skeleton: 'basic_string_field',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'schoolkit_get_in_port_number',
+ },
+ ],
+ type: 'schoolkit_get_input_value',
+ },
+ paramsKeyMap: {
+ VALUE: 0,
+ },
+ class: 'schoolkit_value',
+ isNotFor: ['roborobo_schoolkit'],
+ func: function (sprite, script) {
+ var signal = script.getNumberValue('VALUE', script);
+ return Entry.hw.portData[signal - 7];
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: 'Roborobo_schoolkit.read_digital(%1)',
+ textParams: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ },
+ ],
+ },
+ },
+ schoolkit_motor: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roborobo_motor1, 'motor1'],
+ [Lang.Blocks.roborobo_motor2, 'motor2'],
+ ],
+ value: 'motor1',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ ['0', '45'],
+ ['1', '59'],
+ ['2', '73'],
+ ['3', '87'],
+ ['4', '101'],
+ ['5', '115'],
+ ['6', '129'],
+ ['7', '143'],
+ ['8', '157'],
+ ['9', '171'],
+ ['10', '185'],
+ ['11', '199'],
+ ['12', '213'],
+ ['13', '227'],
+ ['14', '241'],
+ ['15', '255'],
+ ],
+ value: '45',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roborobo_motor_CW, 'cw'],
+ [Lang.Blocks.roborobo_motor_CCW, 'ccw'],
+ [Lang.Blocks.roborobo_motor_stop, 'stop'],
+ ],
+ value: 'cw',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null, null, null, null],
+ type: 'schoolkit_motor',
+ },
+ paramsKeyMap: {
+ MODE: 0,
+ VALUE: 1,
+ OPERATOR: 2,
+ },
+ class: 'schoolkit_set',
+ isNotFor: ['roborobo_schoolkit'],
+ func: function (sprite, script) {
+ var mode = script.getField('MODE');
+ var pin = 0;
+ var operator = script.getField('OPERATOR');
+ var value = script.getField('VALUE');
+
+ if (mode == 'motor1') {
+ pin = 0;
+ } else {
+ pin = 1;
+ }
+
+ if (value > 255) {
+ value = 255;
+ } else if (value < 0) {
+ value = 0;
+ }
+
+ if (!Entry.hw.sendQueue.digitalPinMode) {
+ Entry.hw.sendQueue.digitalPinMode = {};
+ }
+
+ Entry.hw.sendQueue.digitalPinMode[pin] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[pin + 7] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ if (operator == 'cw') {
+ Entry.hw.sendQueue[pin] = value;
+ } else if (operator == 'ccw') {
+ Entry.hw.sendQueue[pin] = -value;
+ } else if (operator == 'stop') {
+ Entry.hw.sendQueue[pin] = 0x00;
+ }
+ return script.callReturn();
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: 'Roborobo_schoolkit.move_motor_speed(%1, %2, %3)',
+ textParams: [
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roborobo_motor1, 'motor1'],
+ [Lang.Blocks.roborobo_motor2, 'motor2'],
+ ],
+ value: 'motor1',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ converter: Entry.block.converters.returnStringValue,
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ ['0', '45'],
+ ['1', '59'],
+ ['2', '73'],
+ ['3', '87'],
+ ['4', '101'],
+ ['5', '115'],
+ ['6', '129'],
+ ['7', '143'],
+ ['8', '157'],
+ ['9', '171'],
+ ['10', '185'],
+ ['11', '199'],
+ ['12', '213'],
+ ['13', '227'],
+ ['14', '241'],
+ ['15', '255'],
+ ],
+ value: '45',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ [Lang.Blocks.roborobo_motor_CW, 'cw'],
+ [Lang.Blocks.roborobo_motor_CCW, 'ccw'],
+ [Lang.Blocks.roborobo_motor_stop, 'stop'],
+ ],
+ value: 'cw',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ converter: Entry.block.converters.returnStringValue,
+ },
+ ],
+ },
+ ],
+ },
+ },
+ schoolkit_set_servo_value: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ skeleton: 'basic',
+ statements: [],
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/hardware_icon.svg',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ {
+ type: 'schoolkit_get_servo_port_number',
+ },
+ {
+ type: 'number',
+ params: ['0'],
+ },
+ null,
+ ],
+ type: 'schoolkit_set_servo_value',
+ },
+ paramsKeyMap: {
+ PIN: 0,
+ VALUE: 1,
+ },
+ class: 'schoolkit_set',
+ isNotFor: ['roborobo_schoolkit'],
+ func: function (sprite, script) {
+ var pin = script.getNumberValue('PIN', script);
+ var value = script.getNumberValue('VALUE');
+
+ if (!Entry.hw.sendQueue.digitalPinMode) {
+ Entry.hw.sendQueue.digitalPinMode = {};
+ }
+ Entry.hw.sendQueue.digitalPinMode[pin] = Entry.Roborobo_SchoolKit.pinMode.SERVO;
+
+ if (value < 0) {
+ value = 0;
+ } else if (value > 180) {
+ value = 180;
+ }
+ Entry.hw.sendQueue[pin] = value;
+ return script.callReturn();
+ },
+ syntax: {
+ js: [],
+ py: [
+ {
+ syntax: 'Roborobo_schoolkit.move_servo(%1, %2)',
+ textParams: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ },
+ ],
+ },
+ },
+ //endregion schoolkit 스쿨키트
+ };
+};
+
+Entry.Roborobo_SchoolKit.getPracticalBlocks = function () {
+ return {
+ // roborobo_mini
+ roborobo_motor_speed: {
+ color: '#00B200',
+ outerLine: '#019101',
+ skeleton: 'basic_string_field',
+ statements: [],
+ isNotFor: ['roborobo_schoolkit'],
+ template: '%1',
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['1', '52'],
+ ['2', '66'],
+ ['3', '80'],
+ ['4', '94'],
+ ['5', '107'],
+ ['6', '120'],
+ ['7', '134'],
+ ['8', '148'],
+ ['9', '162'],
+ ['10', '176'],
+ ['11', '190'],
+ ['12', '204'],
+ ['13', '218'],
+ ['14', '232'],
+ ['15', '255'],
+ ],
+ value: '255',
+ fontSize: 11,
+ bgColor: '#019101',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ },
+ paramsKeyMap: {
+ VALUE: 0,
+ },
+ func (sprite, script) {
+ return script.getStringField('VALUE');
+ },
+ },
+ roborobo_move_for_secs: {
+ color: '#00B200',
+ outerLine: '#019101',
+ skeleton: 'basic',
+ fontColor: '#fff',
+ statements: [],
+ isNotFor: ['roborobo_schoolkit'],
+ template: '%1모터를 %2 %3의 속도로 %4초 동안 회전 %5',
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['양쪽', '1'],
+ ['오른쪽', '2'],
+ ['왼쪽', '3'],
+ ],
+ value: '1',
+ fontSize: 11,
+ bgColor: '#019101',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ ['앞으로', '1'],
+ ['뒤로', '2'],
+ ],
+ value: '1',
+ fontSize: 11,
+ bgColor: '#019101',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/practical_course/dcmotor.png',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ null,
+ {
+ type: 'roborobo_motor_speed',
+ },
+ {
+ type: 'number',
+ params: ['2'],
+ },
+ null,
+ ],
+ type: 'roborobo_move_for_secs',
+ },
+ paramsKeyMap: {
+ WHEEL: 0,
+ DIRECTION: 1,
+ SPEED: 2,
+ DURATION: 3,
+ },
+ class: 'roborobo_motor',
+ func (sprite, script) {
+ const motor1 = 0;
+ const motor2 = 1;
+ const wheel = script.getNumberField('WHEEL');
+ const speed = script.getNumberValue('SPEED');
+ const direction = script.getNumberField('DIRECTION');
+ const duration = script.getNumberValue('DURATION');
+
+ if (!Entry.hw.sendQueue.digitalPinMode) {
+ Entry.hw.sendQueue.digitalPinMode = {};
+ }
+
+ if (!script.isStart) {
+ if (wheel == 1) {
+ Entry.hw.sendQueue.digitalPinMode[7] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[0] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[8] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[1] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+
+ if (direction == 1) {
+ Entry.hw.sendQueue[motor1] = speed;
+ Entry.hw.sendQueue[motor2] = speed;
+ } else if (direction == 2) {
+ Entry.hw.sendQueue[motor1] = -speed;
+ Entry.hw.sendQueue[motor2] = -speed;
+ }
+ } else if (wheel == 2) {
+ Entry.hw.sendQueue.digitalPinMode[8] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[1] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+
+ if (direction == 1) {
+ Entry.hw.sendQueue[motor1] = 0x00;
+ Entry.hw.sendQueue[motor2] = speed;
+ } else if (direction == 2) {
+ Entry.hw.sendQueue[motor1] = 0x00;
+ Entry.hw.sendQueue[motor2] = -speed;
+ }
+ } else if (wheel == 3) {
+ Entry.hw.sendQueue.digitalPinMode[7] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[0] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+
+ if (direction == 1) {
+ Entry.hw.sendQueue[motor1] = speed;
+ Entry.hw.sendQueue[motor2] = 0x00;
+ } else if (direction == 2) {
+ Entry.hw.sendQueue[motor1] = -speed;
+ Entry.hw.sendQueue[motor2] = 0x00;
+ }
+ }
+
+ script.wheelMode = wheel;
+ script.isStart = true;
+ script.timeFlag = 1;
+ setTimeout(() => {
+ script.timeFlag = 0;
+ }, duration * 1000);
+ return script;
+ } else if (script.timeFlag == 1) {
+ return script;
+ } else {
+ Entry.hw.sendQueue[motor1] = 0x00;
+ Entry.hw.sendQueue[motor2] = 0x00;
+
+ delete script.timeFlag;
+ delete script.isStart;
+ delete script.wheelMode;
+ Entry.engine.isContinue = false;
+ return script.callReturn();
+ }
+ },
+ },
+ roborobo_move_for: {
+ color: '#00B200',
+ outerLine: '#019101',
+ skeleton: 'basic',
+ fontColor: '#fff',
+ statements: [],
+ isNotFor: ['roborobo_schoolkit'],
+ template: '%1모터를 %2 %3의 속도로 계속 회전 %4',
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['양쪽', '1'],
+ ['오른쪽', '2'],
+ ['왼쪽', '3'],
+ ],
+ value: '1',
+ fontSize: 11,
+ bgColor: '#019101',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ ['앞으로', '1'],
+ ['뒤로', '2'],
+ ],
+ value: '1',
+ fontSize: 11,
+ bgColor: '#019101',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/practical_course/dcmotor.png',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ null,
+ {
+ type: 'roborobo_motor_speed',
+ },
+ null,
+ ],
+ type: 'roborobo_move_for',
+ },
+ paramsKeyMap: {
+ WHEEL: 0,
+ DIRECTION: 1,
+ SPEED: 2,
+ },
+ class: 'roborobo_motor',
+ //'isNotFor': ['mini'],
+ func (sprite, script) {
+ const motor1 = 0;
+ const motor2 = 1;
+ const wheel = script.getNumberField('WHEEL');
+ const speed = script.getNumberValue('SPEED');
+ const direction = script.getNumberField('DIRECTION');
+
+ if (!Entry.hw.sendQueue.digitalPinMode) {
+ Entry.hw.sendQueue.digitalPinMode = {};
+ }
+
+ if (wheel == 1) {
+ Entry.hw.sendQueue.digitalPinMode[7] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[0] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[8] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[1] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+
+ if (direction == 1) {
+ Entry.hw.sendQueue[motor1] = speed;
+ Entry.hw.sendQueue[motor2] = speed;
+ } else if (direction == 2) {
+ Entry.hw.sendQueue[motor1] = -speed;
+ Entry.hw.sendQueue[motor2] = -speed;
+ }
+ } else if (wheel == 2) {
+ Entry.hw.sendQueue.digitalPinMode[8] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[1] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+
+ if (direction == 1) {
+ Entry.hw.sendQueue[motor1] = 0x00;
+ Entry.hw.sendQueue[motor2] = speed;
+ } else if (direction == 2) {
+ Entry.hw.sendQueue[motor1] = 0x00;
+ Entry.hw.sendQueue[motor2] = -speed;
+ }
+ } else if (wheel == 3) {
+ Entry.hw.sendQueue.digitalPinMode[7] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[0] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+
+ if (direction == 1) {
+ Entry.hw.sendQueue[motor1] = speed;
+ Entry.hw.sendQueue[motor2] = 0x00;
+ } else if (direction == 2) {
+ Entry.hw.sendQueue[motor1] = -speed;
+ //Entry.hw.sendQueue[motor2] = 0x00;
+ }
+ }
+
+ return script.callReturn();
+ },
+ },
+ roborobo_turn_for: {
+ color: '#00B200',
+ outerLine: '#019101',
+ skeleton: 'basic',
+ fontColor: '#fff',
+ statements: [],
+ isNotFor: ['roborobo_schoolkit'],
+ template: '오른쪽 모터를 %1 %2, 왼쪽 모터를 %3 %4의 속도로 계속 회전 %5',
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['앞으로', '1'],
+ ['뒤로', '2'],
+ ],
+ value: '1',
+ fontSize: 11,
+ bgColor: '#019101',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ ['앞으로', '1'],
+ ['뒤로', '2'],
+ ],
+ value: '1',
+ fontSize: 11,
+ bgColor: '#019101',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/practical_course/dcmotor.png',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ {type: 'roborobo_motor_speed'},
+ null,
+ {type: 'roborobo_motor_speed'},
+ null,
+ ],
+ type: 'roborobo_turn_for',
+ },
+ paramsKeyMap: {
+ RDIR: 0,
+ RSPEED: 1,
+ LDIR: 2,
+ LSPEED: 3,
+ },
+ class: 'roborobo_motor',
+ //'isNotFor': ['mini'],
+ func (sprite, script) {
+ const motor1 = 0;
+ const motor2 = 1;
+
+ const rightDir = script.getNumberField('RDIR');
+ const rightSpeed = script.getNumberValue('RSPEED');
+ const leftDir = script.getNumberField('LDIR');
+ const leftSpeed = script.getNumberValue('LSPEED');
+
+ if (!Entry.hw.sendQueue.digitalPinMode) {
+ Entry.hw.sendQueue.digitalPinMode = {};
+ }
+
+ Entry.hw.sendQueue.digitalPinMode[7] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[0] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[8] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[1] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+
+ if (leftDir == 1) {
+ Entry.hw.sendQueue[motor1] = leftSpeed;
+ } else {
+ Entry.hw.sendQueue[motor1] = -leftSpeed;
+ }
+
+ if (rightDir == 1) {
+ Entry.hw.sendQueue[motor2] = rightSpeed;
+ } else {
+ Entry.hw.sendQueue[motor2] = -rightSpeed;
+ }
+
+ return script.callReturn();
+ },
+ },
+ roborobo_stop_for: {
+ color: '#00B200',
+ outerLine: '#019101',
+ skeleton: 'basic',
+ fontColor: '#fff',
+ statements: [],
+ isNotFor: ['roborobo_schoolkit'],
+ template: '%1모터를 정지 %2',
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['양쪽', '1'],
+ ['오른쪽', '2'],
+ ['왼쪽', '3'],
+ ],
+ value: '1',
+ fontSize: 11,
+ bgColor: '#019101',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/practical_course/dcmotor.png',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null, null],
+ type: 'roborobo_stop_for',
+ },
+ paramsKeyMap: {
+ WHEEL: 0,
+ },
+ class: 'roborobo_motor',
+ func (sprite, script) {
+ const motor1 = 0;
+ const motor2 = 1;
+ const wheel = script.getNumberField('WHEEL');
+
+ if (!Entry.hw.sendQueue.digitalPinMode) {
+ Entry.hw.sendQueue.digitalPinMode = {};
+ }
+
+ if (wheel == 1) {
+ Entry.hw.sendQueue.digitalPinMode[7] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[0] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[8] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[1] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+
+ Entry.hw.sendQueue[motor1] = 0x00;
+ Entry.hw.sendQueue[motor2] = 0x00;
+ } else if (wheel == 2) {
+ Entry.hw.sendQueue.digitalPinMode[8] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[1] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+
+ Entry.hw.sendQueue[motor2] = 0x00;
+ } else if (wheel == 3) {
+ Entry.hw.sendQueue.digitalPinMode[7] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue.digitalPinMode[0] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+
+ Entry.hw.sendQueue[motor1] = 0x00;
+ }
+
+ return script.callReturn();
+ },
+ },
+ roborobo_touch_value: {
+ color: '#2AB4D3',
+ outerLine: '#0e93b1',
+ skeleton: 'basic_string_field',
+ fontColor: '#fff',
+ statements: [],
+ isNotFor: ['roborobo_schoolkit'],
+ template: '접촉 센서 값',
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ type: 'roborobo_touch_value',
+ },
+ paramsKeyMap: {},
+ class: 'roborobo_touch',
+ func (sprite, script) {
+ const port = Entry.Roborobo_SchoolKit.inputPort.contact;
+ Entry.hw.sendQueue.digitalPinMode[port] = Entry.Roborobo_SchoolKit.pinMode.INPUT;
+ Entry.hw.update();
+ return Entry.hw.portData[port - 7];
+ },
+ },
+ roborobo_touch_value_boolean: {
+ color: '#2AB4D3',
+ outerLine: '#0e93b1',
+ skeleton: 'basic_boolean_field',
+ fontColor: '#fff',
+ isNotFor: ['roborobo_schoolkit'],
+ template: '접촉 센서가 %1',
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['접촉 되면', '1'],
+ ['접촉 안되면', '0'],
+ ],
+ value: '1',
+ fontSize: 11,
+ bgColor: '#0e93b1',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ ],
+ def: {
+ params: [null],
+ type: 'roborobo_touch_value_boolean',
+ },
+ paramsKeyMap: {
+ TOUCH: 0,
+ },
+ class: 'roborobo_touch',
+ func (sprite, script) {
+ const port = Entry.Roborobo_SchoolKit.inputPort.contact;
+ const touch = script.getNumberField('TOUCH', script);
+
+ Entry.hw.sendQueue.digitalPinMode[port] = Entry.Roborobo_SchoolKit.pinMode.INPUT;
+ Entry.hw.update();
+
+ const value = Entry.hw.portData[port - 7];
+ const isTouch = touch == value;
+
+ return isTouch;
+ },
+ },
+ roborobo_light_value: {
+ color: '#ff8d0f',
+ outerLine: '#e37100',
+ skeleton: 'basic_string_field',
+ fontColor: '#fff',
+ statements: [],
+ isNotFor: ['roborobo_schoolkit'],
+ template: 'CDS 센서 값',
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ type: 'roborobo_light_value',
+ },
+ paramsKeyMap: {},
+ class: 'roborobo_light',
+ func (sprite, script) {
+ const port = Entry.Roborobo_SchoolKit.inputPort.cds;
+ return Entry.hw.portData[port - 7];
+ },
+ },
+ roborobo_light_value_boolean: {
+ color: '#ff8d0f',
+ outerLine: '#e37100',
+ skeleton: 'basic_boolean_field',
+ fontColor: '#fff',
+ isNotFor: ['roborobo_schoolkit'],
+ template: 'CDS 센서 값 %1 %2',
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['=', 'EQUAL'],
+ ['>', 'GREATER'],
+ ['<', 'LESS'],
+ ['≥', 'GREATER_OR_EQUAL'],
+ ['≤', 'LESS_OR_EQUAL'],
+ ],
+ value: 'LESS',
+ fontSize: 11,
+ bgColor: '#e37100',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ noaRrow: true,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ def: {
+ params: [
+ null,
+ {
+ type: 'number',
+ params: ['512'],
+ },
+ ],
+ type: 'roborobo_light_value_boolean',
+ },
+ paramsKeyMap: {
+ OPERATOR: 0,
+ RIGHTVALUE: 1,
+ },
+ class: 'roborobo_light',
+ func (sprite, script) {
+ const port = Entry.Roborobo_SchoolKit.inputPort.cds;
+ const operator = script.getField('OPERATOR', script);
+ let rightValue = script.getNumberValue('RIGHTVALUE', script);
+ const leftValue = Entry.hw.portData[port - 7];
+ let isCheck = false;
+
+ if (rightValue < 0) {
+ rightValue = 0;
+ } else if (rightValue > 1023) {
+ rightValue = 1023;
+ }
+ switch (operator) {
+ case 'EQUAL':
+ isCheck = leftValue == rightValue;
+ break;
+ case 'GREATER':
+ isCheck = Number(leftValue) > Number(rightValue);
+ break;
+ case 'LESS':
+ isCheck = Number(leftValue) < Number(rightValue);
+ break;
+ case 'GREATER_OR_EQUAL':
+ isCheck = Number(leftValue) >= Number(rightValue);
+ break;
+ case 'LESS_OR_EQUAL':
+ isCheck = Number(leftValue) <= Number(rightValue);
+ break;
+ }
+ return isCheck;
+ },
+ },
+ roborobo_sound_value: {
+ color: '#01d67f',
+ outerLine: '#00b36a',
+ skeleton: 'basic_string_field',
+ fontColor: '#fff',
+ statements: [],
+ isNotFor: ['roborobo_schoolkit'],
+ template: '소리 센서에 감지되는 소리 값',
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ type: 'roborobo_sound_value',
+ },
+ paramsKeyMap: {},
+ class: 'roborobo_sound',
+ func (sprite, script) {
+ const port = Entry.Roborobo_SchoolKit.inputPort.sound;
+ return Entry.hw.portData[port - 7];
+ },
+ },
+ roborobo_sound_value_boolean: {
+ color: '#01d67f',
+ outerLine: '#00b36a',
+ skeleton: 'basic_boolean_field',
+ fontColor: '#fff',
+ isNotFor: ['roborobo_schoolkit'],
+ template: '소리 센서에 감지되는 소리 값 %1 %2',
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['=', 'EQUAL'],
+ ['>', 'GREATER'],
+ ['<', 'LESS'],
+ ['≥', 'GREATER_OR_EQUAL'],
+ ['≤', 'LESS_OR_EQUAL'],
+ ],
+ value: 'LESS',
+ fontSize: 11,
+ bgColor: '#00b36a',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ noaRrow: true,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ def: {
+ params: [
+ null,
+ {
+ type: 'number',
+ params: ['512'],
+ },
+ ],
+ type: 'roborobo_sound_value_boolean',
+ },
+ paramsKeyMap: {
+ OPERATOR: 0,
+ RIGHTVALUE: 1,
+ },
+ class: 'roborobo_sound',
+ func (sprite, script) {
+ const port = Entry.Roborobo_SchoolKit.inputPort.sound;
+ const operator = script.getField('OPERATOR', script);
+ let rightValue = script.getNumberValue('RIGHTVALUE', script);
+ const leftValue = Entry.hw.portData[port - 7];
+ let isCheck = false;
+
+ if (rightValue < 0) {
+ rightValue = 0;
+ } else if (rightValue > 1023) {
+ rightValue = 1023;
+ }
+
+ switch (operator) {
+ case 'EQUAL':
+ isCheck = leftValue == rightValue;
+ break;
+ case 'GREATER':
+ isCheck = Number(leftValue) > Number(rightValue);
+ break;
+ case 'LESS':
+ isCheck = Number(leftValue) < Number(rightValue);
+ break;
+ case 'GREATER_OR_EQUAL':
+ isCheck = Number(leftValue) >= Number(rightValue);
+ break;
+ case 'LESS_OR_EQUAL':
+ isCheck = Number(leftValue) <= Number(rightValue);
+ break;
+ }
+
+ return isCheck;
+ },
+ },
+ roborobo_irs_value: {
+ color: '#C4065C',
+ outerLine: '#9a0045',
+ skeleton: 'basic_string_field',
+ fontColor: '#fff',
+ statements: [],
+ isNotFor: ['roborobo_schoolkit'],
+ template: '적외선 센서 값',
+ params: [
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ type: 'roborobo_irs_value',
+ },
+ paramsKeyMap: {},
+ class: 'roborobo_irs',
+ //'isNotFor': ['mini'],
+ func (sprite, script) {
+ const port = Entry.Roborobo_SchoolKit.inputPort.ir;
+ const value =
+ Entry.hw.portData[port - 7] == undefined ? 0 : Entry.hw.portData[port - 7];
+ return value;
+ },
+ },
+ roborobo_irs_value_boolean: {
+ color: '#C4065C',
+ outerLine: '#9a0045',
+ skeleton: 'basic_boolean_field',
+ fontColor: '#fff',
+ isNotFor: ['roborobo_schoolkit'],
+ template: '적외선 센서가 %1',
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['감지 되면', '1'],
+ ['감지 안되면', '0'],
+ ],
+ value: '1',
+ fontSize: 11,
+ bgColor: '#9a0045',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ ],
+ def: {
+ params: [null],
+ type: 'roborobo_irs_value_boolean',
+ },
+ paramsKeyMap: {
+ DETECT: 0,
+ },
+ class: 'roborobo_irs',
+ //'isNotFor': ['mini'],
+ func (sprite, script) {
+ const port = Entry.Roborobo_SchoolKit.inputPort.ir;
+ const detect = script.getNumberField('DETECT', script);
+
+ Entry.hw.sendQueue.digitalPinMode[port] = Entry.Roborobo_SchoolKit.pinMode.INPUT;
+ Entry.hw.update();
+
+ const value = Entry.hw.portData[port - 7];
+ const isDetect = detect == value;
+
+ return isDetect;
+ },
+ },
+ roborobo_diode_secs_toggle: {
+ color: '#ff8d0f',
+ outerLine: '#e37100',
+ skeleton: 'basic',
+ fontColor: '#fff',
+ statements: [],
+ isNotFor: ['roborobo_schoolkit'],
+ template: '%1번 포트의 발광다이오드를 %2초 동안 %3 %4',
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['LED 1', '5'],
+ ['LED 2', '4'],
+ ['R - A', '3'],
+ ['R - B', '2'],
+ ],
+ value: '5',
+ fontSize: 11,
+ bgColor: '#e37100',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ ['켜기', '255'],
+ ['끄기', '0'],
+ ],
+ value: '255',
+ fontSize: 11,
+ bgColor: '#e37100',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/practical_course/diode.png',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ {
+ type: 'number',
+ params: ['2'],
+ },
+ null,
+ null,
+ ],
+ type: 'roborobo_diode_secs_toggle',
+ },
+ paramsKeyMap: {
+ PORT: 0,
+ DURATION: 1,
+ VALUE: 2,
+ },
+ class: 'roborobo_diode',
+ func (sprite, script) {
+ const port = script.getNumberField('PORT');
+ const duration = script.getNumberValue('DURATION');
+ const value = script.getNumberField('VALUE');
+ if (!Entry.hw.sendQueue.digitalPinMode) {
+ Entry.hw.sendQueue.digitalPinMode = {};
+ }
+ Entry.hw.sendQueue.digitalPinMode[port] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+
+ if (!script.isStart) {
+ script.isStart = true;
+ script.timeFlag = 1;
+ Entry.hw.sendQueue[port] = value;
+
+ setTimeout(() => {
+ script.timeFlag = 0;
+ }, duration * 1000);
+ return script;
+ } else if (script.timeFlag == 1) {
+ return script;
+ } else {
+ Entry.hw.sendQueue[port] = 0;
+ delete script.timeFlag;
+ delete script.isStart;
+ Entry.engine.isContinue = false;
+ return script.callReturn();
+ }
+ },
+ },
+ roborobo_diode_toggle: {
+ color: '#ff8d0f',
+ outerLine: '#e37100',
+ skeleton: 'basic',
+ fontColor: '#fff',
+ statements: [],
+ isNotFor: ['roborobo_schoolkit'],
+ template: '%1번 포트의 발광다이오드를 %2 %3',
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['LED 1', '5'],
+ ['LED 2', '4'],
+ ['R - A', '3'],
+ ['R - B', '2'],
+ ],
+ value: '5',
+ fontSize: 11,
+ bgColor: '#e37100',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ ['켜기', '255'],
+ ['끄기', '0'],
+ ],
+ value: '255',
+ fontSize: 11,
+ bgColor: '#e37100',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/practical_course/diode.png',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null, null, null],
+ type: 'roborobo_diode_toggle',
+ },
+ paramsKeyMap: {
+ PORT: 0,
+ VALUE: 1,
+ },
+ class: 'roborobo_diode',
+ //'isNotFor': ['mini'],
+ func (sprite, script) {
+ const port = script.getNumberField('PORT');
+ const value = script.getNumberField('VALUE');
+
+ if (!Entry.hw.sendQueue.digitalPinMode) {
+ Entry.hw.sendQueue.digitalPinMode = {};
+ }
+
+ Entry.hw.sendQueue.digitalPinMode[port] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue[port] = value;
+
+ return script.callReturn();
+ },
+ },
+ roborobo_diode_inout_toggle: {
+ color: '#ff8d0f',
+ outerLine: '#e37100',
+ skeleton: 'basic',
+ fontColor: '#fff',
+ statements: [],
+ isNotFor: ['roborobo_schoolkit'],
+ template: '%1번 포트의 발광다이오드를 %2번 포트의 %3~%4의 범위로 켜기%5',
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['LED 1', '5'],
+ ['LED 2', '4'],
+ ['R - A', '3'],
+ ['R - B', '2'],
+ ],
+ value: '5',
+ fontSize: 11,
+ bgColor: '#e37100',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ ['소 리', '8'],
+ ['CDS', '10'],
+ ],
+ value: '8',
+ fontSize: 11,
+ bgColor: '#e37100',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/practical_course/diode.png',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ null,
+ {type: 'number', params: ['0']},
+ {type: 'number', params: ['255']},
+ null,
+ ],
+ type: 'roborobo_diode_inout_toggle',
+ },
+ paramsKeyMap: {
+ OUTPUT: 0,
+ INPUT: 1,
+ MIN: 2,
+ MAX: 3,
+ },
+ class: 'roborobo_diode',
+ //'isNotFor': ['mini'],
+ func (sprite, script) {
+ const outputPort = script.getNumberField('OUTPUT');
+ const inputPort = script.getNumberField('INPUT');
+
+ const oMin = script.getNumberValue('MIN');
+ const oMax = script.getNumberValue('MAX');
+ const nMin = 0;
+ const nMax = 255;
+ const x = Entry.hw.portData[inputPort - 7] / 4;
+ const percent = (x - oMin) / (oMax - oMin);
+ let result = percent * (nMax - nMin) + nMin;
+ if (result > nMax) {
+ result = nMax;
+ }
+ if (result < nMin) {
+ result = nMin;
+ }
+
+ if (!Entry.hw.sendQueue.digitalPinMode) {
+ Entry.hw.sendQueue.digitalPinMode = {};
+ }
+
+ Entry.hw.sendQueue.digitalPinMode[outputPort] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue[outputPort] = result;
+
+ return script.callReturn();
+ },
+ },
+ roborobo_diode_set_output: {
+ color: '#ff8d0f',
+ outerLine: '#e37100',
+ skeleton: 'basic',
+ statements: [],
+ isNotFor: ['roborobo_schoolkit'],
+ template: '%1번 포트의 발광다이오드를 %2의 밝기로 켜기 %3',
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['LED 1', '5'],
+ ['LED 2', '4'],
+ ['R - A', '3'],
+ ['R - B', '2'],
+ ],
+ value: '5',
+ fontSize: 11,
+ bgColor: '#e37100',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ {
+ type: 'Block',
+ accept: 'string',
+ },
+ {
+ type: 'Indicator',
+ img: 'block_icon/practical_course/diode.png',
+ size: 12,
+ },
+ ],
+ events: {},
+ def: {
+ params: [
+ null,
+ {
+ type: 'number',
+ params: ['255'],
+ },
+ null,
+ ],
+ type: 'roborobo_diode_set_output',
+ },
+ paramsKeyMap: {
+ PORT: 0,
+ VALUE: 1,
+ },
+ class: 'roborobo_diode',
+ //'isNotFor': ['mini'],
+ func (sprite, script) {
+ const port = script.getStringField('PORT', script);
+ let value = script.getNumberValue('VALUE', script);
+
+ if (value < 0) {
+ value = 0;
+ } else if (value > 255) {
+ value = 255;
+ }
+ if (!Entry.hw.sendQueue.digitalPinMode) {
+ Entry.hw.sendQueue.digitalPinMode = {};
+ }
+ Entry.hw.sendQueue.digitalPinMode[port] = Entry.Roborobo_SchoolKit.pinMode.PWM;
+ Entry.hw.sendQueue[port] = value;
+
+ return script.callReturn();
+ },
+ },
+ roborobo_diode_input_value: {
+ color: '#ff8d0f',
+ outerLine: '#e37100',
+ skeleton: 'basic_string_field',
+ fontColor: '#fff',
+ statements: [],
+ isNotFor: ['roborobo_schoolkit'],
+ template: '%1 포트의 값',
+ params: [
+ {
+ type: 'Dropdown',
+ options: [
+ ['적외선', '7'],
+ ['소 리', '8'],
+ ['접 촉', '9'],
+ ['CDS', '10'],
+ ],
+ value: '8',
+ fontSize: 11,
+ bgColor: '#e37100',
+ arrowColor: EntryStatic.colorSet.common.WHITE,
+ },
+ ],
+ events: {},
+ def: {
+ params: [null],
+ type: 'roborobo_diode_input_value',
+ },
+ paramsKeyMap: {
+ PORT: 0,
+ },
+ class: 'roborobo_diode',
+ func (sprite, script) {
+ const port = script.getNumberField('PORT');
+ return Entry.hw.portData[port - 7];
+ },
+ },
+ }
+}
+
+module.exports = Entry.Roborobo_SchoolKit;
diff --git a/src/playground/blocks/hardwareLite/block_microbit2_lite.js b/src/playground/blocks/hardwareLite/block_microbit2_lite.js
index e92e1435eb..a74f28e860 100644
--- a/src/playground/blocks/hardwareLite/block_microbit2_lite.js
+++ b/src/playground/blocks/hardwareLite/block_microbit2_lite.js
@@ -1,9 +1,14 @@
'use strict';
-(function() {
+const _throttle = require('lodash/throttle');
+
+const EVENT_INTERVAL = 150;
+
+(function () {
Entry.Microbit2lite = new (class Microbit2Lite {
constructor() {
this.commandStatus = {};
+ this.btnEventIntervalId = -1;
this.retryLimitCnt = 5;
this.portData = {
baudRate: 115200,
@@ -13,7 +18,7 @@
bufferSize: 512,
connectionType: 'ascii',
};
- this.duration = 32;
+ this.duration = 64;
this.functionKeys = {
LOCALDATA: 'localdata',
GET_ANALOG: 'get-analog',
@@ -258,11 +263,19 @@
'microbit2lite_set_pwm',
'microbit2lite_v2_title',
'microbit2lite_get_logo',
+ 'microbit2lite_btn_event',
'microbit2lite_speaker_toggle',
'microbit2lite_play_sound_effect',
'microbit2lite_get_sound_level',
];
this.version = '2';
+ this.firePressedBtnEventWithThrottle = _throttle(
+ (pressedBtn) => {
+ Entry.engine.fireEventWithValue('microbit2lite_btn_pressed', pressedBtn);
+ },
+ EVENT_INTERVAL,
+ { leading: true, trailing: false }
+ );
}
_clamp(value, min, max) {
if (value < min) {
@@ -277,6 +290,48 @@
return Entry.hwLite.sendAsyncWithThrottle(this.functionKeys.RESET);
}
+ async initialHandshake() {
+ const defaultCMD = `${this.functionKeys.LOCALDATA}`;
+ const response = await Entry.hwLite.sendAsync(defaultCMD);
+ if (response && response.indexOf('localdata') > -1) {
+ const version = response.split(';')[1];
+ if (!version) {
+ return;
+ }
+ const major = version[0];
+ if (this.version !== major) {
+ this.version = major;
+ }
+ }
+
+ if (this.version === '2') {
+ Entry.addEventListener('run', this.handleBtnEventInterval.bind(this));
+ Entry.addEventListener('beforeStop', () => { clearInterval(this.btnEventIntervalId) });
+ }
+
+ return response;
+ }
+
+ handleBtnEventInterval() {
+ this.btnEventIntervalId = setInterval(this.listenBtnPressedEvent.bind(this), this.duration);
+ }
+
+ async listenBtnPressedEvent() {
+ if (Object.keys(this.commandStatus).length > 0) {
+ return;
+ }
+
+ const defaultCMD = `${this.functionKeys.LOCALDATA};`;
+ const response = await Entry.hwLite.sendAsyncWithThrottle(defaultCMD);
+ // const response = await this.getResponseWithSync(defaultCMD);
+
+ // INFO: A,B 버튼이벤트 관련 로직
+ const pressedBtn = response.split(':btn:')[1];
+ if (pressedBtn) {
+ this.firePressedBtnEventWithThrottle(pressedBtn);
+ }
+ }
+
waitMilliSec(milli) {
this.blockReq = true;
setTimeout(() => {
@@ -318,7 +373,11 @@
}
const result = await Entry.hwLite.sendAsyncWithThrottle(command);
- if (!result || this.getCommandType(command) !== this.getCommandType(result)) {
+ if (!result ||
+ this.getCommandType(command) !== this.getCommandType(result) ||
+ // INFO : localdata 명령어는 우선순위가 낮으므로 반복하지 않음
+ command !== `${this.functionKeys.LOCALDATA};`
+ ) {
if (!this.commandStatus[command]) {
this.commandStatus[command] = 1;
throw new Entry.Utils.AsyncError();
@@ -367,6 +426,7 @@
microbit2lite_get_logo: '로고를 터치했는가?',
microbit2lite_get_gesture: '움직임이 %1 인가?',
microbit2lite_get_acc: '%1 의 가속도 값',
+ microbit2lite_btn_event: '%1 %2 버튼을 눌렀을 때',
microbit2lite_get_direction: '나침반 방향',
microbit2lite_get_field_strength_axis: '%1 의 자기장 세기 값',
microbit2lite_get_light_level: '빛 센서 값',
@@ -522,7 +582,8 @@
microbit2lite_get_btn: "선택한 버튼이 눌렸다면 '참'으로 판단합니다.",
microbit2lite_get_logo: "로고를 터치했다면 '참'으로 판단합니다.",
microbit2lite_get_gesture: "선택한 움직임이 감지되면 '참'으로 판단합니다.",
- microbit2lite_get_acc: '선택한 축의 가속도 값입니다.',
+ microbit2lite_get_acc: '선택한 버튼이 눌리면 아래에 연결된 블록들을 실행합니다.',
+ microbit2lite_btn_event: '%1 %2 버튼을 눌렀을 때',
microbit2lite_get_direction: '나침반 방향 값입니다. (0~360) ',
microbit2lite_get_field_strength_axis: '선택한 축의 자기장 세기 값입니다.',
microbit2lite_get_light_level: '빛 센서의 값입니다.',
@@ -565,6 +626,7 @@
microbit2lite_get_logo: 'logo touched?',
microbit2lite_get_gesture: 'Is the movement %1?',
microbit2lite_get_acc: 'acceleration value of %1',
+ microbit2lite_btn_event: '%1 When %2 button pressed',
microbit2lite_get_direction: 'compass direction',
microbit2lite_get_field_strength_axis:
'magnetic field strength value of %1 ',
@@ -731,6 +793,7 @@
microbit2lite_get_gesture:
"When the selected movement is detected, it is judged as 'True'.",
microbit2lite_get_acc: 'The acceleration value of the selected axis.',
+ microbit2lite_btn_event: 'When the selected button is pressed, the connected blocks below will run',
microbit2lite_get_direction: 'The compass direction value. (0~360)',
microbit2lite_get_field_strength_axis:
'The magnetic field strength value of the selected axis.',
@@ -949,7 +1012,7 @@
};
}
- getBlocks = function() {
+ getBlocks = function () {
return {
microbit2lite_common_title: {
skeleton: 'basic_text',
@@ -1862,6 +1925,45 @@
}
},
},
+ microbit2lite_btn_event: {
+ color: EntryStatic.colorSet.block.default.HARDWARE,
+ outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
+ fontColor: '#fff',
+ skeleton: 'basic_event',
+ statements: [],
+ params: [
+ {
+ type: 'Indicator',
+ img: 'block_icon/start_icon_hardware.svg',
+ size: 14,
+ position: { x: 0, y: -2 },
+ },
+ {
+ type: 'Dropdown',
+ options: [
+ ['A', '1'],
+ ['B', '2'],
+ ['A+B', '3'],
+ ],
+ value: '1',
+ fontSize: 11,
+ bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
+ arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
+ },
+ ],
+ def: {
+ type: 'microbit2lite_btn_event'
+ },
+ paramsKeyMap: {
+ VALUE: 1,
+ },
+ class: 'microbit2litev2',
+ isNotFor: ['Microbit2lite'],
+ event: 'microbit2lite_btn_pressed',
+ func: (sprite, script) => {
+ return script.callReturn();
+ },
+ },
microbit2lite_get_acc: {
color: EntryStatic.colorSet.block.default.HARDWARE,
outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
diff --git a/src/playground/board.js b/src/playground/board.js
index c9326f79b4..2bcc22a859 100644
--- a/src/playground/board.js
+++ b/src/playground/board.js
@@ -1507,6 +1507,9 @@ Entry.Board = class Board {
y: 26,
});
requestAnimationFrame(() => {
+ if (!this.svgObjectBlockCount.countText) {
+ return;
+ }
const rectWidth =
this.svgObjectBlockCount.countText.getBoundingClientRect().width / this.scale;
this.svgObjectBlockCount.rect.attr({
@@ -1522,10 +1525,12 @@ Entry.Board = class Board {
if (count === 1) {
langText = Lang.Workspace.use_block_project;
}
- this.svgObjectBlockCount.countText.textContent = Entry.Utils.stringFormat(
- langText,
- Entry.Utils.shortenNumber(count)
- );
+ if (this.svgObjectBlockCount.countText) {
+ this.svgObjectBlockCount.countText.textContent = Entry.Utils.stringFormat(
+ langText,
+ Entry.Utils.shortenNumber(count)
+ );
+ }
}
clearObjectTitle() {
diff --git a/src/playground/workspace.js b/src/playground/workspace.js
index 11278c15d9..5b862bbe97 100644
--- a/src/playground/workspace.js
+++ b/src/playground/workspace.js
@@ -198,13 +198,19 @@ Entry.Workspace = class Workspace {
if (alertMessage.type === 'warning') {
Entry.modal.confirm(alertMessage.message).then((result) => {
if (result) {
+ Entry.variableContainer.removeNotPythonSupportedFunction();
Entry.expansion.banExpansionBlocks(Entry.expansionBlocks);
Entry.aiUtilize.banAIUtilizeBlocks(Entry.aiUtilizeBlocks);
Entry.hwLite.banClassAllHardwareLite();
Entry.playground.dataTable.removeAllBlocks();
Entry.aiLearning.removeAllBlocks();
- changeToPythonMode();
- dispatchChangeBoardEvent();
+ Util.removeNotSupportedBlock();
+ Entry.playground.blockMenu.banClass('python_disable');
+ // 블럭 삭제되고 처리
+ requestAnimationFrame(() => {
+ changeToPythonMode();
+ dispatchChangeBoardEvent();
+ });
} else {
const mode = {};
mode.boardType = WORKSPACE.MODE_BOARD;
@@ -233,6 +239,7 @@ Entry.Workspace = class Workspace {
try {
this.board.show();
blockMenu.unbanClass('functionInit', true);
+ Entry.playground.blockMenu.unbanClass('python_disable');
this.set({ selectedBoard: this.board });
this.textToCode(this.oldMode, this.oldTextType);
if (this.overlayBoard) {
diff --git a/src/textcoding/parser/core/block/blockToPy.js b/src/textcoding/parser/core/block/blockToPy.js
index 003d9767ec..7965860638 100755
--- a/src/textcoding/parser/core/block/blockToPy.js
+++ b/src/textcoding/parser/core/block/blockToPy.js
@@ -64,10 +64,17 @@ Entry.BlockToPyParser = class {
let contentResult = '';
blocks.forEach((block, index) => {
- if (index === 0 && Entry.TextCodingUtil.isEventBlock(block)) {
- rootResult = `${this.Block(block)}\n`;
- } else {
- contentResult += `${this.Block(block)}\n`;
+ try {
+ if (index === 0 && Entry.TextCodingUtil.isEventBlock(block)) {
+ rootResult = `${this.Block(block)}\n`;
+ } else {
+ contentResult += `${this.Block(block)}\n`;
+ }
+ } catch (e) {
+ Entry.toast.alert(
+ Lang.TextCoding.title_converting,
+ Lang.TextCoding.alert_legacy_no_support
+ );
}
});
@@ -350,7 +357,7 @@ Entry.BlockToPyParser = class {
schema = datum;
}
- if (schema && schema.syntax) {
+ if (schema && schema.syntax && schema.syntax.py && schema.syntax.py.length > 0) {
const syntaxes = schema.syntax.py.concat();
while (syntaxes.length) {
let isFail = false;
diff --git a/src/textcoding/util/textCodingUtil.js b/src/textcoding/util/textCodingUtil.js
index 41245f9734..cb89ab7c44 100755
--- a/src/textcoding/util/textCodingUtil.js
+++ b/src/textcoding/util/textCodingUtil.js
@@ -504,11 +504,20 @@ class TextCodingUtil {
const activatedExpansionBlocks = Entry.expansionBlocks;
const activatedUtilizeBlock = Entry.aiUtilizeBlocks;
const tables = Entry.playground.dataTable ? Entry.playground.dataTable.tables : [];
+ const functions = Entry.variableContainer.functions_;
+ const isNotPythonSupportFunciton = Object.keys(functions).some(
+ (key) => functions[key].useLocalVariables || functions[key].type === 'value'
+ );
+ const isNotSupportedUsed = this.getNotSupportedBlocks().some((name) =>
+ Entry.Utils.isUsedBlockType(name)
+ );
if (
activatedExpansionBlocks.length > 0 ||
activatedUtilizeBlock.length > 0 ||
Entry.aiLearning.isLoaded ||
- tables.length > 0
+ isNotPythonSupportFunciton ||
+ tables.length > 0 ||
+ isNotSupportedUsed
) {
return {
message: Lang.TextCoding[Entry.TextCodingError.ALERT_API_NO_SUPPORT],
@@ -517,6 +526,22 @@ class TextCodingUtil {
}
}
+ getNotSupportedBlocks() {
+ if (EntryStatic.pythonDisabled) {
+ return EntryStatic.pythonDisabled;
+ }
+ EntryStatic.pythonDisabled = Object.keys(Entry.block).filter(
+ (key) => Entry.block[key]?.isNotFor.indexOf('python_disable') >= 0
+ );
+ return EntryStatic.pythonDisabled;
+ }
+
+ removeNotSupportedBlock(names = []) {
+ this.getNotSupportedBlocks().forEach((blockType) => {
+ Entry.Utils.removeBlockByType(blockType);
+ });
+ }
+
/**
* 현재 코드 내 변수, 리스트에 대해 공백/특수문자/예약어/숫자시작 여부를 검사한다.
* @return {Object} 에러오브젝트
diff --git a/types/entry.d.ts b/types/entry.d.ts
index 351a2bc05f..d7061acd27 100644
--- a/types/entry.d.ts
+++ b/types/entry.d.ts
@@ -71,6 +71,7 @@ declare interface IEntry extends EntryOptions {
hwLite: typeof import('../src/class/hw_lite').default;
hw: import('../src/class/hw').default; // HW instance
interfaceState: { [key: string]: any };
+ modal: any; // @entrylabs/modal
// 엔트리 전역에 할당된 이벤트 객체
disposeEvent: any;