Skip to content

Commit

Permalink
fix: use pin 9,10,11 in rgb block for all nano robots (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmoesbergen authored Oct 19, 2024
1 parent 8e2c8e2 commit 43b1773
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"dist",
"media"
],
"version": "3.2.2",
"version": "3.2.3",
"description": "Leaphy custom Blockly blocks and arduino code generator",
"name": "@leaphy-robotics/leaphy-blocks"
}
28 changes: 23 additions & 5 deletions src/generators/arduino/leaphy_original.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@ function getCodeGenerators(arduino: Arduino) {
"0";
const blue =
arduino.valueToCode(block, "LED_BLUE", arduino.ORDER_ATOMIC) || "0";
arduino.addInclude(
"include_leaphy_original",
'#include "Leaphyoriginal1.h"',
);
return `setLed(${red}, ${green}, ${blue});\n`;

let pin_red, pin_blue, pin_green;
if (arduino.robotType.includes("nano")) {
pin_red = 11;
pin_green = 10;
pin_blue = 9;
arduino.addSetup(
"setup_nano_rgb",
"pinMode(8, OUTPUT);\n digitalWrite(8, LOW);",
false,
);
} else {
pin_red = 3;
pin_green = 5;
pin_blue = 6;
}
// Ground is connected to pin 8 on the nano, so it needs to be pulled LOW
const code =
`analogWrite(${pin_red}, ${red});\n` +
`analogWrite(${pin_green}, ${green});\n` +
`analogWrite(${pin_blue}, ${blue});\n`;

return code;
};

arduino.forBlock["leaphy_original_set_motor"] = function (block) {
Expand Down

0 comments on commit 43b1773

Please sign in to comment.