add watchdog
This commit is contained in:
parent
3e3956b185
commit
0c8ae90124
@ -21,6 +21,7 @@ import "./procedures";
|
||||
import "./time";
|
||||
import "./variables";
|
||||
import "./lists";
|
||||
import "./watchdog";
|
||||
import "./webserver";
|
||||
|
||||
import "../helpers/types";
|
||||
|
28
src/components/Blockly/blocks/watchdog.js
Normal file
28
src/components/Blockly/blocks/watchdog.js
Normal file
@ -0,0 +1,28 @@
|
||||
import Blockly from "blockly/core";
|
||||
import { getColour } from "../helpers/colour";
|
||||
|
||||
Blockly.Blocks["watchdog_enable"] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField("Watchdog aktivieren")
|
||||
.appendField(new Blockly.FieldTextInput("10000"), "TIME")
|
||||
.appendField("ms");
|
||||
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().io);
|
||||
this.setTooltip("");
|
||||
this.setHelpUrl("");
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["watchdog_reset"] = {
|
||||
init: function () {
|
||||
this.appendDummyInput().appendField("Watchdog zurücksetzen");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setColour(getColour().io);
|
||||
this.setTooltip("");
|
||||
this.setHelpUrl("");
|
||||
},
|
||||
};
|
@ -22,4 +22,5 @@ import "./procedures";
|
||||
import "./time";
|
||||
import "./variables";
|
||||
import "./lists";
|
||||
import "./watchdog";
|
||||
import "./webserver";
|
||||
|
16
src/components/Blockly/generator/watchdog.js
Normal file
16
src/components/Blockly/generator/watchdog.js
Normal file
@ -0,0 +1,16 @@
|
||||
import * as Blockly from "blockly/core";
|
||||
|
||||
Blockly.Arduino.watchdog_enable = function () {
|
||||
var time = this.getFieldValue("TIME");
|
||||
|
||||
Blockly.Arduino.libraries_["Adafruit_sleepydog"] =
|
||||
"#include <Adafruit_SleepyDog.h>";
|
||||
Blockly.Arduino.setupCode_["watchdog_enable"] = `Watchdog.enable(${time});`;
|
||||
var code = "";
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.watchdog_reset = function () {
|
||||
var code = "Watchdog.reset();";
|
||||
return code;
|
||||
};
|
@ -608,28 +608,34 @@ class Toolbox extends React.Component {
|
||||
custom="PROCEDURE"
|
||||
></Category>
|
||||
<sep></sep>
|
||||
<Category name={Blockly.Msg.toolbox_io} colour={getColour().io}>
|
||||
<Block type="io_digitalwrite"></Block>
|
||||
<Block type="io_digitalread"></Block>
|
||||
<Block type="io_builtin_led"></Block>
|
||||
<Block type="io_analogwrite"></Block>
|
||||
<Block type="io_analogread"></Block>
|
||||
<Block type="io_highlow"></Block>
|
||||
<Block type="io_pulsein">
|
||||
<Value name="PULSETYPE">
|
||||
<Shadow type="io_highlow"></Shadow>
|
||||
</Value>
|
||||
</Block>
|
||||
<Block type="io_pulsetimeout">
|
||||
<Value name="PULSETYPE">
|
||||
<Shadow type="io_highlow"></Shadow>
|
||||
</Value>
|
||||
<Value name="TIMEOUT">
|
||||
<Shadow type="math_number">
|
||||
<Field name="NUM">100</Field>
|
||||
</Shadow>
|
||||
</Value>
|
||||
</Block>
|
||||
<Category name="Advanced" colour={getColour().io}>
|
||||
<Category name={Blockly.Msg.toolbox_io} colour={getColour().io}>
|
||||
<Block type="io_digitalwrite"></Block>
|
||||
<Block type="io_digitalread"></Block>
|
||||
<Block type="io_builtin_led"></Block>
|
||||
<Block type="io_analogwrite"></Block>
|
||||
<Block type="io_analogread"></Block>
|
||||
<Block type="io_highlow"></Block>
|
||||
<Block type="io_pulsein">
|
||||
<Value name="PULSETYPE">
|
||||
<Shadow type="io_highlow"></Shadow>
|
||||
</Value>
|
||||
</Block>
|
||||
<Block type="io_pulsetimeout">
|
||||
<Value name="PULSETYPE">
|
||||
<Shadow type="io_highlow"></Shadow>
|
||||
</Value>
|
||||
<Value name="TIMEOUT">
|
||||
<Shadow type="math_number">
|
||||
<Field name="NUM">100</Field>
|
||||
</Shadow>
|
||||
</Value>
|
||||
</Block>
|
||||
</Category>
|
||||
<Category name="Watchdog" colour={getColour().io}>
|
||||
<Block type="watchdog_enable"></Block>
|
||||
<Block type="watchdog_reset"></Block>
|
||||
</Category>
|
||||
</Category>
|
||||
{/* this block is the initial block of the workspace; not necessary
|
||||
to display, because it can only be used once anyway
|
||||
|
Loading…
x
Reference in New Issue
Block a user