Skip to content

Commit

Permalink
fix: 360 servo code doesn't compile (missing ;) (#104)
Browse files Browse the repository at this point in the history
* fix: add some generic formatting in setup code
  • Loading branch information
rmoesbergen authored May 19, 2024
1 parent ee8ef50 commit 313d1cc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 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.0.0",
"version": "3.0.1",
"description": "Leaphy custom Blockly blocks and arduino code generator",
"name": "@leaphy-robotics/leaphy-blocks"
}
2 changes: 1 addition & 1 deletion src/generators/arduino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export class Arduino extends Blockly.Generator {
this.nameDB_?.reset();

const allDefs = includes.join("\n") + definitions.join("\n");
const setup = "void setup() {" + setups.join("\n ") + "\n}\n\n";
const setup = "void setup() {\n\t" + setups.join("\n ") + "\n}\n\n";
const loop = "void loop() {\n " + code.replace(/\n/g, "\n ") + "\n}";

return allDefs + setup + loop;
Expand Down
2 changes: 1 addition & 1 deletion src/generators/arduino/leaphy_original.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function getCodeGenerators(arduino: Arduino) {
const speed =
arduino.valueToCode(block, "SPEED", arduino.ORDER_ATOMIC) || "100";

return `servo_${motor}.write(90 + 90*${speed}/100)`;
return `servo_${motor}.write(90 + 90*${speed}/100);\n`;
};

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

0 comments on commit 313d1cc

Please sign in to comment.