update code generators
This commit is contained in:
		
							parent
							
								
									59a226f22e
								
							
						
					
					
						commit
						6fe4c3aab3
					
				| @ -18,16 +18,6 @@ Blockly.Blocks["sensebox_osem_connection"] = { | |||||||
|     this.setColour(getColour().sensebox); |     this.setColour(getColour().sensebox); | ||||||
|     this.appendDummyInput() |     this.appendDummyInput() | ||||||
|       .appendField(Blockly.Msg.senseBox_osem_connection) |       .appendField(Blockly.Msg.senseBox_osem_connection) | ||||||
|       .appendField( |  | ||||||
|         new Blockly.FieldDropdown([ |  | ||||||
|           [Blockly.Msg.senseBox_osem_host, '"ingress.opensensemap.org"'], |  | ||||||
|           [ |  | ||||||
|             Blockly.Msg.senseBox_osem_host_workshop, |  | ||||||
|             '"ingress.workshop.opensensemap.org"', |  | ||||||
|           ], |  | ||||||
|         ]), |  | ||||||
|         "host" |  | ||||||
|       ) |  | ||||||
|       .appendField("SSL") |       .appendField("SSL") | ||||||
|       .appendField(new Blockly.FieldCheckbox("TRUE"), "SSL"); |       .appendField(new Blockly.FieldCheckbox("TRUE"), "SSL"); | ||||||
|     this.appendDummyInput() |     this.appendDummyInput() | ||||||
|  | |||||||
| @ -50,7 +50,7 @@ Blockly.Blocks["sensebox_wifi_status"] = { | |||||||
|   }, |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks["sensebox_wifi_ip"] = { | Blockly.Blocks["sensebox_get_ip"] = { | ||||||
|   init: function () { |   init: function () { | ||||||
|     this.setTooltip(Blockly.Msg.senseBox_wifi_ip_tooltip); |     this.setTooltip(Blockly.Msg.senseBox_wifi_ip_tooltip); | ||||||
|     this.setColour(getColour().sensebox); |     this.setColour(getColour().sensebox); | ||||||
|  | |||||||
| @ -18,7 +18,6 @@ Blockly.Arduino.sensebox_send_to_osem = function (block) { | |||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_osem_connection = function (Block) { | Blockly.Arduino.sensebox_osem_connection = function (Block) { | ||||||
|   var box_id = this.getFieldValue("BoxID"); |   var box_id = this.getFieldValue("BoxID"); | ||||||
|   var host = this.getFieldValue("host"); |  | ||||||
|   var branch = Blockly.Arduino.statementToCode(Block, "DO"); |   var branch = Blockly.Arduino.statementToCode(Block, "DO"); | ||||||
|   var access_token = this.getFieldValue("access_token"); |   var access_token = this.getFieldValue("access_token"); | ||||||
|   var blocks = this.getDescendants(); |   var blocks = this.getDescendants(); | ||||||
| @ -42,7 +41,7 @@ Blockly.Arduino.sensebox_osem_connection = function (Block) { | |||||||
|   Blockly.Arduino.definitions_["SenseBoxID"] = |   Blockly.Arduino.definitions_["SenseBoxID"] = | ||||||
|     'const char SENSEBOX_ID [] PROGMEM = "' + box_id + '";'; |     'const char SENSEBOX_ID [] PROGMEM = "' + box_id + '";'; | ||||||
|   Blockly.Arduino.definitions_["host"] = |   Blockly.Arduino.definitions_["host"] = | ||||||
|     "const char server [] PROGMEM =" + host + ";"; |     'const char server [] PROGMEM ="ingress.opensensemap.org";'; | ||||||
|   if (ssl === "TRUE") { |   if (ssl === "TRUE") { | ||||||
|     Blockly.Arduino.libraries_["library_bearSSL"] = |     Blockly.Arduino.libraries_["library_bearSSL"] = | ||||||
|       "#include <ArduinoBearSSL.h>"; |       "#include <ArduinoBearSSL.h>"; | ||||||
|  | |||||||
| @ -26,9 +26,7 @@ Blockly.Arduino.sensebox_sensor_uv_light = function () { | |||||||
|   var dropdown_name = this.getFieldValue("NAME"); |   var dropdown_name = this.getFieldValue("NAME"); | ||||||
|   let code = ""; |   let code = ""; | ||||||
|   Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>"; |   Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>"; | ||||||
| 
 |   Blockly.Arduino.libraries_["library_ltr329"] = `#include <LTR329.h>`; | ||||||
|   Blockly.Arduino.libraries_["library_senseBoxMCU"] = |  | ||||||
|     '#include "SenseBoxMCU.h"'; |  | ||||||
|   if (dropdown_name === "UvIntensity") { |   if (dropdown_name === "UvIntensity") { | ||||||
|     Blockly.Arduino.libraries_["library_veml6070"] = "#include <VEML6070.h>"; |     Blockly.Arduino.libraries_["library_veml6070"] = "#include <VEML6070.h>"; | ||||||
|     Blockly.Arduino.definitions_["define_veml"] = "VEML6070 veml;;"; |     Blockly.Arduino.definitions_["define_veml"] = "VEML6070 veml;;"; | ||||||
| @ -67,11 +65,9 @@ Blockly.Arduino.sensebox_sensor_uv_light = function () { | |||||||
|     { |     { | ||||||
|       Wire.begin(); |       Wire.begin(); | ||||||
|       unsigned int u = 0; |       unsigned int u = 0; | ||||||
|       DEBUG(F("Checking lightsensortype")); |  | ||||||
|       u = read_reg(0x29, 0x80 | 0x0A); //id register
 |       u = read_reg(0x29, 0x80 | 0x0A); //id register
 | ||||||
|       if ((u & 0xF0) == 0xA0)            // TSL45315
 |       if ((u & 0xF0) == 0xA0)            // TSL45315
 | ||||||
|       { |       { | ||||||
|         DEBUG(F("TSL45315")); |  | ||||||
|         write_reg(0x29, 0x80 | 0x00, 0x03); //control: power on
 |         write_reg(0x29, 0x80 | 0x00, 0x03); //control: power on
 | ||||||
|         write_reg(0x29, 0x80 | 0x01, 0x02); //config: M=4 T=100ms
 |         write_reg(0x29, 0x80 | 0x01, 0x02); //config: M=4 T=100ms
 | ||||||
|         delay(120); |         delay(120); | ||||||
| @ -79,7 +75,6 @@ Blockly.Arduino.sensebox_sensor_uv_light = function () { | |||||||
|       } |       } | ||||||
|       else |       else | ||||||
|       { |       { | ||||||
|         DEBUG(F("LTR329")); |  | ||||||
|         LTR.begin(); |         LTR.begin(); | ||||||
|         LTR.setControl(gain, false, false); |         LTR.setControl(gain, false, false); | ||||||
|         LTR.setMeasurementRate(integrationTime, measurementRate); |         LTR.setMeasurementRate(integrationTime, measurementRate); | ||||||
| @ -107,14 +102,11 @@ Blockly.Arduino.sensebox_sensor_uv_light = function () { | |||||||
|     for (int i = 0; i < 5; i++) { |     for (int i = 0; i < 5; i++) { | ||||||
|       if (LTR.getData(data0, data1)) { |       if (LTR.getData(data0, data1)) { | ||||||
|         if(LTR.getLux(gain, integrationTime, data0, data1, lux)); |         if(LTR.getLux(gain, integrationTime, data0, data1, lux)); | ||||||
|         else DEBUG(F("LTR sensor saturated")); |  | ||||||
|         if(lux > 0) break; |         if(lux > 0) break; | ||||||
|         else delay(10); |         else delay(10); | ||||||
|       } |       } | ||||||
|       else { |       else { | ||||||
|         DEBUG2(F("LTR getData error ")); |  | ||||||
|         byte error = LTR.getError(); |         byte error = LTR.getError(); | ||||||
|         Serial.println(error); |  | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| @ -131,8 +123,8 @@ Blockly.Arduino.sensebox_sensor_uv_light = function () { | |||||||
|     unsigned char measurementRate = 3; |     unsigned char measurementRate = 3; | ||||||
|     `;
 |     `;
 | ||||||
|     Blockly.Arduino.setupCode_["sensebox_sensor_illuminance"] = |     Blockly.Arduino.setupCode_["sensebox_sensor_illuminance"] = | ||||||
|       "Lightsensor_begin()"; |       "Lightsensor_begin();"; | ||||||
|     code = "Lightsensor_getIlluminance();"; |     code = "Lightsensor_getIlluminance()"; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   return [code, Blockly.Arduino.ORDER_ATOMIC]; |   return [code, Blockly.Arduino.ORDER_ATOMIC]; | ||||||
| @ -147,6 +139,7 @@ Blockly.Arduino.sensebox_sensor_bmx055_accelerometer = function () { | |||||||
|   var dropdown_value = this.getFieldValue("VALUE"); |   var dropdown_value = this.getFieldValue("VALUE"); | ||||||
|   var range = this.getFieldValue("RANGE"); |   var range = this.getFieldValue("RANGE"); | ||||||
|   Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>"; |   Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>"; | ||||||
|  |   Blockly.Arduino.libraries_["library_bmx055"] = `#include <BMX055.h>`; | ||||||
|   Blockly.Arduino.definitions_["define_bmx"] = "BMX055 bmx;"; |   Blockly.Arduino.definitions_["define_bmx"] = "BMX055 bmx;"; | ||||||
|   Blockly.Arduino.setupCode_["sensebox_sensor_bmx055"] = |   Blockly.Arduino.setupCode_["sensebox_sensor_bmx055"] = | ||||||
|     "bmx.beginAcc(" + range + ");"; |     "bmx.beginAcc(" + range + ");"; | ||||||
|  | |||||||
| @ -34,13 +34,13 @@ while (status != WL_CONNECTED) { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_wifi_status = function () { | Blockly.Arduino.sensebox_wifi_status = function () { | ||||||
|   var code = "WiFi.status();"; |   var code = "WiFi.status()"; | ||||||
|   return code; |   return [code, Blockly.Arduino.ORDER_ATOMIC]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_wifi_rssi = function () { | Blockly.Arduino.sensebox_wifi_rssi = function () { | ||||||
|   var code = "WiFi.RSSI();"; |   var code = "WiFi.RSSI();"; | ||||||
|   return code; |   return [code, Blockly.Arduino.ORDER_ATOMIC]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_get_ip = function () { | Blockly.Arduino.sensebox_get_ip = function () { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user