Skip to content

Commit

Permalink
Merge pull request #39 from leaphy-robotics/development
Browse files Browse the repository at this point in the history
feat: add set text size
  • Loading branch information
koen1711 authored Jan 17, 2024
2 parents 87da0a2 + 7a0cf47 commit c3f57be
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 40 deletions.
91 changes: 52 additions & 39 deletions blocks/leaphy_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ const displayPinNumbers = [
];

function getBlocks(board) {
const blocks = [
return [
{
type: "digital_read",
message0: "%%{BKY_LEAPHY_DIGITAL_READ} %1",
args0: [
{ type: "field_dropdown", name: "PIN", options: board.digitalPins },
{type: "field_dropdown", name: "PIN", options: board.digitalPins},
],
style: "leaphy_blocks",
output: "Number",
Expand All @@ -48,7 +48,7 @@ function getBlocks(board) {
type: "analog_read",
message0: "%%{BKY_LEAPHY_ANALOG_READ} %1",
args0: [
{ type: "field_dropdown", name: "PIN", options: board.analogPins },
{type: "field_dropdown", name: "PIN", options: board.analogPins},
],
style: "leaphy_blocks",
output: "Number",
Expand All @@ -68,7 +68,7 @@ function getBlocks(board) {
{
type: "leaphy_serial_print_line",
message0: "%%{BKY_LEAPHY_SERIAL_PRINT} %1 %2",
args0: [{ type: "input_dummy" }, { type: "input_value", name: "VALUE" }],
args0: [{type: "input_dummy"}, {type: "input_value", name: "VALUE"}],
inputsInline: true,
previousStatement: null,
nextStatement: null,
Expand All @@ -80,10 +80,10 @@ function getBlocks(board) {
type: "leaphy_serial_print_value",
message0: "%%{BKY_LEAPHY_SERIAL_PRINT} %1 %2 = %3 %4",
args0: [
{ type: "input_dummy" },
{ type: "input_value", name: "NAME" },
{ type: "input_dummy" },
{ type: "input_value", name: "VALUE" },
{type: "input_dummy"},
{type: "input_value", name: "NAME"},
{type: "input_dummy"},
{type: "input_value", name: "VALUE"},
],
inputsInline: true,
previousStatement: null,
Expand All @@ -96,7 +96,7 @@ function getBlocks(board) {
type: "leaphy_rgb_color",
message0: "%1",
args0: [
{ type: "field_dropdown", name: "COLOR_TYPE", options: rgbColor },
{type: "field_dropdown", name: "COLOR_TYPE", options: rgbColor},
],
style: "leaphy_blocks",
output: "Number",
Expand Down Expand Up @@ -168,11 +168,11 @@ function getBlocks(board) {
{
type: "leaphy_led_set_strip",
message0:
"%%{BKY_LEAPHY_LED_SET_STRIP} %1 %%{BKY_LEAPHY_LED_SET_PIN} %2 %%{BKY_LEAPHY_LED_SET_LEDS} %3",
"%%{BKY_LEAPHY_LED_SET_STRIP} %1 %%{BKY_LEAPHY_LED_SET_PIN} %2 %%{BKY_LEAPHY_LED_SET_LEDS} %3",
args0: [
{ type: "input_dummy" },
{ type: "input_value", name: "LED_SET_PIN", check: "Number" },
{ type: "input_value", name: "LED_SET_LEDS", check: "Number" },
{type: "input_dummy"},
{type: "input_value", name: "LED_SET_PIN", check: "Number"},
{type: "input_value", name: "LED_SET_LEDS", check: "Number"},
],
inputsInline: true,
previousStatement: null,
Expand All @@ -184,12 +184,12 @@ function getBlocks(board) {
{
type: "leaphy_led_set_basic",
message0:
"%%{BKY_LEAPHY_LED_BASIC_LED} %1 %%{BKY_LEAPHY_LED_BASIC_RED} %2 %%{BKY_LEAPHY_LED_BASIC_GREEN} %3 %%{BKY_LEAPHY_LED_BASIC_BLUE} %4",
"%%{BKY_LEAPHY_LED_BASIC_LED} %1 %%{BKY_LEAPHY_LED_BASIC_RED} %2 %%{BKY_LEAPHY_LED_BASIC_GREEN} %3 %%{BKY_LEAPHY_LED_BASIC_BLUE} %4",
args0: [
{ type: "input_value", name: "LED_SET_LED", check: "Number" },
{ type: "input_value", name: "LED_BASIC_RED", check: "Number" },
{ type: "input_value", name: "LED_BASIC_GREEN", check: "Number" },
{ type: "input_value", name: "LED_BASIC_BLUE", check: "Number" },
{type: "input_value", name: "LED_SET_LED", check: "Number"},
{type: "input_value", name: "LED_BASIC_RED", check: "Number"},
{type: "input_value", name: "LED_BASIC_GREEN", check: "Number"},
{type: "input_value", name: "LED_BASIC_BLUE", check: "Number"},
],
inputsInline: true,
previousStatement: null,
Expand All @@ -202,7 +202,7 @@ function getBlocks(board) {
type: "leaphy_led_set_speed",
message0: "%%{BKY_LEAPHY_LED_SET_SPEEDVALUE} %1",
args0: [
{ type: "input_value", name: "LED_SET_SPEEDVALUE", check: "Number" },
{type: "input_value", name: "LED_SET_SPEEDVALUE", check: "Number"},
],
inputsInline: true,
previousStatement: null,
Expand All @@ -220,14 +220,14 @@ function getBlocks(board) {
name: "DEMO_TYPE",
options: ledstripDemoOptions,
},
{ type: "input_dummy" },
{ type: "input_value", name: "LED_STRIP_DEMO_RED", check: "Number" },
{type: "input_dummy"},
{type: "input_value", name: "LED_STRIP_DEMO_RED", check: "Number"},
{
type: "input_value",
name: "LED_STRIP_DEMO_GREEN",
check: "Number",
},
{ type: "input_value", name: "LED_STRIP_DEMO_BLUE", check: "Number" },
{type: "input_value", name: "LED_STRIP_DEMO_BLUE", check: "Number"},
],
inputsInline: true,
previousStatement: null,
Expand All @@ -239,17 +239,17 @@ function getBlocks(board) {
{
type: "leaphy_servo_write",
message0:
"%%{" +
board.servoName +
"} %1 %2 %%{BKY_ARD_SERVO_WRITE_TO} %3 %%{BKY_ARD_SERVO_WRITE_DEG_180}",
"%%{" +
board.servoName +
"} %1 %2 %%{BKY_ARD_SERVO_WRITE_TO} %3 %%{BKY_ARD_SERVO_WRITE_DEG_180}",
args0: [
{
type: "field_dropdown",
name: "SERVO_PIN",
options: board.digitalPins,
},
{ type: "input_dummy" },
{ type: "input_value", name: "SERVO_ANGLE", check: "Number" },
{type: "input_dummy"},
{type: "input_value", name: "SERVO_ANGLE", check: "Number"},
],
inputsInline: true,
previousStatement: null,
Expand Down Expand Up @@ -279,8 +279,8 @@ function getBlocks(board) {
type: "leaphy_io_digitalwrite",
message0: "%%{BKY_ARD_DIGITALWRITE} %1 %%{BKY_ARD_WRITE_TO} %2",
args0: [
{ type: "field_dropdown", name: "PIN", options: board.digitalPins },
{ type: "input_value", name: "STATE", check: "Boolean" },
{type: "field_dropdown", name: "PIN", options: board.digitalPins},
{type: "input_value", name: "STATE", check: "Boolean"},
],
inputsInline: true,
previousStatement: null,
Expand All @@ -293,8 +293,8 @@ function getBlocks(board) {
type: "leaphy_io_analogwrite",
message0: "%%{BKY_ARD_ANALOGWRITE} %1 %%{BKY_ARD_WRITE_TO} %2",
args0: [
{ type: "field_dropdown", name: "PIN", options: board.digitalPins },
{ type: "input_value", name: "NUM", check: "Number" },
{type: "field_dropdown", name: "PIN", options: board.digitalPins},
{type: "input_value", name: "NUM", check: "Number"},
],
inputsInline: true,
previousStatement: null,
Expand All @@ -307,7 +307,7 @@ function getBlocks(board) {
{
type: "leaphy_sonar_read",
message0:
"%%{BKY_LEAPHY_SONAR_READ_TRIG} %1 %%{BKY_LEAPHY_SONAR_READ_ECHO} %2",
"%%{BKY_LEAPHY_SONAR_READ_TRIG} %1 %%{BKY_LEAPHY_SONAR_READ_ECHO} %2",
args0: [
{
type: "field_dropdown",
Expand Down Expand Up @@ -347,13 +347,27 @@ function getBlocks(board) {
type: "leaphy_display_print_line",
message0: "%%{BKY_LEAPHY_DISPLAY_PRINT} %1 %2 %3",
args0: [
{ type: "input_dummy" },
{type: "input_dummy"},
{
type: "field_dropdown",
name: "DISPLAY_ROW",
options: displayPinNumbers,
},
{ type: "input_value", name: "VALUE" },
{type: "input_value", name: "VALUE"},
],
inputsInline: true,
previousStatement: null,
nextStatement: null,
style: "leaphy_blocks",
// "extensions": "updateDisplay",
tooltip: "",
helpUrl: "",
},
{
type: "leaphy_display_set_text_size",
message0: "%%{BKY_LEAPHY_DISPLAY_SET_TEXT_SIZE} %1",
args0: [
{type: "input_value", name: "NUM", check: "Number"},
],
inputsInline: true,
previousStatement: null,
Expand All @@ -367,15 +381,15 @@ function getBlocks(board) {
type: "leaphy_display_print_value",
message0: "%%{BKY_LEAPHY_DISPLAY_PRINT} %1 %2 %3 = %4 %5",
args0: [
{ type: "input_dummy" },
{type: "input_dummy"},
{
type: "field_dropdown",
name: "DISPLAY_ROW",
options: displayPinNumbers,
},
{ type: "input_value", name: "NAME" },
{ type: "input_dummy" },
{ type: "input_value", name: "VALUE" },
{type: "input_value", name: "NAME"},
{type: "input_dummy"},
{type: "input_value", name: "VALUE"},
],
inputsInline: true,
previousStatement: null,
Expand Down Expand Up @@ -452,7 +466,6 @@ function getBlocks(board) {
helpUrl: "",
},
];
return blocks;
}

export default getBlocks;
8 changes: 8 additions & 0 deletions generators/arduino/leaphy_extra.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,14 @@ function getCodeGenerators(Arduino) {
return code;
};

Arduino.forBlock["leaphy_display_set_text_size"] = function (block) {
addDisplaySetupCode();

const stateOutput =
Arduino.valueToCode(block, "NUM", Arduino.ORDER_ATOMIC) || "0";
return "display.setTextSize(" + stateOutput + ");\n";
};

Arduino.forBlock["leaphy_display_print_line"] = function (block) {
addDisplaySetupCode();

Expand Down
1 change: 1 addition & 0 deletions msg/js/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,5 +507,6 @@ Blockly.Msg["COLOUR_HUE"] = "20";
Blockly.Msg["VARIABLES_HUE"] = "330";
Blockly.Msg["VARIABLES_DYNAMIC_HUE"] = "310";
Blockly.Msg["PROCEDURES_HUE"] = "290";
Blockly.Msg["LEAPHY_DISPLAY_SET_TEXT_SIZE"] = "Set text size";

export default Blockly.Msg;
1 change: 1 addition & 0 deletions msg/js/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,5 +505,6 @@ Blockly.Msg["COLOUR_HUE"] = "20";
Blockly.Msg["VARIABLES_HUE"] = "330";
Blockly.Msg["VARIABLES_DYNAMIC_HUE"] = "310";
Blockly.Msg["PROCEDURES_HUE"] = "290";
Blockly.Msg["LEAPHY_DISPLAY_SET_TEXT_SIZE"] = "Zet tekstgrootte op";

export default Blockly.Msg;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"msg",
"theme"
],
"version": "1.6.0",
"version": "1.7.1",
"description": "Leaphy custom Blockly blocks and arduino code generator",
"name": "@leaphy-robotics/leaphy-blocks"
}

0 comments on commit c3f57be

Please sign in to comment.