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

Added Pesto Link Blocks #80

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 84 additions & 1 deletion js/xrp_blockly_toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,89 @@ var blocklyToolbox = {
]},
]
},
{
"kind": "CATEGORY",
"name": "Controller",
"colour": "#a5a55b",
"contents": [
{
"kind": "CATEGORY",
"name": "JoyStick",
"colour": "#a5a55b",
"contents": [
{
"kind": "BLOCK",
"type": "pestolink_get_controller_left_x"
},
{
"kind": "BLOCK",
"type": "pestolink_get_controller_left_y"
},
{
"kind": "BLOCK",
"type": "pestolink_get_controller_right_x"
},
{
"kind": "BLOCK",
"type": "pestolink_get_controller_right_y"
},
{
"kind": "BLOCK",
"type": "pestolink_get_axis",
"inputs": {
"axis": {"shadow": {"type": "math_number", "fields": {"axis": "0"}}}
}
},
]
},
{
"kind": "CATEGORY",
"name": "Buttons",
"colour": "#a5a55b",
"contents": [
{
"kind": "BLOCK",
"type": "pestolink_is_a_pressed"
},
{
"kind": "BLOCK",
"type": "pestolink_is_b_pressed"
},
{
"kind": "BLOCK",
"type": "pestolink_is_x_pressed"
},
{
"kind": "BLOCK",
"type": "pestolink_is_y_pressed"
},
{
"kind": "BLOCK",
"type": "pestolink_is_right_trigger_pressed"
},
{
"kind": "BLOCK",
"type": "pestolink_is_left_trigger_pressed"
},
{
"kind": "BLOCK",
"type": "pestolink_is_right_bumper_pressed"
},
{
"kind": "BLOCK",
"type": "pestolink_is_left_bumper_pressed"
},
{
"kind": "BLOCK",
"type": "pestolink_get_button",
"inputs":{
"num": {"shadow": {"type": "math_number", "fields": {"num": "0"}}}
}
}
]
}
]
},
{
"kind": "CATEGORY",
"name": "Control Board",
Expand Down Expand Up @@ -546,4 +629,4 @@ var blocklyToolbox = {
"xmlns": "https://developers.google.com/blockly/xml",
"id": "toolbox",
"style": "display: none"
}
}
157 changes: 157 additions & 0 deletions js/xrp_blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,162 @@ Blockly.Blocks['xrp_sleep'] = {
}
};

//Pesto Link Controller: Credit Kavin Muralikrishnan FRC Team 5338 Roboloco
Blockly.Blocks['pestolink_get_controller_left_x']={
init: function () {
this.appendDummyInput()
.appendField("Get Horizontal Value of Left Joystick");
this.setOutput(true, null);
this.setColour(60);
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.Blocks['pestolink_get_controller_left_y']={
init: function () {
this.appendDummyInput()
.appendField("Get Vertical Value of Left Joystick");
this.setOutput(true, null);
this.setColour(60);
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.Blocks['pestolink_get_controller_right_x']={
init: function () {
this.appendDummyInput()
.appendField("Get Horizontal Value of Right Joystick");
this.setOutput(true, null);
this.setColour(60);
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.Blocks['pestolink_get_controller_right_y']={
init: function () {
this.appendDummyInput()
.appendField("Get Vertical Value of Right Joystick");
this.setOutput(true, null);
this.setColour(60);
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.Blocks['pestolink_is_a_pressed']={
init: function () {
this.appendDummyInput()
.appendField("A Pressed");
this.setOutput(true, null);
this.setColour(60);
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.Blocks['pestolink_is_b_pressed']={
init: function () {
this.appendDummyInput()
.appendField("B Pressed");
this.setOutput(true, null);
this.setColour(60);
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.Blocks['pestolink_is_x_pressed']={
init: function () {
this.appendDummyInput()
.appendField("X Pressed");
this.setOutput(true, null);
this.setColour(60);
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.Blocks['pestolink_is_y_pressed']={
init: function () {
this.appendDummyInput()
.appendField("Y Pressed");
this.setOutput(true, null);
this.setColour(60);
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.Blocks['pestolink_is_right_bumper_pressed']={
init: function () {
this.appendDummyInput()
.appendField("Right Bumper Pressed");
this.setOutput(true, null);
this.setColour(60);
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.Blocks['pestolink_is_left_bumper_pressed']={
init: function () {
this.appendDummyInput()
.appendField("Left Bumper Pressed");
this.setOutput(true, null);
this.setColour(60);
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.Blocks['pestolink_is_right_trigger_pressed']={
init: function () {
this.appendDummyInput()
.appendField("Right Trigger Pressed");
this.setOutput(true, null);
this.setColour(60);
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.Blocks['pestolink_is_left_trigger_pressed']={
init: function () {
this.appendDummyInput()
.appendField("Left Trigger Pressed");
this.setOutput(true, null);
this.setColour(60);
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.Blocks['pestolink_get_axis'] = {
init: function() {
this.appendValueInput("axis")
.setCheck("Number")
.appendField("Get Pesto Link Axis");
this.setOutput(true, null);
this.setColour(60);
this.setTooltip("Get a specific axis from Pesto Link");
this.setHelpUrl("");
}
}

Blockly.Blocks['pestolink_get_button'] = {
init: function() {
this.appendValueInput("num")
.setCheck("Number")
.appendField("Is Pesto Link Button Pressed");
this.setOutput(true, null);
this.setColour(60);
this.setTooltip("Get the pressed state of a specific button from Pesto Link");
this.setHelpUrl("");
}
}
// OTHER BLOCK COLORS - These colors can be found in the xrp_blockly_toolbox1.js file
// BLOCK TYPE --> COLOR
// Loops --> grass green
Expand All @@ -588,3 +744,4 @@ Blockly.Blocks['xrp_sleep'] = {
// Lists --> eggplant purple
// Variables --> grey
// Functions --> medium purple
// Controller --> Some random shade of yellow idk
126 changes: 126 additions & 0 deletions js/xrp_blocks_python.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,130 @@ Blockly.Python['xrp_sleep'] = function (block) {
return code;
};

//Pesto Link Controller: Credit Kavin Muralikrishnan FRC Team 5338 Roboloco
Blockly.Python['pestolink_get_controller_left_x'] = function (block) {
PY.definitions_['import_random']='import random\n ';
PY.definitions_['import_pestolink']='import string\n from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"("".join(random.choice(string.ascii_lowercase) for i in range(5)))\"\npestolink = PestoLinkAgent(robot_name) \n print("The name of your robot is, robot_name")'
var code = `pestolink.get_axis(0)`;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
};

Blockly.Python['pestolink_get_controller_left_y'] = function (block) {
PY.definitions_['import_random']='import random\n ';
PY.definitions_['import_pestolink']='import string\n from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"("".join(random.choice(string.ascii_lowercase) for i in range(5)))\"\npestolink = PestoLinkAgent(robot_name) \n print("The name of your robot is, robot_name")'

var code = `-pestolink.get_axis(1)`;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
};

Blockly.Python['pestolink_get_controller_right_x'] = function (block) {
PY.definitions_['import_random']='import random\n ';
PY.definitions_['import_pestolink']='import string\n from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"("".join(random.choice(string.ascii_lowercase) for i in range(5)))\"\npestolink = PestoLinkAgent(robot_name) \n print("The name of your robot is, robot_name")'

var code = `pestolink.get_axis(2)`;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
};

Blockly.Python['pestolink_get_controller_right_y'] = function (block) {
PY.definitions_['import_random']='import random\n ';
PY.definitions_['import_pestolink']='import string\n from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"("".join(random.choice(string.ascii_lowercase) for i in range(5)))\"\npestolink = PestoLinkAgent(robot_name) \n print("The name of your robot is, robot_name")'

var code = `-pestolink.get_axis(3)`;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
};

Blockly.Python['pestolink_is_a_pressed'] = function (block) {
PY.definitions_['import_random']='import random\n ';
PY.definitions_['import_pestolink']='import string\n from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"("".join(random.choice(string.ascii_lowercase) for i in range(5)))\"\npestolink = PestoLinkAgent(robot_name) \n print("The name of your robot is, robot_name")'

var code = `pestolink.get_button(0)`;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
};

Blockly.Python['pestolink_is_b_pressed'] = function (block) {
PY.definitions_['import_random']='import random\n ';
PY.definitions_['import_pestolink']='import string\n from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"("".join(random.choice(string.ascii_lowercase) for i in range(5)))\"\npestolink = PestoLinkAgent(robot_name) \n print("The name of your robot is, robot_name")'

var code = `pestolink.get_button(1)`;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
};

Blockly.Python['pestolink_is_y_pressed'] = function (block) {
PY.definitions_['import_random']='import random\n ';
PY.definitions_['import_pestolink']='import string\n from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"("".join(random.choice(string.ascii_lowercase) for i in range(5)))\"\npestolink = PestoLinkAgent(robot_name) \n print("The name of your robot is, robot_name")'

var code = `pestolink.get_button(3)`;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
};

Blockly.Python['pestolink_is_x_pressed'] = function (block) {
PY.definitions_['import_random']='import random\n ';
PY.definitions_['import_pestolink']='import string\n from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"("".join(random.choice(string.ascii_lowercase) for i in range(5)))\"\npestolink = PestoLinkAgent(robot_name) \n print("The name of your robot is, robot_name")'

var code = `pestolink.get_button(2)`;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
};

Blockly.Python['pestolink_is_left_bumper_pressed'] = function (block) {
PY.definitions_['import_random']='import random\n ';
PY.definitions_['import_pestolink']='import string\n from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"("".join(random.choice(string.ascii_lowercase) for i in range(5)))\"\npestolink = PestoLinkAgent(robot_name) \n print("The name of your robot is, robot_name")'

var code = `pestolink.get_button(4)`;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
};

Blockly.Python['pestolink_is_right_bumper_pressed'] = function (block) {
PY.definitions_['import_random']='import random\n ';
PY.definitions_['import_pestolink']='import string\n from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"("".join(random.choice(string.ascii_lowercase) for i in range(5)))\"\npestolink = PestoLinkAgent(robot_name) \n print("The name of your robot is, robot_name")'

var code = `pestolink.get_button(5)`;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
};

Blockly.Python['pestolink_is_left_trigger_pressed'] = function (block) {
PY.definitions_['import_random']='import random\n ';
PY.definitions_['import_pestolink']='import string\n from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"("".join(random.choice(string.ascii_lowercase) for i in range(5)))\"\npestolink = PestoLinkAgent(robot_name) \n print("The name of your robot is, robot_name")'

var code = `pestolink.get_button(6)`;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
};

Blockly.Python['pestolink_is_right_trigger_pressed'] = function (block) {
PY.definitions_['import_random']='import random\n ';
PY.definitions_['import_pestolink']='import string\n from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"("".join(random.choice(string.ascii_lowercase) for i in range(5)))\"\npestolink = PestoLinkAgent(robot_name) \n print("The name of your robot is, robot_name")'

var code = `pestolink.get_button(7)`;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
};


Blockly.Python['pestolink_get_axis'] = function (block) {
PY.definitions_['import_random']='import random\n ';
PY.definitions_['import_pestolink']='import string\n from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"("".join(random.choice(string.ascii_lowercase) for i in range(5)))\"\npestolink = PestoLinkAgent(robot_name) \n print("The name of your robot is, robot_name")'
var axis = block.getFieldValue("axis");
var code = `pestolink.get_axis(${axis})`;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
};


Blockly.Python['pestolink_get_button'] = function (block) {
PY.definitions_['import_random']='import random\n ';
PY.definitions_['import_pestolink']='import string\n from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"("".join(random.choice(string.ascii_lowercase) for i in range(5)))\"\npestolink = PestoLinkAgent(robot_name) \n print("The name of your robot is, robot_name")'
var button = block.getFieldValue("num");
var code = `pestolink.get_button(${button})`;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Python.ORDER_NONE];
};
Loading