solve compiling warnings
This commit is contained in:
parent
440622a66c
commit
4e2b25947d
@ -3,10 +3,8 @@ import PropTypes from 'prop-types';
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { onChangeWorkspace } from '../../actions/workspaceActions';
|
import { onChangeWorkspace } from '../../actions/workspaceActions';
|
||||||
|
|
||||||
import BlocklyComponent, { Block, Value, Field, Shadow, Category } from './';
|
import BlocklyComponent from './';
|
||||||
import * as Blockly from 'blockly/core';
|
import * as Blockly from 'blockly/core';
|
||||||
//import * as De from './msg/de'; // de locale files
|
|
||||||
import * as En from './msg/en'; // en locale files
|
|
||||||
import './blocks/index';
|
import './blocks/index';
|
||||||
import './generator/index';
|
import './generator/index';
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
*
|
*
|
||||||
* TODO: maybe change this to a "PIN" BlocklyType
|
* TODO: maybe change this to a "PIN" BlocklyType
|
||||||
*/
|
*/
|
||||||
import { defineBlocksWithJsonArray } from 'blockly';
|
|
||||||
import Blockly from 'blockly/core';
|
import Blockly from 'blockly/core';
|
||||||
import { selectedBoard } from '../helpers/board'
|
import { selectedBoard } from '../helpers/board'
|
||||||
import * as Types from '../helpers/types'
|
import * as Types from '../helpers/types'
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { defineBlocksWithJsonArray } from 'blockly';
|
|
||||||
import Blockly from 'blockly/core';
|
import Blockly from 'blockly/core';
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
|
|
||||||
import Blockly from 'blockly';
|
|
@ -1,6 +1,5 @@
|
|||||||
import * as Blockly from 'blockly/core';
|
import * as Blockly from 'blockly/core';
|
||||||
import { getColour } from '../helpers/colour';
|
import { getColour } from '../helpers/colour';
|
||||||
import Block from 'blockly'
|
|
||||||
|
|
||||||
|
|
||||||
Blockly.Blocks['sensebox_osem_connection'] = {
|
Blockly.Blocks['sensebox_osem_connection'] = {
|
||||||
@ -28,8 +27,7 @@ Blockly.Blocks['sensebox_osem_connection'] = {
|
|||||||
this.setNextStatement(true, null);
|
this.setNextStatement(true, null);
|
||||||
},
|
},
|
||||||
onchange: function (e) {
|
onchange: function (e) {
|
||||||
var block = this;
|
|
||||||
var blocks = block.getDescendants()
|
|
||||||
//Blockly.Blocks.sensebox.getDescendants = blocks;
|
//Blockly.Blocks.sensebox.getDescendants = blocks;
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -54,7 +52,7 @@ Blockly.Blocks['sensebox_osem_connection'] = {
|
|||||||
updateShape_: function () {
|
updateShape_: function () {
|
||||||
var extraFieldExist = this.getFieldValue('gps');
|
var extraFieldExist = this.getFieldValue('gps');
|
||||||
var input = this.getFieldValue('type');
|
var input = this.getFieldValue('type');
|
||||||
if ((input == 'Mobile') && extraFieldExist == null) {
|
if ((input === 'Mobile') && extraFieldExist === null) {
|
||||||
this.appendValueInput('lat', 'Number')
|
this.appendValueInput('lat', 'Number')
|
||||||
.appendField(Blockly.Msg.senseBox_gps_lat, 'gps');
|
.appendField(Blockly.Msg.senseBox_gps_lat, 'gps');
|
||||||
this.appendValueInput('lng', 'Number')
|
this.appendValueInput('lng', 'Number')
|
||||||
@ -65,7 +63,7 @@ Blockly.Blocks['sensebox_osem_connection'] = {
|
|||||||
.appendField(Blockly.Msg.senseBox_gps_timeStamp);
|
.appendField(Blockly.Msg.senseBox_gps_timeStamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input == 'Stationary' && extraFieldExist != null) {
|
if (input === 'Stationary' && extraFieldExist !== null) {
|
||||||
this.removeInput('lat');
|
this.removeInput('lat');
|
||||||
this.removeInput('lng');
|
this.removeInput('lng');
|
||||||
this.removeInput('altitude');
|
this.removeInput('altitude');
|
||||||
@ -98,7 +96,7 @@ Blockly.Blocks['sensebox_send_to_osem'] = {
|
|||||||
// Is the block nested in a loop?
|
// Is the block nested in a loop?
|
||||||
var block = this;
|
var block = this;
|
||||||
do {
|
do {
|
||||||
if (this.LOOP_TYPES.indexOf(block.type) != -1) {
|
if (this.LOOP_TYPES.indexOf(block.type) !== -1) {
|
||||||
legal = true;
|
legal = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ Blockly.Blocks['sensebox_sensor_pressure'] = {
|
|||||||
init: function () {
|
init: function () {
|
||||||
var dropdownOptions = [[Blockly.Msg.senseBox_pressure, "Pressure"], [Blockly.Msg.senseBox_temp, "Temperature"], [Blockly.Msg.senseBox_gps_alt, "Altitude"]];
|
var dropdownOptions = [[Blockly.Msg.senseBox_pressure, "Pressure"], [Blockly.Msg.senseBox_temp, "Temperature"], [Blockly.Msg.senseBox_gps_alt, "Altitude"]];
|
||||||
var dropdown = new Blockly.FieldDropdown(dropdownOptions, function (option) {
|
var dropdown = new Blockly.FieldDropdown(dropdownOptions, function (option) {
|
||||||
var input = (option == 'Pressure') || (option == 'Temperature') || (option == 'Altitude');
|
var input = (option === 'Pressure') || (option === 'Temperature') || (option === 'Altitude');
|
||||||
this.sourceBlock_.updateShape_(input);
|
this.sourceBlock_.updateShape_(input);
|
||||||
});
|
});
|
||||||
this.appendDummyInput()
|
this.appendDummyInput()
|
||||||
@ -132,7 +132,7 @@ Blockly.Blocks['sensebox_sensor_pressure'] = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
domToMutation: function (xmlElement) {
|
domToMutation: function (xmlElement) {
|
||||||
var input = (xmlElement.getAttribute('port'));
|
(xmlElement.getAttribute('port'));
|
||||||
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@ -156,7 +156,7 @@ Blockly.Blocks['sensebox_sensor_pressure'] = {
|
|||||||
updateShape_: function () {
|
updateShape_: function () {
|
||||||
var extraFieldExist = this.getFieldValue('referencePressure');
|
var extraFieldExist = this.getFieldValue('referencePressure');
|
||||||
var input = this.getFieldValue('NAME');
|
var input = this.getFieldValue('NAME');
|
||||||
if (input == 'Altitude' && extraFieldExist == null) {
|
if (input === 'Altitude' && extraFieldExist === null) {
|
||||||
this.appendDummyInput('extraField')
|
this.appendDummyInput('extraField')
|
||||||
.setAlign(Blockly.ALIGN_RIGHT)
|
.setAlign(Blockly.ALIGN_RIGHT)
|
||||||
.appendField(Blockly.Msg.senseBox_pressure_referencePressure)
|
.appendField(Blockly.Msg.senseBox_pressure_referencePressure)
|
||||||
@ -164,13 +164,13 @@ Blockly.Blocks['sensebox_sensor_pressure'] = {
|
|||||||
.appendField(Blockly.Msg.senseBox_pressure_referencePressure_dim);
|
.appendField(Blockly.Msg.senseBox_pressure_referencePressure_dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((input == 'Pressure' || input == 'Temperature') && extraFieldExist != null) {
|
if ((input === 'Pressure' || input === 'Temperature') && extraFieldExist !== null) {
|
||||||
this.removeInput('extraField');
|
this.removeInput('extraField');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getBlockType: function () {
|
getBlockType: function () {
|
||||||
var input = this.getFieldValue('NAME');
|
var input = this.getFieldValue('NAME');
|
||||||
if (input == 'Temperature') {
|
if (input === 'Temperature') {
|
||||||
return Types.DECIMAL.typeId;
|
return Types.DECIMAL.typeId;
|
||||||
} else {
|
} else {
|
||||||
return Types.LARGE_NUMBER.typeId;
|
return Types.LARGE_NUMBER.typeId;
|
||||||
@ -215,7 +215,7 @@ Blockly.Blocks['sensebox_sensor_ultrasonic_ranger'] = {
|
|||||||
var dropdownOptions = [[Blockly.Msg.senseBox_ultrasonic_port_A, 'A'],
|
var dropdownOptions = [[Blockly.Msg.senseBox_ultrasonic_port_A, 'A'],
|
||||||
[Blockly.Msg.senseBox_ultrasonic_port_B, 'B'], [Blockly.Msg.senseBox_ultrasonic_port_C, 'C']];
|
[Blockly.Msg.senseBox_ultrasonic_port_B, 'B'], [Blockly.Msg.senseBox_ultrasonic_port_C, 'C']];
|
||||||
var dropdown = new Blockly.FieldDropdown(dropdownOptions, function (option) {
|
var dropdown = new Blockly.FieldDropdown(dropdownOptions, function (option) {
|
||||||
var input = (option == 'A') || (option == 'B') || (option == 'C');
|
var input = (option === 'A') || (option === 'B') || (option === 'C');
|
||||||
this.sourceBlock_.updateShape_(input);
|
this.sourceBlock_.updateShape_(input);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -241,7 +241,7 @@ Blockly.Blocks['sensebox_sensor_ultrasonic_ranger'] = {
|
|||||||
* @this Blockly.Block
|
* @this Blockly.Block
|
||||||
*/
|
*/
|
||||||
domToMutation: function (xmlElement) {
|
domToMutation: function (xmlElement) {
|
||||||
var input = (xmlElement.getAttribute('port'));
|
(xmlElement.getAttribute('port'));
|
||||||
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@ -277,6 +277,8 @@ Blockly.Blocks['sensebox_sensor_ultrasonic_ranger'] = {
|
|||||||
this.setFieldValue('5', 'ultrasonic_trigger');
|
this.setFieldValue('5', 'ultrasonic_trigger');
|
||||||
this.setFieldValue('6', 'ultrasonic_echo');
|
this.setFieldValue('6', 'ultrasonic_echo');
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Blockly from 'blockly';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
// https://developers.google.com/blockly/guides/create-custom-blocks/generating-code
|
// https://developers.google.com/blockly/guides/create-custom-blocks/generating-code
|
||||||
|
|
||||||
import * as Blockly from 'blockly/core';
|
import * as Blockly from 'blockly/core';
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Arduino code generator.
|
* Arduino code generator.
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import * as Blockly from 'blockly/core';
|
import * as Blockly from 'blockly/core';
|
||||||
import { Block } from 'blockly';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function for 'set pin' (X) to a state (Y).
|
* Function for 'set pin' (X) to a state (Y).
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import * as Blockly from 'blockly/core';
|
import * as Blockly from 'blockly/core';
|
||||||
import { Block } from 'blockly';
|
|
||||||
|
|
||||||
Blockly.Arduino['logic_boolean'] = function (Block) {
|
Blockly.Arduino['logic_boolean'] = function (Block) {
|
||||||
// Boolean values true and false.
|
// Boolean values true and false.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as Blockly from 'blockly/core';
|
import * as Blockly from 'blockly/core';
|
||||||
import { Block } from 'blockly';
|
|
||||||
|
|
||||||
Blockly['Arduino']['controls_repeat_ext'] = function (Block) {
|
Blockly['Arduino']['controls_repeat_ext'] = function (Block) {
|
||||||
// Repeat n times.
|
// Repeat n times.
|
||||||
@ -111,6 +111,8 @@ Blockly['Arduino']['controls_flow_statements'] = function (Block) {
|
|||||||
return 'break;\n';
|
return 'break;\n';
|
||||||
case 'CONTINUE':
|
case 'CONTINUE':
|
||||||
return 'continue;\n';
|
return 'continue;\n';
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
throw Error('Unknown flow statement.');
|
throw Error('Unknown flow statement.');
|
||||||
};
|
};
|
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
import * as Blockly from 'blockly/core';
|
import * as Blockly from 'blockly/core';
|
||||||
import { Block } from 'blockly';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @license Licensed under the Apache License, Version 2.0 (the "License"):
|
* @license Licensed under the Apache License, Version 2.0 (the "License"):
|
||||||
@ -23,9 +22,9 @@ import { Block } from 'blockly';
|
|||||||
Blockly.Arduino['math_number'] = function (block) {
|
Blockly.Arduino['math_number'] = function (block) {
|
||||||
// Numeric value.
|
// Numeric value.
|
||||||
var code = parseFloat(block.getFieldValue('NUM'));
|
var code = parseFloat(block.getFieldValue('NUM'));
|
||||||
if (code == Infinity) {
|
if (code === Infinity) {
|
||||||
code = 'INFINITY';
|
code = 'INFINITY';
|
||||||
} else if (code == -Infinity) {
|
} else if (code === -Infinity) {
|
||||||
code = '-INFINITY';
|
code = '-INFINITY';
|
||||||
}
|
}
|
||||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||||
@ -71,21 +70,21 @@ Blockly.Arduino['math_single'] = function (block) {
|
|||||||
var operator = block.getFieldValue('OP');
|
var operator = block.getFieldValue('OP');
|
||||||
var code;
|
var code;
|
||||||
var arg;
|
var arg;
|
||||||
if (operator == 'NEG') {
|
if (operator === 'NEG') {
|
||||||
// Negation is a special case given its different operator precedents.
|
// Negation is a special case given its different operator precedents.
|
||||||
arg = Blockly.Arduino.valueToCode(block, 'NUM',
|
arg = Blockly.Arduino.valueToCode(block, 'NUM',
|
||||||
Blockly.Arduino.ORDER_UNARY_PREFIX) || '0';
|
Blockly.Arduino.ORDER_UNARY_PREFIX) || '0';
|
||||||
if (arg[0] == '-') {
|
if (arg[0] === '-') {
|
||||||
// --3 is not legal in C++ in this context.
|
// --3 is not legal in C++ in this context.
|
||||||
arg = ' ' + arg;
|
arg = ' ' + arg;
|
||||||
}
|
}
|
||||||
code = '-' + arg;
|
code = '-' + arg;
|
||||||
return [code, Blockly.Arduino.ORDER_UNARY_PREFIX];
|
return [code, Blockly.Arduino.ORDER_UNARY_PREFIX];
|
||||||
}
|
}
|
||||||
if (operator == 'ABS' || operator.substring(0, 5) == 'ROUND') {
|
if (operator === 'ABS' || operator.substring(0, 5) === 'ROUND') {
|
||||||
arg = Blockly.Arduino.valueToCode(block, 'NUM',
|
arg = Blockly.Arduino.valueToCode(block, 'NUM',
|
||||||
Blockly.Arduino.ORDER_UNARY_POSTFIX) || '0';
|
Blockly.Arduino.ORDER_UNARY_POSTFIX) || '0';
|
||||||
} else if (operator == 'SIN' || operator == 'COS' || operator == 'TAN') {
|
} else if (operator === 'SIN' || operator === 'COS' || operator === 'TAN') {
|
||||||
arg = Blockly.Arduino.valueToCode(block, 'NUM',
|
arg = Blockly.Arduino.valueToCode(block, 'NUM',
|
||||||
Blockly.Arduino.ORDER_MULTIPLICATIVE) || '0';
|
Blockly.Arduino.ORDER_MULTIPLICATIVE) || '0';
|
||||||
} else {
|
} else {
|
||||||
@ -127,6 +126,8 @@ Blockly.Arduino['math_single'] = function (block) {
|
|||||||
case 'TAN':
|
case 'TAN':
|
||||||
code = 'tan(' + arg + ' / 180 * Math.PI)';
|
code = 'tan(' + arg + ' / 180 * Math.PI)';
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (code) {
|
if (code) {
|
||||||
return [code, Blockly.Arduino.ORDER_UNARY_POSTFIX];
|
return [code, Blockly.Arduino.ORDER_UNARY_POSTFIX];
|
||||||
@ -146,7 +147,7 @@ Blockly.Arduino['math_single'] = function (block) {
|
|||||||
code = 'atan(' + arg + ') / M_PI * 180';
|
code = 'atan(' + arg + ') / M_PI * 180';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw 'Unknown math operator: ' + operator;
|
throw new Error('Unknown math operator: ' + operator);
|
||||||
}
|
}
|
||||||
return [code, Blockly.Arduino.ORDER_MULTIPLICATIVE];
|
return [code, Blockly.Arduino.ORDER_MULTIPLICATIVE];
|
||||||
};
|
};
|
||||||
@ -184,7 +185,7 @@ Blockly.Arduino['math_number_property'] = function (block) {
|
|||||||
Blockly.Arduino.ORDER_MULTIPLICATIVE) || '0';
|
Blockly.Arduino.ORDER_MULTIPLICATIVE) || '0';
|
||||||
var dropdown_property = block.getFieldValue('PROPERTY');
|
var dropdown_property = block.getFieldValue('PROPERTY');
|
||||||
var code;
|
var code;
|
||||||
if (dropdown_property == 'PRIME') {
|
if (dropdown_property === 'PRIME') {
|
||||||
var func = [
|
var func = [
|
||||||
'boolean ' + Blockly.Arduino.DEF_FUNC_NAME + '(int n) {',
|
'boolean ' + Blockly.Arduino.DEF_FUNC_NAME + '(int n) {',
|
||||||
' // https://en.wikipedia.org/wiki/Primality_test#Naive_methods',
|
' // https://en.wikipedia.org/wiki/Primality_test#Naive_methods',
|
||||||
@ -232,6 +233,8 @@ Blockly.Arduino['math_number_property'] = function (block) {
|
|||||||
Blockly.Arduino.ORDER_MULTIPLICATIVE) || '0';
|
Blockly.Arduino.ORDER_MULTIPLICATIVE) || '0';
|
||||||
code = number_to_check + ' % ' + divisor + ' == 0';
|
code = number_to_check + ' % ' + divisor + ' == 0';
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return [code, Blockly.Arduino.ORDER_EQUALITY];
|
return [code, Blockly.Arduino.ORDER_EQUALITY];
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as Blockly from 'blockly/core';
|
import * as Blockly from 'blockly/core';
|
||||||
import { Block } from 'blockly';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Code generator to add code into the setup() and loop() functions.
|
* Code generator to add code into the setup() and loop() functions.
|
||||||
@ -13,7 +13,7 @@ Blockly.Arduino['arduino_functions'] = function (block) {
|
|||||||
var targetBlock = block.getInputTargetBlock(name);
|
var targetBlock = block.getInputTargetBlock(name);
|
||||||
var code = Blockly.Arduino.blockToCode(targetBlock);
|
var code = Blockly.Arduino.blockToCode(targetBlock);
|
||||||
if (typeof code != 'string') {
|
if (typeof code != 'string') {
|
||||||
throw 'Expecting code from statement block "' + targetBlock.type + '".';
|
throw new Error('Expecting code from statement block "' + targetBlock.type + '".');
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import Blockly, { Blocks } from 'blockly';
|
import Blockly from 'blockly';
|
||||||
import { getColour } from '../helpers/colour'
|
|
||||||
import Block from 'blockly';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,7 +18,7 @@ Blockly.Arduino.sensebox_osem_connection = function (Block) {
|
|||||||
var box_id = this.getFieldValue('BoxID');
|
var box_id = this.getFieldValue('BoxID');
|
||||||
var host = this.getFieldValue('host');
|
var host = this.getFieldValue('host');
|
||||||
var branch = Blockly.Arduino.statementToCode(Block, 'DO');
|
var branch = Blockly.Arduino.statementToCode(Block, 'DO');
|
||||||
var blocks = Blockly.Block.getDescendants;
|
//var blocks = Blockly.Block.getDescendants;
|
||||||
var type = this.getFieldValue('type');
|
var type = this.getFieldValue('type');
|
||||||
var ssl = this.getFieldValue('SSL');
|
var ssl = this.getFieldValue('SSL');
|
||||||
var port = 0;
|
var port = 0;
|
||||||
@ -36,10 +34,10 @@ Blockly.Arduino.sensebox_osem_connection = function (Block) {
|
|||||||
Blockly.Arduino.definitions_['num_sensors'] = 'static const uint8_t NUM_SENSORS = ' + num_sensors + ';'
|
Blockly.Arduino.definitions_['num_sensors'] = 'static const uint8_t NUM_SENSORS = ' + num_sensors + ';'
|
||||||
Blockly.Arduino.definitions_['SenseBoxID'] = 'const char SENSEBOX_ID [] PROGMEM = "' + box_id + '";';
|
Blockly.Arduino.definitions_['SenseBoxID'] = 'const char SENSEBOX_ID [] PROGMEM = "' + box_id + '";';
|
||||||
Blockly.Arduino.definitions_['host'] = 'const char server [] PROGMEM =' + host + ';';
|
Blockly.Arduino.definitions_['host'] = 'const char server [] PROGMEM =' + host + ';';
|
||||||
if (ssl == 'TRUE') {
|
if (ssl === 'TRUE') {
|
||||||
Blockly.Arduino.definitions_['WiFiSSLClient'] = 'WiFiSSLClient client;';
|
Blockly.Arduino.definitions_['WiFiSSLClient'] = 'WiFiSSLClient client;';
|
||||||
port = 443;
|
port = 443;
|
||||||
} else if (ssl == 'FALSE') {
|
} else if (ssl === 'FALSE') {
|
||||||
Blockly.Arduino.definitions_['WiFiClient'] = 'WiFiClient client;';
|
Blockly.Arduino.definitions_['WiFiClient'] = 'WiFiClient client;';
|
||||||
port = 80;
|
port = 80;
|
||||||
}
|
}
|
||||||
@ -170,7 +168,7 @@ Blockly.Arduino.sensebox_osem_connection = function (Block) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
var code = '';
|
code = '';
|
||||||
code += branch;
|
code += branch;
|
||||||
code += 'submitValues(' + lat + ',' + lng + ',' + altitude + ',' + timestamp + ');\n';
|
code += 'submitValues(' + lat + ',' + lng + ',' + altitude + ',' + timestamp + ');\n';
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import Blockly from 'blockly';
|
import Blockly from 'blockly';
|
||||||
import { getColour } from '../helpers/colour';
|
|
||||||
import { selectedBoard } from '../helpers/board';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HDC1080 Temperature and Humidity Sensor
|
* HDC1080 Temperature and Humidity Sensor
|
||||||
@ -23,16 +21,17 @@ Blockly.Arduino.sensebox_sensor_temp_hum = function () {
|
|||||||
|
|
||||||
Blockly.Arduino.sensebox_sensor_uv_light = function () {
|
Blockly.Arduino.sensebox_sensor_uv_light = function () {
|
||||||
var dropdown_name = this.getFieldValue('NAME');
|
var dropdown_name = this.getFieldValue('NAME');
|
||||||
|
let code = '';
|
||||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||||
if (dropdown_name === 'UvIntensity') {
|
if (dropdown_name === 'UvIntensity') {
|
||||||
Blockly.Arduino.definitions_['define_veml'] = 'VEML6070 veml;'
|
Blockly.Arduino.definitions_['define_veml'] = 'VEML6070 veml;'
|
||||||
Blockly.Arduino.setupCode_['sensebox_sensor_uv_light'] = 'veml.begin();'
|
Blockly.Arduino.setupCode_['sensebox_sensor_uv_light'] = 'veml.begin();'
|
||||||
var code = 'veml.get' + dropdown_name + '()';
|
code = 'veml.get' + dropdown_name + '()';
|
||||||
}
|
}
|
||||||
if (dropdown_name === 'Illuminance') {
|
if (dropdown_name === 'Illuminance') {
|
||||||
Blockly.Arduino.definitions_['define_tsl'] = 'TSL45315 tsl;'
|
Blockly.Arduino.definitions_['define_tsl'] = 'TSL45315 tsl;'
|
||||||
Blockly.Arduino.setupCode_['sensebox_sensor_illuminance'] = 'tsl.begin();'
|
Blockly.Arduino.setupCode_['sensebox_sensor_illuminance'] = 'tsl.begin();'
|
||||||
var code = 'tsl.get' + dropdown_name + '()';
|
code = 'tsl.get' + dropdown_name + '()';
|
||||||
}
|
}
|
||||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||||
};
|
};
|
||||||
@ -76,15 +75,16 @@ Blockly.Arduino.sensebox_sensor_sds011 = function () {
|
|||||||
|
|
||||||
Blockly.Arduino.sensebox_sensor_pressure = function () {
|
Blockly.Arduino.sensebox_sensor_pressure = function () {
|
||||||
var dropdown_name = this.getFieldValue('NAME');
|
var dropdown_name = this.getFieldValue('NAME');
|
||||||
|
var code = '';
|
||||||
var referencePressure = this.getFieldValue('referencePressure');
|
var referencePressure = this.getFieldValue('referencePressure');
|
||||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||||
Blockly.Arduino.definitions_['define_pressure'] = 'BMP280 bmp_sensor;';
|
Blockly.Arduino.definitions_['define_pressure'] = 'BMP280 bmp_sensor;';
|
||||||
Blockly.Arduino.setupCode_['sensebox_bmp_sensor'] = 'bmp_sensor.begin();';
|
Blockly.Arduino.setupCode_['sensebox_bmp_sensor'] = 'bmp_sensor.begin();';
|
||||||
if (dropdown_name === 'Pressure' || dropdown_name == 'Temperature') {
|
if (dropdown_name === 'Pressure' || dropdown_name === 'Temperature') {
|
||||||
var code = 'bmp_sensor.get' + dropdown_name + '()';
|
code = 'bmp_sensor.get' + dropdown_name + '()';
|
||||||
}
|
}
|
||||||
else if (dropdown_name === 'Altitude') {
|
else if (dropdown_name === 'Altitude') {
|
||||||
var code = 'bmp_sensor.getAltitude(' + referencePressure + ')';
|
code = 'bmp_sensor.getAltitude(' + referencePressure + ')';
|
||||||
}
|
}
|
||||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||||
};
|
};
|
||||||
@ -98,6 +98,7 @@ Blockly.Arduino.sensebox_sensor_pressure = function () {
|
|||||||
|
|
||||||
Blockly.Arduino.sensebox_sensor_bme680_bsec = function () {
|
Blockly.Arduino.sensebox_sensor_bme680_bsec = function () {
|
||||||
var dropdown_name = this.getFieldValue('dropdown');
|
var dropdown_name = this.getFieldValue('dropdown');
|
||||||
|
let code = '';
|
||||||
Blockly.Arduino.libraries_['library_bsec'] = '#include "bsec.h"';
|
Blockly.Arduino.libraries_['library_bsec'] = '#include "bsec.h"';
|
||||||
Blockly.Arduino.definitions_['bsec_iaqSensor'] = 'Bsec iaqSensor;'
|
Blockly.Arduino.definitions_['bsec_iaqSensor'] = 'Bsec iaqSensor;'
|
||||||
Blockly.Arduino.variables_['bmeTemperatur'] = 'float bmeTemperatur;';
|
Blockly.Arduino.variables_['bmeTemperatur'] = 'float bmeTemperatur;';
|
||||||
@ -170,25 +171,27 @@ Blockly.Arduino.sensebox_sensor_bme680_bsec = function () {
|
|||||||
`;
|
`;
|
||||||
switch (dropdown_name) {
|
switch (dropdown_name) {
|
||||||
case 'temperature':
|
case 'temperature':
|
||||||
var code = 'bmeTemperatur';
|
code = 'bmeTemperatur';
|
||||||
break;
|
break;
|
||||||
case 'humidity':
|
case 'humidity':
|
||||||
var code = 'bmeHumidity';
|
code = 'bmeHumidity';
|
||||||
break;
|
break;
|
||||||
case 'pressure':
|
case 'pressure':
|
||||||
var code = 'bmePressure'
|
code = 'bmePressure'
|
||||||
break;
|
break;
|
||||||
case 'IAQ':
|
case 'IAQ':
|
||||||
var code = 'bmeIAQ';
|
code = 'bmeIAQ';
|
||||||
break;
|
break;
|
||||||
case 'IAQAccuracy':
|
case 'IAQAccuracy':
|
||||||
var code = 'bmeIAQAccuracy';
|
code = 'bmeIAQAccuracy';
|
||||||
break;
|
break;
|
||||||
case 'CO2':
|
case 'CO2':
|
||||||
var code = 'bmeCO2';
|
code = 'bmeCO2';
|
||||||
break;
|
break;
|
||||||
case 'breathVocEquivalent':
|
case 'breathVocEquivalent':
|
||||||
var code = 'bmeBreathVocEquivalent';
|
code = 'bmeBreathVocEquivalent';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||||
|
@ -1,30 +1,29 @@
|
|||||||
import * as Blockly from 'blockly/core';
|
import * as Blockly from 'blockly/core';
|
||||||
import { Block } from 'blockly';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Telegram Bot by re:edu
|
* Telegram Bot by re:edu
|
||||||
*/
|
*/
|
||||||
Blockly.Arduino.sensebox_telegram = function (Block) {
|
Blockly.Arduino.sensebox_telegram = function (Block) {
|
||||||
let token = Block.getFieldValue('telegram_token');
|
let token = Block.getFieldValue('telegram_token');
|
||||||
Blockly['Arduino'].libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
Blockly['Arduino'].libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||||
Blockly['Arduino'].libraries_['library_telegram'] = `#include <UniversalTelegramBot.h>`
|
Blockly['Arduino'].libraries_['library_telegram'] = `#include <UniversalTelegramBot.h>`
|
||||||
Blockly['Arduino'].functionNames_['WiFiSSLClient'] = 'WiFiSSLClient client;';
|
Blockly['Arduino'].functionNames_['WiFiSSLClient'] = 'WiFiSSLClient client;';
|
||||||
Blockly['Arduino'].functionNames_['telegram_objects'] = `#define BOTtoken "${token}" // your Bot Token (Get from Botfather)
|
Blockly['Arduino'].functionNames_['telegram_objects'] = `#define BOTtoken "${token}" // your Bot Token (Get from Botfather)
|
||||||
|
|
||||||
UniversalTelegramBot bot(BOTtoken, client);`
|
UniversalTelegramBot bot(BOTtoken, client);`
|
||||||
|
|
||||||
let code = 'testcode';
|
let code = 'testcode';
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
Blockly.Arduino.sensebox_telegram_do = function (block) {
|
Blockly.Arduino.sensebox_telegram_do = function (block) {
|
||||||
var messageProcessing = Blockly.Arduino.statementToCode(block, 'telegram_do', Blockly.Arduino.ORDER_ATOMIC);
|
var messageProcessing = Blockly.Arduino.statementToCode(block, 'telegram_do', Blockly.Arduino.ORDER_ATOMIC);
|
||||||
|
|
||||||
Blockly.Arduino.definitions_['telegram_variables'] = `int Bot_mtbs = 1000; //mean time between scan messages
|
Blockly.Arduino.definitions_['telegram_variables'] = `int Bot_mtbs = 1000; //mean time between scan messages
|
||||||
long Bot_lasttime; //last time messages' scan has been done`
|
long Bot_lasttime; //last time messages' scan has been done`
|
||||||
|
|
||||||
Blockly.Arduino.loopCodeOnce_['sensebox_telegram_loop'] = `if (millis() > Bot_lasttime + Bot_mtbs) {
|
Blockly.Arduino.loopCodeOnce_['sensebox_telegram_loop'] = `if (millis() > Bot_lasttime + Bot_mtbs) {
|
||||||
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
|
int numNewMessages = bot.getUpdates(bot.last_message_received + 1);
|
||||||
while(numNewMessages) {
|
while(numNewMessages) {
|
||||||
for(int i=0; i<numNewMessages; i++) {
|
for(int i=0; i<numNewMessages; i++) {
|
||||||
@ -37,22 +36,22 @@ Blockly.Arduino.sensebox_telegram_do = function (block) {
|
|||||||
}
|
}
|
||||||
Bot_lasttime = millis();
|
Bot_lasttime = millis();
|
||||||
}`;
|
}`;
|
||||||
var code = '';
|
var code = '';
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
Blockly.Arduino.sensebox_telegram_do_on_message = function (block) {
|
Blockly.Arduino.sensebox_telegram_do_on_message = function (block) {
|
||||||
var message = this.getFieldValue('telegram_message');
|
var message = this.getFieldValue('telegram_message');
|
||||||
var stuffToDo = Blockly.Arduino.statementToCode(block, 'telegram_do_on_message', Blockly.Arduino.ORDER_ATOMIC);
|
var stuffToDo = Blockly.Arduino.statementToCode(block, 'telegram_do_on_message', Blockly.Arduino.ORDER_ATOMIC);
|
||||||
var code = `
|
var code = `
|
||||||
if (text == "${message}") {
|
if (text == "${message}") {
|
||||||
${stuffToDo}
|
${stuffToDo}
|
||||||
}`;
|
}`;
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
Blockly.Arduino.sensebox_telegram_send = function (block) {
|
Blockly.Arduino.sensebox_telegram_send = function (block) {
|
||||||
var textToSend = Blockly.Arduino.valueToCode(this, 'telegram_text_to_send', Blockly.Arduino.ORDER_ATOMIC) || '"Keine Eingabe"';
|
var textToSend = Blockly.Arduino.valueToCode(this, 'telegram_text_to_send', Blockly.Arduino.ORDER_ATOMIC) || '"Keine Eingabe"';
|
||||||
var code = `bot.sendMessage(chat_id, String(${textToSend}), "");\n`;
|
var code = `bot.sendMessage(chat_id, String(${textToSend}), "");\n`;
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
@ -33,7 +33,7 @@ const sensebox_mcu = {
|
|||||||
i2cPins: { Wire: [['SDA', '17'], ['SCL', '16']] },
|
i2cPins: { Wire: [['SDA', '17'], ['SCL', '16']] },
|
||||||
i2cSpeed: [['100kHz', '100000L'], ['400kHz', '400000L']],
|
i2cSpeed: [['100kHz', '100000L'], ['400kHz', '400000L']],
|
||||||
builtinLed: [['BUILTIN_1', '7'], ['BUILTIN_2', '8']],
|
builtinLed: [['BUILTIN_1', '7'], ['BUILTIN_2', '8']],
|
||||||
interrupt: [['interrupt1', '1'], ['interrupt2', '2'], , ['interrupt3', '3'], ['interrupt4', '4'], ['interrupt5', '5'], ['interrupt6', '6']],
|
interrupt: [['interrupt1', '1'], ['interrupt2', '2'], ['interrupt3', '3'], ['interrupt4', '4'], ['interrupt5', '5'], ['interrupt6', '6']],
|
||||||
analogPins: [['A1', 'A1'], ['A2', 'A2'], ['A3', 'A3'], ['A4', 'A4'], ['A5', 'A5'], ['A6', 'A6']],
|
analogPins: [['A1', 'A1'], ['A2', 'A2'], ['A3', 'A3'], ['A4', 'A4'], ['A5', 'A5'], ['A6', 'A6']],
|
||||||
serial_baud_rate: 9600,
|
serial_baud_rate: 9600,
|
||||||
parseKey: '_*_'
|
parseKey: '_*_'
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
import React, { Component } from 'react';
|
import React from 'react';
|
||||||
import BlocklyComponent, { Block, Value, Field, Shadow, Category } from '../';
|
import { Block, Value, Field, Shadow, Category } from '../';
|
||||||
import { getColour } from '../helpers/colour'
|
import { getColour } from '../helpers/colour'
|
||||||
|
|
||||||
|
|
||||||
class Toolbox extends React.Component {
|
class Toolbox extends React.Component {
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user