Compare commits
2 Commits
master
...
block/upda
Author | SHA1 | Date | |
---|---|---|---|
|
5901caa278 | ||
|
b74aef8167 |
35
package-lock.json
generated
35
package-lock.json
generated
@ -10,7 +10,7 @@
|
||||
"dependencies": {
|
||||
"@blockly/block-plus-minus": "^2.0.10",
|
||||
"@blockly/field-slider": "^2.1.1",
|
||||
"@blockly/plugin-typed-variable-modal": "^3.1.1",
|
||||
"@blockly/plugin-typed-variable-modal": "^3.1.15",
|
||||
"@fortawesome/fontawesome-svg-core": "^1.2.30",
|
||||
"@fortawesome/free-solid-svg-icons": "^5.14.0",
|
||||
"@fortawesome/react-fontawesome": "^0.1.11",
|
||||
@ -21,7 +21,7 @@
|
||||
"@testing-library/react": "^9.5.0",
|
||||
"@testing-library/user-event": "^7.2.1",
|
||||
"axios": "^0.21.0",
|
||||
"blockly": "^3.20200924.0",
|
||||
"blockly": "^5.20210325.1",
|
||||
"file-saver": "^2.0.2",
|
||||
"mnemonic-id": "^3.2.7",
|
||||
"moment": "^2.28.0",
|
||||
@ -1477,14 +1477,17 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@blockly/plugin-typed-variable-modal": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@blockly/plugin-typed-variable-modal/-/plugin-typed-variable-modal-3.1.1.tgz",
|
||||
"integrity": "sha512-+g/lQ3HrCcivBNOtgvQEvfZCPq9VeP1Zgs7J02zxAfw4f+s4aOQb+hChv7qAb5AnzEnMk0BoB5vKgQmaP6Wkuw==",
|
||||
"version": "3.1.15",
|
||||
"resolved": "https://registry.npmjs.org/@blockly/plugin-typed-variable-modal/-/plugin-typed-variable-modal-3.1.15.tgz",
|
||||
"integrity": "sha512-X+s2Vd8tjt1GPV2gGfZUB+srabRUDWcZ7cOzjajV8gmc0zFu0IOLsR991cBptF1bsp207TEtUyIsoWONHBNp4A==",
|
||||
"dependencies": {
|
||||
"@blockly/plugin-modal": "^1.20200427.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.17.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"blockly": ">3.20200625.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@cnakazawa/watch": {
|
||||
@ -5845,11 +5848,11 @@
|
||||
}
|
||||
},
|
||||
"node_modules/blockly": {
|
||||
"version": "3.20200924.0",
|
||||
"resolved": "https://registry.npmjs.org/blockly/-/blockly-3.20200924.0.tgz",
|
||||
"integrity": "sha512-mOZiXi908oNFAcVb8Q5LKJNRZ5jtBJtgNilddqTYMAXEdqSY/BhcnU2rgytWARDnu2iSQlI374kEafCNuUEWKQ==",
|
||||
"version": "5.20210325.1",
|
||||
"resolved": "https://registry.npmjs.org/blockly/-/blockly-5.20210325.1.tgz",
|
||||
"integrity": "sha512-qrilYPovJeDfxKDWm1YBUCPVNElh/iyC1szaHTIPZHj9C9YPpSzZOeFyyrPBbYRudzbo8kjBOWMtHnN1bLjkoQ==",
|
||||
"dependencies": {
|
||||
"jsdom": "^15.2.1"
|
||||
"jsdom": "15.2.1"
|
||||
}
|
||||
},
|
||||
"node_modules/blockly/node_modules/jsdom": {
|
||||
@ -26216,9 +26219,9 @@
|
||||
"integrity": "sha512-eA9p+W3mtcWLJQZ23D0Le/Uw3JdxFxwJqTUYtAiRlVON4qnuDXrHQLlvxEiWctNXJZGUTh57zqbvO6ZxNRQPrA=="
|
||||
},
|
||||
"@blockly/plugin-typed-variable-modal": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@blockly/plugin-typed-variable-modal/-/plugin-typed-variable-modal-3.1.1.tgz",
|
||||
"integrity": "sha512-+g/lQ3HrCcivBNOtgvQEvfZCPq9VeP1Zgs7J02zxAfw4f+s4aOQb+hChv7qAb5AnzEnMk0BoB5vKgQmaP6Wkuw==",
|
||||
"version": "3.1.15",
|
||||
"resolved": "https://registry.npmjs.org/@blockly/plugin-typed-variable-modal/-/plugin-typed-variable-modal-3.1.15.tgz",
|
||||
"integrity": "sha512-X+s2Vd8tjt1GPV2gGfZUB+srabRUDWcZ7cOzjajV8gmc0zFu0IOLsR991cBptF1bsp207TEtUyIsoWONHBNp4A==",
|
||||
"requires": {
|
||||
"@blockly/plugin-modal": "^1.20200427.4"
|
||||
}
|
||||
@ -29613,11 +29616,11 @@
|
||||
}
|
||||
},
|
||||
"blockly": {
|
||||
"version": "3.20200924.0",
|
||||
"resolved": "https://registry.npmjs.org/blockly/-/blockly-3.20200924.0.tgz",
|
||||
"integrity": "sha512-mOZiXi908oNFAcVb8Q5LKJNRZ5jtBJtgNilddqTYMAXEdqSY/BhcnU2rgytWARDnu2iSQlI374kEafCNuUEWKQ==",
|
||||
"version": "5.20210325.1",
|
||||
"resolved": "https://registry.npmjs.org/blockly/-/blockly-5.20210325.1.tgz",
|
||||
"integrity": "sha512-qrilYPovJeDfxKDWm1YBUCPVNElh/iyC1szaHTIPZHj9C9YPpSzZOeFyyrPBbYRudzbo8kjBOWMtHnN1bLjkoQ==",
|
||||
"requires": {
|
||||
"jsdom": "^15.2.1"
|
||||
"jsdom": "15.2.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"jsdom": {
|
||||
|
@ -5,7 +5,7 @@
|
||||
"dependencies": {
|
||||
"@blockly/block-plus-minus": "^2.0.10",
|
||||
"@blockly/field-slider": "^2.1.1",
|
||||
"@blockly/plugin-typed-variable-modal": "^3.1.1",
|
||||
"@blockly/plugin-typed-variable-modal": "^3.1.15",
|
||||
"@fortawesome/fontawesome-svg-core": "^1.2.30",
|
||||
"@fortawesome/free-solid-svg-icons": "^5.14.0",
|
||||
"@fortawesome/react-fontawesome": "^0.1.11",
|
||||
@ -16,7 +16,7 @@
|
||||
"@testing-library/react": "^9.5.0",
|
||||
"@testing-library/user-event": "^7.2.1",
|
||||
"axios": "^0.21.0",
|
||||
"blockly": "^3.20200924.0",
|
||||
"blockly": "^5.20210325.1",
|
||||
"file-saver": "^2.0.2",
|
||||
"mnemonic-id": "^3.2.7",
|
||||
"moment": "^2.28.0",
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,80 +1,103 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
import { getColour } from '../helpers/colour';
|
||||
import * as Blockly from "blockly/core";
|
||||
import { getColour } from "../helpers/colour";
|
||||
|
||||
var checkFileName = function (filename) {
|
||||
var length = filename.length;
|
||||
if (length > 8) {
|
||||
alert("dateiname sollte kleiner als 8 Zeichen sein");
|
||||
return filename.slice(0, 8);
|
||||
}
|
||||
return filename;
|
||||
};
|
||||
|
||||
Blockly.Blocks['sensebox_sd_open_file'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_sd_open_file)
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(
|
||||
new Blockly.FieldTextInput('Data.txt'),
|
||||
'Filename');
|
||||
this.appendStatementInput('SD')
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_sd_open_file_tooltip);
|
||||
this.setHelpUrl('https://docs.sensebox.de/hardware/bee-sd/');
|
||||
Blockly.Blocks["sensebox_sd_open_file"] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_sd_open_file)
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(
|
||||
new Blockly.FieldTextInput("Data", checkFileName),
|
||||
"Filename"
|
||||
)
|
||||
.appendField(".")
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
["txt", "txt"],
|
||||
["csv", "csv"],
|
||||
]),
|
||||
"extension"
|
||||
);
|
||||
this.appendStatementInput("SD").setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_sd_open_file_tooltip);
|
||||
this.setHelpUrl("https://docs.sensebox.de/hardware/bee-sd/");
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_sd_create_file"] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_sd_create_file)
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(
|
||||
new Blockly.FieldTextInput("Data", checkFileName),
|
||||
"Filename"
|
||||
)
|
||||
.appendField(".")
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
["txt", "txt"],
|
||||
["csv", "csv"],
|
||||
]),
|
||||
"extension"
|
||||
);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_sd_create_file_tooltip);
|
||||
this.setHelpUrl("https://docs.sensebox.de/hardware/bee-sd/");
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_sd_write_file"] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_sd_write_file)
|
||||
.setAlign(Blockly.ALIGN_LEFT);
|
||||
this.appendValueInput("DATA").setCheck(null);
|
||||
this.appendDummyInput("CheckboxText")
|
||||
.appendField(Blockly.Msg.senseBox_output_linebreak)
|
||||
.appendField(new Blockly.FieldCheckbox("TRUE"), "linebreak");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_sd_write_file_tooltip);
|
||||
this.setHelpUrl("https://docs.sensebox.de/hardware/bee-sd/");
|
||||
},
|
||||
/**
|
||||
* Called whenever anything on the workspace changes.
|
||||
* Add warning if block is not nested inside a the correct loop.
|
||||
* @param {!Blockly.Events.Abstract} e Change event.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
onchange: function (e) {
|
||||
var legal = false;
|
||||
// Is the block nested in a loop?
|
||||
var block = this;
|
||||
do {
|
||||
if (this.LOOP_TYPES.indexOf(block.type) !== -1) {
|
||||
legal = true;
|
||||
break;
|
||||
}
|
||||
block = block.getSurroundParent();
|
||||
} while (block);
|
||||
if (legal) {
|
||||
this.setWarningText(null);
|
||||
} else {
|
||||
this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING);
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['sensebox_sd_create_file'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_sd_create_file)
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_output_filename)
|
||||
.appendField(
|
||||
new Blockly.FieldTextInput('Data.txt'),
|
||||
'Filename');
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_sd_create_file_tooltip);
|
||||
this.setHelpUrl('https://docs.sensebox.de/hardware/bee-sd/');
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Blocks['sensebox_sd_write_file'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_sd_write_file)
|
||||
.setAlign(Blockly.ALIGN_LEFT);
|
||||
this.appendValueInput('DATA')
|
||||
.setCheck(null);
|
||||
this.appendDummyInput('CheckboxText')
|
||||
.appendField(Blockly.Msg.senseBox_output_linebreak)
|
||||
.appendField(new Blockly.FieldCheckbox('TRUE'), 'linebreak');
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_sd_write_file_tooltip);
|
||||
this.setHelpUrl('https://docs.sensebox.de/hardware/bee-sd/');
|
||||
},
|
||||
/**
|
||||
* Called whenever anything on the workspace changes.
|
||||
* Add warning if block is not nested inside a the correct loop.
|
||||
* @param {!Blockly.Events.Abstract} e Change event.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
onchange: function (e) {
|
||||
var legal = false;
|
||||
// Is the block nested in a loop?
|
||||
var block = this;
|
||||
do {
|
||||
if (this.LOOP_TYPES.indexOf(block.type) !== -1) {
|
||||
legal = true;
|
||||
break;
|
||||
}
|
||||
block = block.getSurroundParent();
|
||||
} while (block);
|
||||
if (legal) {
|
||||
this.setWarningText(null);
|
||||
} else {
|
||||
this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING);
|
||||
}
|
||||
},
|
||||
LOOP_TYPES: ['sensebox_sd_open_file'],
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_sd_open_file"],
|
||||
};
|
||||
|
@ -8,123 +8,118 @@
|
||||
* The arduino built in functions syntax can be found in
|
||||
* http://arduino.cc/en/Reference/HomePage
|
||||
*/
|
||||
import Blockly from 'blockly';
|
||||
import { getColour } from '../helpers/colour'
|
||||
import * as Types from '../helpers/types'
|
||||
import Blockly from "blockly";
|
||||
import { getColour } from "../helpers/colour";
|
||||
import * as Types from "../helpers/types";
|
||||
|
||||
|
||||
Blockly.Blocks['time_delay'] = {
|
||||
/**
|
||||
* Delay block definition
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/Delay');
|
||||
this.setColour(getColour().time);
|
||||
this.appendValueInput('DELAY_TIME_MILI')
|
||||
.setCheck(Types.NUMBER.checkList)
|
||||
.appendField(Blockly.Msg.ARD_TIME_DELAY);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ARD_TIME_MS);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_DELAY_TIP);
|
||||
}
|
||||
Blockly.Blocks["time_delay"] = {
|
||||
/**
|
||||
* Delay block definition
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl("http://arduino.cc/en/Reference/Delay");
|
||||
this.setColour(getColour().time);
|
||||
this.appendValueInput("DELAY_TIME_MILI")
|
||||
.setCheck(Types.NUMBER.checkList)
|
||||
.appendField(Blockly.Msg.ARD_TIME_DELAY);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.ARD_TIME_MS);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_DELAY_TIP);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks['time_delaymicros'] = {
|
||||
/**
|
||||
* delayMicroseconds block definition
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/DelayMicroseconds');
|
||||
this.setColour(getColour().time);
|
||||
this.appendValueInput('DELAY_TIME_MICRO')
|
||||
.setCheck(Types.NUMBER.checkList)
|
||||
.appendField(Blockly.Msg.ARD_TIME_DELAY);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ARD_TIME_DELAY_MICROS);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_DELAY_MICRO_TIP);
|
||||
}
|
||||
Blockly.Blocks["time_delaymicros"] = {
|
||||
/**
|
||||
* delayMicroseconds block definition
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl("http://arduino.cc/en/Reference/DelayMicroseconds");
|
||||
this.setColour(getColour().time);
|
||||
this.appendValueInput("DELAY_TIME_MICRO")
|
||||
.setCheck(Types.NUMBER.checkList)
|
||||
.appendField(Blockly.Msg.ARD_TIME_DELAY);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.ARD_TIME_DELAY_MICROS);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_DELAY_MICRO_TIP);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks['time_millis'] = {
|
||||
/**
|
||||
* Elapsed time in milliseconds block definition
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/Millis');
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ARD_TIME_MILLIS);
|
||||
this.setOutput(true, Types.LARGE_NUMBER.typeId);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_MILLIS_TIP);
|
||||
},
|
||||
/** @return {string} The type of return value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
return Blockly.Types.LARGE_NUMBER;
|
||||
}
|
||||
Blockly.Blocks["time_millis"] = {
|
||||
/**
|
||||
* Elapsed time in milliseconds block definition
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl("http://arduino.cc/en/Reference/Millis");
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.ARD_TIME_MILLIS);
|
||||
this.setOutput(true, Types.LARGE_NUMBER.typeId);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_MILLIS_TIP);
|
||||
},
|
||||
/** @return {string} The type of return value for the block, an integer. */
|
||||
getBlockType: function () {
|
||||
return Blockly.Types.LARGE_NUMBER;
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks['time_micros'] = {
|
||||
/**
|
||||
* Elapsed time in microseconds block definition
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl('http://arduino.cc/en/Reference/Micros');
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ARD_TIME_MICROS);
|
||||
this.setOutput(true, Types.LARGE_NUMBER.typeId);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_MICROS_TIP);
|
||||
},
|
||||
/**
|
||||
* Should be a long (32bit), but for for now an int.
|
||||
* @return {string} The type of return value for the block, an integer.
|
||||
*/
|
||||
getBlockType: function () {
|
||||
return Types.LARGE_NUMBER;
|
||||
}
|
||||
Blockly.Blocks["time_micros"] = {
|
||||
/**
|
||||
* Elapsed time in microseconds block definition
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl("http://arduino.cc/en/Reference/Micros");
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.ARD_TIME_MICROS);
|
||||
this.setOutput(true, Types.LARGE_NUMBER.typeId);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_MICROS_TIP);
|
||||
},
|
||||
/**
|
||||
* Should be a long (32bit), but for for now an int.
|
||||
* @return {string} The type of return value for the block, an integer.
|
||||
*/
|
||||
getBlockType: function () {
|
||||
return Types.LARGE_NUMBER;
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks['infinite_loop'] = {
|
||||
/**
|
||||
* Waits forever, end of program.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.ARD_TIME_INF);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_INF_TIP);
|
||||
}
|
||||
Blockly.Blocks["infinite_loop"] = {
|
||||
/**
|
||||
* Waits forever, end of program.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
init: function () {
|
||||
this.setHelpUrl("");
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.ARD_TIME_INF);
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true);
|
||||
this.setTooltip(Blockly.Msg.ARD_TIME_INF_TIP);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks['sensebox_interval_timer'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_interval_timer_tip);
|
||||
this.setInputsInline(true);
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_interval_timer);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(new Blockly.FieldTextInput("10000"), "interval")
|
||||
.appendField(Blockly.Msg.senseBox_interval);
|
||||
this.appendStatementInput('DO')
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
}
|
||||
Blockly.Blocks["sensebox_interval_timer"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_interval_timer_tip);
|
||||
this.setInputsInline(true);
|
||||
this.setHelpUrl("");
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_interval_timer)
|
||||
.appendField(new Blockly.FieldTextInput("name"), "name");
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.senseBox_interval_time)
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(new Blockly.FieldTextInput("10000"), "interval")
|
||||
.appendField(Blockly.Msg.senseBox_interval);
|
||||
this.appendStatementInput("DO").setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
};
|
||||
|
@ -1,43 +1,43 @@
|
||||
import Blockly from 'blockly/core';
|
||||
import { getColour } from '../helpers/colour';
|
||||
import { getCompatibleTypes } from '../helpers/types'
|
||||
import Blockly from "blockly/core";
|
||||
import { getColour } from "../helpers/colour";
|
||||
import { getCompatibleTypes } from "../helpers/types";
|
||||
|
||||
Blockly.Blocks["variables_set_dynamic"] = {
|
||||
init: function () {
|
||||
// const type = myVar.type;
|
||||
this.setColour(getColour().variables);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.appendValueInput("VALUE")
|
||||
.appendField("set", "set")
|
||||
.appendField("", "type")
|
||||
.appendField(new Blockly.FieldVariable("VAR"), "VAR")
|
||||
.appendField("to");
|
||||
},
|
||||
onchange: function (e) {
|
||||
let variableID = this.getFieldValue("VAR");
|
||||
let variable = Blockly.getMainWorkspace()
|
||||
.getVariableMap()
|
||||
.getVariableById(variableID);
|
||||
this.getField("type").setValue(variable.type);
|
||||
this.getInput("VALUE").setCheck(getCompatibleTypes(variable.type));
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks['variables_set_dynamic'] = {
|
||||
init: function () {
|
||||
|
||||
// const type = myVar.type;
|
||||
this.setColour(getColour().variables);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.appendValueInput('VALUE')
|
||||
.appendField('set', 'set')
|
||||
.appendField('', 'type')
|
||||
.appendField(new Blockly.FieldVariable('VAR'), 'VAR')
|
||||
.appendField('to');
|
||||
},
|
||||
onchange: function (e) {
|
||||
let variableID = this.getFieldValue('VAR');
|
||||
let variable = Blockly.getMainWorkspace().getVariableMap().getVariableById(variableID)
|
||||
this.getField('type').setValue(variable.type);
|
||||
this.getInput('VALUE').setCheck(getCompatibleTypes(variable.type));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Blockly.Blocks['variables_get_dynamic'] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().variables);
|
||||
this.appendDummyInput()
|
||||
.appendField('', 'type')
|
||||
.appendField(new Blockly.FieldVariable('VAR'), 'VAR');
|
||||
this.setOutput(true);
|
||||
},
|
||||
onchange: function (e) {
|
||||
let variableID = this.getFieldValue('VAR');
|
||||
let variable = Blockly.getMainWorkspace().getVariableMap().getVariableById(variableID)
|
||||
this.getField('type').setValue(variable.type);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Blockly.Blocks["variables_get_dynamic"] = {
|
||||
init: function () {
|
||||
this.setColour(getColour().variables);
|
||||
this.appendDummyInput()
|
||||
.appendField("", "type")
|
||||
.appendField(new Blockly.FieldVariable("VAR"), "VAR");
|
||||
this.setOutput(true);
|
||||
},
|
||||
onchange: function (e) {
|
||||
let variableID = this.getFieldValue("VAR");
|
||||
let variable = Blockly.getMainWorkspace()
|
||||
.getVariableMap()
|
||||
.getVariableById(variableID);
|
||||
this.getField("type").setValue(variable.type);
|
||||
this.setOutput(true, variable.type);
|
||||
},
|
||||
};
|
||||
|
@ -1,5 +1,4 @@
|
||||
import Blockly from 'blockly';
|
||||
|
||||
import Blockly from "blockly";
|
||||
|
||||
/* SD-Card Blocks using the Standard SD Library*/
|
||||
/**
|
||||
@ -10,45 +9,49 @@ import Blockly from 'blockly';
|
||||
*/
|
||||
|
||||
Blockly.Arduino.sensebox_sd_create_file = function (block) {
|
||||
var filename = this.getFieldValue('Filename');
|
||||
var res = filename.slice(0, 4);
|
||||
Blockly.Arduino.libraries_['library_spi'] = '#include <SPI.h>';
|
||||
Blockly.Arduino.libraries_['library_sd'] = '#include <SD.h>';
|
||||
Blockly.Arduino.definitions_['define_' + res] = 'File dataFile' + res + ';';
|
||||
Blockly.Arduino.setupCode_['sensebox_sd'] = 'SD.begin(28);';
|
||||
Blockly.Arduino.setupCode_['sensebox_sd' + filename] = 'dataFile' + res + ' = SD.open("' + filename + '", FILE_WRITE);\ndataFile' + res + '.close();\n';
|
||||
var code = '';
|
||||
return code;
|
||||
var filename = this.getFieldValue("Filename");
|
||||
var extension = this.getFieldValue("extension");
|
||||
var newFileName = filename.concat(".", extension);
|
||||
Blockly.Arduino.libraries_["library_spi"] = "#include <SPI.h>";
|
||||
Blockly.Arduino.libraries_["library_sd"] = "#include <SD.h>";
|
||||
Blockly.Arduino.definitions_["define_" + filename] = `File ${filename};`;
|
||||
Blockly.Arduino.setupCode_["sensebox_sd"] = "SD.begin(28);\n";
|
||||
Blockly.Arduino.setupCode_[
|
||||
"sensebox_sd" + filename
|
||||
] = `${filename} = SD.open("${newFileName}", FILE_WRITE);\n${filename}.close();\n`;
|
||||
var code = "";
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_sd_open_file = function (block) {
|
||||
var filename = this.getFieldValue('Filename');
|
||||
var res = filename.slice(0, 4);
|
||||
var branch = Blockly.Arduino.statementToCode(block, 'SD');
|
||||
var code = 'dataFile' + res + ' = SD.open("' + filename + '", FILE_WRITE);\n'
|
||||
code += branch;
|
||||
code += 'dataFile' + res + '.close();\n'
|
||||
return code;
|
||||
var filename = this.getFieldValue("Filename");
|
||||
var extension = this.getFieldValue("extension");
|
||||
var newFileName = filename.concat(".", extension);
|
||||
var branch = Blockly.Arduino.statementToCode(block, "SD");
|
||||
var code = `${filename} = SD.open("${newFileName}", FILE_WRITE);\n`;
|
||||
code += branch;
|
||||
code += `${filename}.close();\n`;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_sd_write_file = function (block) {
|
||||
if (this.parentBlock_ != null) {
|
||||
var filename = this.getSurroundParent().getFieldValue('Filename');
|
||||
}
|
||||
var res = filename.slice(0, 4);
|
||||
var text = Blockly.Arduino.valueToCode(this, 'DATA', Blockly.Arduino.ORDER_ATOMIC) || '"Keine Eingabe"';
|
||||
var linebreak = this.getFieldValue('linebreak');
|
||||
if (linebreak === "TRUE") {
|
||||
linebreak = "ln";
|
||||
} else {
|
||||
linebreak = "";
|
||||
}
|
||||
var code = '';
|
||||
if (text === "gps.getLongitude()" || text === "gps.getLatitude()") {
|
||||
code = 'dataFile' + res + '.print' + linebreak + '(' + text + ',5);\n'
|
||||
}
|
||||
else {
|
||||
code = 'dataFile' + res + '.print' + linebreak + '(' + text + ');\n'
|
||||
}
|
||||
return code;
|
||||
if (this.parentBlock_ != null) {
|
||||
var filename = this.getSurroundParent().getFieldValue("Filename");
|
||||
}
|
||||
var branch =
|
||||
Blockly.Arduino.valueToCode(this, "DATA", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
'"Keine Eingabe"';
|
||||
var linebreak = this.getFieldValue("linebreak");
|
||||
if (linebreak === "TRUE") {
|
||||
linebreak = "ln";
|
||||
} else {
|
||||
linebreak = "";
|
||||
}
|
||||
var code = "";
|
||||
if (branch === "gps.getLongitude()" || branch === "gps.getLatitude()") {
|
||||
code = `${filename}.print${linebreak}(${branch},5);\n`;
|
||||
} else {
|
||||
code = `${filename}.print${linebreak}(${branch});\n`;
|
||||
}
|
||||
return code;
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Blockly from 'blockly';
|
||||
import Blockly from "blockly";
|
||||
|
||||
/**
|
||||
* @license Licensed under the Apache License, Version 2.0 (the "License"):
|
||||
@ -16,11 +16,15 @@ import Blockly from 'blockly';
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {string} Completed code.
|
||||
*/
|
||||
Blockly.Arduino['time_delay'] = function (block) {
|
||||
var delayTime = Blockly.Arduino.valueToCode(
|
||||
block, 'DELAY_TIME_MILI', Blockly.Arduino.ORDER_ATOMIC) || '0';
|
||||
var code = 'delay(' + delayTime + ');\n';
|
||||
return code;
|
||||
Blockly.Arduino["time_delay"] = function (block) {
|
||||
var delayTime =
|
||||
Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"DELAY_TIME_MILI",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
) || "0";
|
||||
var code = "delay(" + delayTime + ");\n";
|
||||
return code;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -29,11 +33,15 @@ Blockly.Arduino['time_delay'] = function (block) {
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {string} Completed code.
|
||||
*/
|
||||
Blockly.Arduino['time_delaymicros'] = function (block) {
|
||||
var delayTimeMs = Blockly.Arduino.valueToCode(
|
||||
block, 'DELAY_TIME_MICRO', Blockly.Arduino.ORDER_ATOMIC) || '0';
|
||||
var code = 'delayMicroseconds(' + delayTimeMs + ');\n';
|
||||
return code;
|
||||
Blockly.Arduino["time_delaymicros"] = function (block) {
|
||||
var delayTimeMs =
|
||||
Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"DELAY_TIME_MICRO",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
) || "0";
|
||||
var code = "delayMicroseconds(" + delayTimeMs + ");\n";
|
||||
return code;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -42,9 +50,9 @@ Blockly.Arduino['time_delaymicros'] = function (block) {
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {array} Completed code with order of operation.
|
||||
*/
|
||||
Blockly.Arduino['time_millis'] = function (block) {
|
||||
var code = 'millis()';
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
Blockly.Arduino["time_millis"] = function (block) {
|
||||
var code = "millis()";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
/**
|
||||
@ -53,9 +61,9 @@ Blockly.Arduino['time_millis'] = function (block) {
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {array} Completed code with order of operation.
|
||||
*/
|
||||
Blockly.Arduino['time_micros'] = function (block) {
|
||||
var code = 'micros()';
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
Blockly.Arduino["time_micros"] = function (block) {
|
||||
var code = "micros()";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
/**
|
||||
@ -64,17 +72,22 @@ Blockly.Arduino['time_micros'] = function (block) {
|
||||
* @param {!Blockly.Block} block Block to generate the code from.
|
||||
* @return {string} Completed code.
|
||||
*/
|
||||
Blockly.Arduino['infinite_loop'] = function (block) {
|
||||
return 'while(true);\n';
|
||||
Blockly.Arduino["infinite_loop"] = function (block) {
|
||||
return "while(true);\n";
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_interval_timer = function (block) {
|
||||
var interval = this.getFieldValue('interval');
|
||||
Blockly.Arduino.variables_['define_interval_variables'] = 'const long interval = ' + interval + ';\nlong time_start = 0;\nlong time_actual = 0;';
|
||||
var branch = Blockly.Arduino.statementToCode(block, 'DO');
|
||||
var code = 'time_start = millis();\n';
|
||||
code += 'if (time_start > time_actual + interval) {\n time_actual = millis();\n'
|
||||
code += branch;
|
||||
code += '}\n'
|
||||
return code;
|
||||
var intervalTime = this.getFieldValue("interval");
|
||||
var intervalName = this.getFieldValue("name");
|
||||
Blockly.Arduino.variables_[`define_interval_variables${intervalName}`] = `
|
||||
const long interval${intervalName} = ${intervalTime};
|
||||
long time_start${intervalName} = 0;
|
||||
long time_actual${intervalName} = 0;`;
|
||||
var branch = Blockly.Arduino.statementToCode(block, "DO");
|
||||
var code = `time_start${intervalName} = millis();\n`;
|
||||
code += `
|
||||
if (time_start${intervalName} > time_actual${intervalName} + interval${intervalName}) {\n time_actual${intervalName} = millis();\n`;
|
||||
code += branch;
|
||||
code += "}\n";
|
||||
return code;
|
||||
};
|
@ -1,114 +1,127 @@
|
||||
import Blockly from 'blockly';
|
||||
import Blockly from "blockly";
|
||||
/**
|
||||
* Webserver Blocks by Lucas Steinmann
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Arduino.sensebox_initialize_http_server = function (block) {
|
||||
var box_id = this.getFieldValue('Port');
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.codeFunctions_['define_wifi_server'] = 'WiFiServer server(' + box_id + ');';
|
||||
Blockly.Arduino.setupCode_['sensebox_wifi_server_beging'] = 'server.begin();';
|
||||
return '';
|
||||
var box_id = this.getFieldValue("Port");
|
||||
Blockly.Arduino.libraries_["library_senseBoxMCU"] =
|
||||
'#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.codeFunctions_["define_wifi_server"] =
|
||||
"WiFiServer server(" + box_id + ");";
|
||||
Blockly.Arduino.setupCode_["sensebox_wifi_server_beging"] = "server.begin();";
|
||||
return "";
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_http_on_client_connect = function (block) {
|
||||
var onConnect = Blockly.Arduino.statementToCode(block, 'ON_CONNECT');
|
||||
var code = '';
|
||||
code += 'WiFiClient client = server.available();\n';
|
||||
code += 'if (client && client.available()) {\n';
|
||||
code += ' String request_string = listenClient(client);\n';
|
||||
code += ' Request request;\n';
|
||||
code += ' if (parseRequestSafe(request_string, request)) {\n';
|
||||
code += onConnect;
|
||||
code += ' }\n';
|
||||
code += ' delay(1);\n';
|
||||
code += ' client.stop();\n';
|
||||
code += ' delay(1);\n';
|
||||
code += '}\n';
|
||||
return code;
|
||||
var onConnect = Blockly.Arduino.statementToCode(block, "ON_CONNECT");
|
||||
var code = "";
|
||||
code += "WiFiClient client = server.available();\n";
|
||||
code += "if (client && client.available()) {\n";
|
||||
code += " String request_string = listenClient(client);\n";
|
||||
code += " Request request;\n";
|
||||
code += " if (parseRequestSafe(request_string, request)) {\n";
|
||||
code += onConnect;
|
||||
code += " }\n";
|
||||
code += " delay(1);\n";
|
||||
code += " client.stop();\n";
|
||||
code += " delay(1);\n";
|
||||
code += "}\n";
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_http_method = function (block) {
|
||||
var code = "request.method";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
var code = "request.method";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
|
||||
Blockly.Arduino.sensebox_http_uri = function (block) {
|
||||
var code = "request.uri";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
var code = "request.uri";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_http_protocol_version = function (block) {
|
||||
var code = "request.protocol_version";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
var code = "request.protocol_version";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_http_user_agent = function (block) {
|
||||
var code = "request.user_agent";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
var code = "request.user_agent";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_generate_html_doc = function (block) {
|
||||
var header = Blockly.Arduino.valueToCode(block, 'HEADER', Blockly.Arduino.ORDER_NONE) || '""';
|
||||
var body = Blockly.Arduino.valueToCode(block, 'BODY', Blockly.Arduino.ORDER_NONE) || '""';
|
||||
var code = 'buildHTML(' + header + ', ' + body + ')';
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
var header =
|
||||
Blockly.Arduino.valueToCode(block, "HEADER", Blockly.Arduino.ORDER_NONE) ||
|
||||
'""';
|
||||
var body =
|
||||
Blockly.Arduino.valueToCode(block, "BODY", Blockly.Arduino.ORDER_NONE) ||
|
||||
'""';
|
||||
var code = "buildHTML(" + header + ", " + body + ")";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_generate_http_succesful_response = function (block) {
|
||||
var content = Blockly.Arduino.valueToCode(block, 'CONTENT', Blockly.Arduino.ORDER_NONE) || '""';
|
||||
var code = 'client.println(buildSuccessfulResponse(request, ' + content + '));\n';
|
||||
return code;
|
||||
var content =
|
||||
Blockly.Arduino.valueToCode(block, "CONTENT", Blockly.Arduino.ORDER_NONE) ||
|
||||
'""';
|
||||
var code =
|
||||
"client.println(buildSuccessfulResponse(request, " + content + "));\n";
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_generate_http_not_found_response = function (block) {
|
||||
var code = 'client.println(buildNotFoundResponse(request));\n';
|
||||
return code;
|
||||
var code = "client.println(buildNotFoundResponse(request));\n";
|
||||
return code;
|
||||
};
|
||||
|
||||
|
||||
Blockly.Arduino.sensebox_ip_address = function (block) {
|
||||
var code = "b->getIpAddress()";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
var code = "b->getIpAddress()";
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_general_html_tag = function (block) {
|
||||
var tag = this.getFieldValue('TAG');
|
||||
var code = 'buildTag("' + tag + '",';
|
||||
var n = 0;
|
||||
var branch = Blockly.Arduino.valueToCode(block, 'DO' + n, Blockly.Arduino.ORDER_NONE);
|
||||
if (branch.length > 0) {
|
||||
code += '\n ' + branch;
|
||||
} else {
|
||||
code += '""';
|
||||
}
|
||||
for (n = 1; n <= block.additionalChildCount_; n++) {
|
||||
branch = Blockly.Arduino.valueToCode(block, 'DO' + n, Blockly.Arduino.ORDER_NONE);
|
||||
code += ' +' + branch;
|
||||
}
|
||||
return [code + ')', Blockly.Arduino.ORDER_ATOMIC];
|
||||
var tag = this.getFieldValue("TAG");
|
||||
var code = 'buildTag("' + tag + '",';
|
||||
var n = 0;
|
||||
var branch = Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"DO" + n,
|
||||
Blockly.Arduino.ORDER_NONE
|
||||
);
|
||||
if (branch.length > 0) {
|
||||
code += "\n " + branch;
|
||||
} else {
|
||||
code += '""';
|
||||
}
|
||||
for (n = 1; n <= block.additionalChildCount_; n++) {
|
||||
branch = Blockly.Arduino.valueToCode(
|
||||
block,
|
||||
"DO" + n,
|
||||
Blockly.Arduino.ORDER_NONE
|
||||
);
|
||||
code += " +" + branch;
|
||||
}
|
||||
return [code + ")", Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_web_readHTML = function (block) {
|
||||
var filename = this.getFieldValue('FILENAME');
|
||||
Blockly.Arduino.libraries_['library_spi'] = '#include <SPI.h>';
|
||||
Blockly.Arduino.libraries_['library_sd'] = '#include <SD.h>';
|
||||
Blockly.Arduino.codeFunctions_['define_sd' + filename] = 'File webFile;';
|
||||
Blockly.Arduino.setupCode_['sensebox_sd'] = 'SD.begin(28);';
|
||||
var func = [
|
||||
'String generateHTML(){',
|
||||
' webFile = SD.open("' + filename + '", FILE_READ);',
|
||||
' String finalString ="";',
|
||||
' while (webFile.available())',
|
||||
' {',
|
||||
' finalString+=(char)webFile.read();',
|
||||
' }',
|
||||
' return finalString;',
|
||||
'}'];
|
||||
var functionName = Blockly.Arduino.addFunction(
|
||||
'generateHTML', func.join('\n'));
|
||||
var code = functionName + '()';
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
var filename = this.getFieldValue("FILENAME");
|
||||
Blockly.Arduino.libraries_["library_spi"] = "#include <SPI.h>";
|
||||
Blockly.Arduino.libraries_["library_sd"] = "#include <SD.h>";
|
||||
Blockly.Arduino.codeFunctions_["define_sd" + filename] = "File webFile;";
|
||||
Blockly.Arduino.setupCode_["sensebox_sd"] = "SD.begin(28);";
|
||||
Blockly.Arduino.codeFunctions_["generateHTML"] = `
|
||||
String generateHTML(){
|
||||
webFile = SD.open("${filename}", FILE_READ);
|
||||
String finalString ="";
|
||||
while (webFile.available())
|
||||
{
|
||||
finalString+=(char)webFile.read();
|
||||
}
|
||||
return finalString;
|
||||
}`;
|
||||
var code = `generateHTML()`;
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
@ -8,103 +8,110 @@
|
||||
* types.
|
||||
*/
|
||||
|
||||
|
||||
/** Single character. */
|
||||
export const CHARACTER = {
|
||||
typeId: 'Character',
|
||||
typeName: 'char',
|
||||
typeMsgName: 'ARD_TYPE_CHAR',
|
||||
}
|
||||
typeId: "Character",
|
||||
typeName: "char",
|
||||
typeMsgName: "ARD_TYPE_CHAR",
|
||||
};
|
||||
|
||||
export const BOOLEAN = {
|
||||
typeId: 'Boolean',
|
||||
typeName: 'boolean',
|
||||
typeMsgName: 'ARD_TYPE_BOOL',
|
||||
}
|
||||
typeId: "Boolean",
|
||||
typeName: "boolean",
|
||||
typeMsgName: "ARD_TYPE_BOOL",
|
||||
};
|
||||
|
||||
/** Text string. */
|
||||
export const TEXT = {
|
||||
typeId: 'Text',
|
||||
typeName: 'String',
|
||||
typeMsgName: 'ARD_TYPE_TEXT',
|
||||
}
|
||||
typeId: "Text",
|
||||
typeName: "String",
|
||||
typeMsgName: "ARD_TYPE_TEXT",
|
||||
};
|
||||
|
||||
/** Short integer number. */
|
||||
export const SHORT_NUMBER = {
|
||||
typeId: 'Short_Number',
|
||||
typeName: 'int',
|
||||
typeMsgName: 'ARD_TYPE_SHORT',
|
||||
}
|
||||
typeId: "Short_Number",
|
||||
typeName: "int",
|
||||
typeMsgName: "ARD_TYPE_SHORT",
|
||||
};
|
||||
|
||||
/** Integer number. */
|
||||
export const NUMBER = {
|
||||
typeId: 'Number',
|
||||
typeName: 'int',
|
||||
typeMsgName: 'ARD_TYPE_NUMBER',
|
||||
}
|
||||
typeId: "Number",
|
||||
typeName: "int",
|
||||
typeMsgName: "ARD_TYPE_NUMBER",
|
||||
};
|
||||
|
||||
/** Large integer number. */
|
||||
export const LARGE_NUMBER = {
|
||||
typeId: 'Large Number',
|
||||
typeName: 'long',
|
||||
typeMsgName: 'ARD_TYPE_LONG',
|
||||
}
|
||||
typeId: "Large Number",
|
||||
typeName: "long",
|
||||
typeMsgName: "ARD_TYPE_LONG",
|
||||
};
|
||||
|
||||
/** Decimal/floating point number. */
|
||||
export const DECIMAL = {
|
||||
typeId: 'Decimal',
|
||||
typeName: 'float',
|
||||
typeMsgName: 'ARD_TYPE_DECIMAL',
|
||||
}
|
||||
typeId: "Decimal",
|
||||
typeName: "float",
|
||||
typeMsgName: "ARD_TYPE_DECIMAL",
|
||||
};
|
||||
|
||||
/** Array/List of items. */
|
||||
export const ARRAY = {
|
||||
typeId: 'Array',
|
||||
typeName: 'Array',
|
||||
typeMsgName: 'ARD_TYPE_ARRAY',
|
||||
compatibleTypes: []
|
||||
}
|
||||
typeId: "Array",
|
||||
typeName: "Array",
|
||||
typeMsgName: "ARD_TYPE_ARRAY",
|
||||
compatibleTypes: [],
|
||||
};
|
||||
|
||||
/** Null indicate there is no type. */
|
||||
export const NULL = {
|
||||
typeId: 'Null',
|
||||
typeName: 'void',
|
||||
typeMsgName: 'ARD_TYPE_NULL',
|
||||
}
|
||||
typeId: "Null",
|
||||
typeName: "void",
|
||||
typeMsgName: "ARD_TYPE_NULL",
|
||||
};
|
||||
|
||||
/** Type not defined, or not yet defined. */
|
||||
export const UNDEF = {
|
||||
typeId: 'Undefined',
|
||||
typeName: 'undef',
|
||||
typeMsgName: 'ARD_TYPE_UNDEF',
|
||||
}
|
||||
typeId: "Undefined",
|
||||
typeName: "undef",
|
||||
typeMsgName: "ARD_TYPE_UNDEF",
|
||||
};
|
||||
|
||||
/** Set when no child block (meant to define the variable type) is connected. */
|
||||
export const CHILD_BLOCK_MISSING = {
|
||||
typeId: 'ChildBlockMissing',
|
||||
typeMsgName: 'ARD_TYPE_CHILDBLOCKMISSING',
|
||||
compatibleTypes: []
|
||||
}
|
||||
|
||||
const compatibleTypes = {
|
||||
Array: ['Array'],
|
||||
boolean: ['boolean'],
|
||||
int: ['int', 'long', 'double', 'float'],
|
||||
char: ['char'],
|
||||
String: ['String'],
|
||||
void: ['void'],
|
||||
long: ['int', 'long'],
|
||||
double: ['int', 'long', 'double'],
|
||||
float: ['int', 'long', 'double', 'float'],
|
||||
null: ['null']
|
||||
|
||||
}
|
||||
|
||||
export const getCompatibleTypes = (type) => {
|
||||
return compatibleTypes[type];
|
||||
typeId: "ChildBlockMissing",
|
||||
typeMsgName: "ARD_TYPE_CHILDBLOCKMISSING",
|
||||
compatibleTypes: [],
|
||||
};
|
||||
|
||||
export const VARIABLE_TYPES = [['SHORT_NUMBER', 'char'], ['NUMBER', 'int'], ['DECIMAL', 'long'], ['TEXT', 'String'], ['CHARACTER', 'char'], ['BOOLEAN', 'boolean'], ['NULL', 'void'], ['UNDEF', 'undefined']];
|
||||
const compatibleTypes = {
|
||||
Array: ["Array"],
|
||||
boolean: ["boolean"],
|
||||
int: ["int", "long", "double", "float"],
|
||||
char: ["char"],
|
||||
String: ["String"],
|
||||
void: ["void"],
|
||||
long: ["int", "long"],
|
||||
double: ["int", "long", "double"],
|
||||
float: ["int", "long", "double", "float"],
|
||||
null: ["null"],
|
||||
};
|
||||
|
||||
export const getCompatibleTypes = (type) => {
|
||||
return compatibleTypes[type];
|
||||
};
|
||||
|
||||
export const VARIABLE_TYPES = [
|
||||
["SHORT_NUMBER", "char"],
|
||||
["NUMBER", "int"],
|
||||
["DECIMAL", "long"],
|
||||
["TEXT", "String"],
|
||||
["CHARACTER", "char"],
|
||||
["BOOLEAN", "boolean"],
|
||||
["NULL", "void"],
|
||||
["UNDEF", "undefined"],
|
||||
];
|
||||
|
||||
// /**
|
||||
// * Some Types have circular dependencies on their compatibilities, so add them
|
||||
@ -233,7 +240,3 @@ export const VARIABLE_TYPES = [['SHORT_NUMBER', 'char'], ['NUMBER', 'int'], ['DE
|
||||
// }
|
||||
// return Blockly.Types.NULL;
|
||||
// };
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,13 +1,16 @@
|
||||
export const SD = {
|
||||
/**
|
||||
* SD-Block
|
||||
*/
|
||||
senseBox_sd_create_file: "Erstelle Datei auf SD-Karte",
|
||||
senseBox_sd_write_file: "Schreibe Daten auf SD-Karte",
|
||||
senseBox_sd_open_file: "Öffne eine Datei auf der SD-Karte",
|
||||
senseBox_sd_create_file_tooltip: "Erstellt eine Datei auf der Karte. Stecke das SD-Bee auf den Steckplatz **XBEE2**. Die **maximale** Länge des Dateinamen sind **8 Zeichen**. Die Datei sollte zuerst im *Setup()* erstellt werden",
|
||||
senseBox_sd_write_file_tooptip: "Schreibe Daten auf die SD-Karte. Beachte, dass die Datei zuerst geöffnet werden muss.",
|
||||
senseBox_sd_open_file_tooltip: "Öffne die Datei auf der SD-Karte, um Dateien zu speichern. Am Ende der Schleife wird die Datei automatisch wieder geschlossen.",
|
||||
sensebox_sd_filename: "Daten",
|
||||
senseBox_sd_decimals: "Dezimalen",
|
||||
}
|
||||
/**
|
||||
* SD-Block
|
||||
*/
|
||||
senseBox_sd_create_file: "Erstelle Datei auf SD-Karte",
|
||||
senseBox_sd_write_file: "Schreibe Daten auf SD-Karte",
|
||||
senseBox_sd_open_file: "Öffne Datei auf der SD-Karte",
|
||||
senseBox_sd_create_file_tooltip:
|
||||
"Erstellt eine Datei auf der Karte. Stecke das SD-Bee auf den Steckplatz **XBEE2**. Die **maximale** Länge des Dateinamen sind **8 Zeichen**. Die Datei sollte zuerst im *Setup()* erstellt werden",
|
||||
senseBox_sd_write_file_tooptip:
|
||||
"Schreibe Daten auf die SD-Karte. Beachte, dass die Datei zuerst geöffnet werden muss.",
|
||||
senseBox_sd_open_file_tooltip:
|
||||
"Öffne die Datei auf der SD-Karte, um Dateien zu speichern. Am Ende der Schleife wird die Datei automatisch wieder geschlossen.",
|
||||
sensebox_sd_filename: "Daten",
|
||||
senseBox_sd_decimals: "Dezimalen",
|
||||
};
|
||||
|
@ -1,20 +1,22 @@
|
||||
export const TIME = {
|
||||
|
||||
/**
|
||||
* Interval Block
|
||||
*/
|
||||
senseBox_interval_timer: "Messintervall",
|
||||
senseBox_interval: "ms",
|
||||
senseBox_interval_timer_tip: "Intervall",
|
||||
ARD_TIME_DELAY: "Warte",
|
||||
ARD_TIME_DELAY_MICROS: "Mikrosekunden",
|
||||
ARD_TIME_DELAY_MICRO_TIP: "Warte eine spezifischen Zeit in Microsekunden",
|
||||
ARD_TIME_DELAY_TIP: "Warte spezifische Zeit in Millisekunden",
|
||||
ARD_TIME_INF: "Warte für immer (Beende Programm)",
|
||||
ARD_TIME_INF_TIP: "Stoppt das Programm.",
|
||||
ARD_TIME_MICROS: "Bereits vergangen Zeit (Mikrosekunden)",
|
||||
ARD_TIME_MICROS_TIP: "Gibt eine Zahl in Microsekunden zurück, die der Zeitdauer des Aktuellen Programms entspricht. Muss als positiven Integer gespeichert werden", // untranslated
|
||||
ARD_TIME_MILLIS: "Bereits vergangen Zeit (Millisekunden)",
|
||||
ARD_TIME_MILLIS_TIP: "Gibt eine Zahl in Millisekunden zurück, die der Zeitdauer des Aktuellen Programms entspricht. Muss als positiven Integer gespeichert werden", // untranslated
|
||||
ARD_TIME_MS: "Millisekunden",
|
||||
}
|
||||
/**
|
||||
* Interval Block
|
||||
*/
|
||||
senseBox_interval_timer: "Intervall:",
|
||||
senseBox_interval: "ms",
|
||||
senseBox_interval_timer_tip: "Intervall",
|
||||
senseBox_interval_time: "Zeit: ",
|
||||
ARD_TIME_DELAY: "Warte",
|
||||
ARD_TIME_DELAY_MICROS: "Mikrosekunden",
|
||||
ARD_TIME_DELAY_MICRO_TIP: "Warte eine spezifischen Zeit in Microsekunden",
|
||||
ARD_TIME_DELAY_TIP: "Warte spezifische Zeit in Millisekunden",
|
||||
ARD_TIME_INF: "Warte für immer (Beende Programm)",
|
||||
ARD_TIME_INF_TIP: "Stoppt das Programm.",
|
||||
ARD_TIME_MICROS: "Bereits vergangen Zeit (Mikrosekunden)",
|
||||
ARD_TIME_MICROS_TIP:
|
||||
"Gibt eine Zahl in Microsekunden zurück, die der Zeitdauer des Aktuellen Programms entspricht. Muss als positiven Integer gespeichert werden", // untranslated
|
||||
ARD_TIME_MILLIS: "Bereits vergangen Zeit (Millisekunden)",
|
||||
ARD_TIME_MILLIS_TIP:
|
||||
"Gibt eine Zahl in Millisekunden zurück, die der Zeitdauer des Aktuellen Programms entspricht. Muss als positiven Integer gespeichert werden", // untranslated
|
||||
ARD_TIME_MS: "Millisekunden",
|
||||
};
|
||||
|
@ -1,17 +1,19 @@
|
||||
export const TIME = {
|
||||
|
||||
senseBox_interval: "ms",
|
||||
senseBox_interval_timer: "Measuring interval",
|
||||
senseBox_interval_timer_tip: "Setup an Intervall",
|
||||
ARD_TIME_DELAY: "wait",
|
||||
ARD_TIME_DELAY_MICROS: "microseconds",
|
||||
ARD_TIME_DELAY_MICRO_TIP: "Wait specific time in microseconds",
|
||||
ARD_TIME_DELAY_TIP: "Wait specific time in milliseconds",
|
||||
ARD_TIME_INF: "wait forever (end program)",
|
||||
ARD_TIME_INF_TIP: "Wait indefinitely, stopping the program.",
|
||||
ARD_TIME_MICROS: "current elapsed Time (microseconds)",
|
||||
ARD_TIME_MICROS_TIP: "Returns the number of microseconds since the Arduino board began running the current program. Has to be stored in a positive long integer",
|
||||
ARD_TIME_MILLIS: "current elapsed Time (milliseconds)",
|
||||
ARD_TIME_MILLIS_TIP: "Returns the number of milliseconds since the Arduino board began running the current program. Has to be stored in a positive long integer",
|
||||
ARD_TIME_MS: "milliseconds",
|
||||
}
|
||||
senseBox_interval: "ms",
|
||||
senseBox_interval_timer: "Interval",
|
||||
senseBox_interval_timer_tip: "Setup an Interval",
|
||||
senseBox_interval_time: "time",
|
||||
ARD_TIME_DELAY: "wait",
|
||||
ARD_TIME_DELAY_MICROS: "microseconds",
|
||||
ARD_TIME_DELAY_MICRO_TIP: "Wait specific time in microseconds",
|
||||
ARD_TIME_DELAY_TIP: "Wait specific time in milliseconds",
|
||||
ARD_TIME_INF: "wait forever (end program)",
|
||||
ARD_TIME_INF_TIP: "Wait indefinitely, stopping the program.",
|
||||
ARD_TIME_MICROS: "current elapsed Time (microseconds)",
|
||||
ARD_TIME_MICROS_TIP:
|
||||
"Returns the number of microseconds since the Arduino board began running the current program. Has to be stored in a positive long integer",
|
||||
ARD_TIME_MILLIS: "current elapsed Time (milliseconds)",
|
||||
ARD_TIME_MILLIS_TIP:
|
||||
"Returns the number of milliseconds since the Arduino board began running the current program. Has to be stored in a positive long integer",
|
||||
ARD_TIME_MS: "milliseconds",
|
||||
};
|
||||
|
82
yarn.lock
82
yarn.lock
@ -1142,10 +1142,10 @@
|
||||
"resolved" "https://registry.npmjs.org/@blockly/plugin-modal/-/plugin-modal-1.20200427.4.tgz"
|
||||
"version" "1.20200427.4"
|
||||
|
||||
"@blockly/plugin-typed-variable-modal@^3.1.1":
|
||||
"integrity" "sha512-+g/lQ3HrCcivBNOtgvQEvfZCPq9VeP1Zgs7J02zxAfw4f+s4aOQb+hChv7qAb5AnzEnMk0BoB5vKgQmaP6Wkuw=="
|
||||
"resolved" "https://registry.npmjs.org/@blockly/plugin-typed-variable-modal/-/plugin-typed-variable-modal-3.1.1.tgz"
|
||||
"version" "3.1.1"
|
||||
"@blockly/plugin-typed-variable-modal@^3.1.15":
|
||||
"integrity" "sha512-X+s2Vd8tjt1GPV2gGfZUB+srabRUDWcZ7cOzjajV8gmc0zFu0IOLsR991cBptF1bsp207TEtUyIsoWONHBNp4A=="
|
||||
"resolved" "https://registry.npmjs.org/@blockly/plugin-typed-variable-modal/-/plugin-typed-variable-modal-3.1.15.tgz"
|
||||
"version" "3.1.15"
|
||||
dependencies:
|
||||
"@blockly/plugin-modal" "^1.20200427.4"
|
||||
|
||||
@ -3106,12 +3106,12 @@
|
||||
dependencies:
|
||||
"file-uri-to-path" "1.0.0"
|
||||
|
||||
"blockly@^3.20200924.0":
|
||||
"integrity" "sha512-mOZiXi908oNFAcVb8Q5LKJNRZ5jtBJtgNilddqTYMAXEdqSY/BhcnU2rgytWARDnu2iSQlI374kEafCNuUEWKQ=="
|
||||
"resolved" "https://registry.npmjs.org/blockly/-/blockly-3.20200924.0.tgz"
|
||||
"version" "3.20200924.0"
|
||||
"blockly@^5.20210325.1", "blockly@>3.20200625.0":
|
||||
"integrity" "sha512-qrilYPovJeDfxKDWm1YBUCPVNElh/iyC1szaHTIPZHj9C9YPpSzZOeFyyrPBbYRudzbo8kjBOWMtHnN1bLjkoQ=="
|
||||
"resolved" "https://registry.npmjs.org/blockly/-/blockly-5.20210325.1.tgz"
|
||||
"version" "5.20210325.1"
|
||||
dependencies:
|
||||
"jsdom" "^15.2.1"
|
||||
"jsdom" "15.2.1"
|
||||
|
||||
"bluebird@^3.5.5":
|
||||
"integrity" "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
|
||||
@ -7382,38 +7382,6 @@
|
||||
"resolved" "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz"
|
||||
"version" "0.1.1"
|
||||
|
||||
"jsdom@^15.2.1":
|
||||
"integrity" "sha512-fAl1W0/7T2G5vURSyxBzrJ1LSdQn6Tr5UX/xD4PXDx/PDgwygedfW6El/KIj3xJ7FU61TTYnc/l/B7P49Eqt6g=="
|
||||
"resolved" "https://registry.npmjs.org/jsdom/-/jsdom-15.2.1.tgz"
|
||||
"version" "15.2.1"
|
||||
dependencies:
|
||||
"abab" "^2.0.0"
|
||||
"acorn" "^7.1.0"
|
||||
"acorn-globals" "^4.3.2"
|
||||
"array-equal" "^1.0.0"
|
||||
"cssom" "^0.4.1"
|
||||
"cssstyle" "^2.0.0"
|
||||
"data-urls" "^1.1.0"
|
||||
"domexception" "^1.0.1"
|
||||
"escodegen" "^1.11.1"
|
||||
"html-encoding-sniffer" "^1.0.2"
|
||||
"nwsapi" "^2.2.0"
|
||||
"parse5" "5.1.0"
|
||||
"pn" "^1.1.0"
|
||||
"request" "^2.88.0"
|
||||
"request-promise-native" "^1.0.7"
|
||||
"saxes" "^3.1.9"
|
||||
"symbol-tree" "^3.2.2"
|
||||
"tough-cookie" "^3.0.1"
|
||||
"w3c-hr-time" "^1.0.1"
|
||||
"w3c-xmlserializer" "^1.1.2"
|
||||
"webidl-conversions" "^4.0.2"
|
||||
"whatwg-encoding" "^1.0.5"
|
||||
"whatwg-mimetype" "^2.3.0"
|
||||
"whatwg-url" "^7.0.0"
|
||||
"ws" "^7.0.0"
|
||||
"xml-name-validator" "^3.0.0"
|
||||
|
||||
"jsdom@^16.4.0":
|
||||
"integrity" "sha512-pF73EOsJgwZekbDHEY5VO/yKXUkab/DuvrQB/ANVizbr6UAHJsDdHXuotZYwkJSGQl1JM+ivXaqY+XBDDL4TiA=="
|
||||
"resolved" "https://registry.npmjs.org/jsdom/-/jsdom-16.5.1.tgz"
|
||||
@ -7446,6 +7414,38 @@
|
||||
"ws" "^7.4.4"
|
||||
"xml-name-validator" "^3.0.0"
|
||||
|
||||
"jsdom@15.2.1":
|
||||
"integrity" "sha512-fAl1W0/7T2G5vURSyxBzrJ1LSdQn6Tr5UX/xD4PXDx/PDgwygedfW6El/KIj3xJ7FU61TTYnc/l/B7P49Eqt6g=="
|
||||
"resolved" "https://registry.npmjs.org/jsdom/-/jsdom-15.2.1.tgz"
|
||||
"version" "15.2.1"
|
||||
dependencies:
|
||||
"abab" "^2.0.0"
|
||||
"acorn" "^7.1.0"
|
||||
"acorn-globals" "^4.3.2"
|
||||
"array-equal" "^1.0.0"
|
||||
"cssom" "^0.4.1"
|
||||
"cssstyle" "^2.0.0"
|
||||
"data-urls" "^1.1.0"
|
||||
"domexception" "^1.0.1"
|
||||
"escodegen" "^1.11.1"
|
||||
"html-encoding-sniffer" "^1.0.2"
|
||||
"nwsapi" "^2.2.0"
|
||||
"parse5" "5.1.0"
|
||||
"pn" "^1.1.0"
|
||||
"request" "^2.88.0"
|
||||
"request-promise-native" "^1.0.7"
|
||||
"saxes" "^3.1.9"
|
||||
"symbol-tree" "^3.2.2"
|
||||
"tough-cookie" "^3.0.1"
|
||||
"w3c-hr-time" "^1.0.1"
|
||||
"w3c-xmlserializer" "^1.1.2"
|
||||
"webidl-conversions" "^4.0.2"
|
||||
"whatwg-encoding" "^1.0.5"
|
||||
"whatwg-mimetype" "^2.3.0"
|
||||
"whatwg-url" "^7.0.0"
|
||||
"ws" "^7.0.0"
|
||||
"xml-name-validator" "^3.0.0"
|
||||
|
||||
"jsesc@^2.5.1":
|
||||
"integrity" "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA=="
|
||||
"resolved" "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz"
|
||||
|
Loading…
x
Reference in New Issue
Block a user