small code fixes

This commit is contained in:
Mario 2020-11-16 09:27:26 +01:00
parent 13d2d3d301
commit c17fc8a50f
4 changed files with 11 additions and 11 deletions

View File

@ -115,7 +115,7 @@ Blockly.Blocks['controls_if'] = {
elseStatementConnection = clauseBlock.statementConnection_;
break;
default:
throw 'Unknown block type.';
throw new Error('Unknown block type.');
}
clauseBlock = clauseBlock.nextConnection &&
clauseBlock.nextConnection.targetBlock();
@ -153,7 +153,7 @@ Blockly.Blocks['controls_if'] = {
inputDo && inputDo.connection.targetConnection;
break;
default:
throw 'Unknown block type.';
throw new Error('Unknown block type.');
}
clauseBlock = clauseBlock.nextConnection &&
clauseBlock.nextConnection.targetBlock();

View File

@ -74,14 +74,14 @@ Blockly.Arduino['controls_if'] = function (Block) {
conditionCode +
') {\n' +
branchCode +
'}';
'}\n';
++n;
} while (Block.getInput('IF' + n));
if (Block.getInput('ELSE')) {
branchCode = Blockly.Arduino.statementToCode(Block, 'ELSE');
code += ' else {\n' + branchCode + '}';
code += ' else {\n' + branchCode + '}\n';
}
return code + '\n';
};
@ -106,14 +106,14 @@ Blockly.Arduino['controls_ifelse'] = function (Block) {
conditionCode +
') {\n' +
branchCode +
'}';
'}\n';
++n;
} while (Block.getInput('IF' + n));
if (Block.getInput('ELSE')) {
branchCode = Blockly.Arduino.statementToCode(Block, 'ELSE');
code += ' else {\n' + branchCode + '}';
code += ' else {\n' + branchCode + '}\n';
}
return code + '\n';
}

View File

@ -19,10 +19,10 @@ Blockly.Arduino.sensebox_display_clearDisplay = function () {
};
Blockly.Arduino.sensebox_display_printDisplay = function () {
var x = Blockly.Arduino.valueToCode(this, 'X', Blockly.Arduino.ORDER_ATOMIC) || '0'
var y = Blockly.Arduino.valueToCode(this, 'Y', Blockly.Arduino.ORDER_ATOMIC) || '0'
var x = this.getFieldValue('X');
var y = this.getFieldValue('Y');
var printDisplay = Blockly.Arduino.valueToCode(this, 'printDisplay', Blockly.Arduino.ORDER_ATOMIC) || '"Keine Eingabe"';
var size = Blockly.Arduino.valueToCode(this, 'SIZE', Blockly.Arduino.ORDER_ATOMIC) || '1'
var size = this.getFieldValue('SIZE');
var color = this.getFieldValue('COLOR');
var code = 'display.setCursor(' + x + ',' + y + ');\n';
code += 'display.setTextSize(' + size + ');\n';

View File

@ -272,13 +272,13 @@ Blockly.Arduino.sensebox_scd30 = function () {
var code = '';
switch (dropdown) {
case 'temperature':
code = 'aireSensor.getTemperature()';
code = 'airSensor.getTemperature()';
break;
case 'humidity':
code = 'airSensor.getHumiditiy()';
break;
case 'CO2':
code = 'aireSensor.getCO2()';
code = 'airSensor.getCO2()';
break;
default:
code = ''