diff --git a/js/xrp_blockly_toolbox.js b/js/xrp_blockly_toolbox.js index a8ed4f1..e931599 100644 --- a/js/xrp_blockly_toolbox.js +++ b/js/xrp_blockly_toolbox.js @@ -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", @@ -546,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 77bea18..c39859e 100644 --- a/js/xrp_blocks.js +++ b/js/xrp_blocks.js @@ -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 @@ -588,3 +744,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..1fd3786 100644 --- a/js/xrp_blocks_python.js +++ b/js/xrp_blocks_python.js @@ -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]; +}; 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"],