diff --git a/src/components/Blockly/blocks/sensebox-sensors.js b/src/components/Blockly/blocks/sensebox-sensors.js index 145a5e18..1a54e39c 100644 --- a/src/components/Blockly/blocks/sensebox-sensors.js +++ b/src/components/Blockly/blocks/sensebox-sensors.js @@ -514,6 +514,40 @@ Blockly.Blocks["sensebox_soundsensor_dfrobot"] = { }, }; + + +/** + * rainsensor hydreon rg-15 + */ + +Blockly.Blocks["sensebox_rainsensor_hydreon_rg15"] = { + init: function () { + var dropdownOptionsPorts = [ + [Blockly.Msg.sensebox_rainsensor_hydreon_rg15_serial1, "Serial1"], + [Blockly.Msg.sensebox_rainsensor_hydreon_rg15_serial2, "Serial2"], + ]; + var dropdownOptionsValues = [ + [Blockly.Msg.sensebox_rainsensor_hydreon_rg15_acc, "getAccumulation"], + [Blockly.Msg.sensebox_rainsensor_hydreon_rg15_totalAcc, "getTotalAccumulation"], + [Blockly.Msg.sensebox_rainsensor_hydreon_rg15_eventAcc, "getEventAccumulation"], + [Blockly.Msg.sensebox_rainsensor_hydreon_rg15_rainInt, "getRainfallIntensity"], + ]; + this.setColour(getColour().sensebox); + this.appendDummyInput() + .appendField(Blockly.Msg.sensebox_rainsensor_hydreon_rg15); + this.appendDummyInput() + .appendField(Blockly.Msg.sensebox_rainsensor_hydreon_rg15_port) + .appendField(new Blockly.FieldDropdown(dropdownOptionsPorts), "SERIAL"); + this.appendDummyInput() + .appendField(Blockly.Msg.sensebox_rainsensor_hydreon_rg15_value) + .appendField(new Blockly.FieldDropdown(dropdownOptionsValues), "VALUE"); + this.setOutput(true, Types.DECIMAL.typeName); + this.setTooltip(Blockly.Msg.sensebox_rainsensor_hydreon_rg15_tooltip); + this.setHelpUrl(Blockly.Msg.sensebox_rainsensor_hydreon_rg15_helpurl); + }, +}; + + /** * Infineon DPS310 Pressure Sensor * diff --git a/src/components/Blockly/generator/sensebox-sensors.js b/src/components/Blockly/generator/sensebox-sensors.js index f0d62dd1..379940d6 100644 --- a/src/components/Blockly/generator/sensebox-sensors.js +++ b/src/components/Blockly/generator/sensebox-sensors.js @@ -654,6 +654,23 @@ float getSoundValue(){ return [code, Blockly.Arduino.ORDER_ATOMIC]; }; +/** + * rainsensor hydreon rg-15 + */ + +Blockly.Arduino.sensebox_rainsensor_hydreon_rg15 = function () { + var port = this.getFieldValue("SERIAL"); + var value = this.getFieldValue("VALUE"); + Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include "; + Blockly.Arduino.libraries_["library_rainsensor_rg15"] = "#include "; + Blockly.Arduino.definitions_["def_rainsensor_rg15_" + port] = "HYDREON rainsensor_" + port + "(" + port + ");"; + Blockly.Arduino.setupCode_["setup_rainsensor_rg15_" + port] = "rainsensor_" + port + ".begin();"; + Blockly.Arduino.loopCodeOnce_["loop_rainsensor_rg15_" + port] = "rainsensor_" + port + ".readAllData();" + + var code = "rainsensor_" + port + "." + value + "()"; + return [code, Blockly.Arduino.ORDER_ATOMIC]; +}; + /** * Infineon DPS310 Pressure Sensor * diff --git a/src/components/Blockly/msg/de/sensebox-sensors.js b/src/components/Blockly/msg/de/sensebox-sensors.js index 64d0baaa..955a17db 100644 --- a/src/components/Blockly/msg/de/sensebox-sensors.js +++ b/src/components/Blockly/msg/de/sensebox-sensors.js @@ -132,10 +132,25 @@ Wenn die maximale Distanz überschritten wird, wird ein Wert von **O** ausgegebe "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 - */ + * rainsensor hydreon rg-15 + */ + sensebox_rainsensor_hydreon_rg15: "Regensensor (RG-15)", + sensebox_rainsensor_hydreon_rg15_port: "Serieller Port:", + sensebox_rainsensor_hydreon_rg15_serial1: "Serial1", + sensebox_rainsensor_hydreon_rg15_serial2: "Serial2", + sensebox_rainsensor_hydreon_rg15_value: "Messwert:", + sensebox_rainsensor_hydreon_rg15_totalAcc: "gesamter Niederschlag in mm", + sensebox_rainsensor_hydreon_rg15_rainInt: "Niederschlagsintensität in mm/h", + sensebox_rainsensor_hydreon_rg15_eventAcc: "Niederschlag pro Event in mm", + sensebox_rainsensor_hydreon_rg15_acc: "Niederschlag seit letzter Messung in mm", + sensebox_rainsensor_hydreon_rg15_tooltip: "Regensensor (RG-15) an einen der Seriellen Ports anschließen.", + sensebox_rainsensor_hydreon_rg15_helpurl: "https://rainsensors.com/products/rg-15/", + /* + * BME680 + */ senseBox_bme680: "Umweltsensor (BME680)", senseBox_bme_iaq: "Innenraumluftqualität (IAQ)", senseBox_bme_iaq_accuracy: "Kalibrierungswert", diff --git a/src/components/Blockly/msg/en/sensebox-sensors.js b/src/components/Blockly/msg/en/sensebox-sensors.js index 94f698ac..b4bfa84c 100644 --- a/src/components/Blockly/msg/en/sensebox-sensors.js +++ b/src/components/Blockly/msg/en/sensebox-sensors.js @@ -134,6 +134,21 @@ If the max distance is reached the a value of **O** will be returned`, senseBox_soundsensor_dfrobot_helpurl: "https://en.docs.sensebox.de/hardware/sensoren-lautstaerke/", + /* + * rainsensor hydreon rg-15 + */ + sensebox_rainsensor_hydreon_rg15: "Rainsensor (RG-15)", + sensebox_rainsensor_hydreon_rg15_port: "Serial Port:", + sensebox_rainsensor_hydreon_rg15_serial1: "Serial1", + sensebox_rainsensor_hydreon_rg15_serial2: "Serial2", + sensebox_rainsensor_hydreon_rg15_value: "value:", + sensebox_rainsensor_hydreon_rg15_totalAcc: "total Accumulation in mm", + sensebox_rainsensor_hydreon_rg15_rainInt: "Rainfall Intensity in mm/h", + sensebox_rainsensor_hydreon_rg15_eventAcc: "Accumulation per Event in mm", + sensebox_rainsensor_hydreon_rg15_acc: "Accumulation since last loop in mm", + sensebox_rainsensor_hydreon_rg15_tooltip: "Connect Rainsensor (RG-15) to one of the Serial ports.", + sensebox_rainsensor_hydreon_rg15_helpurl: "https://rainsensors.com/products/rg-15/", + /* * BME680 */ diff --git a/src/components/Blockly/toolbox/Toolbox.js b/src/components/Blockly/toolbox/Toolbox.js index 275af4d0..423cd065 100644 --- a/src/components/Blockly/toolbox/Toolbox.js +++ b/src/components/Blockly/toolbox/Toolbox.js @@ -76,6 +76,7 @@ class Toolbox extends React.Component { {/* */} +