}
}
}
+ block(type="delay") {
+ value(name="millisec") {
+ shadow(type="math_number") {
+ field(name="NUM") {
+ '1000'
+ }
+ }
+ }
+ }
block(type="math_arithmetic") {
value(name="A") {
shadow(type="math_number") {
async _out => {
div.container-fluid {
div.row(style="margin-top: 10px; margin-bottom: 0px;") {
- div.col-md-4 {
- h1(style="margin-top: 0px;") {
+ div.col-md-3 {
+ h2(style="margin-top: 0px;") {
'MiRobot Demonstration'
}
}
- div.col-md-6(style="text-align: right;") {
+ div.col-md-5(style="text-align: right;") {
div.form-group.form-inline {
label(style="margin-right: 6px;") {
'Connected device:'
}
}
}
+ div.col-md-2(style="text-align: right;") {
+ button.btn#home(type="button" style="width: 50%;") {
+ 'Home'
+ }
+ }
div.col-md-2(style="text-align: right;") {
button.btn#run(type="button" style="width: 50%;") {
'Run'
"previousStatement": null,
"nextStatement": null,
"colour": "%{BKY_LOGIC_HUE}"
+ },
+ {
+ "type": "delay",
+ "message0": "delay %1",
+ "args0": [
+ {"type": "input_value", "name": "millisecs", "check": "Number"},
+ ],
+ "inputsInline": true,
+ "previousStatement": null,
+ "nextStatement": null,
+ "colour": "%{BKY_LOGIC_HUE}"
}
+
]);
return 'await deviceGripper(' + d + ');\n'
};
+ Blockly.JavaScript['delay'] = function(block) {
+ var millisecs = Blockly.JavaScript.valueToCode(block, 'millisecs',
+ Blockly.JavaScript.ORDER_COMMA) || '0';
+ return 'await delay(' + millisecs + ');\n'
+ };
+
var deviceA = 90;
var deviceB = 90;
var deviceC = 90;
}
);
+ document.getElementById('home').addEventListener(
+ 'click',
+ async () => {
+ if (device && !deviceBusy) {
+ deviceBusy = true;
+
+ deviceA = 90;
+ deviceB = 105;
+ deviceC = 70;
+ deviceD = 80;
+ deviceE = 90;
+ deviceF = 90;
+ setToolboxTimeout();
+
+ A.value = 90
+ B.value = 105
+ C.value = 70
+ D.value = 80
+ E.value = 90
+ F.value = 90
+
+ await deviceSend("A090010\nB105010\nC070010\nD080010\nE090010\nF090010\n");
+ await delay(90 * 50);
+
+ deviceBusy = false;
+ }
+ }
+ );
+
document.getElementById('run').addEventListener(
'click',
async () => {