put initLora always to the end of the setup
This commit is contained in:
		
							parent
							
								
									7b89897e54
								
							
						
					
					
						commit
						b4a59d3875
					
				| @ -106,6 +106,9 @@ Blockly['Arduino'].init = function (workspace) { | ||||
|     // creates a list of code to be setup before the setup block
 | ||||
|     Blockly['Arduino'].setupCode_ = Object.create(null); | ||||
| 
 | ||||
|     // creates a list of code to be setup before the setup block
 | ||||
|     Blockly['Arduino'].loraSetupCode_ = Object.create(null); | ||||
| 
 | ||||
|     // creates a list of code for the loop to be runned once
 | ||||
|     Blockly['Arduino'].loopCodeOnce_ = Object.create(null) | ||||
| 
 | ||||
| @ -202,6 +205,7 @@ Blockly['Arduino'].finish = function (code) { | ||||
|     let loopCodeOnce = ''; | ||||
|     let setupCode = ''; | ||||
|     let preSetupCode = ''; | ||||
|     let loraSetupCode = ''; | ||||
|     let devVariables = '\n'; | ||||
| 
 | ||||
|     for (const key in Blockly['Arduino'].libraries_) { | ||||
| @ -233,7 +237,13 @@ Blockly['Arduino'].finish = function (code) { | ||||
|     for (const key in Blockly['Arduino'].setupCode_) { | ||||
|         preSetupCode += Blockly['Arduino'].setupCode_[key] || ''; | ||||
|     } | ||||
|     setupCode = '\nvoid setup() { \n' + preSetupCode + '\n}\n'; | ||||
| 
 | ||||
|     for (const key in Blockly['Arduino'].loraSetupCode_) { | ||||
|         loraSetupCode += Blockly['Arduino'].loraSetupCode_[key] || ''; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     setupCode = '\nvoid setup() { \n' + preSetupCode + '\n' + loraSetupCode + '\n}\n'; | ||||
| 
 | ||||
|     let loopCode = '\nvoid loop() { \n' + loopCodeOnce + code + '\n}\n'; | ||||
| 
 | ||||
|  | ||||
| @ -120,9 +120,9 @@ Blockly.Arduino.sensebox_lora_initialize_otaa = function (block) { | ||||
|               break; | ||||
|       } | ||||
|   }`;
 | ||||
|     Blockly.Arduino.setupCode_['initLora'] = 'initLora();'; | ||||
|     Blockly.Arduino.setupCode_['serial.begin'] = 'Serial.begin(9600);'; | ||||
|     var code = '' | ||||
|     Blockly.Arduino.loraSetupCode_['initLora'] = 'initLora();\n'; | ||||
|     Blockly.Arduino.setupCode_['serial.begin'] = 'Serial.begin(9600);\n'; | ||||
|     var code = ''; | ||||
|     return code; | ||||
| }; | ||||
| 
 | ||||
| @ -425,8 +425,8 @@ Blockly.Arduino.sensebox_lora_initialize_abp = function (block) { | ||||
|               break; | ||||
|       } | ||||
|   }`;
 | ||||
|     Blockly.Arduino.setupCode_['initLora'] = 'initLora();'; | ||||
|     Blockly.Arduino.setupCode_['serial.begin'] = 'Serial.begin(9600);'; | ||||
|     Blockly.Arduino.loraSetupCode_['initLora'] = 'initLora();\n'; | ||||
|     Blockly.Arduino.setupCode_['serial.begin'] = 'Serial.begin(9600);\n'; | ||||
|     return ''; | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user