From 6fe4c3aab3d6d60e0efaa8309d358922cad7132c Mon Sep 17 00:00:00 2001 From: Mario Pesch Date: Wed, 15 Dec 2021 10:08:31 +0100 Subject: [PATCH] update code generators --- src/components/Blockly/blocks/sensebox-osem.js | 10 ---------- src/components/Blockly/blocks/sensebox-web.js | 2 +- src/components/Blockly/generator/sensebox-osem.js | 3 +-- .../Blockly/generator/sensebox-sensors.js | 15 ++++----------- src/components/Blockly/generator/sensebox-web.js | 6 +++--- 5 files changed, 9 insertions(+), 27 deletions(-) diff --git a/src/components/Blockly/blocks/sensebox-osem.js b/src/components/Blockly/blocks/sensebox-osem.js index e88f522..fa6345f 100644 --- a/src/components/Blockly/blocks/sensebox-osem.js +++ b/src/components/Blockly/blocks/sensebox-osem.js @@ -18,16 +18,6 @@ Blockly.Blocks["sensebox_osem_connection"] = { this.setColour(getColour().sensebox); this.appendDummyInput() .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(new Blockly.FieldCheckbox("TRUE"), "SSL"); this.appendDummyInput() diff --git a/src/components/Blockly/blocks/sensebox-web.js b/src/components/Blockly/blocks/sensebox-web.js index a982291..c6a33c7 100644 --- a/src/components/Blockly/blocks/sensebox-web.js +++ b/src/components/Blockly/blocks/sensebox-web.js @@ -50,7 +50,7 @@ Blockly.Blocks["sensebox_wifi_status"] = { }, }; -Blockly.Blocks["sensebox_wifi_ip"] = { +Blockly.Blocks["sensebox_get_ip"] = { init: function () { this.setTooltip(Blockly.Msg.senseBox_wifi_ip_tooltip); this.setColour(getColour().sensebox); diff --git a/src/components/Blockly/generator/sensebox-osem.js b/src/components/Blockly/generator/sensebox-osem.js index f616a41..7ca312e 100644 --- a/src/components/Blockly/generator/sensebox-osem.js +++ b/src/components/Blockly/generator/sensebox-osem.js @@ -18,7 +18,6 @@ Blockly.Arduino.sensebox_send_to_osem = function (block) { Blockly.Arduino.sensebox_osem_connection = function (Block) { var box_id = this.getFieldValue("BoxID"); - var host = this.getFieldValue("host"); var branch = Blockly.Arduino.statementToCode(Block, "DO"); var access_token = this.getFieldValue("access_token"); var blocks = this.getDescendants(); @@ -42,7 +41,7 @@ Blockly.Arduino.sensebox_osem_connection = function (Block) { Blockly.Arduino.definitions_["SenseBoxID"] = 'const char SENSEBOX_ID [] PROGMEM = "' + box_id + '";'; Blockly.Arduino.definitions_["host"] = - "const char server [] PROGMEM =" + host + ";"; + 'const char server [] PROGMEM ="ingress.opensensemap.org";'; if (ssl === "TRUE") { Blockly.Arduino.libraries_["library_bearSSL"] = "#include "; diff --git a/src/components/Blockly/generator/sensebox-sensors.js b/src/components/Blockly/generator/sensebox-sensors.js index 0c908ed..a72a14c 100644 --- a/src/components/Blockly/generator/sensebox-sensors.js +++ b/src/components/Blockly/generator/sensebox-sensors.js @@ -26,9 +26,7 @@ Blockly.Arduino.sensebox_sensor_uv_light = function () { var dropdown_name = this.getFieldValue("NAME"); let code = ""; Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include "; - - Blockly.Arduino.libraries_["library_senseBoxMCU"] = - '#include "SenseBoxMCU.h"'; + Blockly.Arduino.libraries_["library_ltr329"] = `#include `; if (dropdown_name === "UvIntensity") { Blockly.Arduino.libraries_["library_veml6070"] = "#include "; Blockly.Arduino.definitions_["define_veml"] = "VEML6070 veml;;"; @@ -67,11 +65,9 @@ Blockly.Arduino.sensebox_sensor_uv_light = function () { { Wire.begin(); unsigned int u = 0; - DEBUG(F("Checking lightsensortype")); u = read_reg(0x29, 0x80 | 0x0A); //id register if ((u & 0xF0) == 0xA0) // TSL45315 { - DEBUG(F("TSL45315")); write_reg(0x29, 0x80 | 0x00, 0x03); //control: power on write_reg(0x29, 0x80 | 0x01, 0x02); //config: M=4 T=100ms delay(120); @@ -79,7 +75,6 @@ Blockly.Arduino.sensebox_sensor_uv_light = function () { } else { - DEBUG(F("LTR329")); LTR.begin(); LTR.setControl(gain, false, false); LTR.setMeasurementRate(integrationTime, measurementRate); @@ -107,14 +102,11 @@ Blockly.Arduino.sensebox_sensor_uv_light = function () { for (int i = 0; i < 5; i++) { if (LTR.getData(data0, data1)) { if(LTR.getLux(gain, integrationTime, data0, data1, lux)); - else DEBUG(F("LTR sensor saturated")); if(lux > 0) break; else delay(10); } else { - DEBUG2(F("LTR getData error ")); byte error = LTR.getError(); - Serial.println(error); } } } @@ -131,8 +123,8 @@ Blockly.Arduino.sensebox_sensor_uv_light = function () { unsigned char measurementRate = 3; `; Blockly.Arduino.setupCode_["sensebox_sensor_illuminance"] = - "Lightsensor_begin()"; - code = "Lightsensor_getIlluminance();"; + "Lightsensor_begin();"; + code = "Lightsensor_getIlluminance()"; } return [code, Blockly.Arduino.ORDER_ATOMIC]; @@ -147,6 +139,7 @@ Blockly.Arduino.sensebox_sensor_bmx055_accelerometer = function () { var dropdown_value = this.getFieldValue("VALUE"); var range = this.getFieldValue("RANGE"); Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include "; + Blockly.Arduino.libraries_["library_bmx055"] = `#include `; Blockly.Arduino.definitions_["define_bmx"] = "BMX055 bmx;"; Blockly.Arduino.setupCode_["sensebox_sensor_bmx055"] = "bmx.beginAcc(" + range + ");"; diff --git a/src/components/Blockly/generator/sensebox-web.js b/src/components/Blockly/generator/sensebox-web.js index eefa627..f7caa36 100644 --- a/src/components/Blockly/generator/sensebox-web.js +++ b/src/components/Blockly/generator/sensebox-web.js @@ -34,13 +34,13 @@ while (status != WL_CONNECTED) { }; Blockly.Arduino.sensebox_wifi_status = function () { - var code = "WiFi.status();"; - return code; + var code = "WiFi.status()"; + return [code, Blockly.Arduino.ORDER_ATOMIC]; }; Blockly.Arduino.sensebox_wifi_rssi = function () { var code = "WiFi.RSSI();"; - return code; + return [code, Blockly.Arduino.ORDER_ATOMIC]; }; Blockly.Arduino.sensebox_get_ip = function () {