Merge branch 'remove-senseboxmcu-lib' into block/add-ethernet-bee
This commit is contained in:
@@ -18,6 +18,7 @@ import "./audio";
|
||||
import "./math";
|
||||
import "./map";
|
||||
import "./procedures";
|
||||
import "./serial";
|
||||
import "./time";
|
||||
import "./variables";
|
||||
import "./lists";
|
||||
|
||||
@@ -24,16 +24,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(ssl), "SSL");
|
||||
this.appendDummyInput()
|
||||
@@ -70,6 +60,11 @@ Blockly.Blocks["sensebox_osem_connection"] = {
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.getField("type").setValidator(
|
||||
function (val) {
|
||||
this.updateShape_(val === "Mobile");
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
onchange: function (e) {
|
||||
var legal = false;
|
||||
@@ -105,49 +100,28 @@ Blockly.Blocks["sensebox_osem_connection"] = {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
mutationToDom: function () {
|
||||
var container = document.createElement("mutation");
|
||||
var input = this.getFieldValue("type");
|
||||
this.updateShape_(input);
|
||||
container.setAttribute("type", input);
|
||||
return container;
|
||||
},
|
||||
|
||||
domToMutation: function (xmlElement) {
|
||||
var connections = xmlElement.getAttribute("connections");
|
||||
this.updateShape_(connections);
|
||||
},
|
||||
/**
|
||||
* Modify this block to have the correct number of pins available.
|
||||
* @param {boolean}
|
||||
* @private
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
updateShape_: function () {
|
||||
var extraFieldExist = this.getFieldValue("gps");
|
||||
var input = this.getFieldValue("type");
|
||||
if (input === "Mobile" && extraFieldExist === null) {
|
||||
this.appendValueInput("lat", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_lat,
|
||||
"gps"
|
||||
);
|
||||
this.appendValueInput("lng", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_lng
|
||||
);
|
||||
this.appendValueInput("altitude", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_alt
|
||||
);
|
||||
this.appendValueInput("timeStamp", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_timeStamp
|
||||
);
|
||||
}
|
||||
|
||||
if (input === "Stationary" && extraFieldExist !== null) {
|
||||
this.removeInput("lat");
|
||||
this.removeInput("lng");
|
||||
this.removeInput("altitude");
|
||||
this.removeInput("timeStamp");
|
||||
updateShape_(isMobile) {
|
||||
if (isMobile) {
|
||||
if (this.getInput("lat") == null) {
|
||||
this.appendValueInput("lat", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_lat,
|
||||
"gps"
|
||||
);
|
||||
this.appendValueInput("lng", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_lng
|
||||
);
|
||||
this.appendValueInput("altitude", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_alt
|
||||
);
|
||||
this.appendValueInput("timeStamp", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_timeStamp
|
||||
);
|
||||
}
|
||||
} else {
|
||||
this.removeInput("lat", true);
|
||||
this.removeInput("lng", true);
|
||||
this.removeInput("altitude", true);
|
||||
this.removeInput("timeStamp", true);
|
||||
}
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_interval_timer"],
|
||||
|
||||
@@ -129,48 +129,35 @@ Blockly.Blocks["sensebox_sd_osem"] = {
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
mutationToDom: function () {
|
||||
var container = document.createElement("mutation");
|
||||
var input = this.getFieldValue("type");
|
||||
this.updateShape_(input);
|
||||
container.setAttribute("type", input);
|
||||
return container;
|
||||
this.getField("type").setValidator(
|
||||
function (val) {
|
||||
this.updateShape_(val === "Mobile");
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
|
||||
domToMutation: function (xmlElement) {
|
||||
var connections = xmlElement.getAttribute("connections");
|
||||
this.updateShape_(connections);
|
||||
},
|
||||
/**
|
||||
* Modify this block to have the correct number of pins available.
|
||||
* @param {boolean}
|
||||
* @private
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
updateShape_: function () {
|
||||
var extraFieldExist = this.getFieldValue("gps");
|
||||
var input = this.getFieldValue("type");
|
||||
if (input === "Mobile" && extraFieldExist === null) {
|
||||
this.appendValueInput("lat", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_lat,
|
||||
"gps"
|
||||
);
|
||||
this.appendValueInput("lng", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_lng
|
||||
);
|
||||
this.appendValueInput("altitude", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_alt
|
||||
);
|
||||
}
|
||||
|
||||
if (input === "Stationary" && extraFieldExist !== null) {
|
||||
this.removeInput("lat");
|
||||
this.removeInput("lng");
|
||||
this.removeInput("altitude");
|
||||
updateShape_(isMobile) {
|
||||
if (isMobile) {
|
||||
if (this.getInput("lat") == null) {
|
||||
this.appendValueInput("lat", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_lat,
|
||||
"gps"
|
||||
);
|
||||
this.appendValueInput("lng", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_lng
|
||||
);
|
||||
this.appendValueInput("altitude", "Number").appendField(
|
||||
Blockly.Msg.senseBox_gps_alt
|
||||
);
|
||||
}
|
||||
} else {
|
||||
this.removeInput("lat", true);
|
||||
this.removeInput("lng", true);
|
||||
this.removeInput("altitude", true);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_sd_save_for_osem"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.sensebox_sd_save_for_osem_tip);
|
||||
|
||||
@@ -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
|
||||
@@ -156,50 +157,23 @@ Blockly.Blocks["sensebox_sensor_pressure"] = {
|
||||
this.setOutput(true, Types.DECIMAL.typeName);
|
||||
this.setTooltip(Blockly.Msg.senseBox_pressure_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_pressure_helpurl);
|
||||
this.getField("NAME").setValidator(
|
||||
function (val) {
|
||||
this.updateShape_(val === "Altitude");
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
/**
|
||||
* 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("NAME");
|
||||
this.updateShape_(input);
|
||||
container.setAttribute("NAME", 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("referencePressure");
|
||||
var input = this.getFieldValue("NAME");
|
||||
if (input === "Altitude" && extraFieldExist === null) {
|
||||
this.appendDummyInput("extraField")
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_pressure_referencePressure)
|
||||
.appendField(new Blockly.FieldTextInput("1013"), "referencePressure")
|
||||
.appendField(Blockly.Msg.senseBox_pressure_referencePressure_dim);
|
||||
}
|
||||
|
||||
if (
|
||||
(input === "Pressure" || input === "Temperature") &&
|
||||
extraFieldExist !== null
|
||||
) {
|
||||
this.removeInput("extraField");
|
||||
updateShape_(isAltitude) {
|
||||
if (isAltitude) {
|
||||
if (this.getInput("extraField") == null) {
|
||||
this.appendDummyInput("extraField")
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_pressure_referencePressure)
|
||||
.appendField(new Blockly.FieldTextInput("1013"), "referencePressure")
|
||||
.appendField(Blockly.Msg.senseBox_pressure_referencePressure_dim);
|
||||
}
|
||||
} else {
|
||||
this.removeInput("extraField", true);
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -245,9 +219,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 +240,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 +331,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"
|
||||
)
|
||||
@@ -366,6 +343,24 @@ Blockly.Blocks["sensebox_button"] = {
|
||||
this.setOutput(true, Types.BOOLEAN.typeName);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setTooltip(Blockly.Msg.senseBox_button_tooltip);
|
||||
this.getField("FUNCTION").setValidator(
|
||||
function (val) {
|
||||
this.updateShape_(val === "longPress");
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
updateShape_(isLongPress) {
|
||||
if (isLongPress) {
|
||||
if (this.getInput("extraField") == null) {
|
||||
this.appendDummyInput("extraField")
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_button_longPress_time)
|
||||
.appendField(new Blockly.FieldTextInput("1000"), "time")
|
||||
.appendField("ms");
|
||||
}
|
||||
} else {
|
||||
this.removeInput("extraField", true);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -519,3 +514,54 @@ Blockly.Blocks["sensebox_soundsensor_dfrobot"] = {
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_soundsensor_dfrobot_helpurl);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Infineon DPS310 Pressure Sensor
|
||||
*
|
||||
*/
|
||||
|
||||
Blockly.Blocks["sensebox_sensor_dps310"] = {
|
||||
init: function () {
|
||||
var dropdownOptions = [
|
||||
[Blockly.Msg.senseBox_pressure, "Pressure"],
|
||||
[Blockly.Msg.senseBox_temp, "Temperature"],
|
||||
[Blockly.Msg.senseBox_gps_alt, "Altitude"],
|
||||
];
|
||||
var dropdown = new Blockly.FieldDropdown(dropdownOptions, function (
|
||||
option
|
||||
) {
|
||||
var input =
|
||||
option === "Pressure" ||
|
||||
option === "Temperature" ||
|
||||
option === "Altitude";
|
||||
this.sourceBlock_.updateShape_(input);
|
||||
});
|
||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_sensor_dps310);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_value)
|
||||
.appendField(dropdown, "NAME");
|
||||
this.setColour(getColour().sensebox);
|
||||
this.setOutput(true, Types.DECIMAL.typeName);
|
||||
this.setTooltip(Blockly.Msg.senseBox_sensor_dps310_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_sensor_dps310_helpurl);
|
||||
this.getField("NAME").setValidator(
|
||||
function (val) {
|
||||
this.updateShape_(val === "Altitude");
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
updateShape_(isAltitude) {
|
||||
if (isAltitude) {
|
||||
if (this.getInput("extraField") == null) {
|
||||
this.appendDummyInput("extraField")
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField(Blockly.Msg.senseBox_pressure_referencePressure)
|
||||
.appendField(new Blockly.FieldTextInput("1013"), "referencePressure")
|
||||
.appendField(Blockly.Msg.senseBox_pressure_referencePressure_dim);
|
||||
}
|
||||
} else {
|
||||
this.removeInput("extraField", true);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Blockly from "blockly";
|
||||
import { getColour } from "../helpers/colour";
|
||||
import * as Types from "../helpers/types";
|
||||
|
||||
Blockly.Blocks["sensebox_wifi"] = {
|
||||
init: function () {
|
||||
@@ -117,5 +118,36 @@ Blockly.Blocks["sensebox_ethernetIp"] = {
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_ethernetIp_helpurl);
|
||||
this.setTooltip(Blockly.Msg.senseBox_ethernet_ip_tooltip);
|
||||
this.setOutput(true, null);
|
||||
}
|
||||
};
|
||||
|
||||
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_get_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);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user