From 5621fdc62077afa9ef80dbaba228afd9ef67be4d Mon Sep 17 00:00:00 2001 From: felixerdy Date: Thu, 5 Nov 2020 20:57:17 +0100 Subject: [PATCH] add some delay and fix type limit --- src/components/Blockly/blocks/sensebox-lora.js | 5 +++++ src/components/Blockly/generator/sensebox-lora.js | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/Blockly/blocks/sensebox-lora.js b/src/components/Blockly/blocks/sensebox-lora.js index 9f757aa..79a4b6d 100644 --- a/src/components/Blockly/blocks/sensebox-lora.js +++ b/src/components/Blockly/blocks/sensebox-lora.js @@ -122,6 +122,11 @@ Blockly.Blocks['sensebox_send_lora_sensor_value'] = { Blockly.Blocks['sensebox_lora_ttn_mapper'] = { init: function (block) { this.setColour(getColour().sensebox); + this.appendDummyInput() + .setAlign(Blockly.ALIGN_RIGHT) + .appendField("Fix Type Limit") + .appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"]].reverse()), "dropdown") + // reverse() because i want 3 be be at first and i'm to lazy to write the array again this.appendDummyInput() .appendField("TTN Mapper") this.appendValueInput('Latitude') diff --git a/src/components/Blockly/generator/sensebox-lora.js b/src/components/Blockly/generator/sensebox-lora.js index 987a390..6c03c2c 100644 --- a/src/components/Blockly/generator/sensebox-lora.js +++ b/src/components/Blockly/generator/sensebox-lora.js @@ -121,7 +121,7 @@ Blockly.Arduino.sensebox_lora_initialize_otaa = function (block) { } }`; Blockly.Arduino.loraSetupCode_['initLora'] = 'initLora();\n'; - Blockly.Arduino.setupCode_['serial.begin'] = 'Serial.begin(9600);\n'; + Blockly.Arduino.setupCode_['serial.begin'] = 'Serial.begin(9600);\ndelay(1000);\n'; var code = ''; return code; }; @@ -201,6 +201,7 @@ Blockly.Arduino.sensebox_lora_ttn_mapper = function (block) { var altitude = Blockly.Arduino.valueToCode(this, 'Altitude', Blockly.Arduino.ORDER_ATOMIC) var pDOP = Blockly.Arduino.valueToCode(this, 'pDOP', Blockly.Arduino.ORDER_ATOMIC) var fixType = Blockly.Arduino.valueToCode(this, 'Fix Type', Blockly.Arduino.ORDER_ATOMIC) + var fixTypeLimit = this.getFieldValue('dropdown'); Blockly.Arduino.functionNames_['functions_do_send'] = ` void do_send(osjob_t* j){ // Check if there is not a current TX/RX job running @@ -209,7 +210,7 @@ Blockly.Arduino.sensebox_lora_ttn_mapper = function (block) { } else { int fixType = ${fixType}; - if (fixType >= 3) { // we have a 3D fix + if (fixType >= ${fixTypeLimit}) { // we have a 3D fix int32_t latitude = ${latitude}; // in degrees * 10^-7 int32_t longitude = ${longitude}; // in degrees * 10^-7 int32_t altitude = ${altitude} / 100; // in dm above mean sea level @@ -426,7 +427,7 @@ Blockly.Arduino.sensebox_lora_initialize_abp = function (block) { } }`; Blockly.Arduino.loraSetupCode_['initLora'] = 'initLora();\n'; - Blockly.Arduino.setupCode_['serial.begin'] = 'Serial.begin(9600);\n'; + Blockly.Arduino.setupCode_['serial.begin'] = 'Serial.begin(9600);\ndelay(1000);\n'; return ''; }