update code generator
This commit is contained in:
parent
d67cb74401
commit
faaabf907b
@ -26,6 +26,17 @@
|
|||||||
|
|
||||||
import * as Blockly from "blockly/core";
|
import * as Blockly from "blockly/core";
|
||||||
|
|
||||||
|
import store from "../../../store";
|
||||||
|
|
||||||
|
var ota = store.getState().general.platform
|
||||||
|
? store.getState().general.platform
|
||||||
|
: null;
|
||||||
|
store.subscribe(() => {
|
||||||
|
ota = store.getState().general.platform
|
||||||
|
? store.getState().general.platform
|
||||||
|
: null;
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Arduino code generator.
|
* Arduino code generator.
|
||||||
* @type !Blockly.Generator
|
* @type !Blockly.Generator
|
||||||
@ -254,8 +265,8 @@ Blockly["Arduino"].finish = function (code) {
|
|||||||
"\n}\n";
|
"\n}\n";
|
||||||
|
|
||||||
let loopCode = "\nvoid loop() { \n" + loopCodeOnce + code + "\n}\n";
|
let loopCode = "\nvoid loop() { \n" + loopCodeOnce + code + "\n}\n";
|
||||||
|
// only add OTA code if tablet mode is enabled
|
||||||
// Convert the definitions dictionary into a list.
|
if (ota === true) {
|
||||||
code =
|
code =
|
||||||
devVariables +
|
devVariables +
|
||||||
"\n" +
|
"\n" +
|
||||||
@ -276,6 +287,27 @@ Blockly["Arduino"].finish = function (code) {
|
|||||||
setupCode +
|
setupCode +
|
||||||
"\n" +
|
"\n" +
|
||||||
loopCode;
|
loopCode;
|
||||||
|
} else {
|
||||||
|
// Convert the definitions dictionary into a list.
|
||||||
|
code =
|
||||||
|
devVariables +
|
||||||
|
"\n" +
|
||||||
|
libraryCode +
|
||||||
|
"\n" +
|
||||||
|
variablesCode +
|
||||||
|
"\n" +
|
||||||
|
definitionsCode +
|
||||||
|
"\n" +
|
||||||
|
codeFunctions +
|
||||||
|
"\n" +
|
||||||
|
Blockly["Arduino"].variablesInitCode_ +
|
||||||
|
"\n" +
|
||||||
|
functionsCode +
|
||||||
|
"\n" +
|
||||||
|
setupCode +
|
||||||
|
"\n" +
|
||||||
|
loopCode;
|
||||||
|
}
|
||||||
|
|
||||||
// Clean up temporary data.
|
// Clean up temporary data.
|
||||||
delete Blockly["Arduino"].definitions_;
|
delete Blockly["Arduino"].definitions_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user