add watchdog
This commit is contained in:
		
							parent
							
								
									3e3956b185
								
							
						
					
					
						commit
						0c8ae90124
					
				| @ -21,6 +21,7 @@ import "./procedures"; | |||||||
| import "./time"; | import "./time"; | ||||||
| import "./variables"; | import "./variables"; | ||||||
| import "./lists"; | import "./lists"; | ||||||
|  | import "./watchdog"; | ||||||
| import "./webserver"; | import "./webserver"; | ||||||
| 
 | 
 | ||||||
| import "../helpers/types"; | 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 "./time"; | ||||||
| import "./variables"; | import "./variables"; | ||||||
| import "./lists"; | import "./lists"; | ||||||
|  | import "./watchdog"; | ||||||
| import "./webserver"; | 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" |           custom="PROCEDURE" | ||||||
|         ></Category> |         ></Category> | ||||||
|         <sep></sep> |         <sep></sep> | ||||||
|         <Category name={Blockly.Msg.toolbox_io} colour={getColour().io}> |         <Category name="Advanced" colour={getColour().io}> | ||||||
|           <Block type="io_digitalwrite"></Block> |           <Category name={Blockly.Msg.toolbox_io} colour={getColour().io}> | ||||||
|           <Block type="io_digitalread"></Block> |             <Block type="io_digitalwrite"></Block> | ||||||
|           <Block type="io_builtin_led"></Block> |             <Block type="io_digitalread"></Block> | ||||||
|           <Block type="io_analogwrite"></Block> |             <Block type="io_builtin_led"></Block> | ||||||
|           <Block type="io_analogread"></Block> |             <Block type="io_analogwrite"></Block> | ||||||
|           <Block type="io_highlow"></Block> |             <Block type="io_analogread"></Block> | ||||||
|           <Block type="io_pulsein"> |             <Block type="io_highlow"></Block> | ||||||
|             <Value name="PULSETYPE"> |             <Block type="io_pulsein"> | ||||||
|               <Shadow type="io_highlow"></Shadow> |               <Value name="PULSETYPE"> | ||||||
|             </Value> |                 <Shadow type="io_highlow"></Shadow> | ||||||
|           </Block> |               </Value> | ||||||
|           <Block type="io_pulsetimeout"> |             </Block> | ||||||
|             <Value name="PULSETYPE"> |             <Block type="io_pulsetimeout"> | ||||||
|               <Shadow type="io_highlow"></Shadow> |               <Value name="PULSETYPE"> | ||||||
|             </Value> |                 <Shadow type="io_highlow"></Shadow> | ||||||
|             <Value name="TIMEOUT"> |               </Value> | ||||||
|               <Shadow type="math_number"> |               <Value name="TIMEOUT"> | ||||||
|                 <Field name="NUM">100</Field> |                 <Shadow type="math_number"> | ||||||
|               </Shadow> |                   <Field name="NUM">100</Field> | ||||||
|             </Value> |                 </Shadow> | ||||||
|           </Block> |               </Value> | ||||||
|  |             </Block> | ||||||
|  |           </Category> | ||||||
|  |           <Category name="Watchdog" colour={getColour().io}> | ||||||
|  |             <Block type="watchdog_enable"></Block> | ||||||
|  |             <Block type="watchdog_reset"></Block> | ||||||
|  |           </Category> | ||||||
|         </Category> |         </Category> | ||||||
|         {/* this block is the initial block of the workspace; not necessary |         {/* this block is the initial block of the workspace; not necessary | ||||||
|                     to display, because it can only be used once anyway |                     to display, because it can only be used once anyway | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user