update generated code
This commit is contained in:
		
							parent
							
								
									0c8ae90124
								
							
						
					
					
						commit
						c711596285
					
				| @ -108,3 +108,14 @@ Blockly.Blocks["sensebox_ethernet"] = { | |||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
| }; | }; | ||||||
|  | 
 | ||||||
|  | Blockly.Blocks["sensebox_ethernetIp"] = { | ||||||
|  |   init: function () { | ||||||
|  |     this.appendDummyInput().appendField(Blockly.Msg.senseBox_ethernet_ip); | ||||||
|  | 
 | ||||||
|  |     this.setColour(getColour().sensebox); | ||||||
|  |     this.setHelpUrl(Blockly.Msg.senseBox_ethernetIp_helpurl); | ||||||
|  |     this.setTooltip(Blockly.Msg.senseBox_ethernet_ip_tooltip); | ||||||
|  |     this.setOutput(true, null); | ||||||
|  |   }, | ||||||
|  | }; | ||||||
|  | |||||||
| @ -41,36 +41,41 @@ Blockly.Arduino.sensebox_ethernet = function () { | |||||||
|   Blockly.Arduino.libraries_["library_ethernet"] = "#include <Ethernet.h>"; |   Blockly.Arduino.libraries_["library_ethernet"] = "#include <Ethernet.h>"; | ||||||
| 
 | 
 | ||||||
|   Blockly.Arduino.definitions_["ethernet_config"] = ` |   Blockly.Arduino.definitions_["ethernet_config"] = ` | ||||||
|     byte mac[] = { ${mac}};`;
 | byte mac[] = { ${mac}};`;
 | ||||||
|   if (dhcp === "Manual") { |   if (dhcp === "Manual") { | ||||||
|     Blockly.Arduino.definitions_["ethernet_manual_config"] = ` |     Blockly.Arduino.definitions_["ethernet_manual_config"] = ` | ||||||
|     //Configure static IP setup (only needed if DHCP is disabled)
 | //Configure static IP setup (only needed if DHCP is disabled)
 | ||||||
|     IPAddress myIp(${ip.replaceAll(".", ", ")}); | IPAddress myIp(${ip.replaceAll(".", ", ")}); | ||||||
|     IPAddress myDns(${dns.replaceAll(".", ",")}); | IPAddress myDns(${dns.replaceAll(".", ",")}); | ||||||
|     IPAddress myGateway(${gateway.replaceAll(".", ",")}); | IPAddress myGateway(${gateway.replaceAll(".", ",")}); | ||||||
|     IPAddress mySubnet(${subnetmask.replaceAll(".", ",")}); | IPAddress mySubnet(${subnetmask.replaceAll(".", ",")}); | ||||||
|     `;
 |     `;
 | ||||||
|     Blockly.Arduino.setupCode_["ethernet_setup"] = ` |     Blockly.Arduino.setupCode_["ethernet_setup"] = ` | ||||||
|     Ethernet.init(23); | Ethernet.init(23); | ||||||
|     // start the Ethernet connection:
 | // start the Ethernet connection:
 | ||||||
|     if (Ethernet.begin(mac) == 0) { | if (Ethernet.begin(mac) == 0) { | ||||||
|     // no point in carrying on, so do nothing forevermore:
 |     // no point in carrying on, so do nothing forevermore:
 | ||||||
|     // try to congifure using IP address instead of DHCP:
 |     // try to congifure using IP address instead of DHCP:
 | ||||||
|     Ethernet.begin(mac, myIp); |     Ethernet.begin(mac, myIp); | ||||||
|     } | } | ||||||
|     // give the Ethernet shield a second to initialize:
 | // give the Ethernet shield a second to initialize:
 | ||||||
|     delay(1000); | delay(1000); | ||||||
|     `;
 |     `;
 | ||||||
|   } else { |   } else { | ||||||
|     Blockly.Arduino.setupCode_["ethernet_setup"] = ` |     Blockly.Arduino.setupCode_["ethernet_setup"] = ` | ||||||
|     Ethernet.init(23); | Ethernet.init(23); | ||||||
|     // start the Ethernet connection:
 | // start the Ethernet connection:
 | ||||||
|     Ethernet.begin(mac); | Ethernet.begin(mac); | ||||||
|     // give the Ethernet shield a second to initialize:
 | // give the Ethernet shield a second to initialize:
 | ||||||
|     delay(1000); | delay(1000); | ||||||
|     `;
 |     `;
 | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   var code = ""; |   var code = ""; | ||||||
|   return code; |   return code; | ||||||
| }; | }; | ||||||
|  | 
 | ||||||
|  | Blockly.Arduino.sensebox_ethernetIp = function () { | ||||||
|  |   var code = "Ethernet.localIP()"; | ||||||
|  |   return [code, Blockly.Arduino.ORDER_ATOMIC]; | ||||||
|  | }; | ||||||
|  | |||||||
| @ -94,8 +94,9 @@ class Toolbox extends React.Component { | |||||||
|           <Block type="sensebox_wifi" /> |           <Block type="sensebox_wifi" /> | ||||||
|           <Block type="sensebox_startap" /> |           <Block type="sensebox_startap" /> | ||||||
|         </Category> |         </Category> | ||||||
|         <Category name="Misc" colour={getColour().sensebox}> |         <Category name="Ethernet" colour={getColour().sensebox}> | ||||||
|           <Block type="sensebox_ethernet" /> |           <Block type="sensebox_ethernet" /> | ||||||
|  |           <Block type="sensebox_ethernetIp" /> | ||||||
|         </Category> |         </Category> | ||||||
|         <Category name="SD" colour={getColour().sensebox}> |         <Category name="SD" colour={getColour().sensebox}> | ||||||
|           <Block type="sensebox_sd_create_file" /> |           <Block type="sensebox_sd_create_file" /> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user