Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

26 block maken voor co2 sensor #31

Merged
merged 14 commits into from
Jan 4, 2024
20 changes: 20 additions & 0 deletions blocks/leaphy_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,26 @@ function getBlocks(board) {
tooltip: "",
helpUrl: "",
},
{
type: "leaphy_gas_sensor",
message0: "%%{BKY_LEAPHY_CHOOSE_GAS}: %1",
args0: [
{
type: "field_dropdown",
name: "GAS",
options: [
["TVOC", "TVOC"],
["eCO2", "eCO2"],
["Raw H2", "Raw H2"],
["Raw Ethanol", "RAWETHANOL"],
],
},
],
style: "leaphy_blocks",
output: "Number",
tooltip: "",
helpUrl: "",
},
];
return blocks;
}
Expand Down
23 changes: 23 additions & 0 deletions generators/arduino/leaphy_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,29 @@ function getCodeGenerators(Arduino) {
return [code, Arduino.ORDER_ATOMIC];
};

Arduino.forBlock["leaphy_gas_sensor"] = function (block) {
Arduino.addInclude("leaphy_gas_sensor", "#include <Adafruit_SGP30.h>");
Arduino.addDeclaration("leaphy_gas_sensor", "Adafruit_SGP30 sgp;");
Arduino.addSetup(
"leaphy_gas_sensor",
"if (! sgp.begin()){\n" + "\treturn -1;\n" + "}",
);

var gasValue = block.getFieldValue("GAS");
let code = "";
if (gasValue == "TVOC") {
code = "sgp.TVOC";
} else if (gasValue == "eCO2") {
code = "sgp.eCO2";
} else if (gasValue == "Raw H2") {
code = "sgp.rawH2";
} else if (gasValue == "Raw Ethanol") {
code = "sgp.rawEthanol";
}

return [code, Arduino.ORDER_ATOMIC];
};

Arduino.forBlock["leaphy_i2c_rgb_color"] = function (block) {
const rgb_declaration =
"int r = 0, g = 0, b = 0, a = 0;\n" +
Expand Down
1 change: 1 addition & 0 deletions msg/js/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Blockly.Msg["LEAPHY_BUZZ_MS"] = "ms";
Blockly.Msg["LEAPHY_CLICK_CATEGORY"] = "Leaphy Click";
Blockly.Msg["LEAPHY_COMPASS"] = "Read compass";
Blockly.Msg["LEAPHY_DIGITAL_READ"] = "Read digipin";
Blockly.Msg["LEAPHY_CHOOSE_GAS"] = "Choose gas: ";
Blockly.Msg["LEAPHY_DISPLAY_CLEAR"] = "Clear display";
Blockly.Msg["LEAPHY_DISPLAY_DISPLAY"] = "Show on display";
Blockly.Msg["LEAPHY_DISPLAY_PRINT"] = "Display - Set Ln.";
Expand Down
1 change: 1 addition & 0 deletions msg/js/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Blockly.Msg["LEAPHY_BUZZ_MS"] = "ms"; // untranslated
Blockly.Msg["LEAPHY_CLICK_CATEGORY"] = "Leaphy Click"; // untranslated
Blockly.Msg["LEAPHY_COMPASS"] = "Lees kompas";
Blockly.Msg["LEAPHY_DIGITAL_READ"] = "Lees digipin";
Blockly.Msg["LEAPHY_CHOOSE_GAS"] = "Kies gas: ";
Blockly.Msg["LEAPHY_DISPLAY_CLEAR"] = "Maak display leeg";
Blockly.Msg["LEAPHY_DISPLAY_DISPLAY"] = "Toon op display";
Blockly.Msg["LEAPHY_DISPLAY_PRINT"] = "Stel display in - Rg.";
Expand Down
1 change: 1 addition & 0 deletions msg/json/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"LEAPHY_MOTOR_DIRECTION": "Direction",
"LEAPHY_GET_DISTANCE": "Get distance",
"LEAPHY_DIGITAL_READ": "Read digipin",
"LEAPHY_CHOOSE_GAS": "Choose gas: ",
"LEAPHY_ANALOG_READ": "Read anapin",
"LEAPHY_RGB_READ_SENSOR": "Read RGB sensor",
"LEAPHY_RGB_COLOR_RED": "Color R-255",
Expand Down
1 change: 1 addition & 0 deletions msg/json/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"LEAPHY_MOTOR_DIRECTION": "Richting",
"LEAPHY_GET_DISTANCE": "Lees afstand",
"LEAPHY_DIGITAL_READ": "Lees digipin",
"LEAPHY_CHOOSE_GAS": "Kies gas: ",
"LEAPHY_ANALOG_READ": "Lees anapin",
"LEAPHY_RGB_READ_SENSOR": "Lees RGB Sensor",
"LEAPHY_RGB_COLOR_RED": "R-255",
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@babel/preset-env": "^7.22.15",
"babel-loader": "^9.1.3",
"eslint": "^8.52.0",
"prettier": "^3.0.3"
"prettier": "3.1.1"
},
"repository": {
"type": "git",
Expand Down