minor changes

This commit is contained in:
Mario 2020-09-17 15:16:41 +02:00
parent 6a4de9c7a2
commit 42299a374a
8 changed files with 44 additions and 32 deletions

View File

@ -33,11 +33,11 @@ class BlocklyWindow extends Component {
componentDidUpdate(props) { componentDidUpdate(props) {
const workspace = Blockly.getMainWorkspace(); const workspace = Blockly.getMainWorkspace();
var initialXML = this.props.initialXml var initialXML = this.props.initialXml
if(props.initialXml !== initialXml){ if (props.initialXml !== initialXml) {
// guarantees that the current xml-code (this.props.initialXml) is rendered // guarantees that the current xml-code (this.props.initialXml) is rendered
workspace.clear(); workspace.clear();
if(!initialXML) initialXML = initialXml; if (!initialXML) initialXML = initialXml;
Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom(initialXML), workspace) ; Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom(initialXML), workspace);
} }
Blockly.svgResize(workspace); Blockly.svgResize(workspace);
} }
@ -48,11 +48,11 @@ class BlocklyWindow extends Component {
style={this.props.blocklyCSS} style={this.props.blocklyCSS}
readOnly={this.props.readOnly !== undefined ? this.props.readOnly : false} readOnly={this.props.readOnly !== undefined ? this.props.readOnly : false}
trashcan={this.props.trashcan !== undefined ? this.props.trashcan : true} trashcan={this.props.trashcan !== undefined ? this.props.trashcan : true}
renderer='zelos' renderer='geras'
zoom={{ // https://developers.google.com/blockly/guides/configure/web/zoom zoom={{ // https://developers.google.com/blockly/guides/configure/web/zoom
controls: this.props.zoomControls !== undefined ? this.props.zoomControls : true, controls: this.props.zoomControls !== undefined ? this.props.zoomControls : true,
wheel: false, wheel: false,
startScale: 0.8, startScale: 1.0,
maxScale: 3, maxScale: 3,
minScale: 0.3, minScale: 0.3,
scaleSpeed: 1.2 scaleSpeed: 1.2
@ -63,14 +63,14 @@ class BlocklyWindow extends Component {
length: 1, length: 1,
colour: '#4EAF47', // senseBox-green colour: '#4EAF47', // senseBox-green
snap: false snap: false
}} }}
media={'/media/'} media={'/media/'}
move={this.props.move !== undefined && !this.props.move ? {} : move={this.props.move !== undefined && !this.props.move ? {} :
{ // https://developers.google.com/blockly/guides/configure/web/move { // https://developers.google.com/blockly/guides/configure/web/move
scrollbars: true, scrollbars: true,
drag: true, drag: true,
wheel: false wheel: false
}} }}
initialXml={this.props.initialXml ? this.props.initialXml : initialXml} initialXml={this.props.initialXml ? this.props.initialXml : initialXml}
> >

View File

@ -14,9 +14,9 @@ Blockly['Arduino']['controls_repeat_ext'] = function (Block) {
let branch = Blockly['Arduino'].statementToCode(Block, 'DO'); let branch = Blockly['Arduino'].statementToCode(Block, 'DO');
branch = Blockly['Arduino'].addLoopTrap(branch, Block.id); branch = Blockly['Arduino'].addLoopTrap(branch, Block.id);
let code = ''; let code = '';
const loopVar = 'simple_loop_variable'; const loopVar = 'i';
code += code +=
'for (' + 'for (int ' +
loopVar + loopVar +
' = 1; ' + ' = 1; ' +
loopVar + loopVar +
@ -36,6 +36,8 @@ Blockly['Arduino']['controls_for'] = function (Block) {
Block.getFieldValue('VAR') Block.getFieldValue('VAR')
).name; ).name;
const branch = Blockly['Arduino'].statementToCode(Block, 'DO'); const branch = Blockly['Arduino'].statementToCode(Block, 'DO');
const startNumber = const startNumber =

View File

@ -19,9 +19,9 @@ Blockly.Arduino['arduino_functions'] = function (block) {
} }
var setupBranch = Blockly.Arduino.statementToCode(block, 'SETUP_FUNC'); var setupBranch = Blockly.Arduino.statementToCode(block, 'SETUP_FUNC');
//var setupCode = Blockly.Arduino.scrub_(block, setupBranch); No comment block // //var setupCode = Blockly.Arduino.scrub_(block, setupBranch); No comment block
if (setupBranch) { if (setupBranch) {
Blockly.Arduino.setupCode_('userSetupCode', setupBranch, true); Blockly.Arduino.setupCode_['mainsetup'] = setupBranch;
} }
var loopBranch = statementToCodeNoTab(block, 'LOOP_FUNC'); var loopBranch = statementToCodeNoTab(block, 'LOOP_FUNC');

View File

@ -14,7 +14,7 @@ Blockly.Arduino.sensebox_sd_create_file = function (block) {
var res = filename.slice(0, 4); var res = filename.slice(0, 4);
Blockly.Arduino.libraries_['library_spi'] = '#include <SPI.h>'; Blockly.Arduino.libraries_['library_spi'] = '#include <SPI.h>';
Blockly.Arduino.libraries_['library_sd'] = '#include <SD.h>'; Blockly.Arduino.libraries_['library_sd'] = '#include <SD.h>';
Blockly.Arduino.definitions_['define_' + filename] = 'File dataFile' + res + ';'; Blockly.Arduino.definitions_['define_' + res] = 'File dataFile' + res + ';';
Blockly.Arduino.setupCode_['sensebox_sd'] = 'SD.begin(28);'; 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'; Blockly.Arduino.setupCode_['sensebox_sd' + filename] = 'dataFile' + res + ' = SD.open("' + filename + '", FILE_WRITE);\ndataFile' + res + '.close();\n';
var code = ''; var code = '';

View File

@ -13,7 +13,7 @@ Blockly.Arduino.sensebox_telegram = function (Block) {
UniversalTelegramBot bot(BOTtoken, client);` UniversalTelegramBot bot(BOTtoken, client);`
let code = 'testcode'; let code = '';
return code; return code;
}; };

View File

@ -9,7 +9,6 @@ class Toolbox extends React.Component {
render() { render() {
return ( return (
<xml xmlns="https://developers.google.com/blockly/xml" id="blockly" style={{ display: 'none' }} ref={this.props.toolbox}> <xml xmlns="https://developers.google.com/blockly/xml" id="blockly" style={{ display: 'none' }} ref={this.props.toolbox}>
<Category name="senseBox" colour={getColour().sensebox}>
<Category name="Sensoren" colour={getColour().sensebox}> <Category name="Sensoren" colour={getColour().sensebox}>
<Block type="sensebox_sensor_temp_hum" /> <Block type="sensebox_sensor_temp_hum" />
<Block type="sensebox_sensor_uv_light" /> <Block type="sensebox_sensor_uv_light" />
@ -149,8 +148,9 @@ class Toolbox extends React.Component {
<Block type="sensebox_telegram_do_on_message" /> <Block type="sensebox_telegram_do_on_message" />
<Block type="sensebox_telegram_send" /> <Block type="sensebox_telegram_send" />
</Category> </Category>
<Category name="osem" colour={getColour().sensebox}> <Category name="openSenseMap" colour={getColour().sensebox}>
<Block type="sensebox_osem_connection" /> <Block type="sensebox_osem_connection" />
<Block type="sensebox_send_to_osem" />
</Category> </Category>
<Category id="catSenseBoxOutput_LoRa" name=" LoRa" colour={getColour().sensebox}> <Category id="catSenseBoxOutput_LoRa" name=" LoRa" colour={getColour().sensebox}>
<Category id="catSenseBoxOutput_LoRa_activation" name=" Activation" colour={getColour().sensebox}> <Category id="catSenseBoxOutput_LoRa_activation" name=" Activation" colour={getColour().sensebox}>
@ -172,7 +172,6 @@ class Toolbox extends React.Component {
<Block type="sensebox_lora_cayenne_gps" /> <Block type="sensebox_lora_cayenne_gps" />
</Category> </Category>
</Category> </Category>
</Category>
<Category name="Logic" colour={getColour().logic}> <Category name="Logic" colour={getColour().logic}>
<Block type="controls_if" /> <Block type="controls_if" />
<Block type="controls_ifelse" /> <Block type="controls_ifelse" />

View File

@ -34,18 +34,18 @@ class Compile extends Component {
this.setState({ progress: true }); this.setState({ progress: true });
fetch(`${process.env.REACT_APP_COMPILER_URL}/compile`, { fetch(`${process.env.REACT_APP_COMPILER_URL}/compile`, {
method: "POST", method: "POST",
headers: {'Content-Type': 'application/json'}, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data) body: JSON.stringify(data)
}) })
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
console.log(data) console.log(data)
this.download(data.data.id) this.download(data.data.id)
}) })
.catch(err => { .catch(err => {
console.log(err); console.log(err);
this.setState({ progress: false, open: true }); this.setState({ progress: false, open: true });
}); });
} }
download = (id) => { download = (id) => {
@ -60,7 +60,7 @@ class Compile extends Component {
render() { render() {
return ( return (
<div style={{display: 'inline'}}> <div style={{ display: 'inline' }}>
<Button style={{ float: 'right', color: 'white' }} variant="contained" color="primary" onClick={() => this.compile()}> <Button style={{ float: 'right', color: 'white' }} variant="contained" color="primary" onClick={() => this.compile()}>
Kompilieren Kompilieren
</Button> </Button>
@ -91,4 +91,4 @@ const mapStateToProps = state => ({
arduino: state.workspace.code.arduino arduino: state.workspace.code.arduino
}); });
export default connect(mapStateToProps, null)(withStyles(styles, {withTheme: true})(Compile)); export default connect(mapStateToProps, null)(withStyles(styles, { withTheme: true })(Compile));

View File

@ -8,7 +8,13 @@
"type": "instruction", "type": "instruction",
"headline": "Erste Schritte", "headline": "Erste Schritte",
"text1": "In diesem Tutorial lernst du die ersten Schritte mit der senseBox kennen. Du erstellst ein erstes Programm, baust einen ersten Schaltkreis auf und lernst, wie du das Programm auf die senseBox MCU überträgst.", "text1": "In diesem Tutorial lernst du die ersten Schritte mit der senseBox kennen. Du erstellst ein erstes Programm, baust einen ersten Schaltkreis auf und lernst, wie du das Programm auf die senseBox MCU überträgst.",
"hardware": ["senseboxmcu", "led", "breadboard", "jst-adapter", "resistor"], "hardware": [
"senseboxmcu",
"led",
"breadboard",
"jst-adapter",
"resistor"
],
"requirements": [] "requirements": []
}, },
{ {
@ -49,8 +55,13 @@
"type": "instruction", "type": "instruction",
"headline": "Einführung", "headline": "Einführung",
"text1": "In diesem Tutorial lernst du wie man die senseBox mit dem Internet verbindest.", "text1": "In diesem Tutorial lernst du wie man die senseBox mit dem Internet verbindest.",
"hardware": ["senseboxmcu", "wifi-bee"], "hardware": [
"requirements": [1] "senseboxmcu",
"wifi-bee"
],
"requirements": [
1
]
}, },
{ {
"id": 2, "id": 2,
@ -82,4 +93,4 @@
} }
] ]
} }
] ]