From 9487a490e0362aa48eb167fdc1f04b7d212d0c40 Mon Sep 17 00:00:00 2001 From: Mario Pesch Date: Thu, 9 Dec 2021 09:52:41 +0100 Subject: [PATCH] update code generation to replace mcu library --- package-lock.json | 18 + package.json | 1 + src/components/Blockly/blocks/index.js | 1 + .../Blockly/blocks/sensebox-sensors.js | 55 ++- src/components/Blockly/blocks/sensebox-web.js | 141 ++++---- src/components/Blockly/blocks/serial.js | 47 +++ src/components/Blockly/generator/generator.js | 4 +- src/components/Blockly/generator/index.js | 1 + .../Blockly/generator/sensebox-ble.js | 2 +- .../Blockly/generator/sensebox-sensors.js | 241 ++++++++++--- .../Blockly/generator/sensebox-web.js | 36 +- src/components/Blockly/generator/serial.js | 35 ++ src/components/Blockly/helpers/colour.js | 1 + .../Blockly/msg/de/sensebox-sensors.js | 304 +++++++++-------- src/components/Blockly/msg/de/sensebox-web.js | 28 +- src/components/Blockly/msg/de/ui.js | 1 + .../Blockly/msg/en/sensebox-sensors.js | 318 +++++++++--------- src/components/Blockly/msg/en/sensebox-web.js | 29 +- src/components/Blockly/msg/en/ui.js | 1 + src/components/Blockly/toolbox/Toolbox.js | 7 + yarn.lock | 7 +- 21 files changed, 835 insertions(+), 443 deletions(-) create mode 100644 src/components/Blockly/blocks/serial.js create mode 100644 src/components/Blockly/generator/serial.js diff --git a/package-lock.json b/package-lock.json index 904c851..f494d52 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.1.0", "dependencies": { "@blockly/block-plus-minus": "^2.0.10", + "@blockly/field-grid-dropdown": "^1.0.25", "@blockly/field-slider": "^2.1.1", "@blockly/plugin-scroll-options": "^1.0.2", "@blockly/plugin-typed-variable-modal": "^3.1.26", @@ -1463,6 +1464,17 @@ "node": ">=8.17.0" } }, + "node_modules/@blockly/field-grid-dropdown": { + "version": "1.0.25", + "resolved": "https://registry.npmjs.org/@blockly/field-grid-dropdown/-/field-grid-dropdown-1.0.25.tgz", + "integrity": "sha512-3uGagJiJKltuS54fT/sTVWqN+j8aRUklevYPvchhg711A4gVeQzpWVVtnNk0IywKxTk61Pd/jZNZivPIq8ZFpg==", + "engines": { + "node": ">=8.17.0" + }, + "peerDependencies": { + "blockly": "4.20201217.0 - 6" + } + }, "node_modules/@blockly/field-slider": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/@blockly/field-slider/-/field-slider-2.1.1.tgz", @@ -26245,6 +26257,12 @@ "resolved": "https://registry.npmjs.org/@blockly/block-plus-minus/-/block-plus-minus-2.0.10.tgz", "integrity": "sha512-YWEQd9xHAAn1aJgIuZsAdx2t9ZSjinaSEzbN1c43iU584TvaiPsGq5JcnLpoDIyGgJI90Nk+o4erWyQR+kqLyQ==" }, + "@blockly/field-grid-dropdown": { + "version": "1.0.25", + "resolved": "https://registry.npmjs.org/@blockly/field-grid-dropdown/-/field-grid-dropdown-1.0.25.tgz", + "integrity": "sha512-3uGagJiJKltuS54fT/sTVWqN+j8aRUklevYPvchhg711A4gVeQzpWVVtnNk0IywKxTk61Pd/jZNZivPIq8ZFpg==", + "requires": {} + }, "@blockly/field-slider": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/@blockly/field-slider/-/field-slider-2.1.1.tgz", diff --git a/package.json b/package.json index 3ceca2c..41e1c05 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@blockly/block-plus-minus": "^2.0.10", + "@blockly/field-grid-dropdown": "^1.0.25", "@blockly/field-slider": "^2.1.1", "@blockly/plugin-scroll-options": "^1.0.2", "@blockly/plugin-typed-variable-modal": "^3.1.26", diff --git a/src/components/Blockly/blocks/index.js b/src/components/Blockly/blocks/index.js index b4bf8fa..d39bcb6 100644 --- a/src/components/Blockly/blocks/index.js +++ b/src/components/Blockly/blocks/index.js @@ -18,6 +18,7 @@ import "./audio"; import "./math"; import "./map"; import "./procedures"; +import "./serial"; import "./time"; import "./variables"; import "./lists"; diff --git a/src/components/Blockly/blocks/sensebox-sensors.js b/src/components/Blockly/blocks/sensebox-sensors.js index b7ffa3a..8bb8300 100644 --- a/src/components/Blockly/blocks/sensebox-sensors.js +++ b/src/components/Blockly/blocks/sensebox-sensors.js @@ -2,6 +2,7 @@ import Blockly from "blockly"; import { getColour } from "../helpers/colour"; import * as Types from "../helpers/types"; import { selectedBoard } from "../helpers/board"; +import { FieldGridDropdown } from "@blockly/field-grid-dropdown"; /** * HDC1080 Temperature and Humidity Sensor @@ -245,9 +246,7 @@ Blockly.Blocks["sensebox_sensor_ultrasonic_ranger"] = { [Blockly.Msg.senseBox_ultrasonic_port_B, "B"], [Blockly.Msg.senseBox_ultrasonic_port_C, "C"], ]; - var dropdown = new Blockly.FieldDropdown(dropdownOptions, function ( - option - ) { + var dropdown = new FieldGridDropdown(dropdownOptions, function (option) { var input = option === "A" || option === "B" || option === "C"; this.sourceBlock_.updateShape_(input); }); @@ -268,6 +267,10 @@ Blockly.Blocks["sensebox_sensor_ultrasonic_ranger"] = { new Blockly.FieldDropdown(selectedBoard().digitalPins), "ultrasonic_echo" ); + this.appendDummyInput("maxDistance") + .appendField(Blockly.Msg.senseBox_ultrasonic_maxDistance) + .appendField(new Blockly.FieldTextInput("250"), "maxDistance") + .appendField("cm"); this.setOutput(true, Types.NUMBER.typeName); this.setTooltip(Blockly.Msg.senseBox_ultrasonic_tooltip); this.setHelpUrl(Blockly.Msg.senseBox_ultrasonic_helpurl); @@ -355,6 +358,7 @@ Blockly.Blocks["sensebox_button"] = { [Blockly.Msg.senseBox_button_isPressed, "isPressed"], [Blockly.Msg.senseBox_button_wasPressed, "wasPressed"], [Blockly.Msg.senseBox_button_switch, "Switch"], + [Blockly.Msg.senseBox_button_longPress, "longPress"], ]), "FUNCTION" ) @@ -367,6 +371,51 @@ Blockly.Blocks["sensebox_button"] = { this.setColour(getColour().sensebox); this.setTooltip(Blockly.Msg.senseBox_button_tooltip); }, + /** + * Parse XML to restore the number of pins available. + * @param {!Element} xmlElement XML storage element. + * @this Blockly.Block + */ + + domToMutation: function (xmlElement) { + xmlElement.getAttribute("port"); + }, + /** + * Create XML to represent number of pins selection. + * @return {!Element} XML storage element. + * @this Blockly.Block + */ + mutationToDom: function () { + var container = document.createElement("mutation"); + var input = this.getFieldValue("FUNCTION"); + this.updateShape_(input); + container.setAttribute("FUNCTION", input); + return container; + }, + /** + * Modify this block to have the correct number of pins available. + * @param {boolean} + * @private + * @this Blockly.Block + */ + updateShape_: function () { + var extraFieldExist = this.getFieldValue("time"); + var input = this.getFieldValue("FUNCTION"); + if (input === "longPress" && extraFieldExist === null) { + this.appendDummyInput("extraField") + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(Blockly.Msg.senseBox_pressure_referencePressure) + .appendField(new Blockly.FieldTextInput("1000"), "time") + .appendField("ms"); + } + + if ( + (input === "isPressed" || input === "wasPressed" || input === "Switch") && + extraFieldExist !== null + ) { + this.removeInput("extraField"); + } + }, }; /** diff --git a/src/components/Blockly/blocks/sensebox-web.js b/src/components/Blockly/blocks/sensebox-web.js index 6045657..a982291 100644 --- a/src/components/Blockly/blocks/sensebox-web.js +++ b/src/components/Blockly/blocks/sensebox-web.js @@ -1,60 +1,87 @@ -import Blockly from 'blockly'; -import { getColour } from '../helpers/colour' +import Blockly from "blockly"; +import { getColour } from "../helpers/colour"; +import * as Types from "../helpers/types"; -Blockly.Blocks['sensebox_wifi'] = { - init: function () { - this.setTooltip(Blockly.Msg.senseBox_wifi_tooltip); - this.setHelpUrl(''); - this.setColour(getColour().sensebox); - this.appendDummyInput() - .appendField(Blockly.Msg.senseBox_wifi_connect); - this.appendDummyInput() - .setAlign(Blockly.ALIGN_LEFT) - .appendField(Blockly.Msg.senseBox_wifi_ssid) - .appendField(new Blockly.FieldTextInput("SSID"), "SSID"); - this.appendDummyInput() - .setAlign(Blockly.ALIGN_LEFT) - .appendField(Blockly.Msg.senseBox_output_password) - .appendField(new Blockly.FieldTextInput("Password"), "Password"); - this.setHelpUrl(Blockly.Msg.senseBox_wifi_helpurl) - this.setPreviousStatement(true, null); - this.setNextStatement(true, null); - }, - onchange: function (e) { - var legal = false; - // Is the block nested in a loop? - var block = this; - do { - if (this.LOOP_TYPES.indexOf(block.type) !== -1) { - legal = true; - break; - } - block = block.getSurroundParent(); - } while (block); - if (legal) { - this.setWarningText(null); - - } else { - this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING); - - } - }, - LOOP_TYPES: ['arduino_functions'], +Blockly.Blocks["sensebox_wifi"] = { + init: function () { + this.setTooltip(Blockly.Msg.senseBox_wifi_tooltip); + this.setHelpUrl(""); + this.setColour(getColour().sensebox); + this.appendDummyInput().appendField(Blockly.Msg.senseBox_wifi_connect); + this.appendDummyInput() + .setAlign(Blockly.ALIGN_LEFT) + .appendField(Blockly.Msg.senseBox_wifi_ssid) + .appendField(new Blockly.FieldTextInput("SSID"), "SSID"); + this.appendDummyInput() + .setAlign(Blockly.ALIGN_LEFT) + .appendField(Blockly.Msg.senseBox_output_password) + .appendField(new Blockly.FieldTextInput("Password"), "Password"); + this.setHelpUrl(Blockly.Msg.senseBox_wifi_helpurl); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + }, + onchange: function (e) { + var legal = false; + // Is the block nested in a loop? + var block = this; + do { + if (this.LOOP_TYPES.indexOf(block.type) !== -1) { + legal = true; + break; + } + block = block.getSurroundParent(); + } while (block); + if (legal) { + this.setWarningText(null); + } else { + this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING); + } + }, + LOOP_TYPES: ["arduino_functions"], }; -Blockly.Blocks['sensebox_startap'] = { - init: function () { - this.setTooltip(Blockly.Msg.senseBox_wifi_startap_tooltip); - this.setHelpUrl(''); - this.setColour(getColour().sensebox); - this.appendDummyInput() - .appendField(Blockly.Msg.senseBox_wifi_startap); - this.appendDummyInput() - .setAlign(Blockly.ALIGN_LEFT) - .appendField(Blockly.Msg.senseBox_wifi_ssid) - .appendField(new Blockly.FieldTextInput("SSID"), "SSID"); - this.setHelpUrl(Blockly.Msg.senseBox_wifi_helpurl) - this.setPreviousStatement(true, null); - this.setNextStatement(true, null); - } -}; \ No newline at end of file +Blockly.Blocks["sensebox_wifi_status"] = { + init: function () { + this.setTooltip(Blockly.Msg.senseBox_wifi_status_tooltip); + this.setColour(getColour().sensebox); + this.appendDummyInput().appendField(Blockly.Msg.senseBox_wifi_status); + this.setOutput(true, Types.BOOLEAN.typeName); + this.setHelpUrl(Blockly.Msg.senseBox_wifi_status_helpurl); + }, +}; + +Blockly.Blocks["sensebox_wifi_ip"] = { + init: function () { + this.setTooltip(Blockly.Msg.senseBox_wifi_ip_tooltip); + this.setColour(getColour().sensebox); + this.appendDummyInput().appendField(Blockly.Msg.senseBox_wifi_ip); + this.setOutput(true, Types.TEXT.typeName); + this.setHelpUrl(Blockly.Msg.senseBox_wifi_ip_helpurl); + }, +}; + +Blockly.Blocks["sensebox_wifi_rssi"] = { + init: function () { + this.setTooltip(Blockly.Msg.senseBox_wifi_rssi_tooltip); + this.setColour(getColour().sensebox); + this.appendDummyInput().appendField(Blockly.Msg.senseBox_wifi_rssi); + this.setOutput(true, Types.NUMBER.typeName); + this.setHelpUrl(Blockly.Msg.senseBox_wifi_rssi_helpurl); + }, +}; + +Blockly.Blocks["sensebox_startap"] = { + init: function () { + this.setTooltip(Blockly.Msg.senseBox_wifi_startap_tooltip); + this.setHelpUrl(""); + this.setColour(getColour().sensebox); + this.appendDummyInput().appendField(Blockly.Msg.senseBox_wifi_startap); + this.appendDummyInput() + .setAlign(Blockly.ALIGN_LEFT) + .appendField(Blockly.Msg.senseBox_wifi_ssid) + .appendField(new Blockly.FieldTextInput("SSID"), "SSID"); + this.setHelpUrl(Blockly.Msg.senseBox_wifi_helpurl); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + }, +}; diff --git a/src/components/Blockly/blocks/serial.js b/src/components/Blockly/blocks/serial.js new file mode 100644 index 0000000..1d1a10a --- /dev/null +++ b/src/components/Blockly/blocks/serial.js @@ -0,0 +1,47 @@ +import * as Blockly from "blockly/core"; +import { getColour } from "../helpers/colour"; +import { selectedBoard } from "../helpers/board"; + +Blockly.Blocks["init_serial_monitor"] = { + init: function () { + this.setPreviousStatement(true); + this.setNextStatement(true); + this.setColour(getColour().serial); + this.setHelpUrl("http://arduino.cc/en/Serial/Begin"); + this.appendDummyInput() + .appendField(Blockly.Msg.ARD_SERIAL_SETUP) + .appendField( + new Blockly.FieldDropdown(selectedBoard().serial), + "SERIAL_ID" + ) + .appendField(Blockly.Msg.ARD_SERIAL_SPEED) + .appendField( + new Blockly.FieldDropdown(selectedBoard().serialSpeed), + "SPEED" + ) + .appendField(Blockly.Msg.ARD_SERIAL_BPS); + this.setInputsInline(true); + this.setTooltip(Blockly.Msg.ARD_SERIAL_SETUP_TIP); + }, +}; + +Blockly.Blocks["print_serial_monitor"] = { + init: function () { + this.setPreviousStatement(true); + this.setNextStatement(true); + this.setColour(getColour().serial); + this.setHelpUrl("http://www.arduino.cc/en/Serial/Print"); + this.appendDummyInput() + .appendField( + new Blockly.FieldDropdown(selectedBoard().serial), + "SERIAL_ID" + ) + .appendField(Blockly.Msg.ARD_SERIAL_PRINT); + this.appendValueInput("CONTENT"); + this.appendDummyInput() + .appendField(new Blockly.FieldCheckbox("TRUE"), "NEW_LINE") + .appendField(Blockly.Msg.ARD_SERIAL_PRINT_NEWLINE); + this.setInputsInline(true); + this.setTooltip(Blockly.Msg.ARD_SERIAL_PRINT_TIP); + }, +}; diff --git a/src/components/Blockly/generator/generator.js b/src/components/Blockly/generator/generator.js index 29b77a1..9217522 100644 --- a/src/components/Blockly/generator/generator.js +++ b/src/components/Blockly/generator/generator.js @@ -62,9 +62,7 @@ Blockly["Arduino"].addReservedWords( "pulseIn,millis,micros,delay,delayMicroseconds,min,max,abs,constrain," + "map,pow,sqrt,sin,cos,tan,randomSeed,random,lowByte,highByte,bitRead," + "bitWrite,bitSet,bitClear,ultraSonicDistance,parseDouble,setNeoPixelColor," + - "bit,attachInterrupt,detachInterrupt,interrupts,noInterrupts", - "short", - "isBtnPressed" + "bit,attachInterrupt,detachInterrupt,interrupts,noInterrupts,short,isBtnPressed" ); /** diff --git a/src/components/Blockly/generator/index.js b/src/components/Blockly/generator/index.js index d2cb21e..2083561 100644 --- a/src/components/Blockly/generator/index.js +++ b/src/components/Blockly/generator/index.js @@ -19,6 +19,7 @@ import "./map"; import "./io"; import "./audio"; import "./procedures"; +import "./serial"; import "./time"; import "./variables"; import "./lists"; diff --git a/src/components/Blockly/generator/sensebox-ble.js b/src/components/Blockly/generator/sensebox-ble.js index 910abcf..9f74697 100644 --- a/src/components/Blockly/generator/sensebox-ble.js +++ b/src/components/Blockly/generator/sensebox-ble.js @@ -2,8 +2,8 @@ import * as Blockly from "blockly/core"; Blockly.Arduino.sensebox_phyphox_init = function () { var name = this.getFieldValue("devicename"); - Blockly.Arduino.libraries_["phyphox_library"] = `#include `; Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include "; + Blockly.Arduino.libraries_["phyphox_library"] = `#include `; Blockly.Arduino.phyphoxSetupCode_[ "phyphox_start" ] = `PhyphoxBLE::start("${name}");`; diff --git a/src/components/Blockly/generator/sensebox-sensors.js b/src/components/Blockly/generator/sensebox-sensors.js index 0ef1ec9..0c908ed 100644 --- a/src/components/Blockly/generator/sensebox-sensors.js +++ b/src/components/Blockly/generator/sensebox-sensors.js @@ -7,12 +7,13 @@ import Blockly from "blockly"; Blockly.Arduino.sensebox_sensor_temp_hum = function () { var dropdown_name = this.getFieldValue("NAME"); - Blockly.Arduino.libraries_["library_senseBoxMCU"] = - '#include "SenseBoxMCU.h"'; - Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include "; - Blockly.Arduino.definitions_["define_hdc"] = "HDC1080 hdc;"; + + Blockly.Arduino.libraries_["library_adafruithdc1000"] = + "#include "; + Blockly.Arduino.definitions_["define_hdc"] = + "Adafruit_HDC1000 hdc = Adafruit_HDC1000();;"; Blockly.Arduino.setupCode_["sensebox_sensor_temp_hum"] = "hdc.begin();"; - var code = "hdc.get" + dropdown_name + "()"; + var code = `hdc.read${dropdown_name}()`; return [code, Blockly.Arduino.ORDER_ATOMIC]; }; @@ -24,24 +25,114 @@ Blockly.Arduino.sensebox_sensor_temp_hum = function () { 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"'; if (dropdown_name === "UvIntensity") { - Blockly.Arduino.definitions_["define_veml"] = "VEML6070 veml;"; + Blockly.Arduino.libraries_["library_veml6070"] = "#include "; + Blockly.Arduino.definitions_["define_veml"] = "VEML6070 veml;;"; Blockly.Arduino.setupCode_["sensebox_sensor_uv_light"] = "veml.begin();"; code = "veml.get" + dropdown_name + "()"; } - // if (dropdown_name === 'Illuminance') { - // Blockly.Arduino.definitions_['define_tsl'] = 'TSL45315 tsl;' - // Blockly.Arduino.setupCode_['sensebox_sensor_illuminance'] = 'tsl.begin();' - // code = 'tsl.get' + dropdown_name + '()'; - // } if (dropdown_name === "Illuminance") { - Blockly.Arduino.definitions_["define_lightsensor"] = - "Lightsensor lightsensor;"; + Blockly.Arduino.codeFunctions_["read_reg"] = ` + int read_reg(byte address, uint8_t reg) + { + int i = 0; + Wire.beginTransmission(address); + Wire.write(reg); + Wire.endTransmission(); + Wire.requestFrom((uint8_t)address, (uint8_t)1); + delay(1); + if(Wire.available()) + i = Wire.read(); + return i; + } + `; + Blockly.Arduino.codeFunctions_["write_reg"] = ` + void write_reg(byte address, uint8_t reg, uint8_t val) + { + Wire.beginTransmission(address); + Wire.write(reg); + Wire.write(val); + Wire.endTransmission(); + }`; + + Blockly.Arduino.codeFunctions_["Lightsensor_begin"] = ` + + + + void Lightsensor_begin() + { + 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); + lightsensortype = 0; //TSL45315 + } + else + { + DEBUG(F("LTR329")); + LTR.begin(); + LTR.setControl(gain, false, false); + LTR.setMeasurementRate(integrationTime, measurementRate); + LTR.setPowerUp(); //power on with default settings + delay(10); //Wait 10 ms (max) - wakeup time from standby + lightsensortype = 1; // + } + } +`; + + Blockly.Arduino.codeFunctions_["Lightsensor_getIlluminance"] = ` + unsigned int Lightsensor_getIlluminance() +{ + unsigned int lux = 0; + if (lightsensortype == 0) // TSL45315 + { + unsigned int u = (read_reg(0x29, 0x80 | 0x04) << 0); //data low + u |= (read_reg(0x29, 0x80 | 0x05) << 8); //data high + lux = u * 4; // calc lux with M=4 and T=100ms + } + else if (lightsensortype == 1) //LTR-329ALS-01 + { + delay(100); + unsigned int data0, data1; + 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); + } + } + } + return lux; +} + `; + + Blockly.Arduino.definitions_["define_lightsensor"] = ` + bool lightsensortype = 0; //0 for tsl - 1 for ltr + //settings for LTR sensor + LTR329 LTR; + unsigned char gain = 1; + unsigned char integrationTime = 0; + unsigned char measurementRate = 3; + `; Blockly.Arduino.setupCode_["sensebox_sensor_illuminance"] = - "lightsensor.begin();"; - code = "lightsensor.get" + dropdown_name + "()"; + "Lightsensor_begin()"; + code = "Lightsensor_getIlluminance();"; } return [code, Blockly.Arduino.ORDER_ATOMIC]; @@ -55,8 +146,7 @@ Blockly.Arduino.sensebox_sensor_uv_light = function () { Blockly.Arduino.sensebox_sensor_bmx055_accelerometer = function () { var dropdown_value = this.getFieldValue("VALUE"); var range = this.getFieldValue("RANGE"); - Blockly.Arduino.libraries_["library_senseBoxMCU"] = - '#include "SenseBoxMCU.h"'; + Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include "; Blockly.Arduino.definitions_["define_bmx"] = "BMX055 bmx;"; Blockly.Arduino.setupCode_["sensebox_sensor_bmx055"] = "bmx.beginAcc(" + range + ");"; @@ -72,14 +162,17 @@ Blockly.Arduino.sensebox_sensor_bmx055_accelerometer = function () { Blockly.Arduino.sensebox_sensor_sds011 = function () { var dropdown_name = this.getFieldValue("NAME"); var serial_name = this.getFieldValue("SERIAL"); - Blockly.Arduino.libraries_["library_senseBoxMCU"] = - '#include "SenseBoxMCU.h"'; - Blockly.Arduino.codeFunctions_["define_sds011"] = - "SDS011 my_sds(" + serial_name + ");"; - Blockly.Arduino.variables_["variables_sds011"] = "float p10,p25;\n"; - Blockly.Arduino.setupCode_["sensebox_sensor_sds011"] = - serial_name + ".begin(9600);"; - var code = "my_sds.get" + dropdown_name + "()"; + Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include "; + Blockly.Arduino.libraries_["SdsDustSensor"] = `#include "SdsDustSensor.h"`; + Blockly.Arduino.definitions_["define_sds011"] = + "SdsDustSensor sds(" + serial_name + ");"; + Blockly.Arduino.setupCode_["sds011_begin"] = "sds.begin();"; + Blockly.Arduino.setupCode_["sds011_setActiveReporting"] = + "sds.setActiveReportingMode();"; + Blockly.Arduino.loopCodeOnce_[ + "sds011_getData" + ] = `PmResult pm = sds.readPm();`; + var code = `pm.${dropdown_name}`; return [code, Blockly.Arduino.ORDER_ATOMIC]; }; @@ -92,14 +185,23 @@ Blockly.Arduino.sensebox_sensor_pressure = function () { var dropdown_name = this.getFieldValue("NAME"); var code = ""; var referencePressure = this.getFieldValue("referencePressure"); - Blockly.Arduino.libraries_["library_senseBoxMCU"] = - '#include "SenseBoxMCU.h"'; - Blockly.Arduino.definitions_["define_pressure"] = "BMP280 bmp_sensor;"; - Blockly.Arduino.setupCode_["sensebox_bmp_sensor"] = "bmp_sensor.begin();"; + Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include "; + Blockly.Arduino.libraries_[ + "adafruit_bmp280" + ] = `#include `; + Blockly.Arduino.definitions_["define_pressure"] = "Adafruit_BMP280 bmp;"; + Blockly.Arduino.setupCode_["sensebox_bmp_sensor"] = "bmp.begin();"; + Blockly.Arduino.setupCode_["bmp_setSampling"] = ` +bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, + Adafruit_BMP280::SAMPLING_X2, + Adafruit_BMP280::SAMPLING_X16, + Adafruit_BMP280::FILTER_X16, + Adafruit_BMP280::STANDBY_MS_500); + `; if (dropdown_name === "Pressure" || dropdown_name === "Temperature") { - code = "bmp_sensor.get" + dropdown_name + "()"; + code = "bmp.read" + dropdown_name + "()"; } else if (dropdown_name === "Altitude") { - code = "bmp_sensor.getAltitude(" + referencePressure + ")"; + code = "bmp.readAltitude(" + referencePressure + ")"; } return [code, Blockly.Arduino.ORDER_ATOMIC]; }; @@ -223,18 +325,19 @@ Blockly.Arduino.sensebox_sensor_ultrasonic_ranger = function () { var dropdown_pin_RX = this.getFieldValue("ultrasonic_trigger"); var dropdown_pin_TX = this.getFieldValue("ultrasonic_echo"); var port = this.getFieldValue("port"); - Blockly.Arduino.libraries_["library_senseBoxMCU"] = - '#include "SenseBoxMCU.h"'; - Blockly.Arduino.definitions_["var_ultrasonic" + port] = - "Ultrasonic Ultrasonic" + - port + - "(" + - dropdown_pin_RX + - "," + - dropdown_pin_TX + - ");"; + var maxDistance = this.getFieldValue("maxDistance"); + Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include "; + Blockly.Arduino.libraries_["library_newPing"] = `#include `; + Blockly.Arduino.variables_["define_newPingVariables" + port] = ` +#define TRIGGER_PIN_${port} ${dropdown_pin_RX} +#define ECHO_PIN_${port} ${dropdown_pin_TX} +#define MAX_DISTANCE_${port} ${maxDistance} + `; + Blockly.Arduino.definitions_[ + "define_newPing" + port + ] = `NewPing sonar${port}(TRIGGER_PIN_${port}, ECHO_PIN_${port}, MAX_DISTANCE_${port})`; var code; - code = "Ultrasonic" + port + ".getDistance()"; + code = `sonar${port}.ping_cm()`; return [code, Blockly.Arduino.ORDER_ATOMIC]; }; @@ -245,11 +348,37 @@ Blockly.Arduino.sensebox_sensor_ultrasonic_ranger = function () { Blockly.Arduino.sensebox_sensor_sound = function () { var dropdown_pin = this.getFieldValue("PIN"); - Blockly.Arduino.libraries_["library_senseBoxMCU"] = - '#include "SenseBoxMCU.h"'; - Blockly.Arduino.definitions_["define_microphone"] = - "Microphone microphone(" + dropdown_pin + ");"; - var code = "microphone.getValue()"; + Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include "; + Blockly.Arduino.codeFunctions_["define_sound"] = ` +float getSoundValue(int pin) { + unsigned long start = millis(); // Start des Messintervalls + unsigned int peakToPeak = 0; // Abstand von maximalem zu minimalem Amplitudenausschlag + unsigned int signalMax = 0; + unsigned int signalMin = 1023; + const int sampleTime = 100; + unsigned int micValue; + + // Sammle Daten für 100 Millisekunden + while (millis() - start < sampleTime) + { + micValue = analogRead(pin); // Messe den aktuellen Wert + if (micValue < 1023) // sortiere Fehlmessungen aus, deren Werte über dem max Wert 1024 liegen + { + if (micValue > signalMax) + { + signalMax = micValue; // speichere den maximal gemessenen Wert + } + else if (micValue < signalMin) + { + signalMin = micValue; // speichere den minimal gemessenen Wert + } + } + } + peakToPeak = signalMax - signalMin; // max - min = Abstand von maximalem zu minimalem Amplitudenausschlag + double volts = (peakToPeak * 5.0) / 1023; // wandle in Volt um + return volts; +}`; + var code = "getSoundValue(" + dropdown_pin + ")"; return [code, Blockly.Arduino.ORDER_ATOMIC]; }; @@ -261,12 +390,14 @@ Blockly.Arduino.sensebox_sensor_sound = function () { Blockly.Arduino.sensebox_button = function () { var dropdown_pin = this.getFieldValue("PIN"); var dropown_function = this.getFieldValue("FUNCTION"); - Blockly.Arduino.libraries_["library_senseBoxMCU"] = - '#include "SenseBoxMCU.h"'; + Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include "; + Blockly.Arduino.libraries_["library_jcButtons"] = `#include `; Blockly.Arduino.definitions_["define_button" + dropdown_pin + ""] = "Button button_" + dropdown_pin + "(" + dropdown_pin + ");"; Blockly.Arduino.setupCode_["setup_button" + dropdown_pin + ""] = "button_" + dropdown_pin + ".begin();"; + Blockly.Arduino.loopCodeOnce_["loop_button" + dropdown_pin + ""] = + "button_" + dropdown_pin + ".read();"; var code = ""; if (dropown_function === "isPressed") { code = "button_" + dropdown_pin + ".isPressed()"; @@ -274,6 +405,9 @@ Blockly.Arduino.sensebox_button = function () { code = "button_" + dropdown_pin + ".getSwitch()"; } else if (dropown_function === "wasPressed") { code = "button_" + dropdown_pin + ".wasPressed()"; + } else if (dropown_function === "longPress") { + var time = this.getFieldValue("time"); + code = "button_" + dropdown_pin + ".pressedFor(" + time + ")"; } return [code, Blockly.Arduino.ORDER_ATOMIC]; }; @@ -285,10 +419,9 @@ Blockly.Arduino.sensebox_button = function () { Blockly.Arduino.sensebox_scd30 = function () { var dropdown = this.getFieldValue("dropdown"); + Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include "; Blockly.Arduino.libraries_["scd30_library"] = '#include "SparkFun_SCD30_Arduino_Library.h"'; - Blockly.Arduino.libraries_["library_senseBoxMCU"] = - '#include "SenseBoxMCU.h"'; Blockly.Arduino.definitions_["SCD30"] = "SCD30 airSensor;"; Blockly.Arduino.setupCode_["init_scd30"] = ` Wire.begin(); if (airSensor.begin() == false) @@ -320,11 +453,10 @@ Blockly.Arduino.sensebox_scd30 = function () { Blockly.Arduino.sensebox_gps = function () { var dropdown = this.getFieldValue("dropdown"); + Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include "; Blockly.Arduino.libraries_["gps_library"] = "#include "; Blockly.Arduino.libraries_["library_wire"] = "#include "; - Blockly.Arduino.libraries_["library_senseBoxMCU"] = - '#include "SenseBoxMCU.h"'; Blockly.Arduino.definitions_["GPS"] = "SFE_UBLOX_GNSS myGNSS;"; Blockly.Arduino.setupCode_["init_gps"] = ` Wire.begin(); @@ -384,6 +516,7 @@ return tsBuffer; */ Blockly.Arduino.sensebox_sensor_truebner_smt50 = function () { + Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include "; var dropdown_port = this.getFieldValue("Port"); var dropdown_value = this.getFieldValue("value"); var dropdown_pin = 1; @@ -436,6 +569,7 @@ Blockly.Arduino.sensebox_sensor_watertemperature = function () { if (dropdown_port === "C") { dropdown_pin = 5; } + Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include "; Blockly.Arduino.libraries_["library_oneWire"] = '#include "OneWire.h"'; Blockly.Arduino.libraries_["library_oneDallasTemperature"] = '#include "DallasTemperature.h"'; @@ -489,6 +623,7 @@ float getWindspeed(){ */ Blockly.Arduino.sensebox_soundsensor_dfrobot = function () { + Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include "; var dropdown_port = this.getFieldValue("Port"); var dropdown_pin = 1; if (dropdown_port === "A") { diff --git a/src/components/Blockly/generator/sensebox-web.js b/src/components/Blockly/generator/sensebox-web.js index a1961ca..eefa627 100644 --- a/src/components/Blockly/generator/sensebox-web.js +++ b/src/components/Blockly/generator/sensebox-web.js @@ -10,10 +10,17 @@ Blockly.Arduino.sensebox_wifi = function (block) { Blockly.Arduino.variables_["pass"] = `char pass[] = ${pw};`; Blockly.Arduino.variables_["wifi_Status"] = "int status = WL_IDLE_STATUS;"; if (pw === "") { - Blockly.Arduino.setupCode_["sensebox_network"] = - 'b->connectToWifi("' + ssid + '");\ndelay(1000);'; + Blockly.Arduino.setupCode_["wifi_begin"] = ` + if (WiFi.status() == WL_NO_SHIELD) { + while (true); + } + while (status != WL_CONNECTED) { + status = WiFi.begin(ssid); + delay(5000); + } + `; } else - Blockly.Arduino.setupCode_["sensebox_network"] = ` + Blockly.Arduino.setupCode_["wifi_begin"] = ` if (WiFi.status() == WL_NO_SHIELD) { while (true); } @@ -26,13 +33,28 @@ while (status != WL_CONNECTED) { return code; }; +Blockly.Arduino.sensebox_wifi_status = function () { + var code = "WiFi.status();"; + return code; +}; + +Blockly.Arduino.sensebox_wifi_rssi = function () { + var code = "WiFi.RSSI();"; + return code; +}; + +Blockly.Arduino.sensebox_get_ip = function () { + Blockly.Arduino.definitions_["define_ipadress"] = "IPAddress ip;"; + Blockly.Arduino.setupCode_["sensebox_get_ip"] = " ip = WiFi.localIP(ip);"; + var code = ""; + return [code, Blockly.Arduino.ORDER_ATOMIC]; +}; + Blockly.Arduino.sensebox_startap = function (block) { var ssid = this.getFieldValue("SSID"); - Blockly.Arduino.libraries_["library_senseBoxMCU"] = - '#include "SenseBoxMCU.h"'; + Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include "; Blockly.Arduino.definitions_["define_network"] = "Bee* b = new Bee();"; - Blockly.Arduino.setupCode_["sensebox_network"] = - 'b->startAP("' + ssid + '");'; + Blockly.Arduino.setupCode_["wifi_startAP"] = `WiFi.beginAP(${ssid});`; var code = ""; return code; }; diff --git a/src/components/Blockly/generator/serial.js b/src/components/Blockly/generator/serial.js new file mode 100644 index 0000000..f32e82f --- /dev/null +++ b/src/components/Blockly/generator/serial.js @@ -0,0 +1,35 @@ +import * as Blockly from "blockly/core"; + +Blockly.Arduino["print_serial_monitor"] = function (block) { + var serialId = block.getFieldValue("SERIAL_ID"); + var content = + Blockly.Arduino.valueToCode( + block, + "CONTENT", + Blockly.Arduino.ORDER_ATOMIC + ) || "0"; + var checkbox_name = block.getFieldValue("NEW_LINE") === "TRUE"; + var code = ""; + if (checkbox_name) { + code = serialId + ".println(" + content + ");\n"; + } else { + code = serialId + ".print(" + content + ");\n"; + } + return code; +}; + +/** + * Code generator for block for setting the serial com speed. + * Arduino code: setup{ Serial.begin(X); } + * @param {!Blockly.Block} block Block to generate the code from. + * @return {array} Completed code. + */ +Blockly.Arduino["init_serial_monitor"] = function (block) { + var serialId = block.getFieldValue("SERIAL_ID"); + var serialSpeed = block.getFieldValue("SPEED"); + Blockly.Arduino.setupCode_[ + "init_serial" + ] = `${serialId}.begin(${serialSpeed});`; + var code = ""; + return code; +}; diff --git a/src/components/Blockly/helpers/colour.js b/src/components/Blockly/helpers/colour.js index ac2b0ed..2cf7f78 100644 --- a/src/components/Blockly/helpers/colour.js +++ b/src/components/Blockly/helpers/colour.js @@ -11,6 +11,7 @@ const colours = { audio: 250, arrays: 33, mqtt: 90, + serial: 230, webserver: 40, phyphox: 25, }; diff --git a/src/components/Blockly/msg/de/sensebox-sensors.js b/src/components/Blockly/msg/de/sensebox-sensors.js index 0cd5c57..d14b380 100644 --- a/src/components/Blockly/msg/de/sensebox-sensors.js +++ b/src/components/Blockly/msg/de/sensebox-sensors.js @@ -1,129 +1,138 @@ export const SENSORS = { - /** - * Sensors - * --------------------------------------------------- - * - */ + /** + * Sensors + * --------------------------------------------------- + * + */ - /** - * BMP280 - */ - senseBox_pressure_sensor: "Luftdruck-/Temperatursensor (BMP280)", - senseBox_pressure: "Luftdruck in Pa", - senseBox_pressure_dimension: "Luftdruck in Pa", - senseBox_pressure_tip: "Schließe den Sensor an einen der 5 **I2C-Anschlüsse** an. Der Sensor gibt dir den Messwert für den Luftdruck in Pa. Um die korrekte Höhe über NN zu berechnen benötigt der Sensor einen aktuellen Referenzwert.", - senseBox_pressure_referencePressure: "Luftdruck auf NN", - senseBox_pressure_referencePressure_dim: "hPa", - senseBox_pressure_helpurl: "", + /** + * BMP280 + */ + senseBox_pressure_sensor: "Luftdruck-/Temperatursensor (BMP280)", + senseBox_pressure: "Luftdruck in Pa", + senseBox_pressure_dimension: "Luftdruck in Pa", + senseBox_pressure_tip: + "Schließe den Sensor an einen der 5 **I2C-Anschlüsse** an. Der Sensor gibt dir den Messwert für den Luftdruck in Pa. Um die korrekte Höhe über NN zu berechnen benötigt der Sensor einen aktuellen Referenzwert.", + senseBox_pressure_referencePressure: "Luftdruck auf NN", + senseBox_pressure_referencePressure_dim: "hPa", + senseBox_pressure_helpurl: "", + /** + * Mikro + */ + senseBox_sound: "Mikrofon", + senseBox_sound_tip: + "Schließe den Sensor über das Breadbord an einen der 3 **analog/digital** Ports an. Gibt den Messwert des Mikrofons in Volt zurück", + senseBox_sound_helpurl: "https://docs.sensebox.de/hardware/sensoren-mikro/", - /** - * Mikro - */ - senseBox_sound: "Mikrofon", - senseBox_sound_tip: "Schließe den Sensor über das Breadbord an einen der 3 **analog/digital** Ports an. Gibt den Messwert des Mikrofons in Volt zurück", - senseBox_sound_helpurl: "https://docs.sensebox.de/hardware/sensoren-mikro/", + /** + * Temperature and Humidity Sensor (HDC1080) + */ + senseBox_temp: "Temperatur in °C", + senseBox_temp_hum: "Temperatur-/Luftfeuchtigkeitssensor (HDC1080)", + senseBox_temp_hum_tooltip: + "Dieser Block gibt dir die Messwerte des Temperatur- und Luftfeuchtigkeitssensor zurück. Schließe den Sensor an einen der 5 I2C Anschlüsse an. Messwert wird mit 2 Nachkommastellen ausgegeben.", + senseBox_temp_hum_helpurl: + "https://docs.sensebox.de/hardware/sensoren-temperatur-luftfeuchte/", - /** - * Temperature and Humidity Sensor (HDC1080) - */ - senseBox_temp: "Temperatur in °C", - senseBox_temp_hum: "Temperatur-/Luftfeuchtigkeitssensor (HDC1080)", - senseBox_temp_hum_tooltip: "Dieser Block gibt dir die Messwerte des Temperatur- und Luftfeuchtigkeitssensor zurück. Schließe den Sensor an einen der 5 I2C Anschlüsse an. Messwert wird mit 2 Nachkommastellen ausgegeben.", - senseBox_temp_hum_helpurl: "https://docs.sensebox.de/hardware/sensoren-temperatur-luftfeuchte/", + /** + * Ultraschalldistanzsensor + */ - /** - * Ultraschalldistanzsensor - */ - - senseBox_ultrasonic: "Ultraschall-Abstandssensor an Port", - senseBox_ultrasonic_trigger: "Trigger", - senseBox_ultrasonic_echo: "Echo", - senseBox_ultrasonic_port_A: "A", - senseBox_ultrasonic_port_B: "B", - senseBox_ultrasonic_port_C: "C", - senseBox_ultrasonic_tooltip: `Misst die Distanz mithilfe von Ultraschall in cm. Schließe den Sensor an einen der drei Digital/Analog Ports an: + senseBox_ultrasonic: "Ultraschall-Abstandssensor an Port", + senseBox_ultrasonic_trigger: "Trigger", + senseBox_ultrasonic_echo: "Echo", + senseBox_ultrasonic_maxDistance: "Maximale Distanz", + senseBox_ultrasonic_port_A: "A", + senseBox_ultrasonic_port_B: "B", + senseBox_ultrasonic_port_C: "C", + senseBox_ultrasonic_tooltip: `Misst die Distanz mithilfe von Ultraschall in cm. Schließe den Sensor an einen der drei Digital/Analog Ports an: - Trigger: Grünes Kabel -- Echo: gelbes Kabel`, - senseBox_ultrasonic_helpurl: "https://docs.sensebox.de/hardware/sensoren-distanz/", - /** - * UV and Lightsensor - */ - senseBox_value: "Messwert:", - senseBox_uv_light: "Helligkeit-/UV-Sensor", - senseBox_uv_light_tooltip: "Sensor misst UV-Licht oder die Helligkeit. Die Helligkeit wird als **Ganzezahl** in Lux ausgegeben. Die UV-Intensität als **Kommazahl** in µW/cm².", - senseBox_uv: "UV-Intensität in µW/cm²", - senseBox_light: "Beleuchtungsstärke in Lux", - senseBox_uv_light_helpurl: "https://docs.sensebox.de/hardware/sensoren-helligkeit-uv/", +- Echo: gelbes Kabel +Wenn die maximale Distanz überschritten wird, wird ein Wert von **O** ausgegeben`, + senseBox_ultrasonic_helpurl: + "https://docs.sensebox.de/hardware/sensoren-distanz/", + /** + * UV and Lightsensor + */ + senseBox_value: "Messwert:", + senseBox_uv_light: "Helligkeit-/UV-Sensor", + senseBox_uv_light_tooltip: + "Sensor misst UV-Licht oder die Helligkeit. Die Helligkeit wird als **Ganzezahl** in Lux ausgegeben. Die UV-Intensität als **Kommazahl** in µW/cm².", + senseBox_uv: "UV-Intensität in µW/cm²", + senseBox_light: "Beleuchtungsstärke in Lux", + senseBox_uv_light_helpurl: + "https://docs.sensebox.de/hardware/sensoren-helligkeit-uv/", - /** - * BMX055 - */ + /** + * BMX055 + */ - senseBox_bmx055_compass: "Lage Sensor", - senseBox_bmx055_accelerometer: "Beschleunigungssensor", - senseBox_bmx055_accelerometer_range: "Messbereich", - senseBox_bmx055_accelerometer_range_2g: "2g", - senseBox_bmx055_accelerometer_range_4g: "4g", - senseBox_bmx055_accelerometer_range_8g: "8g", - senseBox_bmx055_accelerometer_range_16g: "16g", - senseBox_bmx055_accelerometer_direction: "Richtung", - senseBox_bmx055_accelerometer_direction_x: "X-Achse", - senseBox_bmx055_accelerometer_direction_y: "Y-Achse", - senseBox_bmx055_accelerometer_direction_z: "Z-Achse", - senseBox_bmx055_accelerometer_direction_total: "Gesamt", - senseBox_bmx055_gyroscope: "Lage Sensor", - senseBox_bmx055_accelerometer_tip: "Lage Sensor", - senseBox_bmx055_compass_tip: "Lage Sensor", - senseBox_bmx055_gyroscope_tip: "Lage Sensor", - senseBox_bmx055_x: "X-Richtung", - senseBox_bmx055_y: "Y-Richtung", - senseBox_bmx055_accelerometer_tooltip: `Dieser Block gibt dir den Messwert des Beschleunigungssensors der direkt auf der senseBox MCU aufgelötet ist. Im Dropdown Menü kannst du die Richtung und den Messbereich auswählen.`, - senseBox_bmx055_helpurl: "", + senseBox_bmx055_compass: "Lage Sensor", + senseBox_bmx055_accelerometer: "Beschleunigungssensor", + senseBox_bmx055_accelerometer_range: "Messbereich", + senseBox_bmx055_accelerometer_range_2g: "2g", + senseBox_bmx055_accelerometer_range_4g: "4g", + senseBox_bmx055_accelerometer_range_8g: "8g", + senseBox_bmx055_accelerometer_range_16g: "16g", + senseBox_bmx055_accelerometer_direction: "Richtung", + senseBox_bmx055_accelerometer_direction_x: "X-Achse", + senseBox_bmx055_accelerometer_direction_y: "Y-Achse", + senseBox_bmx055_accelerometer_direction_z: "Z-Achse", + senseBox_bmx055_accelerometer_direction_total: "Gesamt", + senseBox_bmx055_gyroscope: "Lage Sensor", + senseBox_bmx055_accelerometer_tip: "Lage Sensor", + senseBox_bmx055_compass_tip: "Lage Sensor", + senseBox_bmx055_gyroscope_tip: "Lage Sensor", + senseBox_bmx055_x: "X-Richtung", + senseBox_bmx055_y: "Y-Richtung", + senseBox_bmx055_accelerometer_tooltip: `Dieser Block gibt dir den Messwert des Beschleunigungssensors der direkt auf der senseBox MCU aufgelötet ist. Im Dropdown Menü kannst du die Richtung und den Messbereich auswählen.`, + senseBox_bmx055_helpurl: "", - - /** - * - * GPS - */ - senseBox_gps_getValues: "GPS Modul", - senseBox_gps_lat: "Breitengrad", - senseBox_gps_lng: "Längengrad", - senseBox_gps_alt: "Höhe über NN in m", - senseBox_gps_speed: "Geschwindigkeit in km/h", - senseBox_gps_date: "Datum", - senseBox_gps_time: "Uhrzeit", - senseBox_gps_timeStamp: "Zeitstempel (RFC 3339)", - senseBox_gps_tooltip: `Liest das GPS Modul aus und gibt dir die Standortinformationen. Längen- und Breitengrad werden als Kommazahl mit 6 Nachkommastellen ausgegeben. + /** + * + * GPS + */ + senseBox_gps_getValues: "GPS Modul", + senseBox_gps_lat: "Breitengrad", + senseBox_gps_lng: "Längengrad", + senseBox_gps_alt: "Höhe über NN in m", + senseBox_gps_speed: "Geschwindigkeit in km/h", + senseBox_gps_date: "Datum", + senseBox_gps_time: "Uhrzeit", + senseBox_gps_timeStamp: "Zeitstempel (RFC 3339)", + senseBox_gps_tooltip: `Liest das GPS Modul aus und gibt dir die Standortinformationen. Längen- und Breitengrad werden als Kommazahl mit 6 Nachkommastellen ausgegeben. **Anschluss: I2C** **Beachte:** Das GPS Modul benöigt beim ersten Verwenden relativ lange (ca. 5-10 Minuten) bis es deinen Standort gefunden hat! `, - senseBox_gps_helpurl: "https://docs.sensebox.de/hardware/sensoren-gps/", + senseBox_gps_helpurl: "https://docs.sensebox.de/hardware/sensoren-gps/", - /** - * Windspeed - */ - senseBox_windspeed: "Windgeschwindigkeitssensor", - senseBox_windspeed_tooltip: "", + /** + * Windspeed + */ + senseBox_windspeed: "Windgeschwindigkeitssensor", + senseBox_windspeed_tooltip: "", - /* - * Soundsensor - */ - senseBox_soundsensor_dfrobot: "Soundsensor (DF Robot)", - senseBox_soundsensor_dfrobot_tooltip: "Schließe den Sensor an einen der 3 **digital/analog Ports** an. Der Sensor gibt dir den Messwert in dB mit einer Nachkommastelle", - senseBox_soundsensor_dfrobot_helpurl: "https://docs.sensebox.de/hardware/sensoren-lautstaerke/", - /* - * BME680 - */ + /* + * Soundsensor + */ + senseBox_soundsensor_dfrobot: "Soundsensor (DF Robot)", + senseBox_soundsensor_dfrobot_tooltip: + "Schließe den Sensor an einen der 3 **digital/analog Ports** an. Der Sensor gibt dir den Messwert in dB mit einer Nachkommastelle", + senseBox_soundsensor_dfrobot_helpurl: + "https://docs.sensebox.de/hardware/sensoren-lautstaerke/", + /* + * BME680 + */ - senseBox_bme680: "Umweltsensor (BME680)", - senseBox_bme_iaq: "Innenraumluftqualität (IAQ)", - senseBox_bme_iaq_accuracy: "Kalibrierungswert", - senseBox_bme_co2: "CO2 Äquivalent", - senseBox_bme_breatheVocEquivalent: "Atemluft VOC Äquivalent", - senseBox_bme_tooltip: `Schließe den Umweltsensor an einen der 5 **I2C-Anschlüsse** an. **Beachte:** Der Sensor benöigt eine gewisse Zeit zum kalibrieren. + senseBox_bme680: "Umweltsensor (BME680)", + senseBox_bme_iaq: "Innenraumluftqualität (IAQ)", + senseBox_bme_iaq_accuracy: "Kalibrierungswert", + senseBox_bme_co2: "CO2 Äquivalent", + senseBox_bme_breatheVocEquivalent: "Atemluft VOC Äquivalent", + senseBox_bme_tooltip: `Schließe den Umweltsensor an einen der 5 **I2C-Anschlüsse** an. **Beachte:** Der Sensor benöigt eine gewisse Zeit zum kalibrieren. Den Status der Kalibrierung kann über den Kalibrierungswert abgelesen werden. Er ist entweder 0, 1, 2 oder 3 und sagt folgendes aus: - IAQ Accuracy : 0 heißt Sensor wird stabilisiert (dauert ca. 25 Minuten) oder dass es eine Zeitüberschreitung gab, @@ -132,49 +141,54 @@ Den Status der Kalibrierung kann über den Kalibrierungswert abgelesen werden. E - IAQ Accuracy : 3 heißt Sensor erfolgreich kalibriert. Die Messwerte für Temperatur, Luftfeuchtigkeit und Luftdruck können direkt verwendet werden.`, - senseBox_bme680_helpurl: "https://docs.sensebox.de/hardware/sensoren-umweltsensor/", + senseBox_bme680_helpurl: + "https://docs.sensebox.de/hardware/sensoren-umweltsensor/", + /** + * Truebner SMT50 + */ + senseBox_smt50: "Bodenfeuchte/-temperatur (SMT50)", + senseBox_smt50_helpurl: + "https://docs.sensebox.de/hardware/sensoren-truebner/", + senseBox_smt50_tooltip: + "Schließe den Bodenfeuchtigkeit- und Temperatursensor an einen der 3 digital/analog Ports an und wähle den Port im Block aus. Der Sensor gibt die Bodentemperatur in °C und die Bodenfeuchtigkeit in % aus.", - /** - * Truebner SMT50 - */ - senseBox_smt50: "Bodenfeuchte/-temperatur (SMT50)", - senseBox_smt50_helpurl: "https://docs.sensebox.de/hardware/sensoren-truebner/", - senseBox_smt50_tooltip: "Schließe den Bodenfeuchtigkeit- und Temperatursensor an einen der 3 digital/analog Ports an und wähle den Port im Block aus. Der Sensor gibt die Bodentemperatur in °C und die Bodenfeuchtigkeit in % aus.", + /** + * SCD30 CO2 Sensor + */ + senseBox_scd30: "CO2 Sensor (Sensirion SCD30)", + senseBox_scd_tooltip: + "Schließe den Sensor an einen der 5 **I2C-Anschlüsse** an. Der Sensor gibt dir den Messwert für die CO2-Konzentration in ppm. Der Temperaturmesswert kann aufgrund der Messung direkt am Sensor um einige Grad vom realen Wert abweichen.", + senseBox_scd_co2: "CO2 in ppm", + senseBox_scd_helpurl: "https://docs.sensebox.de/hardware/sensoren-co2/", - /** - * SCD30 CO2 Sensor - */ - senseBox_scd30: "CO2 Sensor (Sensirion SCD30)", - senseBox_scd_tooltip: "Schließe den Sensor an einen der 5 **I2C-Anschlüsse** an. Der Sensor gibt dir den Messwert für die CO2-Konzentration in ppm. Der Temperaturmesswert kann aufgrund der Messung direkt am Sensor um einige Grad vom realen Wert abweichen.", - senseBox_scd_co2: "CO2 in ppm", - senseBox_scd_helpurl: "https://docs.sensebox.de/hardware/sensoren-co2/", + /** + * Feinstaubsensor (SDS011) + */ - /** - * Feinstaubsensor (SDS011) - */ + senseBox_sds011: "Feinstaubsensor", + senseBox_sds011_dimension: "in µg/m³ an", + senseBox_sds011_pm25: "PM2.5", + senseBox_sds011_pm10: "PM10", + senseBox_sds011_tooltip: + "Dieser Block gibt dir den Messwert des Feinstaubsensor. Schließe den Feinstaubsensor an einen der 2 **Serial/UART** Anschlüssen an. Im Dropdown Menü zwischen PM2.5 und PM10 auswählen. Der Messwert wird dir als **Kommazahl** in µg/m3", + senseBox_sds011_serial1: "Serial1", + senseBox_sds011_serial2: "Serial2", + senseBox_sds011_helpurl: + "https://docs.sensebox.de/hardware/sensoren-feinstaub/", - senseBox_sds011: "Feinstaubsensor", - senseBox_sds011_dimension: "in µg/m³ an", - senseBox_sds011_pm25: "PM2.5", - senseBox_sds011_pm10: "PM10", - senseBox_sds011_tooltip: "Dieser Block gibt dir den Messwert des Feinstaubsensor. Schließe den Feinstaubsensor an einen der 2 **Serial/UART** Anschlüssen an. Im Dropdown Menü zwischen PM2.5 und PM10 auswählen. Der Messwert wird dir als **Kommazahl** in µg/m3", - senseBox_sds011_serial1: "Serial1", - senseBox_sds011_serial2: "Serial2", - senseBox_sds011_helpurl: "https://docs.sensebox.de/hardware/sensoren-feinstaub/", + /** + * Button + */ + senseBox_button: "Button", + senseBox_button_isPressed: "ist gedrückt", + senseBox_button_switch: "als Schalter", + senseBox_button_wasPressed: "wurde gedrückt", + senseBox_button_longPress: "Gedrückt für", - - /** - * Button - */ - senseBox_button: "Button", - senseBox_button_isPressed: "ist gedrückt", - senseBox_button_switch: "als Schalter", - senseBox_button_wasPressed: "wurde gedrückt", - senseBox_button_tooltip: `Dieser Block gibt dir den Status des angeschlossenen Buttons. Im Dropdown Menü können verschiedene Modi für den Button ausgewählt werden. Angesteuert können entweder der on Board Button oder ein Button, der an einen der 6 digitalen Pins angeschlossen ist. verschiedene Modi: + senseBox_button_tooltip: `Dieser Block gibt dir den Status des angeschlossenen Buttons. Im Dropdown Menü können verschiedene Modi für den Button ausgewählt werden. Angesteuert können entweder der on Board Button oder ein Button, der an einen der 6 digitalen Pins angeschlossen ist. verschiedene Modi: - "ist gedrückt": Mit diesem Modus kannst du abfragen ob der Block gerade gedrückt wird. Du erhältst entweder den Wert TRUE oder FALSE. - "wurde gedrückt": Mit diesem Modus kannst du abfragen ob der Block gedrückt wurde. Erst wenn der Knopf gedrückt und wieder losgelassen wurde erhältst du TRUE zurück - "als Schalter": Wenn du diesen Block verwendest kannst du den Knopf wie ein Lichtschalter verwenden. Der Status wird gespeichert bis der Button erneut gedrückt wird`, - senseBox_button_helpurl: "", - -} \ No newline at end of file + senseBox_button_helpurl: "", +}; diff --git a/src/components/Blockly/msg/de/sensebox-web.js b/src/components/Blockly/msg/de/sensebox-web.js index d86618c..75e5abd 100644 --- a/src/components/Blockly/msg/de/sensebox-web.js +++ b/src/components/Blockly/msg/de/sensebox-web.js @@ -1,11 +1,19 @@ export const WEB = { - /** - * WiFi - */ - senseBox_wifi_connect: "Verbinde mit WLAN", - senseBox_wifi_ssid: "Netzwerkname", - senseBox_wifi_tooltip: "Stellt eine Verbindung mit einem WLAN-Netzwerk her. Möchtest du dich mit einem ungesicheren Netzwerk (z.B. Freifunk) verbinden lösche das Feld Passwort. Das WiFi-Bee muss auf den Steckplatz **XBEE1** aufgesteckt werden.", - senseBox_wifi_startap: "Initialisiere WLAN Access Point", - senseBox_wifi_startap_tooltip: "Erstellt einen WiFi-Accesspoint zu dem du dich verbinden kannst. Beachte, dass immer nur 1 Gerät gleichzeitig verbunden werden kann.", - senseBox_wifi_helpurl: "https://docs.sensebox.de/blockly/blockly-web-wifi/", -} \ No newline at end of file + /** + * WiFi + */ + senseBox_wifi_connect: "Verbinde mit WLAN", + senseBox_wifi_ssid: "Netzwerkname", + senseBox_wifi_ip: "IP-Address", + senseBox_wifi_ip_tooltip: "Gibt die IP-Address der senseBox aus", + senseBox_wifi_status: "WiFi-Status", + senseBox_wifi_status_tooltip: "Gibt den Status der WiFi-Verbindung aus", + senseBox_wifi_rssi: "RSSI", + senseBox_wifi_rssi_tooltip: "Gibt die Sigal Stärke der WiFi-Verbindung", + senseBox_wifi_tooltip: + "Stellt eine Verbindung mit einem WLAN-Netzwerk her. Möchtest du dich mit einem ungesicheren Netzwerk (z.B. Freifunk) verbinden lösche das Feld Passwort. Das WiFi-Bee muss auf den Steckplatz **XBEE1** aufgesteckt werden.", + senseBox_wifi_startap: "Initialisiere WLAN Access Point", + senseBox_wifi_startap_tooltip: + "Erstellt einen WiFi-Accesspoint zu dem du dich verbinden kannst. Beachte, dass immer nur 1 Gerät gleichzeitig verbunden werden kann.", + senseBox_wifi_helpurl: "https://docs.sensebox.de/blockly/blockly-web-wifi/", +}; diff --git a/src/components/Blockly/msg/de/ui.js b/src/components/Blockly/msg/de/ui.js index 47feefb..545208f 100644 --- a/src/components/Blockly/msg/de/ui.js +++ b/src/components/Blockly/msg/de/ui.js @@ -10,6 +10,7 @@ export const UI = { toolbox_time: "Zeit", toolbox_functions: "Funktionen", toolbox_variables: "Variablen", + toolbox_serial: "Seriell", variable_NUMBER: "Zahl (int)", variable_SHORT_NUMBER: "char", variable_LONG: "große Zahl (long)", diff --git a/src/components/Blockly/msg/en/sensebox-sensors.js b/src/components/Blockly/msg/en/sensebox-sensors.js index a770cc6..746181c 100644 --- a/src/components/Blockly/msg/en/sensebox-sensors.js +++ b/src/components/Blockly/msg/en/sensebox-sensors.js @@ -1,134 +1,142 @@ export const SENSORS = { + /** + * Sensors + * --------------------------------------------------- + * + */ - /** - * Sensors - * --------------------------------------------------- - * - */ + /** + * BMP280 + */ + senseBox_pressure_sensor: "Airpressure/Temperature Sensor (BMP280)", + senseBox_pressure: "Airpressure in Pa", + senseBox_pressure_dimension: "Airpressure in Pa", + senseBox_pressure_tip: + "Connect the sensor to one of the 5 **I2C ports**. The sensor gives you the measured value for the air pressure in Pa. To calculate the correct altitude above sea level the sensor needs a current reference value.", + senseBox_pressure_referencePressure: "Pressure at Sea Level", + senseBox_pressure_referencePressure_dim: "hPa", + senseBox_pressure_helpurl: "", - /** - * BMP280 - */ - senseBox_pressure_sensor: "Airpressure/Temperature Sensor (BMP280)", - senseBox_pressure: "Airpressure in Pa", - senseBox_pressure_dimension: "Airpressure in Pa", - senseBox_pressure_tip: "Connect the sensor to one of the 5 **I2C ports**. The sensor gives you the measured value for the air pressure in Pa. To calculate the correct altitude above sea level the sensor needs a current reference value.", - senseBox_pressure_referencePressure: "Pressure at Sea Level", - senseBox_pressure_referencePressure_dim: "hPa", - senseBox_pressure_helpurl: "", + /** + * Mikro + */ + senseBox_sound: "Microphone", + senseBox_sound_tip: + "Connect the sensor to one of the 3 **analog/digital** ports via the breadbord. Returns the reading of the microphone in volt", + senseBox_sound_helpurl: + "https://en.docs.sensebox.de/hardware/sensoren-mikro/", + /** + * Temperature and Humidity Sensor (HDC1080) + */ + senseBox_temp: "Temperature in °C", + senseBox_temp_hum: "Temperature/Humidity Sensor (HDC1080)", + senseBox_temp_hum_tooltip: + "This block returns the temperature and humidity sensor readings. Connect the sensor to one of the 5 I2C ports. Measured value is output with 2 decimal places.", + senseBox_temp_hum_helpurl: + "https://en.docs.sensebox.de/hardware/sensoren-temperatur-luftfeuchte/", + senseBox_hum: "humidity in %", + senseBox_hum_tip: "Measures humidity in %", - /** - * Mikro - */ - senseBox_sound: "Microphone", - senseBox_sound_tip: "Connect the sensor to one of the 3 **analog/digital** ports via the breadbord. Returns the reading of the microphone in volt", - senseBox_sound_helpurl: "https://en.docs.sensebox.de/hardware/sensoren-mikro/", + /** + * Ultraschalldistanzsensor + */ - /** - * Temperature and Humidity Sensor (HDC1080) - */ - senseBox_temp: "Temperature in °C", - senseBox_temp_hum: "Temperature/Humidity Sensor (HDC1080)", - senseBox_temp_hum_tooltip: "This block returns the temperature and humidity sensor readings. Connect the sensor to one of the 5 I2C ports. Measured value is output with 2 decimal places.", - senseBox_temp_hum_helpurl: "https://en.docs.sensebox.de/hardware/sensoren-temperatur-luftfeuchte/", - senseBox_hum: "humidity in %", - senseBox_hum_tip: "Measures humidity in %", - - - /** - * Ultraschalldistanzsensor - */ - - senseBox_ultrasonic: "Ultrasonic distance sensor at Port", - senseBox_ultrasonic_trigger: "Trigger", - senseBox_ultrasonic_echo: "Echo", - senseBox_ultrasonic_port_A: "A", - senseBox_ultrasonic_port_B: "B", - senseBox_ultrasonic_port_C: "C", - senseBox_ultrasonic_tooltip: `Measures the distance using ultrasound in cm. Connect the sensor to one of the three digital/analog ports: + senseBox_ultrasonic: "Ultrasonic distance sensor at Port", + senseBox_ultrasonic_trigger: "Trigger", + senseBox_ultrasonic_echo: "Echo", + senseBox_ultrasonic_maxDistance: "Max distance", + senseBox_ultrasonic_port_A: "A", + senseBox_ultrasonic_port_B: "B", + senseBox_ultrasonic_port_C: "C", + senseBox_ultrasonic_tooltip: `Measures the distance using ultrasound in cm. Connect the sensor to one of the three digital/analog ports: - Trigger: Green Cable -- Echo: Yellow Cable`, - senseBox_ultrasonic_helpurl: "https://en.docs.sensebox.de/hardware/sensoren-distanz/", +- Echo: Yellow Cable +If the max distance is reached the a value of **O** will be returned`, + senseBox_ultrasonic_helpurl: + "https://en.docs.sensebox.de/hardware/sensoren-distanz/", - /** - * UV and Lightsensor - */ - senseBox_uv: "UV-Light in µW/cm²", - senseBox_uv_light: "Light Visible + UV", - senseBox_value: "Value:", - senseBox_uv_light_tooltip: "Sensor measures UV light or brightness. Brightness is output as **integer** in lux. UV intensity as **decimal** in µW/cm².", - senseBox_light: "Illuminance in Lux", - senseBox_uv_light_helpurl: "https://en.docs.sensebox.de/hardware/sensoren-helligkeit-uv/", + /** + * UV and Lightsensor + */ + senseBox_uv: "UV-Light in µW/cm²", + senseBox_uv_light: "Light Visible + UV", + senseBox_value: "Value:", + senseBox_uv_light_tooltip: + "Sensor measures UV light or brightness. Brightness is output as **integer** in lux. UV intensity as **decimal** in µW/cm².", + senseBox_light: "Illuminance in Lux", + senseBox_uv_light_helpurl: + "https://en.docs.sensebox.de/hardware/sensoren-helligkeit-uv/", - /** - * BMX055 - */ + /** + * BMX055 + */ - senseBox_bmx055_compass: "Lage Sensor", - senseBox_bmx055_accelerometer: "Accelerometer", - senseBox_bmx055_accelerometer_range: "Range", - senseBox_bmx055_accelerometer_range_2g: "2g", - senseBox_bmx055_accelerometer_range_4g: "4g", - senseBox_bmx055_accelerometer_range_8g: "8g", - senseBox_bmx055_accelerometer_range_16g: "16g", - senseBox_bmx055_accelerometer_direction: "Direction", - senseBox_bmx055_accelerometer_direction_x: "X-Axis", - senseBox_bmx055_accelerometer_direction_y: "Y-Axis", - senseBox_bmx055_accelerometer_direction_z: "Z-Axis", - senseBox_bmx055_accelerometer_direction_total: "Total", - senseBox_bmx055_gyroscope: "Gyroscope", + senseBox_bmx055_compass: "Lage Sensor", + senseBox_bmx055_accelerometer: "Accelerometer", + senseBox_bmx055_accelerometer_range: "Range", + senseBox_bmx055_accelerometer_range_2g: "2g", + senseBox_bmx055_accelerometer_range_4g: "4g", + senseBox_bmx055_accelerometer_range_8g: "8g", + senseBox_bmx055_accelerometer_range_16g: "16g", + senseBox_bmx055_accelerometer_direction: "Direction", + senseBox_bmx055_accelerometer_direction_x: "X-Axis", + senseBox_bmx055_accelerometer_direction_y: "Y-Axis", + senseBox_bmx055_accelerometer_direction_z: "Z-Axis", + senseBox_bmx055_accelerometer_direction_total: "Total", + senseBox_bmx055_gyroscope: "Gyroscope", - senseBox_bmx055_compass_tip: "Lage Sensor", - senseBox_bmx055_gyroscope_tip: "Lage Sensor", - senseBox_bmx055_x: "X-Direction", - senseBox_bmx055_y: "Y-Direction", - senseBox_bmx055_accelerometer_tooltip: `This block gives you the measurement value of the accelerometer which is soldered directly on the senseBox MCU. In the dropdown menu you can select the direction and the measuring range.`, - senseBox_bmx055_helpurl: "", + senseBox_bmx055_compass_tip: "Lage Sensor", + senseBox_bmx055_gyroscope_tip: "Lage Sensor", + senseBox_bmx055_x: "X-Direction", + senseBox_bmx055_y: "Y-Direction", + senseBox_bmx055_accelerometer_tooltip: `This block gives you the measurement value of the accelerometer which is soldered directly on the senseBox MCU. In the dropdown menu you can select the direction and the measuring range.`, + senseBox_bmx055_helpurl: "", - - /** - * - * GPS - */ - senseBox_gps_getValues: "GPS Modul", - senseBox_gps_lat: "latitude", - senseBox_gps_lng: "longitude", - senseBox_gps_alt: "altitude in m", - senseBox_gps_speed: "speed in km/h", - senseBox_gps_date: "date", - senseBox_gps_time: "time", - senseBox_gps_timeStamp: "Timestamp (RFC 3339)", - senseBox_gps_tooltip: `Reads the GPS module and gives you the location information. Longitude and latitude are output as a decimal number with 6 decimal places. + /** + * + * GPS + */ + senseBox_gps_getValues: "GPS Modul", + senseBox_gps_lat: "latitude", + senseBox_gps_lng: "longitude", + senseBox_gps_alt: "altitude in m", + senseBox_gps_speed: "speed in km/h", + senseBox_gps_date: "date", + senseBox_gps_time: "time", + senseBox_gps_timeStamp: "Timestamp (RFC 3339)", + senseBox_gps_tooltip: `Reads the GPS module and gives you the location information. Longitude and latitude are output as a decimal number with 6 decimal places. **Connection: I2C** **Note:** The GPS module needs a relatively long time (about 5-10 minutes) until it has found your location! `, - senseBox_gps_helpurl: "https://en.docs.sensebox.de/hardware/sensoren-gps/", + senseBox_gps_helpurl: "https://en.docs.sensebox.de/hardware/sensoren-gps/", - /** - * Windspeed - */ - senseBox_windspeed: "Windspeedsensor", - senseBox_windspeed_tooltip: "", + /** + * Windspeed + */ + senseBox_windspeed: "Windspeedsensor", + senseBox_windspeed_tooltip: "", - /* - * Soundsensor - */ - senseBox_soundsensor_dfrobot: "Soundsensor (DF Robot)", - senseBox_soundsensor_dfrobot_tooltip: "Connect the sensor to one of the 3 **digital/analog ports**. The sensor will give you the reading in dB with one decimal.", - senseBox_soundsensor_dfrobot_helpurl: "https://en.docs.sensebox.de/hardware/sensoren-lautstaerke/", + /* + * Soundsensor + */ + senseBox_soundsensor_dfrobot: "Soundsensor (DF Robot)", + senseBox_soundsensor_dfrobot_tooltip: + "Connect the sensor to one of the 3 **digital/analog ports**. The sensor will give you the reading in dB with one decimal.", + senseBox_soundsensor_dfrobot_helpurl: + "https://en.docs.sensebox.de/hardware/sensoren-lautstaerke/", - /* - * BME680 - */ + /* + * BME680 + */ - senseBox_bme680: "Environmental sensor (BME680)", - senseBox_bme_iaq: "Indoor Air Quality (IAQ)", - senseBox_bme_iaq_accuracy: "Calibration Value", - senseBox_bme_co2: "CO2 Equivalent", - senseBox_bme_breatheVocEquivalent: "Breathe VOC Equivalent", - senseBox_bme_tooltip: `Connect the environmental sensor to one of the 5 **I2C ports**. **Note:** The sensor needs some time to calibrate. + senseBox_bme680: "Environmental sensor (BME680)", + senseBox_bme_iaq: "Indoor Air Quality (IAQ)", + senseBox_bme_iaq_accuracy: "Calibration Value", + senseBox_bme_co2: "CO2 Equivalent", + senseBox_bme_breatheVocEquivalent: "Breathe VOC Equivalent", + senseBox_bme_tooltip: `Connect the environmental sensor to one of the 5 **I2C ports**. **Note:** The sensor needs some time to calibrate. The status of the calibration can be read from the calibration value. It is either 0, 1, 2 or 3 and says the following: - IAQ Accuracy : 0 means sensor is stabilized (takes about 25 minutes) or that there was a timeout, @@ -137,53 +145,57 @@ The status of the calibration can be read from the calibration value. It is eith - IAQ Accuracy : 3 means sensor calibrated successfully. The measured values for temperature, humidity and air pressure can be used directly,`, - senseBox_bme680_helpurl: "https://en.docs.sensebox.de/hardware/sensoren-umweltsensor/", + senseBox_bme680_helpurl: + "https://en.docs.sensebox.de/hardware/sensoren-umweltsensor/", + /** + * Truebner SMT50 + */ + senseBox_smt50: "Soil Moisture and Temperature (SMT50)", + senseBox_smt50_helpurl: + "https://docs.sensebox.de/hardware/sensoren-truebner/", + senseBox_smt50_tooltip: + "Schließe den Bodenfeuchtigkeit- und Temperatursensor an einen der 3 digital/analog Ports an und wähle den Port im Block aus. Der Sensor gibt die Bodentemperatur in °C und die Bodenfeuchtigkeit in % aus.", - /** - * Truebner SMT50 - */ - senseBox_smt50: "Soil Moisture and Temperature (SMT50)", - senseBox_smt50_helpurl: "https://docs.sensebox.de/hardware/sensoren-truebner/", - senseBox_smt50_tooltip: "Schließe den Bodenfeuchtigkeit- und Temperatursensor an einen der 3 digital/analog Ports an und wähle den Port im Block aus. Der Sensor gibt die Bodentemperatur in °C und die Bodenfeuchtigkeit in % aus.", + /** + * SCD30 CO2 Sensor + */ + senseBox_scd30: "CO2 Sensor (Sensirion SCD30)", + senseBox_scd_tooltip: + "Connect the sensor to one of the 5 **I2C ports**. The sensor will give you the reading for the CO2 concentration in ppm. The temperature reading may differ from the real value by a few degrees due to the measurement directly at the sensor.", + senseBox_scd_co2: "CO2 in ppm", + senseBox_scd_helpurl: "https://en.docs.sensebox.de/hardware/sensoren-co2/", + /** + * Feinstaubsensor (SDS011) + */ + senseBox_sds011: "Fine Particular Sensor", + senseBox_sds011_dimension: "in µg/m³ at", + senseBox_sds011_pm25: "PM2.5", + senseBox_sds011_pm10: "PM10", + senseBox_sds011_tooltip: + "This block gives you the reading of the fine dust sensor. Connect the fine dust sensor to one of the 2 **Serial/UART** ports. Select between PM2.5 and PM10 in the dropdown menu. The measured value will be displayed as **comma number** in µg/m3", + senseBox_sds011_serial1: "Serial1", + senseBox_sds011_serial2: "Serial2", + senseBox_sds011_helpurl: + "https://en.docs.sensebox.de/hardware/sensoren-feinstaub/", - /** - * SCD30 CO2 Sensor - */ - senseBox_scd30: "CO2 Sensor (Sensirion SCD30)", - senseBox_scd_tooltip: "Connect the sensor to one of the 5 **I2C ports**. The sensor will give you the reading for the CO2 concentration in ppm. The temperature reading may differ from the real value by a few degrees due to the measurement directly at the sensor.", - senseBox_scd_co2: "CO2 in ppm", - senseBox_scd_helpurl: "https://en.docs.sensebox.de/hardware/sensoren-co2/", - /** - * Feinstaubsensor (SDS011) - */ - senseBox_sds011: "Fine Particular Sensor", - senseBox_sds011_dimension: "in µg/m³ at", - senseBox_sds011_pm25: "PM2.5", - senseBox_sds011_pm10: "PM10", - senseBox_sds011_tooltip: "This block gives you the reading of the fine dust sensor. Connect the fine dust sensor to one of the 2 **Serial/UART** ports. Select between PM2.5 and PM10 in the dropdown menu. The measured value will be displayed as **comma number** in µg/m3", - senseBox_sds011_serial1: "Serial1", - senseBox_sds011_serial2: "Serial2", - senseBox_sds011_helpurl: "https://en.docs.sensebox.de/hardware/sensoren-feinstaub/", - - - /** - * Button - */ - senseBox_button: "Button", - senseBox_button_isPressed: "is Pressed", - senseBox_button_switch: "as Switch", - senseBox_button_wasPressed: "was Pressed", - senseBox_button_tooltip: `This block gives you the status of the connected button. In the dropdown menu you can select different modes for the button. Either the on board button or a button connected to one of the 6 digital pins can be controlled. different modes: + /** + * Button + */ + senseBox_button: "Button", + senseBox_button_isPressed: "is Pressed", + senseBox_button_switch: "as Switch", + senseBox_button_wasPressed: "was Pressed", + senseBox_button_longPress: "Pressed for", + senseBox_button_tooltip: `This block gives you the status of the connected button. In the dropdown menu you can select different modes for the button. Either the on board button or a button connected to one of the 6 digital pins can be controlled. different modes: - "is pressed": With this mode you can check if the block is currently pressed. You get either the value TRUE or FALSE. - "was pressed": With this mode you can query if the block was pressed. Only if the button was pressed and released you will get TRUE. - "as switch": If you use this block you can use the button like a light switch. The status is saved until the button is pressed again. `, - senseBox_button_helpurl: "", + senseBox_button_helpurl: "", - - /** - * - */ - senseBox_watertemperature: "Water Temperature", -} \ No newline at end of file + /** + * + */ + senseBox_watertemperature: "Water Temperature", +}; diff --git a/src/components/Blockly/msg/en/sensebox-web.js b/src/components/Blockly/msg/en/sensebox-web.js index 63fc98a..30d7846 100644 --- a/src/components/Blockly/msg/en/sensebox-web.js +++ b/src/components/Blockly/msg/en/sensebox-web.js @@ -1,11 +1,20 @@ export const WEB = { - /** - * WiFi - */ - senseBox_wifi_connect: "Connect to Wifi", - senseBox_wifi_ssid: "Networkname", - senseBox_wifi_tooltip: "Connects to a wireless network. If you want to connect to an unsecured network (e.g. Freifunk) clear the password field. The WiFi-Bee must be plugged into the **XBEE1** slot.", - senseBox_wifi_startap: "Initialize Wifi Access Point", - senseBox_wifi_startap_tooltip: "Creates a WiFi access point to which you can connect. Note that only 1 device can be connected at a time.", - senseBox_wifi_helpurl: "https://en.docs.sensebox.de/blockly/blockly-web-wifi/", -} \ No newline at end of file + /** + * WiFi + */ + senseBox_wifi_connect: "Connect to Wifi", + senseBox_wifi_ssid: "Networkname", + senseBox_wifi_ip: "IP-Address", + senseBox_wifi_ip_tooltip: "The IP-Address of the SenseBox", + senseBox_wifi_status: "Status", + senseBox_wifi_status_tooltip: "The status of the Wifi connection", + senseBox_wifi_rssi: "RSSI", + senseBox_wifi_rssi_tooltip: "The signal strength of the Wifi connection", + senseBox_wifi_tooltip: + "Connects to a wireless network. If you want to connect to an unsecured network (e.g. Freifunk) clear the password field. The WiFi-Bee must be plugged into the **XBEE1** slot.", + senseBox_wifi_startap: "Initialize Wifi Access Point", + senseBox_wifi_startap_tooltip: + "Creates a WiFi access point to which you can connect. Note that only 1 device can be connected at a time.", + senseBox_wifi_helpurl: + "https://en.docs.sensebox.de/blockly/blockly-web-wifi/", +}; diff --git a/src/components/Blockly/msg/en/ui.js b/src/components/Blockly/msg/en/ui.js index e074276..b573b00 100644 --- a/src/components/Blockly/msg/en/ui.js +++ b/src/components/Blockly/msg/en/ui.js @@ -10,6 +10,7 @@ export const UI = { toolbox_time: "Time", toolbox_functions: "Functions", toolbox_variables: "Variables", + toolbox_serial: "Serial", variable_NUMBER: "Number (int)", variable_SHORT_NUMBER: "char", variable_LONG: " Zahl (long)", diff --git a/src/components/Blockly/toolbox/Toolbox.js b/src/components/Blockly/toolbox/Toolbox.js index 0ee760e..0c1f6e3 100644 --- a/src/components/Blockly/toolbox/Toolbox.js +++ b/src/components/Blockly/toolbox/Toolbox.js @@ -92,6 +92,9 @@ class Toolbox extends React.Component { + + + @@ -397,6 +400,10 @@ class Toolbox extends React.Component { + + + +