update: clean up garbages

This commit is contained in:
ocogeclub 2021-02-28 19:14:39 +09:00
parent e19acb4eb6
commit f30059f4f3
3 changed files with 122 additions and 325 deletions

View File

@ -91,20 +91,6 @@
<block type="logic_null"></block> <block type="logic_null"></block>
<block type="logic_ternary"></block> <block type="logic_ternary"></block>
</category> </category>
<!-- <category name="論理">
<block type="controls_if"></block>
<block type="logic_compare">
<field name="OP">EQ</field>
</block>
<block type="logic_operation">
<field name="OP">AND</field>
</block>
<block type="logic_negate"></block>
<block type="logic_boolean">
<field name="BOOL">TRUE</field>
</block>
</category> -->
<category name="ループ" css-icon="customIcon fas fa-redo-alt" categorystyle="loop_category"> <category name="ループ" css-icon="customIcon fas fa-redo-alt" categorystyle="loop_category">
<block type="controls_repeat_ext"> <block type="controls_repeat_ext">
<value name="TIMES"> <value name="TIMES">
@ -312,14 +298,14 @@
<block type="ugj_gpio_setoutput"> <block type="ugj_gpio_setoutput">
<value name="gpio"> <value name="gpio">
<shadow type="math_number"> <shadow type="math_number">
<field name="NUM">20</field> <field name="NUM">5</field>
</shadow> </shadow>
</value> </value>
</block> </block>
<block type="ugj_gpio_write"> <block type="ugj_gpio_write">
<value name="ugj_gpio_num"> <value name="ugj_gpio_num">
<shadow type="math_number"> <shadow type="math_number">
<field name="NUM">20</field> <field name="NUM">5</field>
</shadow> </shadow>
</value> </value>
<value name="ugj_gpio_value"> <value name="ugj_gpio_value">
@ -332,14 +318,14 @@
<field name="updown">pi.PUD_DOWN</field> <field name="updown">pi.PUD_DOWN</field>
<value name="gpio"> <value name="gpio">
<shadow type="math_number"> <shadow type="math_number">
<field name="NUM">4</field> <field name="NUM">6</field>
</shadow> </shadow>
</value> </value>
</block> </block>
<block type="ugj_gpio_read"> <block type="ugj_gpio_read">
<value name="gpio"> <value name="gpio">
<shadow type="math_number"> <shadow type="math_number">
<field name="NUM">4</field> <field name="NUM">6</field>
</shadow> </shadow>
</value> </value>
</block> </block>
@ -348,7 +334,7 @@
<field name="pwmfreq">50</field> <field name="pwmfreq">50</field>
<value name="gpio"> <value name="gpio">
<shadow type="math_number"> <shadow type="math_number">
<field name="NUM">20</field> <field name="NUM">5</field>
</shadow> </shadow>
</value> </value>
</block> </block>
@ -360,14 +346,14 @@
</value> </value>
<value name="gpio"> <value name="gpio">
<shadow type="math_number"> <shadow type="math_number">
<field name="NUM">20</field> <field name="NUM">5</field>
</shadow> </shadow>
</value> </value>
</block> </block>
<block type="ugj_gpio_servo"> <block type="ugj_gpio_servo">
<value name="gpio"> <value name="gpio">
<shadow type="math_number"> <shadow type="math_number">
<field name="NUM">14</field> <field name="NUM">12</field>
</shadow> </shadow>
</value> </value>
<value name="pulsewidth"> <value name="pulsewidth">
@ -436,16 +422,6 @@
</value> </value>
</block> </block>
<label text="センサー" web-line="4.0" web-line-width="200"></label> <label text="センサー" web-line="4.0" web-line-width="200"></label>
<block type="ugj_dht">
<field name="type">11</field>
<field name="temperature" id="b4bG/!B(8TP1=sB,OJjw" variabletype="">気温</field>
<field name="humidity" id="yh}5iLSHLiaNg8BpL|zd" variabletype="">湿度</field>
<value name="gpio">
<shadow type="math_number">
<field name="NUM">4</field>
</shadow>
</value>
</block>
<label text="Extra" web-line="4.0" web-line-width="200"></label> <label text="Extra" web-line="4.0" web-line-width="200"></label>
<block type="ugj_gpio_sleep"> <block type="ugj_gpio_sleep">
<field name="sec">1</field> <field name="sec">1</field>
@ -564,37 +540,11 @@
<block type="ugj_sound_play"> <block type="ugj_sound_play">
<field name="sound">meow</field> <field name="sound">meow</field>
</block> </block>
<block type="ugj_multimedia_webspeech_recognition"> <block type="ugj_multimedia_webspeech_recognition" disabled="true">
<field name="transcript" id="=3;~1sjv_R.pRhO)=wQY" variabletype="">ことば</field> <field name="transcript" id="=3;~1sjv_R.pRhO)=wQY" variabletype="">ことば</field>
<field name="continuous">once</field> <field name="continuous">once</field>
<field name="interim">TRUE</field> <field name="interim">TRUE</field>
</block> </block>
<!-- <block type="ugj_multimedia_cloudspeech_recognition">
<field name="transcript" id="=3;~1sjv_R.pRhO)=wQY" variabletype="">ことば</field>
<field name="continuous">once</field>
<field name="interim">TRUE</field>
</block> -->
<!-- <label text="顔認識" web-line="4.0" web-line-width="200"></label>
<block type="ugj_library_load">
<value name="lib">
<shadow type="ugj_face_library"></block>
</value>
</block>
<block type="ugj_face_init"></block>
<block type="ugj_face_display"></block>
<block type="ugj_face_detect">
<field name="x" id="TF-ziC[]OAJ9]r}YjUQg" variabletype=""></field>
<field name="y" id="]G:_%S*1v4!9_+yx532d" variabletype=""></field>
<field name="w" id="wP$LdeXDCiWzrI!/9R)G" variabletype=""></field>
<field name="h" id="8+E.-dP-Omt}v2~DCC]M" variabletype="">高さ</field>
</block>
<block type="ugj_face_drawrect">
<value name="color">
<shadow type="colour_picker">
<field name="COLOUR">#ff0000</field>
</shadow>
</value>
</block> -->
<label text="画像認識" web-line="4.0" web-line-width="200"></label> <label text="画像認識" web-line="4.0" web-line-width="200"></label>
<block type="ugj_library_load"> <block type="ugj_library_load">
<value name="lib"> <value name="lib">
@ -658,7 +608,7 @@
</value> </value>
</block> </block>
<label text="ウェブチャット" web-line="4.0" web-line-width="200"></label> <label text="ウェブチャット" web-line="4.0" web-line-width="200"></label>
<block type="ugj_library_load" disabled="true"> <block type="ugj_library_load">
<value name="lib"> <value name="lib">
<shadow type="ugj_library_skyway"></shadow> <shadow type="ugj_library_skyway"></shadow>
</value> </value>
@ -702,11 +652,6 @@
<field name="TEXT">お名前は?</field> <field name="TEXT">お名前は?</field>
</shadow> </shadow>
</value> </value>
<value name="sec">
<shadow type="math_number">
<field name="NUM">5</field>
</shadow>
</value>
</block> </block>
<block type="ugj_blackboard_show"></block> <block type="ugj_blackboard_show"></block>
<block type="ugj_blackboard_write"> <block type="ugj_blackboard_write">
@ -808,9 +753,6 @@
</shadow> </shadow>
</value> </value>
</block> </block>
<block type="ugj_child_facepy">
<field name="win"> </field>
</block>
<block type="ugj_child_gesture"></block> <block type="ugj_child_gesture"></block>
<block type="ugj_child_irrecord"> <block type="ugj_child_irrecord">
<value name="gpio"> <value name="gpio">
@ -902,12 +844,68 @@
</shadow> </shadow>
</value> </value>
</block> </block>
<block type="ugj_child_debug">
<value name="cmd">
</block>
<label text="_" web-line="4.0" web-line-width="200"></label> <label text="_" web-line="4.0" web-line-width="200"></label>
</category> </category>
<category name="スニペット" css-icon="customIcon fas fa-egg" categorystyle="snippets_category"> <category name="スニペット" css-icon="customIcon fas fa-egg" categorystyle="snippets_category">
<label text="入出力" web-line="4.0" web-line-width="200"></label>
<block type="ugj_event_answer">
<field name="answer" id="_m@Uj#wHnIuGJNVwdUR+" variabletype="">答え</field>
<value name="question">
<shadow type="text">
<field name="TEXT">お名前は?</field>
</shadow>
</value>
<statement name="do">
<block type="ugj_canvas_say">
<value name="say">
<shadow type="text">
<field name="TEXT">・・・</field>
</shadow>
</value>
<value name="sec">
<shadow type="math_number">
<field name="NUM">2</field>
</shadow>
</value>
<next>
<block type="ugj_sleep">
<value name="sec">
<shadow type="math_number">
<field name="NUM">2</field>
</shadow>
</value>
<next>
<block type="ugj_canvas_say">
<value name="say">
<block type="text_join">
<mutation items="2"></mutation>
<value name="ADD0">
<block type="variables_get">
<field name="VAR" id="_m@Uj#wHnIuGJNVwdUR+">答え</field>
</block>
</value>
<value name="ADD1">
<block type="text">
<field name="TEXT">たん</field>
</block>
</value>
</block>
</value>
<value name="sec">
<shadow type="math_number">
<field name="NUM">2</field>
</shadow>
</value>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
</category> </category>
</xml> </xml>

View File

@ -24,36 +24,10 @@ Blockly.Blocks['ugj_control_for'] = {
this.setPreviousStatement(true, null); this.setPreviousStatement(true, null);
this.setNextStatement(true, null); this.setNextStatement(true, null);
this.setColour(Blockly.Msg.LOOPS_HUE); this.setColour(Blockly.Msg.LOOPS_HUE);
this.setTooltip(""); this.setTooltip("インデックス番号を決められた数ずつ増やし(減らし)ながら、ステートメントを実行します。");
this.setHelpUrl(""); this.setHelpUrl("");
} }
}; };
// Blockly.Blocks['ugj_controls_for'] = {
// init: function () {
// this.appendDummyInput()
// .appendField(new Blockly.FieldVariable("番号"), "index");
// this.appendValueInput("from")
// .setCheck("Number")
// .appendField("を");
// this.appendValueInput("to")
// .setCheck("Number")
// .appendField("から");
// this.appendValueInput("by")
// .setCheck("Number")
// .appendField("まで");
// this.appendDummyInput()
// .appendField("ずつ増やしながら");
// this.appendStatementInput("do")
// .setCheck(null);
// this.setInputsInline(true);
// this.setPreviousStatement(true, null);
// this.setNextStatement(true, null);
// this.setColour(Blockly.Msg.LOOPS_HUE);
// this.setTooltip("インデックス番号を決められた数ずつ増やし(減らし)ながら、ステートメントを実行します。");
// this.setHelpUrl("");
// }
// };
Blockly.JavaScript['ugj_control_for'] = function (block) { Blockly.JavaScript['ugj_control_for'] = function (block) {
var variable_index = Blockly.JavaScript.variableDB_.getName(block.getFieldValue('index'), Blockly.Variables.NAME_TYPE); var variable_index = Blockly.JavaScript.variableDB_.getName(block.getFieldValue('index'), Blockly.Variables.NAME_TYPE);
var value_from = Blockly.JavaScript.valueToCode(block, 'from', Blockly.JavaScript.ORDER_ATOMIC); var value_from = Blockly.JavaScript.valueToCode(block, 'from', Blockly.JavaScript.ORDER_ATOMIC);
@ -72,20 +46,6 @@ Blockly.JavaScript['ugj_control_for'] = function (block) {
].join('\n'); ].join('\n');
return code; return code;
}; };
// Blockly.JavaScript['ugj_controls_for'] = function (block) {
// var variable_index = Blockly.JavaScript.variableDB_.getName(block.getFieldValue('index'), Blockly.Variables.NAME_TYPE);
// var value_from = Blockly.JavaScript.valueToCode(block, 'from', Blockly.JavaScript.ORDER_ATOMIC);
// var value_to = Blockly.JavaScript.valueToCode(block, 'to', Blockly.JavaScript.ORDER_ATOMIC);
// var value_by = Blockly.JavaScript.valueToCode(block, 'by', Blockly.JavaScript.ORDER_ATOMIC);
// var statements_do = Blockly.JavaScript.statementToCode(block, 'do');
// var code = [
// `for (${variable_index} = ${value_from}; ${variable_index} <= ${value_to}; ${variable_index} += ${value_by}) {`,
// statements_do,
// `}`,
// ''
// ].join('\n');
// return code;
// };
Blockly.Blocks['ugj_controls_forEach'] = { Blockly.Blocks['ugj_controls_forEach'] = {
init: function () { init: function () {
@ -146,16 +106,18 @@ Blockly.JavaScript['ugj_hextodec'] = function (block) {
/************* */ /************* */
/** GPIO Start */ /** GPIO Start */
/************* */ /************* */
var ugjGpioStart = {
"type": "ugj_gpio_start",
"message0": "%{BKY_GPIO_START_TITLE}",
"previousStatement": null,
"nextStatement": null,
"tooltip": "%{BKY_GPIO_START_TOOLTIP}",
"helpUrl": "",
"style": "gpio_blocks"
};
Blockly.Blocks['ugj_gpio_start'] = { Blockly.Blocks['ugj_gpio_start'] = {
init: function () { init: function () {
this.appendDummyInput() this.jsonInit(ugjGpioStart);
.appendField("GPIO を使えるようにする");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setStyle('gpio_blocks')
this.setTooltip("GPIOを初期化して接続します。");
this.setHelpUrl("");
} }
}; };
Blockly.JavaScript['ugj_gpio_start'] = function (block) { Blockly.JavaScript['ugj_gpio_start'] = function (block) {
@ -187,16 +149,40 @@ Blockly.JavaScript['ugj_gpio_start_remote'] = function (block) {
/************ */ /************ */
/** GPIO Stop */ /** GPIO Stop */
/************ */ /************ */
// var ugjGpioStart = {
// "type": "ugj_gpio_start",
// "message0": "%{BKY_GPIO_START_TITLE}",
// "previousStatement": null,
// "nextStatement": null,
// "tooltip": "%{BKY_GPIO_START_TOOLTIP}",
// "helpUrl": "",
// "style": "gpio_blocks"
// };
// Blockly.Blocks['ugj_gpio_start'] = {
// init: function () {
// this.jsonInit(ugjGpioStart);
// }
// };
var ugjGpioStop = {
"type": "ugj_gpio_stop",
"message0": "%{BKY_GPIO_STOP_TITLE}",
"previousStatement": null,
"nextStatement": null,
"tooltip": "%{BKY_GPIO_STOP_TOOLTIP}",
"helpUrl": "",
"style": "gpio_blocks"
};
Blockly.Blocks['ugj_gpio_stop'] = { Blockly.Blocks['ugj_gpio_stop'] = {
init: function () { init: function () {
this.appendDummyInput() this.jsonInit(ugjGpioStop);
.appendField("GPIO の後片付けをする"); // this.appendDummyInput()
this.setInputsInline(true); // .appendField("GPIO の後片付けをする");
this.setPreviousStatement(true, null); // this.setInputsInline(true);
this.setNextStatement(true, null); // this.setPreviousStatement(true, null);
this.setStyle('gpio_blocks') // this.setNextStatement(true, null);
this.setTooltip("GPIOとの接続を終了します。"); // this.setStyle('gpio_blocks')
this.setHelpUrl(""); // this.setTooltip("GPIOとの接続を終了します。");
// this.setHelpUrl("");
} }
}; };
Blockly.JavaScript['ugj_gpio_stop'] = function (block) { Blockly.JavaScript['ugj_gpio_stop'] = function (block) {
@ -584,45 +570,6 @@ Blockly.JavaScript['ugj_gpio_i2creadbyte'] = function (block) {
return [code, Blockly.JavaScript.ORDER_NONE]; return [code, Blockly.JavaScript.ORDER_NONE];
}; };
/*********** */
/** DHT11/22 */
/*********** */
Blockly.Blocks['ugj_dht'] = {
init: function () {
this.appendValueInput("gpio")
.setCheck("Number")
.appendField("GPIO");
this.appendDummyInput()
.appendField("の温湿度センサー DHT")
.appendField(new Blockly.FieldDropdown([["11", "11"], ["22", "22"]]), "type")
.appendField("から")
.appendField(new Blockly.FieldVariable("気温"), "temperature")
.appendField(new Blockly.FieldVariable("湿度"), "humidity")
.appendField("を取得");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setStyle('gpio_blocks')
this.setTooltip("温湿度センサー DHT11/DHT22 を使用して気温と湿度を読み取ります。");
this.setHelpUrl("");
}
};
Blockly.JavaScript['ugj_dht'] = function (block) {
var value_gpio = Blockly.JavaScript.valueToCode(block, 'gpio', Blockly.JavaScript.ORDER_ATOMIC);
var dropdown_type = block.getFieldValue('type');
var variable_temperature = Blockly.JavaScript.variableDB_.getName(block.getFieldValue('temperature'), Blockly.Variables.NAME_TYPE);
var variable_humidity = Blockly.JavaScript.variableDB_.getName(block.getFieldValue('humidity'), Blockly.Variables.NAME_TYPE);
let fix = dropdown_type / 11 - 1;
var code = [
`try {`,
`let res = await dht.read(${dropdown_type}, ${value_gpio});`,
`${variable_temperature} = res.temperature.toFixed(${fix});`,
`${variable_humidity} = res.humidity.toFixed(${fix});`,
`} catch (err) {console.error("Failed to read sensor data:", err);}`,
''
].join('\n');
return code;
};
@ -1223,109 +1170,6 @@ Blockly.JavaScript['ugj_sound_play'] = function (block) {
return code; return code;
}; };
/***************************** */
/** Cloud Speech Recognization */
/***************************** */
Blockly.Blocks['ugj_multimedia_cloudspeech_recognition'] = {
init: function () {
this.appendDummyInput()
.appendField("音声認識で")
.appendField(new Blockly.FieldVariable("ことば"), "transcript")
.appendField("を取得する:")
.appendField(new Blockly.FieldDropdown([["一回のみ", "once"], ["継続", "continue"]]), "continuous")
.appendField(new Blockly.FieldCheckbox("TRUE"), "interim")
.appendField("未確定も取得");
this.appendStatementInput("isFinal_do")
.setCheck(null)
.appendField("確定したら");
this.appendStatementInput("isInterim_do")
.setCheck(null)
.appendField("未確定なら");
this.appendStatementInput("onStart_do")
.setCheck(null)
.appendField("開始したら");
this.appendStatementInput("onError_do")
.setCheck(null)
.appendField("停止したら");
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setStyle('multimedia_blocks')
this.setTooltip("Google Cloud Speech API による音声認識を行います。言葉を検知したらステートメントが実行されます。認識途中の暫定結果を取得することもできます。");
this.setHelpUrl("");
}
};
Blockly.JavaScript['ugj_multimedia_cloudspeech_recognition'] = function (block) {
var variable_transcript = Blockly.JavaScript.variableDB_.getName(block.getFieldValue('transcript'), Blockly.Variables.NAME_TYPE);
var dropdown_continuous = block.getFieldValue('continuous');
var checkbox_interim = block.getFieldValue('interim') == 'TRUE';
var statements_isfinal_do = Blockly.JavaScript.statementToCode(block, 'isFinal_do');
var statements_isinterim_do = Blockly.JavaScript.statementToCode(block, 'isInterim_do');
var statements_onStart_do = Blockly.JavaScript.statementToCode(block, 'onStart_do');
var statements_onError_do = Blockly.JavaScript.statementToCode(block, 'onError_do');
var functionName = Blockly.JavaScript.provideFunction_(
'listenTimeout',
[
'const ' + Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_ + ' = () => {',
'clearTimeout(tout);',
'tout = setTimeout(() => {',
`console.log('Timeout.');`,
'recording.stop();',
'}, 15000);',
'}'
]
);
var code = [
`const client = new speech.SpeechClient({`,
`projectId: 'ugjiclass',`,
`keyFilename: './.shared/OCOGE-8a8e7ecac31c.json',`,
`});`,
`const request = {`,
`config: {`,
`encoding: 'LINEAR16',`,
`sampleRateHertz: 16000,`,
`languageCode: 'ja-JP'`,
`},`,
``].join('\n');
if (dropdown_continuous == 'once') code += 'singleUtterance: true,\n';
if (checkbox_interim == true) code += 'interimResults: true,\n';
code += [
`};`,
`var tout;`,
`${functionName}();`,
`const recognizeStream = client`,
`.streamingRecognize(request)`,
`.on('error', console.error)`,
`.on('data', data => {`,
`let result = data.results[0];`,
`if (result && result.alternatives[0]) {`,
`${variable_transcript} = result.alternatives[0].transcript;`,
`if (result.isFinal) {`,
statements_isfinal_do,
`${functionName}();`,
`} else {`,
statements_isinterim_do,
`}`,
`} else {`,
`console.log('Reached transcription time limit.');`,
`recording.stop();`,
'clearTimeout(tout);',
`}`,
`});`,
`const recording = recorder.record({`,
`sampleRate: 16000,`,
`recorder: 'sox',`,
`silence: '0.5',`,
`});`,
`recording`,
`.stream()`,
`.on('error', err => {${statements_onError_do}})`,
`.pipe(recognizeStream);`,
statements_onStart_do,
''
].join('\n');
return code;
};
/*************************** */ /*************************** */
/** Web Speech Recognization */ /** Web Speech Recognization */
/*************************** */ /*************************** */
@ -1353,7 +1197,7 @@ Blockly.Blocks['ugj_multimedia_webspeech_recognition'] = {
this.setInputsInline(true); this.setInputsInline(true);
this.setPreviousStatement(true); this.setPreviousStatement(true);
this.setStyle('multimedia_blocks') this.setStyle('multimedia_blocks')
this.setTooltip("Web Speech API による音声認識を行います。言葉を検知したらステートメントが実行されます。認識途中の暫定結果を取得することもできます。"); this.setTooltip("Web Speech API による音声認識を行います。言葉を検知したらステートメントが実行されます。認識途中の暫定結果を取得することもできます。※Web版のみの機能です。");
this.setHelpUrl(""); this.setHelpUrl("");
} }
}; };
@ -1996,9 +1840,6 @@ Blockly.Blocks['ugj_event_answer'] = {
init: function () { init: function () {
this.appendValueInput("question") this.appendValueInput("question")
.setCheck("String"); .setCheck("String");
// this.appendValueInput("sec")
// .setCheck("Number")
// .appendField("と");
this.appendDummyInput() this.appendDummyInput()
.appendField("ときいて") .appendField("ときいて")
.appendField(new Blockly.FieldVariable("答え"), "answer") .appendField(new Blockly.FieldVariable("答え"), "answer")
@ -2013,7 +1854,6 @@ Blockly.Blocks['ugj_event_answer'] = {
}; };
Blockly.JavaScript['ugj_event_answer'] = function (block) { Blockly.JavaScript['ugj_event_answer'] = function (block) {
var value_question = Blockly.JavaScript.valueToCode(block, 'question', Blockly.JavaScript.ORDER_ATOMIC); var value_question = Blockly.JavaScript.valueToCode(block, 'question', Blockly.JavaScript.ORDER_ATOMIC);
// var value_sec = Blockly.JavaScript.valueToCode(block, 'sec', Blockly.JavaScript.ORDER_ATOMIC);
var variable_answer = Blockly.JavaScript.variableDB_.getName(block.getFieldValue('answer'), Blockly.Variables.NAME_TYPE); var variable_answer = Blockly.JavaScript.variableDB_.getName(block.getFieldValue('answer'), Blockly.Variables.NAME_TYPE);
var statements_do = Blockly.JavaScript.statementToCode(block, 'do'); var statements_do = Blockly.JavaScript.statementToCode(block, 'do');
var code = [ var code = [
@ -2126,24 +1966,7 @@ Blockly.JavaScript['ugj_child_gesture'] = function (block) {
var code = `'python3', ['./scripts/gesture.py']`; var code = `'python3', ['./scripts/gesture.py']`;
return [code, Blockly.JavaScript.ORDER_NONE]; return [code, Blockly.JavaScript.ORDER_NONE];
}; };
// face.py
Blockly.Blocks['ugj_child_facepy'] = {
init: function () {
this.appendDummyInput()
.appendField("face.pyカメラ画像を表示")
.appendField(new Blockly.FieldDropdown([["しない", " "], ["する", "-w"]]), "win");
this.setOutput(true, "shcmd");
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
this.setStyle('special_blocks')
this.setTooltip("OpenCVによる顔認識 Python2スクリプト - 顔のX座標を返します。");
this.setHelpUrl("");
}
};
Blockly.JavaScript['ugj_child_facepy'] = function (block) {
var dropdown_win = block.getFieldValue('win');
var code = `'python', ['./scripts/face.py', '${dropdown_win}']`;
return [code, Blockly.JavaScript.ORDER_NONE];
};
// open jtalk // open jtalk
Blockly.Blocks['ugj_child_openjtalk'] = { Blockly.Blocks['ugj_child_openjtalk'] = {
init: function () { init: function () {
@ -2364,29 +2187,6 @@ Blockly.JavaScript['ugj_child_testjs'] = function (block) {
// TODO: Change ORDER_NONE to the correct strength. // TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.JavaScript.ORDER_NONE]; return [code, Blockly.JavaScript.ORDER_NONE];
}; };
// Debug *Danger*
Blockly.Blocks['ugj_child_debug'] = {
init: function () {
this.appendValueInput("cmd")
.setCheck("String")
.appendField("cmd");
this.appendValueInput("opt")
.setCheck("Array")
.appendField("opt");
this.setInputsInline(true);
this.setOutput(true, "shcmd");
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
this.setStyle('special_blocks')
this.setTooltip("さわるなきけん");
this.setHelpUrl("");
}
};
Blockly.JavaScript['ugj_child_debug'] = function (block) {
var value_cmd = Blockly.JavaScript.valueToCode(block, 'cmd', Blockly.JavaScript.ORDER_ATOMIC);
var value_opt = Blockly.JavaScript.valueToCode(block, 'opt', Blockly.JavaScript.ORDER_ATOMIC);
var code = `${value_cmd}, ${value_opt}`;
return [code, Blockly.JavaScript.ORDER_NONE];
};
/******************* */ /******************* */
/** Show Blackboard ** */ /** Show Blackboard ** */

View File

@ -13,12 +13,6 @@ var network_color = '340';
var special_color = '20'; var special_color = '20';
var snippets_color = '90'; var snippets_color = '90';
// Blockly.Msg.UGJ_GPIO_HUE = 0;//FF7799
// Blockly.Msg.UGJ_MULTIMEDIA_HUE = 240;//CF63CF
// Blockly.Msg.UGJ_NETWORK_HUE = 340;//"#54C4EA"
// Blockly.Msg.UGJ_SPECIAL_HUE = 20;//"#0FBD8C"
// Blockly.Msg.UGJ_SNIPPETS_HUE = 90;
var theme = Blockly.Theme.defineTheme('ocoge', { var theme = Blockly.Theme.defineTheme('ocoge', {
'base': Blockly.Themes.Classic, 'base': Blockly.Themes.Classic,
'startHats': true, 'startHats': true,
@ -70,6 +64,14 @@ Blockly.Msg["CONTROLS_REPEAT_INPUT_DO"] = "";
Blockly.Msg["MATH_CHANGE_TITLE"] = "変数 %1 を %2 増やす"; Blockly.Msg["MATH_CHANGE_TITLE"] = "変数 %1 を %2 増やす";
Blockly.Msg["VARIABLES_SET"] = "変数 %1 を %2 にする"; Blockly.Msg["VARIABLES_SET"] = "変数 %1 を %2 にする";
Blockly.Msg["TEXT_PRINT_TITLE"] = "ダイアログに %1 を表示"; Blockly.Msg["TEXT_PRINT_TITLE"] = "ダイアログに %1 を表示";
Blockly.Msg["LOGIC_BOOLEAN_FALSE"] = "偽";
Blockly.Msg["LOGIC_BOOLEAN_TOOLTIP"] = "真 または 偽 を返します。";
Blockly.Msg["LOGIC_BOOLEAN_TRUE"] = "真";
// ローカライズ対応の準備
Blockly.Msg["GPIO_START_TITLE"] = "GPIO を使えるようにする";
Blockly.Msg["GPIO_START_TOOLTIP"] = "GPIOを初期化して接続します。";
Blockly.Msg["GPIO_STOP_TITLE"] = "GPIO の後片付けをする";
Blockly.Msg["GPIO_STOP_TOOLTIP"] = "GPIOとの接続を終了します。";
// Customize Toolbox // Customize Toolbox
class CustomCategory extends Blockly.ToolboxCategory { class CustomCategory extends Blockly.ToolboxCategory {
@ -110,7 +112,7 @@ Blockly.registry.register(
//============ User Customize End =============== //============ User Customize End ===============
//背景canvasの準備 //背景canvasとマスコットの準備
const ugj_canvasBgImg = (imgSrc, x, y) => { //x,y == -1: center or middle const ugj_canvasBgImg = (imgSrc, x, y) => { //x,y == -1: center or middle
let el = document.getElementById('canvas_bg'); let el = document.getElementById('canvas_bg');
let ctx = el.getContext('2d'); let ctx = el.getContext('2d');
@ -132,9 +134,6 @@ const ugj_canvasBgImg = (imgSrc, x, y) => { //x,y == -1: center or middle
ctx.drawImage(img, x, y); ctx.drawImage(img, x, y);
} }
}; };
// マスコット
// ugj_canvasBgImg("./img/mimmy.png?" + new Date().getTime()); // ミミィ
// ugj_canvasBgImg("./img/cogechee.png?" + new Date().getTime(), -1,-1); // こげちー
// HTML部品のインスタンス - 画面上の必要な部品はすべてここで取得しておく // HTML部品のインスタンス - 画面上の必要な部品はすべてここで取得しておく
ugjel_displayArea = document.getElementById('display_area'); // ディスプレイ部 ugjel_displayArea = document.getElementById('display_area'); // ディスプレイ部