From f9e06bb79d0a74f1e096c71b7f175cd7a4494130 Mon Sep 17 00:00:00 2001 From: "KAVIN MURALIKRISHNAN (921563)" <921563@lcps.org> Date: Fri, 31 May 2024 20:06:40 -0400 Subject: [PATCH 1/5] added pestolink blocks --- js/xrp_blockly_toolbox.js | 69 ++++++++++++++++++++ js/xrp_blocks.js | 133 ++++++++++++++++++++++++++++++++++++++ js/xrp_blocks_python.js | 96 +++++++++++++++++++++++++++ 3 files changed, 298 insertions(+) diff --git a/js/xrp_blockly_toolbox.js b/js/xrp_blockly_toolbox.js index a8ed4f1..ac55867 100644 --- a/js/xrp_blockly_toolbox.js +++ b/js/xrp_blockly_toolbox.js @@ -185,6 +185,75 @@ 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": "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": "CATEGORY", "name": "Control Board", diff --git a/js/xrp_blocks.js b/js/xrp_blocks.js index 77bea18..bd4ae76 100644 --- a/js/xrp_blocks.js +++ b/js/xrp_blocks.js @@ -580,6 +580,138 @@ 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(""); + } +}; // OTHER BLOCK COLORS - These colors can be found in the xrp_blockly_toolbox1.js file // BLOCK TYPE --> COLOR // Loops --> grass green @@ -588,3 +720,4 @@ Blockly.Blocks['xrp_sleep'] = { // Lists --> eggplant purple // Variables --> grey // Functions --> medium purple +// Controller --> Some random shade of yellow idk \ No newline at end of file diff --git a/js/xrp_blocks_python.js b/js/xrp_blocks_python.js index 34a9451..ca585b0 100644 --- a/js/xrp_blocks_python.js +++ b/js/xrp_blocks_python.js @@ -352,4 +352,100 @@ 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_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(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_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(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_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(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_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(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_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(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_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(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_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(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_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(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_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(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_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(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_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(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_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(robot_name)' + + var code = `pestolink.get_button(7)`; + // TODO: Change ORDER_NONE to the correct strength. + return [code, Blockly.Python.ORDER_NONE]; +}; + From bb226657c40ffbb388323755cfa59dba56ff6284 Mon Sep 17 00:00:00 2001 From: Kavin Muralikrishnan Date: Fri, 31 May 2024 22:56:31 -0400 Subject: [PATCH 2/5] made xrp names random --- js/xrp_blocks_python.js | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/js/xrp_blocks_python.js b/js/xrp_blocks_python.js index ca585b0..2b9f69f 100644 --- a/js/xrp_blocks_python.js +++ b/js/xrp_blocks_python.js @@ -354,14 +354,16 @@ Blockly.Python['xrp_sleep'] = function (block) { //Pesto Link Controller: Credit Kavin Muralikrishnan FRC Team 5338 Roboloco Blockly.Python['pestolink_get_controller_left_x'] = function (block) { - PY.definitions_['import_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(robot_name)' + 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_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(robot_name)' + 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. @@ -369,7 +371,8 @@ Blockly.Python['pestolink_get_controller_left_y'] = function (block) { }; Blockly.Python['pestolink_get_controller_right_x'] = function (block) { - PY.definitions_['import_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(robot_name)' + 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. @@ -377,7 +380,8 @@ Blockly.Python['pestolink_get_controller_right_x'] = function (block) { }; Blockly.Python['pestolink_get_controller_right_y'] = function (block) { - PY.definitions_['import_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(robot_name)' + 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. @@ -385,7 +389,8 @@ Blockly.Python['pestolink_get_controller_right_y'] = function (block) { }; Blockly.Python['pestolink_is_a_pressed'] = function (block) { - PY.definitions_['import_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(robot_name)' + 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. @@ -393,7 +398,8 @@ Blockly.Python['pestolink_is_a_pressed'] = function (block) { }; Blockly.Python['pestolink_is_b_pressed'] = function (block) { - PY.definitions_['import_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(robot_name)' + 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. @@ -401,7 +407,8 @@ Blockly.Python['pestolink_is_b_pressed'] = function (block) { }; Blockly.Python['pestolink_is_y_pressed'] = function (block) { - PY.definitions_['import_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(robot_name)' + 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. @@ -409,7 +416,8 @@ Blockly.Python['pestolink_is_y_pressed'] = function (block) { }; Blockly.Python['pestolink_is_x_pressed'] = function (block) { - PY.definitions_['import_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(robot_name)' + 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. @@ -417,7 +425,8 @@ Blockly.Python['pestolink_is_x_pressed'] = function (block) { }; Blockly.Python['pestolink_is_left_bumper_pressed'] = function (block) { - PY.definitions_['import_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(robot_name)' + 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. @@ -425,7 +434,8 @@ Blockly.Python['pestolink_is_left_bumper_pressed'] = function (block) { }; Blockly.Python['pestolink_is_right_bumper_pressed'] = function (block) { - PY.definitions_['import_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(robot_name)' + 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. @@ -433,7 +443,8 @@ Blockly.Python['pestolink_is_right_bumper_pressed'] = function (block) { }; Blockly.Python['pestolink_is_left_trigger_pressed'] = function (block) { - PY.definitions_['import_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(robot_name)' + 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. @@ -441,7 +452,8 @@ Blockly.Python['pestolink_is_left_trigger_pressed'] = function (block) { }; Blockly.Python['pestolink_is_right_trigger_pressed'] = function (block) { - PY.definitions_['import_pestolink']='from machine import Pin \nimport bluetooth\nfrom pestolink import PestoLinkAgent\n\nrobot_name = \"XRProbot\"\npestolink = PestoLinkAgent(robot_name)' + 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. From 0cb32f67c51cff4e8134bf53e636516c8837f8b3 Mon Sep 17 00:00:00 2001 From: "KAVIN MURALIKRISHNAN (921563)" <921563@lcps.org> Date: Sat, 1 Jun 2024 11:57:24 -0400 Subject: [PATCH 3/5] added generic get pestolink blocks --- js/xrp_blockly_toolbox.js | 8 ++++++++ js/xrp_blocks.js | 28 ++++++++++++++++++++++++++++ js/xrp_blocks_python.js | 18 ++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/js/xrp_blockly_toolbox.js b/js/xrp_blockly_toolbox.js index ac55867..2264575 100644 --- a/js/xrp_blockly_toolbox.js +++ b/js/xrp_blockly_toolbox.js @@ -211,6 +211,10 @@ var blocklyToolbox = { "kind": "BLOCK", "type": "pestolink_get_controller_right_y" }, + { + "kind": "BLOCK", + "type": "pestolink_get_axis" + } ] }, { @@ -250,6 +254,10 @@ var blocklyToolbox = { "kind": "BLOCK", "type": "pestolink_is_left_bumper_pressed" }, + { + "kind": "BLOCK", + "type": "pestolink_get_button" + } ] } ] diff --git a/js/xrp_blocks.js b/js/xrp_blocks.js index bd4ae76..3b2268a 100644 --- a/js/xrp_blocks.js +++ b/js/xrp_blocks.js @@ -712,6 +712,34 @@ Blockly.Blocks['pestolink_is_left_trigger_pressed']={ this.setHelpUrl(""); } }; + +Blockly.Blocks['pestolink_get_axis'] = { + init: function() { + this.appendDummyInput() + .appendField("Get Pesto Link Axis"); + this.appendValueInput("axis") + .setCheck("Number") + .appendField("Axis Number:"); + 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.appendDummyInput() + .appendField("Is Pesto Link Button Pressed"); + this.appendValueInput("num") + .setCheck("Number") + .appendField("Button Number:"); + 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 diff --git a/js/xrp_blocks_python.js b/js/xrp_blocks_python.js index 2b9f69f..1fd3786 100644 --- a/js/xrp_blocks_python.js +++ b/js/xrp_blocks_python.js @@ -461,3 +461,21 @@ Blockly.Python['pestolink_is_right_trigger_pressed'] = function (block) { }; +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]; +}; From 41e5a02a7c7e14b43f665c1e6c1c1f1eedce85fb Mon Sep 17 00:00:00 2001 From: "KAVIN MURALIKRISHNAN (921563)" <921563@lcps.org> Date: Mon, 3 Jun 2024 12:12:19 -0400 Subject: [PATCH 4/5] fixed generic functions --- js/xrp_blockly_toolbox.js | 14 ++++++++++---- js/xrp_blocks.js | 24 ++++++++++-------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/js/xrp_blockly_toolbox.js b/js/xrp_blockly_toolbox.js index 2264575..e931599 100644 --- a/js/xrp_blockly_toolbox.js +++ b/js/xrp_blockly_toolbox.js @@ -213,8 +213,11 @@ var blocklyToolbox = { }, { "kind": "BLOCK", - "type": "pestolink_get_axis" - } + "type": "pestolink_get_axis", + "inputs": { + "axis": {"shadow": {"type": "math_number", "fields": {"axis": "0"}}} + } + }, ] }, { @@ -256,7 +259,10 @@ var blocklyToolbox = { }, { "kind": "BLOCK", - "type": "pestolink_get_button" + "type": "pestolink_get_button", + "inputs":{ + "num": {"shadow": {"type": "math_number", "fields": {"num": "0"}}} + } } ] } @@ -623,4 +629,4 @@ var blocklyToolbox = { "xmlns": "https://developers.google.com/blockly/xml", "id": "toolbox", "style": "display: none" -} +} \ No newline at end of file diff --git a/js/xrp_blocks.js b/js/xrp_blocks.js index 3b2268a..c39859e 100644 --- a/js/xrp_blocks.js +++ b/js/xrp_blocks.js @@ -715,29 +715,25 @@ Blockly.Blocks['pestolink_is_left_trigger_pressed']={ Blockly.Blocks['pestolink_get_axis'] = { init: function() { - this.appendDummyInput() - .appendField("Get Pesto Link Axis"); this.appendValueInput("axis") .setCheck("Number") - .appendField("Axis Number:"); - this.setOutput(true, null); - this.setColour(60); - this.setTooltip("Get a specific axis from Pesto Link"); - this.setHelpUrl(""); + .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.appendDummyInput() - .appendField("Is Pesto Link Button Pressed"); this.appendValueInput("num") .setCheck("Number") - .appendField("Button Number:"); - this.setOutput(true, null); - this.setColour(60); - this.setTooltip("Get the pressed state of a specific button from Pesto Link"); - this.setHelpUrl(""); + .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 From af0a6ad15c8b4ec24963dd2a2045c6366795aeb7 Mon Sep 17 00:00:00 2001 From: Kavin Muralikrishnan <921563@lcps.org> Date: Thu, 12 Dec 2024 18:03:47 -0500 Subject: [PATCH 5/5] UNDO THIS COMMIT --- lib/XRPLib/defaults.py | 4 ++-- lib/package.json | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/XRPLib/defaults.py b/lib/XRPLib/defaults.py index d26b8b8..40c830f 100644 --- a/lib/XRPLib/defaults.py +++ b/lib/XRPLib/defaults.py @@ -7,7 +7,7 @@ from .imu import IMU from .reflectance import Reflectance from .servo import Servo -from .webserver import Webserver +# from .webserver import Webserver """ A simple file that constructs all of the default objects for the XRP robot @@ -22,5 +22,5 @@ reflectance = Reflectance.get_default_reflectance() servo_one = Servo.get_default_servo(index=1) servo_two = Servo.get_default_servo(index=2) -webserver = Webserver.get_default_webserver() +# webserver = Webserver.get_default_webserver() board = Board.get_default_board() \ No newline at end of file diff --git a/lib/package.json b/lib/package.json index 1a2fb78..6ce8639 100644 --- a/lib/package.json +++ b/lib/package.json @@ -1,9 +1,8 @@ { "urls": [ - ["XRPLib/__init__.py", "github:Open-STEM/XRP_Micropython/XRPLib/__init__.py"], ["XRPLib/board.py", "github:Open-STEM/XRP_Micropython/XRPLib/board.py"], ["XRPLib/controller.py", "github:Open-STEM/XRP_Micropython/XRPLib/controller.py"], - ["XRPLib/defaults.py", "github:Open-STEM/XRP_Micropython/XRPLib/defaults.py"], + ["XRPLib/defaults.py", "github:RoboLoCo-5338/XRPCode/lib/XRPLib/defaults.py"], ["XRPLib/differential_drive.py", "github:Open-STEM/XRP_Micropython/XRPLib/differential_drive.py"], ["XRPLib/encoded_motor.py", "github:Open-STEM/XRP_Micropython/XRPLib/encoded_motor.py"], ["XRPLib/encoder.py", "github:Open-STEM/XRP_Micropython/XRPLib/encoder.py"], @@ -18,7 +17,7 @@ ["XRPLib/servo.py", "github:Open-STEM/XRP_Micropython/XRPLib/servo.py"], ["XRPLib/timeout.py", "github:Open-STEM/XRP_Micropython/XRPLib/timeout.py"], ["XRPLib/webserver.py", "github:Open-STEM/XRP_Micropython/XRPLib/webserver.py"], - ["XRPExamples/__init__.py", "github:Open-STEM/XRP_Micropython/Examples/__init__.py"], + ["lib/pestolink.py", "github:RoboLoCo-5338/XRPCode/lib/pestolink.py"], ["XRPExamples/drive_examples.py", "github:Open-STEM/XRP_Micropython/Examples/drive_examples.py"], ["XRPExamples/installation_verification.py", "github:Open-STEM/XRP_Micropython/Examples/installation_verification.py"], ["XRPExamples/misc_examples.py", "github:Open-STEM/XRP_Micropython/Examples/misc_examples.py"],