diff --git a/js/xrp_blockly_toolbox.js b/js/xrp_blockly_toolbox.js
index 694e28d..2896b49 100644
--- a/js/xrp_blockly_toolbox.js
+++ b/js/xrp_blockly_toolbox.js
@@ -1,551 +1,609 @@
var baseToolbox = {
- "contents": [
- {
- "kind": "CATEGORY",
- "name": "Individual Motors",
- "colour": "#a55b65", // crimson red
- "contents": [
- {
- "kind": "BLOCK",
- "type": "xrp_motor_effort",
- "inputs":{
- "effort": {"shadow": {"type": "math_number", "fields": {"NUM": "0.5"}}}
- },
- },
- {
- "kind": "BLOCK",
- "type": "xrp_motor_speed",
- "inputs":{
- "speed": {"shadow": {"type": "math_number", "fields": {"NUM": "60"}}}
- },
- },
- {
- "kind": "BLOCK",
- "type": "xrp_motor_direction",
- },
- {
- "kind": "BLOCK",
- "type": "xrp_motor_get_speed",
- },
- {
- "kind": "BLOCK",
- "type": "xrp_motor_get_position",
- },
- {
- "kind": "BLOCK",
- "type": "xrp_motor_get_count",
- },
- {
- "kind": "BLOCK",
- "type": "xrp_motor_reset_position",
- },
- ]
- },
- {
- "kind": "CATEGORY",
- "name": "DriveTrain",
- "colour": "#a5675b", // rust orange
- "contents": [
- {
- "kind": "BLOCK",
- "type": "xrp_straight_effort",
- "inputs":{
- "dist": {"shadow": {"type": "math_number", "fields": {"NUM": "20"}}},
- "effort": {"shadow": {"type": "math_number", "fields": {"NUM": "0.5"}}}
- },
- },
- {
- "kind": "BLOCK",
- "type": "xrp_turn_effort",
- "inputs":{
- "degrees": {"shadow": {"type": "math_number", "fields": {"NUM": "90"}}},
- "effort": {"shadow": {"type": "math_number", "fields": {"NUM": "0.5"}}}
- },
- },
- {
- "kind": "BLOCK",
- "type": "xrp_seteffort",
- "inputs":{
- "LEFT": {"shadow": {"type": "math_number", "fields": {"NUM": "0.5"}}},
- "RIGHT": {"shadow": {"type": "math_number", "fields": {"NUM": "0.5"}}}
- },
- },
- {
- "kind": "BLOCK",
- "type": "xrp_speed",
- "inputs":{
- "LEFT": {"shadow": {"type": "math_number", "fields": {"NUM": "60"}}},
- "RIGHT": {"shadow": {"type": "math_number", "fields": {"NUM": "60"}}}
- },
- },
- {
- "kind": "BLOCK",
- "type": "xrp_arcade",
- "inputs":{
- "STRAIGHT": {"shadow": {"type": "math_number", "fields": {"NUM": "0.8"}}},
- "TURN": {"shadow": {"type": "math_number", "fields": {"NUM": "0.2"}}}
- },
- },
- {
- "kind": "BLOCK",
- "type": "xrp_stop_motors"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_resetencoders"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_getleftencoder"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_getrightencoder"
- },
- ]
- },
- {
- "kind": "CATEGORY",
- "name": "Servos",
- "colour": "#a55ba5", // purple/pink
- "contents": [
- {
- "kind": "BLOCK",
- "type": "xrp_servo_deg",
- "inputs":{
- "degrees": {"shadow": {"type": "math_number", "fields": {"NUM": "90"}}}
- }
- },
- ]
- },
- {
- "kind": "CATEGORY",
- "name": "Sensors",
- "colour": "#80a55b", // LIGHT GREEN
- "contents": [
- {
- "kind": "CATEGORY",
- "name": "Distance",
- "colour": "#80a55b",
- "contents": [
- {
- "kind": "BLOCK",
- "type": "xrp_getsonardist"
- },
- ]},
- {
- "kind": "CATEGORY",
- "name": "Reflectance",
- "colour": "#80a55b",
- "contents": [
- {
- "kind": "BLOCK",
- "type": "xrp_l_refl"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_r_refl"
- },
- ]},
- {
- "kind": "CATEGORY",
- "name": "Gyro",
- "colour": "#80a55b",
- "contents": [
- {
- "kind": "BLOCK",
- "type": "xrp_yaw"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_roll"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_pitch"
- }
- ]},
- {
- "kind": "CATEGORY",
- "name": "Accelerometer",
- "colour": "#80a55b",
- "contents": [
- {
- "kind": "BLOCK",
- "type": "xrp_acc_x"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_acc_y"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_acc_z"
- }
- ]},
- ]
- },
- {
- "kind": "CATEGORY",
- "name": "Control Board",
- "colour": "#5ba580", // cool green
- "contents": [
- {
- "kind": "BLOCK",
- "type": "xrp_led_on"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_led_off"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_button_pressed"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_wait_for_button_press"
- }
- ]
- },
- {
- "kind": "CATEGORY",
- "name": "Web Server",
- "colour": "#5b99a5", // turquoise
- "contents": [
- {
- "kind": "BLOCK",
- "type": "xrp_ws_forward_button"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_ws_back_button"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_ws_left_button"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_ws_right_button"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_ws_stop_button"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_ws_add_button"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_ws_log_data",
- "inputs":{
- "log_name": {"shadow": {"type": "text", "field": {"text": "label"}}}
- },
- },
- {
- "kind": "BLOCK",
- "type": "xrp_ws_start_server",
- "blockxml": "\n\nxrp_1\n\n\n \n\n\n\n\n",
- },
- {
- "kind": "BLOCK",
- "type": "xrp_ws_connect_server",
- "blockxml": "\n\nxrp_1\n\n\n \n\n\n\n\n",
- },
- ]
- },
- {
- "kind": "CATEGORY",
- "contents": [
- {
- "kind": "BLOCK",
- "type": "xrp_sleep",
- "inputs":{
- "TIME": {"shadow": {"type": "math_number", "fields": {"NUM": "0.5"}}}
- },
- },
- {
- "kind": "BLOCK",
- "type": "controls_if"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n EQ\n ",
- "type": "logic_compare"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n AND\n ",
- "type": "logic_operation"
- },
- {
- "kind": "BLOCK",
- "type": "logic_negate"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n TRUE\n ",
- "type": "logic_boolean"
- },
- {
- "kind": "BLOCK",
- "type": "logic_null"
- },
- {
- "kind": "BLOCK",
- "type": "logic_ternary"
- }
- ],
- "name": "Logic",
- "colour": "#5b80a5" // slate blue
- },
- {
- "kind": "CATEGORY",
- "contents": [
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n 10\n \n \n ",
- "type": "controls_repeat_ext"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n WHILE\n ",
- "type": "controls_whileUntil"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n i\n \n \n 1\n \n \n \n \n 10\n \n \n \n \n 1\n \n \n ",
- "type": "controls_for"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n j\n ",
- "type": "controls_forEach"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n BREAK\n ",
- "type": "controls_flow_statements"
- }
- ],
- "name": "Loops",
- "colour": "#5ba55b" // grass green
- },
- {
- "kind": "CATEGORY",
- "contents": [
- {
- "kind": "BLOCK",
- "blockxml": "\n 0\n ",
- "type": "math_number"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n ADD\n \n \n 1\n \n \n \n \n 1\n \n \n ",
- "type": "math_arithmetic"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n ROOT\n \n \n 9\n \n \n ",
- "type": "math_single"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n SIN\n \n \n 45\n \n \n ",
- "type": "math_trig"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n PI\n ",
- "type": "math_constant"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n EVEN\n \n \n 0\n \n \n ",
- "type": "math_number_property"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n ROUND\n \n \n 3.1\n \n \n ",
- "type": "math_round"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n SUM\n ",
- "type": "math_on_list"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n 64\n \n \n \n \n 10\n \n \n ",
- "type": "math_modulo"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n 50\n \n \n \n \n 1\n \n \n \n \n 100\n \n \n ",
- "type": "math_constrain"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n 1\n \n \n \n \n 100\n \n \n ",
- "type": "math_random_int"
- },
- {
- "kind": "BLOCK",
- "type": "math_random_float"
- }
- ],
- "name": "Math",
- "colour": "#5b67a5" // indigo blue
- },
- {
- "kind": "CATEGORY",
- "contents": [
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n abc\n \n \n ",
- "type": "text_print"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n ",
- "type": "text"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n ",
- "type": "text_join"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n item\n \n \n \n \n \n ",
- "type": "text_append"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n abc\n \n \n ",
- "type": "text_length"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n \n \n \n ",
- "type": "text_isEmpty"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n FIRST\n \n \n text\n \n \n \n \n abc\n \n \n ",
- "type": "text_indexOf"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n FROM_START\n \n \n text\n \n \n ",
- "type": "text_charAt"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n FROM_START\n FROM_START\n \n \n text\n \n \n ",
- "type": "text_getSubstring"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n UPPERCASE\n \n \n abc\n \n \n ",
- "type": "text_changeCase"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n BOTH\n \n \n abc\n \n \n ",
- "type": "text_trim"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n TEXT\n \n \n abc\n \n \n ",
- "type": "text_prompt_ext"
- }
- ],
- "name": "Text",
- "colour": "#5ba58c" // seafoam green
- },
- {
- "kind": "CATEGORY",
- "contents": [
- {
- "kind": "BLOCK",
- "blockxml": "\n \n ",
- "type": "lists_create_with"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n ",
- "type": "lists_create_with"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n 5\n \n \n ",
- "type": "lists_repeat"
- },
- {
- "kind": "BLOCK",
- "blockxml": "",
- "type": "lists_length"
- },
- {
- "kind": "BLOCK",
- "type": "lists_isEmpty"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n FIRST\n \n \n list\n \n \n ",
- "type": "lists_indexOf"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n GET\n FROM_START\n \n \n list\n \n \n ",
- "type": "lists_getIndex"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n SET\n FROM_START\n \n \n list\n \n \n ",
- "type": "lists_setIndex"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n FROM_START\n FROM_START\n \n \n list\n \n \n ",
- "type": "lists_getSublist"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n SPLIT\n \n \n ,\n \n \n ",
- "type": "lists_split"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n NUMERIC\n 1\n ",
- "type": "lists_sort"
- }
- ],
- "name": "Lists",
- "colour": "#745ba5" // eggplant purple
- },
- {
- "kind": "CATEGORY",
- "name": "Variables",
- "colour": "#a55b80", // fuschia
- "custom": "VARIABLE"
- },
- {
- "kind": "CATEGORY",
- "name": "Functions",
- "colour": "#995ba5", // purple
- "custom": "PROCEDURE"
- },
- {
- "kind": "SEP"
- }
- ],
- "xmlns": "https://developers.google.com/blockly/xml",
- "id": "toolbox",
- "style": "display: none"
-}
+ contents: [
+ {
+ kind: "CATEGORY",
+ name: "Individual Motors",
+ colour: "#a55b65", // crimson red
+ contents: [
+ {
+ kind: "BLOCK",
+ type: "xrp_motor_effort",
+ inputs: {
+ effort: { shadow: { type: "math_number", fields: { NUM: "0.5" } } },
+ },
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_motor_speed",
+ inputs: {
+ speed: { shadow: { type: "math_number", fields: { NUM: "60" } } },
+ },
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_motor_direction",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_motor_get_speed",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_motor_get_position",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_motor_get_count",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_motor_reset_position",
+ },
+ ],
+ },
+ {
+ kind: "CATEGORY",
+ name: "DriveTrain",
+ colour: "#a5675b", // rust orange
+ contents: [
+ {
+ kind: "BLOCK",
+ type: "xrp_straight_effort",
+ inputs: {
+ dist: { shadow: { type: "math_number", fields: { NUM: "20" } } },
+ effort: { shadow: { type: "math_number", fields: { NUM: "0.5" } } },
+ },
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_turn_effort",
+ inputs: {
+ degrees: { shadow: { type: "math_number", fields: { NUM: "90" } } },
+ effort: { shadow: { type: "math_number", fields: { NUM: "0.5" } } },
+ },
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_seteffort",
+ inputs: {
+ LEFT: { shadow: { type: "math_number", fields: { NUM: "0.5" } } },
+ RIGHT: { shadow: { type: "math_number", fields: { NUM: "0.5" } } },
+ },
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_speed",
+ inputs: {
+ LEFT: { shadow: { type: "math_number", fields: { NUM: "60" } } },
+ RIGHT: { shadow: { type: "math_number", fields: { NUM: "60" } } },
+ },
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_arcade",
+ inputs: {
+ STRAIGHT: {
+ shadow: { type: "math_number", fields: { NUM: "0.8" } },
+ },
+ TURN: { shadow: { type: "math_number", fields: { NUM: "0.2" } } },
+ },
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_stop_motors",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_resetencoders",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_getleftencoder",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_getrightencoder",
+ },
+ ],
+ },
+ {
+ kind: "CATEGORY",
+ name: "Servos",
+ colour: "#a55ba5", // purple/pink
+ contents: [
+ {
+ kind: "BLOCK",
+ type: "xrp_servo_deg",
+ inputs: {
+ degrees: { shadow: { type: "math_number", fields: { NUM: "90" } } },
+ },
+ },
+ ],
+ },
+ {
+ kind: "CATEGORY",
+ name: "Sensors",
+ colour: "#80a55b", // LIGHT GREEN
+ contents: [
+ {
+ kind: "CATEGORY",
+ name: "HTMLRGB",
+ colour: "#80a55b",
+ contents: [
+ {
+ kind: "BLOCK",
+ type: "html_rgb",
+ },
+ ],
+ },
+ {
+ kind: "CATEGORY",
+ name: "Distance",
+ colour: "#80a55b",
+ contents: [
+ {
+ kind: "BLOCK",
+ type: "xrp_getsonardist",
+ },
+ ],
+ },
+ {
+ kind: "CATEGORY",
+ name: "Reflectance",
+ colour: "#80a55b",
+ contents: [
+ {
+ kind: "BLOCK",
+ type: "xrp_l_refl",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_r_refl",
+ },
+ ],
+ },
+ {
+ kind: "CATEGORY",
+ name: "Gyro",
+ colour: "#80a55b",
+ contents: [
+ {
+ kind: "BLOCK",
+ type: "xrp_yaw",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_roll",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_pitch",
+ },
+ ],
+ },
+ {
+ kind: "CATEGORY",
+ name: "Accelerometer",
+ colour: "#80a55b",
+ contents: [
+ {
+ kind: "BLOCK",
+ type: "xrp_acc_x",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_acc_y",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_acc_z",
+ },
+ ],
+ },
+ ],
+ },
+ {
+ kind: "CATEGORY",
+ name: "Control Board",
+ colour: "#5ba580", // cool green
+ contents: [
+ {
+ kind: "BLOCK",
+ type: "xrp_led_on",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_led_off",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_button_pressed",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_wait_for_button_press",
+ },
+ ],
+ },
+ {
+ kind: "CATEGORY",
+ name: "Web Server",
+ colour: "#5b99a5", // turquoise
+ contents: [
+ {
+ kind: "BLOCK",
+ type: "xrp_ws_forward_button",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_ws_back_button",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_ws_left_button",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_ws_right_button",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_ws_stop_button",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_ws_add_button",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_ws_log_data",
+ inputs: {
+ log_name: { shadow: { type: "text", field: { text: "label" } } },
+ },
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_ws_start_server",
+ blockxml:
+ '\n\nxrp_1\n\n\n \n\n\n\n\n',
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_ws_connect_server",
+ blockxml:
+ '\n\nxrp_1\n\n\n \n\n\n\n\n',
+ },
+ ],
+ },
+ {
+ kind: "CATEGORY",
+ contents: [
+ {
+ kind: "BLOCK",
+ type: "xrp_sleep",
+ inputs: {
+ TIME: { shadow: { type: "math_number", fields: { NUM: "0.5" } } },
+ },
+ },
+ {
+ kind: "BLOCK",
+ type: "controls_if",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n EQ\n ',
+ type: "logic_compare",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n AND\n ',
+ type: "logic_operation",
+ },
+ {
+ kind: "BLOCK",
+ type: "logic_negate",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n TRUE\n ',
+ type: "logic_boolean",
+ },
+ {
+ kind: "BLOCK",
+ type: "logic_null",
+ },
+ {
+ kind: "BLOCK",
+ type: "logic_ternary",
+ },
+ ],
+ name: "Logic",
+ colour: "#5b80a5", // slate blue
+ },
+ {
+ kind: "CATEGORY",
+ contents: [
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n 10\n \n \n ',
+ type: "controls_repeat_ext",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n WHILE\n ',
+ type: "controls_whileUntil",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n i\n \n \n 1\n \n \n \n \n 10\n \n \n \n \n 1\n \n \n ',
+ type: "controls_for",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n j\n ',
+ type: "controls_forEach",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n BREAK\n ',
+ type: "controls_flow_statements",
+ },
+ ],
+ name: "Loops",
+ colour: "#5ba55b", // grass green
+ },
+ {
+ kind: "CATEGORY",
+ contents: [
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n 0\n ',
+ type: "math_number",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n ADD\n \n \n 1\n \n \n \n \n 1\n \n \n ',
+ type: "math_arithmetic",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n ROOT\n \n \n 9\n \n \n ',
+ type: "math_single",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n SIN\n \n \n 45\n \n \n ',
+ type: "math_trig",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n PI\n ',
+ type: "math_constant",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n EVEN\n \n \n 0\n \n \n ',
+ type: "math_number_property",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n ROUND\n \n \n 3.1\n \n \n ',
+ type: "math_round",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n SUM\n ',
+ type: "math_on_list",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n 64\n \n \n \n \n 10\n \n \n ',
+ type: "math_modulo",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n 50\n \n \n \n \n 1\n \n \n \n \n 100\n \n \n ',
+ type: "math_constrain",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n 1\n \n \n \n \n 100\n \n \n ',
+ type: "math_random_int",
+ },
+ {
+ kind: "BLOCK",
+ type: "math_random_float",
+ },
+ ],
+ name: "Math",
+ colour: "#5b67a5", // indigo blue
+ },
+ {
+ kind: "CATEGORY",
+ contents: [
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n abc\n \n \n ',
+ type: "text_print",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n ',
+ type: "text",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n ',
+ type: "text_join",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n item\n \n \n \n \n \n ',
+ type: "text_append",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n abc\n \n \n ',
+ type: "text_length",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n \n \n \n ',
+ type: "text_isEmpty",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n FIRST\n \n \n text\n \n \n \n \n abc\n \n \n ',
+ type: "text_indexOf",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n FROM_START\n \n \n text\n \n \n ',
+ type: "text_charAt",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n FROM_START\n FROM_START\n \n \n text\n \n \n ',
+ type: "text_getSubstring",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n UPPERCASE\n \n \n abc\n \n \n ',
+ type: "text_changeCase",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n BOTH\n \n \n abc\n \n \n ',
+ type: "text_trim",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n TEXT\n \n \n abc\n \n \n ',
+ type: "text_prompt_ext",
+ },
+ ],
+ name: "Text",
+ colour: "#5ba58c", // seafoam green
+ },
+ {
+ kind: "CATEGORY",
+ contents: [
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n ',
+ type: "lists_create_with",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n ',
+ type: "lists_create_with",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n 5\n \n \n ',
+ type: "lists_repeat",
+ },
+ {
+ kind: "BLOCK",
+ blockxml: '',
+ type: "lists_length",
+ },
+ {
+ kind: "BLOCK",
+ type: "lists_isEmpty",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n FIRST\n \n \n list\n \n \n ',
+ type: "lists_indexOf",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n GET\n FROM_START\n \n \n list\n \n \n ',
+ type: "lists_getIndex",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n SET\n FROM_START\n \n \n list\n \n \n ',
+ type: "lists_setIndex",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n FROM_START\n FROM_START\n \n \n list\n \n \n ',
+ type: "lists_getSublist",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n SPLIT\n \n \n ,\n \n \n ',
+ type: "lists_split",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n NUMERIC\n 1\n ',
+ type: "lists_sort",
+ },
+ ],
+ name: "Lists",
+ colour: "#745ba5", // eggplant purple
+ },
+ {
+ kind: "CATEGORY",
+ name: "Variables",
+ colour: "#a55b80", // fuschia
+ custom: "VARIABLE",
+ },
+ {
+ kind: "CATEGORY",
+ name: "Functions",
+ colour: "#995ba5", // purple
+ custom: "PROCEDURE",
+ },
+ {
+ kind: "SEP",
+ },
+ ],
+ xmlns: "https://developers.google.com/blockly/xml",
+ id: "toolbox",
+ style: "display: none",
+};
var blocklyToolbox = JSON.parse(JSON.stringify(baseToolbox));
-
diff --git a/js/xrp_blockly_toolbox1.js b/js/xrp_blockly_toolbox1.js
index a936531..c779e91 100644
--- a/js/xrp_blockly_toolbox1.js
+++ b/js/xrp_blockly_toolbox1.js
@@ -1,394 +1,443 @@
-
- var blocklyToolbox = {"contents": [
- {
- "kind": "CATEGORY",
- "contents": [
- {
- "kind": "BLOCK",
- "inputs":{
- "dist": {"shadow": {"type": "math_number", "fields": {"NUM": "150"}}},
- },
- "blockxml": "\n \n \n 150\n \n \n \n \n 0.5\n \n \n ",
- "type": "xrp_straight_effort"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n 90\n \n \n \n \n 0.5\n \n \n ",
- "type": "xrp_turn_effort"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n 0\n \n \n \n \n 0\n \n \n ",
- "type": "xrp_seteffort"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_stop_motors"
- }
- ],
- "name": "DriveTrain",
- "colour": "#a5675b", // rust orange
- },
- {
- "kind": "CATEGORY",
- "contents": [
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n 90\n \n \n ",
- "type": "xrp_servo_deg"
- }
- ],
- "name": "Servos",
- "colour": "#a55ba5", // purple/pink
- },
- {
- "kind": "CATEGORY",
- "contents": [
- {
- "kind": "BLOCK",
- "type": "xrp_resetencoders"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_getleftencoder"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_getrightencoder"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_getsonardist"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_l_refl"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_r_refl"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_yaw"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_roll"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_pitch"
- }
- ],
- "name": "Sensors",
- "colour": "#7080a55bDB70", // LIGHT GREEN
- },
- {
- "kind": "CATEGORY",
- "contents": [
- {
- "kind": "BLOCK",
- "type": "xrp_led_on"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_led_off"
- },
- {
- "kind": "BLOCK",
- "type": "xrp_button_pressed"
- }
- ],
- "name": "Control Board",
- "colour": "#5ba580", // GREEN
- },
- {
- "kind": "CATEGORY",
- "contents": [
- {
- "kind": "BLOCK",
- "blockxml": "\n 0\n ",
- "type": "xrp_sleep"
- },
- {
- "kind": "BLOCK",
- "type": "controls_if"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n EQ\n ",
- "type": "logic_compare"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n AND\n ",
- "type": "logic_operation"
- },
- {
- "kind": "BLOCK",
- "type": "logic_negate"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n TRUE\n ",
- "type": "logic_boolean"
- },
- {
- "kind": "BLOCK",
- "type": "logic_null"
- },
- {
- "kind": "BLOCK",
- "type": "logic_ternary"
- }
- ],
- "name": "Logic",
- "colour": "#5b80a5" // slate blue
- },
- {
- "kind": "CATEGORY",
- "contents": [
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n 10\n \n \n ",
- "type": "controls_repeat_ext"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n WHILE\n ",
- "type": "controls_whileUntil"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n i\n \n \n 1\n \n \n \n \n 10\n \n \n \n \n 1\n \n \n ",
- "type": "controls_for"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n j\n ",
- "type": "controls_forEach"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n BREAK\n ",
- "type": "controls_flow_statements"
- }
- ],
- "name": "Loops",
- "colour": "#5ba55b" // grass green
- },
- {
- "kind": "CATEGORY",
- "contents": [
- {
- "kind": "BLOCK",
- "blockxml": "\n 0\n ",
- "type": "math_number"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n ADD\n \n \n 1\n \n \n \n \n 1\n \n \n ",
- "type": "math_arithmetic"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n ROOT\n \n \n 9\n \n \n ",
- "type": "math_single"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n SIN\n \n \n 45\n \n \n ",
- "type": "math_trig"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n PI\n ",
- "type": "math_constant"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n EVEN\n \n \n 0\n \n \n ",
- "type": "math_number_property"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n ROUND\n \n \n 3.1\n \n \n ",
- "type": "math_round"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n SUM\n ",
- "type": "math_on_list"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n 64\n \n \n \n \n 10\n \n \n ",
- "type": "math_modulo"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n 50\n \n \n \n \n 1\n \n \n \n \n 100\n \n \n ",
- "type": "math_constrain"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n 1\n \n \n \n \n 100\n \n \n ",
- "type": "math_random_int"
- },
- {
- "kind": "BLOCK",
- "type": "math_random_float"
- }
- ],
- "name": "Math",
- "colour": "#5b67a5" // indigo blue
- },
- {
- "kind": "CATEGORY",
- "contents": [
- {
- "kind": "BLOCK",
- "blockxml": "\n \n ",
- "type": "text"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n ",
- "type": "text_join"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n item\n \n \n \n \n \n ",
- "type": "text_append"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n abc\n \n \n ",
- "type": "text_length"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n \n \n \n ",
- "type": "text_isEmpty"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n FIRST\n \n \n text\n \n \n \n \n abc\n \n \n ",
- "type": "text_indexOf"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n FROM_START\n \n \n text\n \n \n ",
- "type": "text_charAt"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n FROM_START\n FROM_START\n \n \n text\n \n \n ",
- "type": "text_getSubstring"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n UPPERCASE\n \n \n abc\n \n \n ",
- "type": "text_changeCase"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n BOTH\n \n \n abc\n \n \n ",
- "type": "text_trim"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n abc\n \n \n ",
- "type": "text_print"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n TEXT\n \n \n abc\n \n \n ",
- "type": "text_prompt_ext"
- }
- ],
- "name": "Text",
- "colour": "#5ba58c" // sea foam green
- },
- {
- "kind": "CATEGORY",
- "contents": [
- {
- "kind": "BLOCK",
- "blockxml": "\n \n ",
- "type": "lists_create_with"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n ",
- "type": "lists_create_with"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n \n 5\n \n \n ",
- "type": "lists_repeat"
- },
- {
- "kind": "BLOCK",
- "blockxml": "",
- "type": "lists_length"
- },
- {
- "kind": "BLOCK",
- "type": "lists_isEmpty"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n FIRST\n \n \n list\n \n \n ",
- "type": "lists_indexOf"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n GET\n FROM_START\n \n \n list\n \n \n ",
- "type": "lists_getIndex"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n SET\n FROM_START\n \n \n list\n \n \n ",
- "type": "lists_setIndex"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n FROM_START\n FROM_START\n \n \n list\n \n \n ",
- "type": "lists_getSublist"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n \n SPLIT\n \n \n ,\n \n \n ",
- "type": "lists_split"
- },
- {
- "kind": "BLOCK",
- "blockxml": "\n NUMERIC\n 1\n ",
- "type": "lists_sort"
- }
- ],
- "name": "Lists",
- "colour": "#745ba5" // eggplant purple
- },
- {
- "kind": "CATEGORY",
- "name": "Variables",
- "colour": "#a55b80", // dark pink
- "custom": "VARIABLE"
- },
- {
- "kind": "CATEGORY",
- "name": "Functions",
- "colour": "#995ba5", // purple
- "custom": "PROCEDURE"
- },
- {
- "kind": "SEP"
- }
- ],
- "xmlns": "https://developers.google.com/blockly/xml",
- "id": "toolbox",
- "style": "display: none"
-}
+var blocklyToolbox = {
+ contents: [
+ {
+ kind: "CATEGORY",
+ contents: [
+ {
+ kind: "BLOCK",
+ inputs: {
+ dist: { shadow: { type: "math_number", fields: { NUM: "150" } } },
+ },
+ blockxml:
+ '\n \n \n 150\n \n \n \n \n 0.5\n \n \n ',
+ type: "xrp_straight_effort",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n 90\n \n \n \n \n 0.5\n \n \n ',
+ type: "xrp_turn_effort",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n 0\n \n \n \n \n 0\n \n \n ',
+ type: "xrp_seteffort",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_stop_motors",
+ },
+ ],
+ name: "DriveTrain",
+ colour: "#a5675b", // rust orange
+ },
+ {
+ kind: "CATEGORY",
+ contents: [
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n 90\n \n \n ',
+ type: "xrp_servo_deg",
+ },
+ ],
+ name: "Servos",
+ colour: "#a55ba5", // purple/pink
+ },
+ {
+ kind: "CATEGORY",
+ contents: [
+ {
+ kind: "BLOCK",
+ type: "xrp_resetencoders",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_getleftencoder",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_getrightencoder",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_getsonardist",
+ },
+ {
+ kind: "BLOCK",
+ type: "html_rgb",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_l_refl",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_r_refl",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_yaw",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_roll",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_pitch",
+ },
+ ],
+ name: "Sensors",
+ colour: "#7080a55bDB70", // LIGHT GREEN
+ },
+ {
+ kind: "CATEGORY",
+ contents: [
+ {
+ kind: "BLOCK",
+ type: "xrp_led_on",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_led_off",
+ },
+ {
+ kind: "BLOCK",
+ type: "xrp_button_pressed",
+ },
+ ],
+ name: "Control Board",
+ colour: "#5ba580", // GREEN
+ },
+ {
+ kind: "CATEGORY",
+ contents: [
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n 0\n ',
+ type: "xrp_sleep",
+ },
+ {
+ kind: "BLOCK",
+ type: "controls_if",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n EQ\n ',
+ type: "logic_compare",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n AND\n ',
+ type: "logic_operation",
+ },
+ {
+ kind: "BLOCK",
+ type: "logic_negate",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n TRUE\n ',
+ type: "logic_boolean",
+ },
+ {
+ kind: "BLOCK",
+ type: "logic_null",
+ },
+ {
+ kind: "BLOCK",
+ type: "logic_ternary",
+ },
+ ],
+ name: "Logic",
+ colour: "#5b80a5", // slate blue
+ },
+ {
+ kind: "CATEGORY",
+ contents: [
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n 10\n \n \n ',
+ type: "controls_repeat_ext",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n WHILE\n ',
+ type: "controls_whileUntil",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n i\n \n \n 1\n \n \n \n \n 10\n \n \n \n \n 1\n \n \n ',
+ type: "controls_for",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n j\n ',
+ type: "controls_forEach",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n BREAK\n ',
+ type: "controls_flow_statements",
+ },
+ ],
+ name: "Loops",
+ colour: "#5ba55b", // grass green
+ },
+ {
+ kind: "CATEGORY",
+ contents: [
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n 0\n ',
+ type: "math_number",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n ADD\n \n \n 1\n \n \n \n \n 1\n \n \n ',
+ type: "math_arithmetic",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n ROOT\n \n \n 9\n \n \n ',
+ type: "math_single",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n SIN\n \n \n 45\n \n \n ',
+ type: "math_trig",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n PI\n ',
+ type: "math_constant",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n EVEN\n \n \n 0\n \n \n ',
+ type: "math_number_property",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n ROUND\n \n \n 3.1\n \n \n ',
+ type: "math_round",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n SUM\n ',
+ type: "math_on_list",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n 64\n \n \n \n \n 10\n \n \n ',
+ type: "math_modulo",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n 50\n \n \n \n \n 1\n \n \n \n \n 100\n \n \n ',
+ type: "math_constrain",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n 1\n \n \n \n \n 100\n \n \n ',
+ type: "math_random_int",
+ },
+ {
+ kind: "BLOCK",
+ type: "math_random_float",
+ },
+ ],
+ name: "Math",
+ colour: "#5b67a5", // indigo blue
+ },
+ {
+ kind: "CATEGORY",
+ contents: [
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n ',
+ type: "text",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n ',
+ type: "text_join",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n item\n \n \n \n \n \n ',
+ type: "text_append",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n abc\n \n \n ',
+ type: "text_length",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n \n \n \n ',
+ type: "text_isEmpty",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n FIRST\n \n \n text\n \n \n \n \n abc\n \n \n ',
+ type: "text_indexOf",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n FROM_START\n \n \n text\n \n \n ',
+ type: "text_charAt",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n FROM_START\n FROM_START\n \n \n text\n \n \n ',
+ type: "text_getSubstring",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n UPPERCASE\n \n \n abc\n \n \n ',
+ type: "text_changeCase",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n BOTH\n \n \n abc\n \n \n ',
+ type: "text_trim",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n abc\n \n \n ',
+ type: "text_print",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n TEXT\n \n \n abc\n \n \n ',
+ type: "text_prompt_ext",
+ },
+ ],
+ name: "Text",
+ colour: "#5ba58c", // sea foam green
+ },
+ {
+ kind: "CATEGORY",
+ contents: [
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n ',
+ type: "lists_create_with",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n ',
+ type: "lists_create_with",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n \n 5\n \n \n ',
+ type: "lists_repeat",
+ },
+ {
+ kind: "BLOCK",
+ blockxml: '',
+ type: "lists_length",
+ },
+ {
+ kind: "BLOCK",
+ type: "lists_isEmpty",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n FIRST\n \n \n list\n \n \n ',
+ type: "lists_indexOf",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n GET\n FROM_START\n \n \n list\n \n \n ',
+ type: "lists_getIndex",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n SET\n FROM_START\n \n \n list\n \n \n ',
+ type: "lists_setIndex",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n FROM_START\n FROM_START\n \n \n list\n \n \n ',
+ type: "lists_getSublist",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n \n SPLIT\n \n \n ,\n \n \n ',
+ type: "lists_split",
+ },
+ {
+ kind: "BLOCK",
+ blockxml:
+ '\n NUMERIC\n 1\n ',
+ type: "lists_sort",
+ },
+ ],
+ name: "Lists",
+ colour: "#745ba5", // eggplant purple
+ },
+ {
+ kind: "CATEGORY",
+ name: "Variables",
+ colour: "#a55b80", // dark pink
+ custom: "VARIABLE",
+ },
+ {
+ kind: "CATEGORY",
+ name: "Functions",
+ colour: "#995ba5", // purple
+ custom: "PROCEDURE",
+ },
+ {
+ kind: "SEP",
+ },
+ ],
+ xmlns: "https://developers.google.com/blockly/xml",
+ id: "toolbox",
+ style: "display: none",
+};
diff --git a/js/xrp_blocks.js b/js/xrp_blocks.js
index 20a66ab..f837691 100644
--- a/js/xrp_blocks.js
+++ b/js/xrp_blocks.js
@@ -1,4 +1,3 @@
-
/*
This file creates each Block item for Blockly.
You can set and update the colors here based off the HUE value.
@@ -7,530 +6,564 @@
*/
// Individual Motors
-Blockly.Blocks['xrp_motor_effort'] = {
+Blockly.Blocks["xrp_motor_effort"] = {
init: function () {
this.appendDummyInput()
.appendField("Motor:")
- .appendField(new Blockly.FieldDropdown([["Left", "1"], ["Right", "2"], ["3", "3"], ["4", "4"]]), "MOTOR")
+ .appendField(
+ new Blockly.FieldDropdown([
+ ["Left", "1"],
+ ["Right", "2"],
+ ["3", "3"],
+ ["4", "4"],
+ ]),
+ "MOTOR"
+ )
.appendField("Effort:");
- this.appendValueInput("effort")
- .setCheck("Number");
+ this.appendValueInput("effort").setCheck("Number");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(352); // crimson
this.setTooltip("Set the effort for the selected motor");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_motor_speed'] = {
+Blockly.Blocks["xrp_motor_speed"] = {
init: function () {
this.appendDummyInput()
.appendField("Motor:")
- .appendField(new Blockly.FieldDropdown([["Left", "1"], ["Right", "2"], ["3", "3"], ["4", "4"]]), "MOTOR")
+ .appendField(
+ new Blockly.FieldDropdown([
+ ["Left", "1"],
+ ["Right", "2"],
+ ["3", "3"],
+ ["4", "4"],
+ ]),
+ "MOTOR"
+ )
.appendField("Speed:");
- this.appendValueInput("speed")
- .setCheck("Number");
- this.appendDummyInput()
- .appendField("RPM")
+ this.appendValueInput("speed").setCheck("Number");
+ this.appendDummyInput().appendField("RPM");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(352); // crimson
- this.setTooltip("Set the speed in rotations per minute(RPM) for the selected motor");
+ this.setTooltip(
+ "Set the speed in rotations per minute(RPM) for the selected motor"
+ );
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_motor_direction'] = {
+Blockly.Blocks["xrp_motor_direction"] = {
init: function () {
this.appendDummyInput()
.appendField("Motor:")
- .appendField(new Blockly.FieldDropdown([["Left", "1"], ["Right", "2"], ["3", "3"], ["4", "4"]]), "MOTOR")
+ .appendField(
+ new Blockly.FieldDropdown([
+ ["Left", "1"],
+ ["Right", "2"],
+ ["3", "3"],
+ ["4", "4"],
+ ]),
+ "MOTOR"
+ )
.appendField("Direction:")
- .appendField(new Blockly.FieldDropdown([["Reverse", "True"], ["Forward", "False"]]), "DIRECTION");
+ .appendField(
+ new Blockly.FieldDropdown([
+ ["Reverse", "True"],
+ ["Forward", "False"],
+ ]),
+ "DIRECTION"
+ );
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(352); // crimson
this.setTooltip("Set the default direction of the selected motor");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_motor_get_speed'] = {
+Blockly.Blocks["xrp_motor_get_speed"] = {
init: function () {
this.appendDummyInput()
.appendField("Motor:")
- .appendField(new Blockly.FieldDropdown([["Left", "1"], ["Right", "2"], ["3", "3"], ["4", "4"]]), "MOTOR")
+ .appendField(
+ new Blockly.FieldDropdown([
+ ["Left", "1"],
+ ["Right", "2"],
+ ["3", "3"],
+ ["4", "4"],
+ ]),
+ "MOTOR"
+ )
.appendField("Speed");
this.setOutput(true, null);
this.setColour(352); // crimson
this.setTooltip("Get the speed of the selected motor");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_motor_get_position'] = {
+Blockly.Blocks["xrp_motor_get_position"] = {
init: function () {
this.appendDummyInput()
.appendField("Motor:")
- .appendField(new Blockly.FieldDropdown([["Left", "1"], ["Right", "2"], ["3", "3"], ["4", "4"]]), "MOTOR")
+ .appendField(
+ new Blockly.FieldDropdown([
+ ["Left", "1"],
+ ["Right", "2"],
+ ["3", "3"],
+ ["4", "4"],
+ ]),
+ "MOTOR"
+ )
.appendField("Position");
this.setOutput(true, null);
this.setColour(352); // crimson
- this.setTooltip("Get the position (number of revolutions) of the selected motor since the last reset");
+ this.setTooltip(
+ "Get the position (number of revolutions) of the selected motor since the last reset"
+ );
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_motor_get_count'] = {
+Blockly.Blocks["xrp_motor_get_count"] = {
init: function () {
this.appendDummyInput()
.appendField("Motor:")
- .appendField(new Blockly.FieldDropdown([["Left", "1"], ["Right", "2"], ["3", "3"], ["4", "4"]]), "MOTOR")
+ .appendField(
+ new Blockly.FieldDropdown([
+ ["Left", "1"],
+ ["Right", "2"],
+ ["3", "3"],
+ ["4", "4"],
+ ]),
+ "MOTOR"
+ )
.appendField("Encoder count");
this.setOutput(true, null);
this.setColour(352); // crimson
- this.setTooltip("Get the number of encoder count of the selected motor since the last reset");
+ this.setTooltip(
+ "Get the number of encoder count of the selected motor since the last reset"
+ );
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_motor_reset_position'] = {
+Blockly.Blocks["xrp_motor_reset_position"] = {
init: function () {
this.appendDummyInput()
.appendField("Motor:")
- .appendField(new Blockly.FieldDropdown([["Left", "1"], ["Right", "2"], ["3", "3"], ["4", "4"]]), "MOTOR")
- .appendField("Reset encoder")
+ .appendField(
+ new Blockly.FieldDropdown([
+ ["Left", "1"],
+ ["Right", "2"],
+ ["3", "3"],
+ ["4", "4"],
+ ]),
+ "MOTOR"
+ )
+ .appendField("Reset encoder");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(352); // crimson
this.setTooltip("Reset the position and count for the selected motor");
this.setHelpUrl("");
- }
+ },
};
// DriveTrain
-Blockly.Blocks['xrp_straight_effort'] = {
+Blockly.Blocks["xrp_straight_effort"] = {
init: function () {
this.appendValueInput("dist")
.setCheck("Number")
.appendField("Straight")
.appendField("cm:");
- this.appendValueInput("effort")
- .setCheck("Number")
- .appendField("Effort:");
+ this.appendValueInput("effort").setCheck("Number").appendField("Effort:");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(10); // orange
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_turn_effort'] = {
+Blockly.Blocks["xrp_turn_effort"] = {
init: function () {
this.appendValueInput("degrees")
.setCheck("Number")
.appendField("Turn Deg:");
- this.appendValueInput("effort")
- .setCheck("Number")
- .appendField("Effort:");
+ this.appendValueInput("effort").setCheck("Number").appendField("Effort:");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(10); // orange
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_seteffort'] = {
+Blockly.Blocks["xrp_seteffort"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Set effort");
- this.appendValueInput("LEFT")
- .setCheck("Number")
- .appendField("Left:");
- this.appendValueInput("RIGHT")
- .setCheck("Number")
- .appendField("Right:");
+ this.appendDummyInput().appendField("Set effort");
+ this.appendValueInput("LEFT").setCheck("Number").appendField("Left:");
+ this.appendValueInput("RIGHT").setCheck("Number").appendField("Right:");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(10); // orange
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_speed'] = {
+Blockly.Blocks["xrp_speed"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Set speed");
- this.appendValueInput("LEFT")
- .setCheck(null)
- .appendField("Left:");
+ this.appendDummyInput().appendField("Set speed");
+ this.appendValueInput("LEFT").setCheck(null).appendField("Left:");
this.appendValueInput("RIGHT")
.setCheck(null)
.appendField("cm/s")
.appendField("Right:");
- this.appendDummyInput()
- .appendField("cm/s");
+ this.appendDummyInput().appendField("cm/s");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(10); // orange
this.setTooltip("Set the speed in RPM for the motors");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_arcade'] = {
+Blockly.Blocks["xrp_arcade"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Arcade");
+ this.appendDummyInput().appendField("Arcade");
this.appendValueInput("STRAIGHT")
.setCheck("Number")
.appendField("Straight:");
- this.appendValueInput("TURN")
- .setCheck("Number")
- .appendField("Turn:");
+ this.appendValueInput("TURN").setCheck("Number").appendField("Turn:");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(10); // orange
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_stop_motors'] = {
+Blockly.Blocks["xrp_stop_motors"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Stop motors");
+ this.appendDummyInput().appendField("Stop motors");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(10); // orange
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_resetencoders'] = {
+Blockly.Blocks["xrp_resetencoders"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Reset encoders");
+ this.appendDummyInput().appendField("Reset encoders");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(10); // orange
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_getleftencoder'] = {
+Blockly.Blocks["xrp_getleftencoder"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Left encoder");
+ this.appendDummyInput().appendField("Left encoder");
this.setOutput(true, null);
this.setColour(10); // orange
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_getrightencoder'] = {
+Blockly.Blocks["xrp_getrightencoder"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Right encoder");
+ this.appendDummyInput().appendField("Right encoder");
this.setOutput(true, null);
this.setColour(10); // orange
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
// Servo
-servoNames = [["1", "1"], ["2", "2"]];
-Blockly.Blocks['xrp_servo_deg'] = {
+servoNames = [
+ ["1", "1"],
+ ["2", "2"],
+];
+Blockly.Blocks["xrp_servo_deg"] = {
init: function () {
this.appendDummyInput()
- .appendField('Servo:')
+ .appendField("Servo:")
.appendField(new Blockly.FieldDropdown(servoNames), "SERVO")
- .appendField('Deg:');
- this.appendValueInput("degrees")
- .setCheck("Number")
+ .appendField("Deg:");
+ this.appendValueInput("degrees").setCheck("Number");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(300); // light purple
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
+};
+
+// Sensors - HTML RGB
+Blockly.Blocks["html_rgb"] = {
+ init: function () {
+ this.appendDummyInput().appendField("HTML RGB");
+ this.setOutput(true, null);
+ this.setColour(90); // soft green
+ this.setTooltip("");
+ this.setHelpUrl("");
+ },
};
// Sensors - Sonar
-Blockly.Blocks['xrp_getsonardist'] = {
+Blockly.Blocks["xrp_getsonardist"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Sonar distance");
+ this.appendDummyInput().appendField("Sonar distance");
this.setOutput(true, null);
this.setColour(90); // soft green
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
//Sensors - Reflectance
-Blockly.Blocks['xrp_l_refl'] = {
+Blockly.Blocks["xrp_l_refl"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Left reflectance");
+ this.appendDummyInput().appendField("Left reflectance");
this.setOutput(true, null);
this.setColour(90); // soft green
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_r_refl'] = {
+Blockly.Blocks["xrp_r_refl"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Right reflectance");
+ this.appendDummyInput().appendField("Right reflectance");
this.setOutput(true, null);
this.setColour(90); // soft green
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
//Sensors - Gyro
-Blockly.Blocks['xrp_yaw'] = {
+Blockly.Blocks["xrp_yaw"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Yaw");
+ this.appendDummyInput().appendField("Yaw");
this.setOutput(true, null);
this.setColour(90); // soft green
this.setTooltip("");
- this.setHelpUrl("The amount the robot has turned left or right from center");
- }
+ this.setHelpUrl(
+ "The amount the robot has turned left or right from center"
+ );
+ },
};
-Blockly.Blocks['xrp_roll'] = {
+Blockly.Blocks["xrp_roll"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Roll");
+ this.appendDummyInput().appendField("Roll");
this.setOutput(true, null);
this.setColour(90); // soft green
this.setTooltip("The amount of tipping to the left or right");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_pitch'] = {
+Blockly.Blocks["xrp_pitch"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Pitch");
+ this.appendDummyInput().appendField("Pitch");
this.setOutput(true, null);
this.setColour(90); // soft green
this.setTooltip("");
this.setHelpUrl("The amount the front of the robot is tilting up or down");
- }
+ },
};
//Sensors - Accelerometer
-Blockly.Blocks['xrp_acc_x'] = {
+Blockly.Blocks["xrp_acc_x"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Acc_x");
+ this.appendDummyInput().appendField("Acc_x");
this.setOutput(true, null);
this.setColour(90); // soft green
this.setTooltip("");
this.setHelpUrl("The acceleration in the X direction");
- }
+ },
};
-Blockly.Blocks['xrp_acc_y'] = {
+Blockly.Blocks["xrp_acc_y"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Acc_y");
+ this.appendDummyInput().appendField("Acc_y");
this.setOutput(true, null);
this.setColour(90); // soft green
this.setTooltip("");
this.setHelpUrl("The acceleration in the Y direction");
- }
+ },
};
-Blockly.Blocks['xrp_acc_z'] = {
+Blockly.Blocks["xrp_acc_z"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Acc_z");
+ this.appendDummyInput().appendField("Acc_z");
this.setOutput(true, null);
this.setColour(90); // soft green
this.setTooltip("");
this.setHelpUrl("The acceleration in the Z direction");
- }
+ },
};
//Control Board
-Blockly.Blocks['xrp_led_on'] = {
+Blockly.Blocks["xrp_led_on"] = {
init: function () {
- this.appendDummyInput()
- .appendField("LED on");
+ this.appendDummyInput().appendField("LED on");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(150); // darker teal
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_led_off'] = {
+Blockly.Blocks["xrp_led_off"] = {
init: function () {
- this.appendDummyInput()
- .appendField("LED off");
+ this.appendDummyInput().appendField("LED off");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(150); // darker teal
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
// "User Button"
-Blockly.Blocks['xrp_button_pressed'] = {
+Blockly.Blocks["xrp_button_pressed"] = {
init: function () {
- this.appendDummyInput()
- .appendField("User button");
+ this.appendDummyInput().appendField("User button");
this.setOutput(true, null);
this.setColour(150); // darker teal
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
// "Wait for Button Press"
-Blockly.Blocks['xrp_wait_for_button_press'] = {
+Blockly.Blocks["xrp_wait_for_button_press"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Wait for button press");
+ this.appendDummyInput().appendField("Wait for button press");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(150); // darker teal
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
//Web Server
-Blockly.Blocks['xrp_ws_forward_button'] = {
+Blockly.Blocks["xrp_ws_forward_button"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Web forward button")
- this.appendStatementInput('func')
- .appendField('Function:');
+ this.appendDummyInput().appendField("Web forward button");
+ this.appendStatementInput("func").appendField("Function:");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(190); // turquoise
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_ws_back_button'] = {
+Blockly.Blocks["xrp_ws_back_button"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Web back button")
- this.appendStatementInput('func')
- .appendField('Function:');
+ this.appendDummyInput().appendField("Web back button");
+ this.appendStatementInput("func").appendField("Function:");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(190); // turquoise
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_ws_left_button'] = {
+Blockly.Blocks["xrp_ws_left_button"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Web left button")
- this.appendStatementInput('func')
- .appendField('Function:'); this.setPreviousStatement(true, null);
+ this.appendDummyInput().appendField("Web left button");
+ this.appendStatementInput("func").appendField("Function:");
+ this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(190); // turquoise
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_ws_right_button'] = {
+Blockly.Blocks["xrp_ws_right_button"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Web right button")
- this.appendStatementInput('func')
- .appendField('Function:'); this.setPreviousStatement(true, null);
+ this.appendDummyInput().appendField("Web right button");
+ this.appendStatementInput("func").appendField("Function:");
+ this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(190); // turquoise
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_ws_stop_button'] = {
+Blockly.Blocks["xrp_ws_stop_button"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Web stop button")
- this.appendStatementInput('func')
- .appendField('Function:'); this.setPreviousStatement(true, null);
+ this.appendDummyInput().appendField("Web stop button");
+ this.appendStatementInput("func").appendField("Function:");
+ this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(190); // turquoise
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_ws_add_button'] = {
+Blockly.Blocks["xrp_ws_add_button"] = {
init: function () {
this.appendDummyInput()
.appendField("Web add button Name:")
- .appendField(new Blockly.FieldTextInput("name"), "TEXT")
- this.appendStatementInput('func')
- .appendField('Function:');
+ .appendField(new Blockly.FieldTextInput("name"), "TEXT");
+ this.appendStatementInput("func").appendField("Function:");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(190); // turquoise
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_ws_log_data'] = {
+Blockly.Blocks["xrp_ws_log_data"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Web log data");
- this.appendValueInput("log_name")
- .appendField("Label:")
- .setCheck("String");
- this.appendValueInput("DATA")
- .appendField("Data:");
+ this.appendDummyInput().appendField("Web log data");
+ this.appendValueInput("log_name").appendField("Label:").setCheck("String");
+ this.appendValueInput("DATA").appendField("Data:");
this.setInputsInline(false);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(190); // turquoise
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_ws_start_server'] = {
+Blockly.Blocks["xrp_ws_start_server"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Start web server");
+ this.appendDummyInput().appendField("Start web server");
this.appendValueInput("server_ssid")
.appendField("Name:")
.setCheck("String");
@@ -543,13 +576,12 @@ Blockly.Blocks['xrp_ws_start_server'] = {
this.setColour(190); // turquoise
this.setTooltip("Starts a web server from the XRP");
this.setHelpUrl("");
- }
+ },
};
-Blockly.Blocks['xrp_ws_connect_server'] = {
+Blockly.Blocks["xrp_ws_connect_server"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Connect web server");
+ this.appendDummyInput().appendField("Connect web server");
this.appendValueInput("server_ssid")
.appendField("Name:")
.setCheck("String");
@@ -562,23 +594,21 @@ Blockly.Blocks['xrp_ws_connect_server'] = {
this.setColour(190); // turquoise
this.setTooltip("Connects the XRP web server to an existing network");
this.setHelpUrl("");
- }
+ },
};
// Logic
-Blockly.Blocks['xrp_sleep'] = {
+Blockly.Blocks["xrp_sleep"] = {
init: function () {
- this.appendDummyInput()
- .appendField("Sleep:")
- this.appendValueInput("TIME")
- .setCheck("Number");
+ this.appendDummyInput().appendField("Sleep:");
+ this.appendValueInput("TIME").setCheck("Number");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(200); // slate blue
this.setTooltip("");
this.setHelpUrl("");
- }
+ },
};
// OTHER BLOCK COLORS - These colors can be found in the xrp_blockly_toolbox1.js file
diff --git a/js/xrp_blocks_python.js b/js/xrp_blocks_python.js
index bf23956..7cf6edf 100644
--- a/js/xrp_blocks_python.js
+++ b/js/xrp_blocks_python.js
@@ -1,353 +1,514 @@
const PY = Blockly.Python;
//Individual Motors
-Blockly.Python['xrp_motor_effort'] = function (block) {
- PY.definitions_['import_motor'] = 'from XRPLib.encoded_motor import EncodedMotor';
+Blockly.Python["xrp_motor_effort"] = function (block) {
+ PY.definitions_["import_motor"] =
+ "from XRPLib.encoded_motor import EncodedMotor";
var index = block.getFieldValue("MOTOR");
- PY.definitions_[`motor${index}_setup`] = `motor${index} = EncodedMotor.get_default_encoded_motor(${index})`;
- var value_effort = Blockly.Python.valueToCode(block, 'effort', Blockly.Python.ORDER_ATOMIC);
+ PY.definitions_[
+ `motor${index}_setup`
+ ] = `motor${index} = EncodedMotor.get_default_encoded_motor(${index})`;
+ var value_effort = Blockly.Python.valueToCode(
+ block,
+ "effort",
+ Blockly.Python.ORDER_ATOMIC
+ );
var code = `motor${index}.set_effort(${value_effort})\n`;
return code;
};
-Blockly.Python['xrp_motor_speed'] = function (block) {
- PY.definitions_['import_motor'] = 'from XRPLib.encoded_motor import EncodedMotor';
+Blockly.Python["xrp_motor_speed"] = function (block) {
+ PY.definitions_["import_motor"] =
+ "from XRPLib.encoded_motor import EncodedMotor";
var index = block.getFieldValue("MOTOR");
- PY.definitions_[`motor${index}_setup`] = `motor${index} = EncodedMotor.get_default_encoded_motor(${index})`;
- var value_speed = Blockly.Python.valueToCode(block, 'speed', Blockly.Python.ORDER_ATOMIC);
- if(value_speed == 0) value_speed = "";
+ PY.definitions_[
+ `motor${index}_setup`
+ ] = `motor${index} = EncodedMotor.get_default_encoded_motor(${index})`;
+ var value_speed = Blockly.Python.valueToCode(
+ block,
+ "speed",
+ Blockly.Python.ORDER_ATOMIC
+ );
+ if (value_speed == 0) value_speed = "";
var code = `motor${index}.set_speed(${value_speed})\n`;
return code;
};
-Blockly.Python['xrp_motor_get_speed'] = function (block) {
- PY.definitions_['import_motor'] = 'from XRPLib.encoded_motor import EncodedMotor';
+Blockly.Python["xrp_motor_get_speed"] = function (block) {
+ PY.definitions_["import_motor"] =
+ "from XRPLib.encoded_motor import EncodedMotor";
var index = block.getFieldValue("MOTOR");
- PY.definitions_[`motor${index}_setup`] = `motor${index} = EncodedMotor.get_default_encoded_motor(${index})`;
+ PY.definitions_[
+ `motor${index}_setup`
+ ] = `motor${index} = EncodedMotor.get_default_encoded_motor(${index})`;
var code = `motor${index}.get_speed()`;
return [code, Blockly.Python.ORDER_NONE];
};
-Blockly.Python['xrp_motor_direction'] = function (block) {
- PY.definitions_['import_motor'] = 'from XRPLib.encoded_motor import EncodedMotor';
+Blockly.Python["xrp_motor_direction"] = function (block) {
+ PY.definitions_["import_motor"] =
+ "from XRPLib.encoded_motor import EncodedMotor";
var index = block.getFieldValue("MOTOR");
- PY.definitions_[`motor${index}_setup`] = `motor${index} = EncodedMotor.get_default_encoded_motor(${index})`;
+ PY.definitions_[
+ `motor${index}_setup`
+ ] = `motor${index} = EncodedMotor.get_default_encoded_motor(${index})`;
var value_direction = block.getFieldValue("DIRECTION");
var code = `motor${index}._motor.flip_dir = (${value_direction})\n`;
return code;
};
-Blockly.Python['xrp_motor_get_position'] = function (block) {
- PY.definitions_['import_motor'] = 'from XRPLib.encoded_motor import EncodedMotor';
+Blockly.Python["xrp_motor_get_position"] = function (block) {
+ PY.definitions_["import_motor"] =
+ "from XRPLib.encoded_motor import EncodedMotor";
var index = block.getFieldValue("MOTOR");
- PY.definitions_[`motor${index}_setup`] = `motor${index} = EncodedMotor.get_default_encoded_motor(${index})`;
+ PY.definitions_[
+ `motor${index}_setup`
+ ] = `motor${index} = EncodedMotor.get_default_encoded_motor(${index})`;
var code = `motor${index}.get_position()`;
return [code, Blockly.Python.ORDER_NONE];
};
-Blockly.Python['xrp_motor_get_count'] = function (block) {
- PY.definitions_['import_motor'] = 'from XRPLib.encoded_motor import EncodedMotor';
+Blockly.Python["xrp_motor_get_count"] = function (block) {
+ PY.definitions_["import_motor"] =
+ "from XRPLib.encoded_motor import EncodedMotor";
var index = block.getFieldValue("MOTOR");
- PY.definitions_[`motor${index}_setup`] = `motor${index} = EncodedMotor.get_default_encoded_motor(${index})`;
+ PY.definitions_[
+ `motor${index}_setup`
+ ] = `motor${index} = EncodedMotor.get_default_encoded_motor(${index})`;
var code = `motor${index}.get_position_counts()`;
return [code, Blockly.Python.ORDER_NONE];
};
-Blockly.Python['xrp_motor_reset_position'] = function (block) {
- PY.definitions_['import_motor'] = 'from XRPLib.encoded_motor import EncodedMotor';
+Blockly.Python["xrp_motor_reset_position"] = function (block) {
+ PY.definitions_["import_motor"] =
+ "from XRPLib.encoded_motor import EncodedMotor";
var index = block.getFieldValue("MOTOR");
- PY.definitions_[`motor${index}_setup`] = `motor${index} = EncodedMotor.get_default_encoded_motor(${index})`;
+ PY.definitions_[
+ `motor${index}_setup`
+ ] = `motor${index} = EncodedMotor.get_default_encoded_motor(${index})`;
var code = `motor${index}.reset_encoder_position()\n`;
return code;
};
//DriveTrain
-Blockly.Python['xrp_straight_effort'] = function (block) {
- PY.definitions_['import_drivetrain'] = 'from XRPLib.differential_drive import DifferentialDrive';
- PY.definitions_[`drietrain_setup`] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
- var value_dist = Blockly.Python.valueToCode(block, 'dist', Blockly.Python.ORDER_ATOMIC);
- var value_effort = Blockly.Python.valueToCode(block, 'effort', Blockly.Python.ORDER_ATOMIC);
+Blockly.Python["xrp_straight_effort"] = function (block) {
+ PY.definitions_["import_drivetrain"] =
+ "from XRPLib.differential_drive import DifferentialDrive";
+ PY.definitions_[
+ `drietrain_setup`
+ ] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
+ var value_dist = Blockly.Python.valueToCode(
+ block,
+ "dist",
+ Blockly.Python.ORDER_ATOMIC
+ );
+ var value_effort = Blockly.Python.valueToCode(
+ block,
+ "effort",
+ Blockly.Python.ORDER_ATOMIC
+ );
var code = `differentialDrive.straight(${value_dist}, ${value_effort})\n`;
return code;
};
-Blockly.Python['xrp_turn_effort'] = function (block) {
- PY.definitions_['import_drivetrain'] = 'from XRPLib.differential_drive import DifferentialDrive';
- PY.definitions_[`drietrain_setup`] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
- var value_angle = Blockly.Python.valueToCode(block, 'degrees', Blockly.Python.ORDER_ATOMIC);
- var value_effort = Blockly.Python.valueToCode(block, 'effort', Blockly.Python.ORDER_ATOMIC);
+Blockly.Python["xrp_turn_effort"] = function (block) {
+ PY.definitions_["import_drivetrain"] =
+ "from XRPLib.differential_drive import DifferentialDrive";
+ PY.definitions_[
+ `drietrain_setup`
+ ] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
+ var value_angle = Blockly.Python.valueToCode(
+ block,
+ "degrees",
+ Blockly.Python.ORDER_ATOMIC
+ );
+ var value_effort = Blockly.Python.valueToCode(
+ block,
+ "effort",
+ Blockly.Python.ORDER_ATOMIC
+ );
var code = `differentialDrive.turn(${value_angle}, ${value_effort})\n`;
return code;
};
-Blockly.Python['xrp_seteffort'] = function (block) {
- PY.definitions_['import_drivetrain'] = 'from XRPLib.differential_drive import DifferentialDrive';
- PY.definitions_[`drietrain_setup`] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
- var value_l = Blockly.Python.valueToCode(block, 'LEFT', Blockly.Python.ORDER_ATOMIC);
- var value_r = Blockly.Python.valueToCode(block, 'RIGHT', Blockly.Python.ORDER_ATOMIC);
+Blockly.Python["xrp_seteffort"] = function (block) {
+ PY.definitions_["import_drivetrain"] =
+ "from XRPLib.differential_drive import DifferentialDrive";
+ PY.definitions_[
+ `drietrain_setup`
+ ] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
+ var value_l = Blockly.Python.valueToCode(
+ block,
+ "LEFT",
+ Blockly.Python.ORDER_ATOMIC
+ );
+ var value_r = Blockly.Python.valueToCode(
+ block,
+ "RIGHT",
+ Blockly.Python.ORDER_ATOMIC
+ );
var code = `differentialDrive.set_effort(${value_l}, ${value_r})\n`;
return code;
};
-Blockly.Python['xrp_speed'] = function (block) {
- PY.definitions_['import_drivetrain'] = 'from XRPLib.differential_drive import DifferentialDrive';
- PY.definitions_[`drietrain_setup`] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
- var value_l = Blockly.Python.valueToCode(block, 'LEFT', Blockly.Python.ORDER_ATOMIC);
- var value_r = Blockly.Python.valueToCode(block, 'RIGHT', Blockly.Python.ORDER_ATOMIC)
+Blockly.Python["xrp_speed"] = function (block) {
+ PY.definitions_["import_drivetrain"] =
+ "from XRPLib.differential_drive import DifferentialDrive";
+ PY.definitions_[
+ `drietrain_setup`
+ ] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
+ var value_l = Blockly.Python.valueToCode(
+ block,
+ "LEFT",
+ Blockly.Python.ORDER_ATOMIC
+ );
+ var value_r = Blockly.Python.valueToCode(
+ block,
+ "RIGHT",
+ Blockly.Python.ORDER_ATOMIC
+ );
var code = `differentialDrive.set_speed(${value_l}, ${value_r})\n`;
return code;
};
-Blockly.Python['xrp_arcade'] = function (block) {
- PY.definitions_['import_drivetrain'] = 'from XRPLib.differential_drive import DifferentialDrive';
- PY.definitions_[`drietrain_setup`] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
- var value_s = Blockly.Python.valueToCode(block, 'STRAIGHT', Blockly.Python.ORDER_ATOMIC);
- var value_t = Blockly.Python.valueToCode(block, 'TURN', Blockly.Python.ORDER_ATOMIC);
+Blockly.Python["xrp_arcade"] = function (block) {
+ PY.definitions_["import_drivetrain"] =
+ "from XRPLib.differential_drive import DifferentialDrive";
+ PY.definitions_[
+ `drietrain_setup`
+ ] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
+ var value_s = Blockly.Python.valueToCode(
+ block,
+ "STRAIGHT",
+ Blockly.Python.ORDER_ATOMIC
+ );
+ var value_t = Blockly.Python.valueToCode(
+ block,
+ "TURN",
+ Blockly.Python.ORDER_ATOMIC
+ );
var code = `differentialDrive.arcade(${value_s}, ${value_t})\n`;
return code;
};
-Blockly.Python['xrp_stop_motors'] = function (block) {
- PY.definitions_['import_drivetrain'] = 'from XRPLib.differential_drive import DifferentialDrive';
- PY.definitions_[`drietrain_setup`] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
+Blockly.Python["xrp_stop_motors"] = function (block) {
+ PY.definitions_["import_drivetrain"] =
+ "from XRPLib.differential_drive import DifferentialDrive";
+ PY.definitions_[
+ `drietrain_setup`
+ ] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
var code = `differentialDrive.stop()\n`;
return code;
};
-Blockly.Python['xrp_resetencoders'] = function (block) {
- PY.definitions_['import_drivetrain'] = 'from XRPLib.differential_drive import DifferentialDrive';
- PY.definitions_[`drietrain_setup`] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
- var value_degrees = Blockly.Python.valueToCode(block, 'degrees', Blockly.Python.ORDER_ATOMIC);
+Blockly.Python["xrp_resetencoders"] = function (block) {
+ PY.definitions_["import_drivetrain"] =
+ "from XRPLib.differential_drive import DifferentialDrive";
+ PY.definitions_[
+ `drietrain_setup`
+ ] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
+ var value_degrees = Blockly.Python.valueToCode(
+ block,
+ "degrees",
+ Blockly.Python.ORDER_ATOMIC
+ );
var code = `differentialDrive.reset_encoder_position()\n`;
return code;
};
-Blockly.Python['xrp_getleftencoder'] = function (block) {
- PY.definitions_['import_drivetrain'] = 'from XRPLib.differential_drive import DifferentialDrive';
- PY.definitions_[`drietrain_setup`] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
+Blockly.Python["xrp_getleftencoder"] = function (block) {
+ PY.definitions_["import_drivetrain"] =
+ "from XRPLib.differential_drive import DifferentialDrive";
+ PY.definitions_[
+ `drietrain_setup`
+ ] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
var code = `differentialDrive.get_left_encoder_position()`;
return [code, Blockly.Python.ORDER_NONE];
};
-Blockly.Python['xrp_getrightencoder'] = function (block) {
- PY.definitions_['import_drivetrain'] = 'from XRPLib.differential_drive import DifferentialDrive';
- PY.definitions_[`drietrain_setup`] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
+Blockly.Python["xrp_getrightencoder"] = function (block) {
+ PY.definitions_["import_drivetrain"] =
+ "from XRPLib.differential_drive import DifferentialDrive";
+ PY.definitions_[
+ `drietrain_setup`
+ ] = `differentialDrive = DifferentialDrive.get_default_differential_drive()`;
var code = `differentialDrive.get_right_encoder_position()`;
return [code, Blockly.Python.ORDER_NONE];
};
//Servo
-Blockly.Python['xrp_servo_deg'] = function (block) {
- PY.definitions_['import_servo'] = 'from XRPLib.servo import Servo';
+Blockly.Python["xrp_servo_deg"] = function (block) {
+ PY.definitions_["import_servo"] = "from XRPLib.servo import Servo";
var index = block.getFieldValue("SERVO");
- PY.definitions_[`servo` + index + `_setup`] = `servo` + index + ` = Servo.get_default_servo(` + index +`)`;
- var value_degrees = Blockly.Python.valueToCode(block, 'degrees', Blockly.Python.ORDER_ATOMIC);
+ PY.definitions_[`servo` + index + `_setup`] =
+ `servo` + index + ` = Servo.get_default_servo(` + index + `)`;
+ var value_degrees = Blockly.Python.valueToCode(
+ block,
+ "degrees",
+ Blockly.Python.ORDER_ATOMIC
+ );
var code = `servo${index}.set_angle(${value_degrees})\n`;
return code;
};
//Distance
-Blockly.Python['xrp_getsonardist'] = function (block) {
- PY.definitions_['import_rangefinder'] = 'from XRPLib.rangefinder import Rangefinder';
- PY.definitions_[`rangefinder_setup`] = `rangefinder = Rangefinder.get_default_rangefinder()`;
+Blockly.Python["xrp_getsonardist"] = function (block) {
+ PY.definitions_["import_rangefinder"] =
+ "from XRPLib.rangefinder import Rangefinder";
+ PY.definitions_[
+ `rangefinder_setup`
+ ] = `rangefinder = Rangefinder.get_default_rangefinder()`;
var code = `rangefinder.distance()`;
return [code, Blockly.Python.ORDER_NONE];
};
+//HTMLRGB
+Blockly.Python["html_rgb"] = function (block) {
+ PY.definitions_["import_imu"] = "from XRPLib.imu import IMU";
+ // PY.definitions_[`rangefinder_setup`] = `rangefinder = Rangefinder.get_default_rangefinder()`;
+ // var code = `rangefinder.distance()`;
+ return [code, Blockly.Python.ORDER_NONE];
+};
+
//reflectance
-Blockly.Python['xrp_l_refl'] = function (block) {
- PY.definitions_['import_reflectance'] = 'from XRPLib.reflectance import Reflectance';
- PY.definitions_[`reflectance_setup`] = `reflectance = Reflectance.get_default_reflectance()`;
+Blockly.Python["xrp_l_refl"] = function (block) {
+ PY.definitions_["import_reflectance"] =
+ "from XRPLib.reflectance import Reflectance";
+ PY.definitions_[
+ `reflectance_setup`
+ ] = `reflectance = Reflectance.get_default_reflectance()`;
var code = `reflectance.get_left()`;
return [code, Blockly.Python.ORDER_NONE];
};
-Blockly.Python['xrp_r_refl'] = function (block) {
- PY.definitions_['import_reflectance'] = 'from XRPLib.reflectance import Reflectance';
- PY.definitions_[`reflectance_setup`] = `reflectance = Reflectance.get_default_reflectance()`;
+Blockly.Python["xrp_r_refl"] = function (block) {
+ PY.definitions_["import_reflectance"] =
+ "from XRPLib.reflectance import Reflectance";
+ PY.definitions_[
+ `reflectance_setup`
+ ] = `reflectance = Reflectance.get_default_reflectance()`;
var code = `reflectance.get_right()`;
return [code, Blockly.Python.ORDER_NONE];
};
//Gyro
-Blockly.Python['xrp_yaw'] = function (block) {
- PY.definitions_['import_imu'] = 'from XRPLib.imu import IMU';
- PY.definitions_[`imu_setup`] = `imu = IMU.get_default_imu()\nimu.calibrate(1)`;
- PY.definitions_['yaw_setup'] = 'imu.reset_yaw()'
+Blockly.Python["xrp_yaw"] = function (block) {
+ PY.definitions_["import_imu"] = "from XRPLib.imu import IMU";
+ PY.definitions_[
+ `imu_setup`
+ ] = `imu = IMU.get_default_imu()\nimu.calibrate(1)`;
+ PY.definitions_["yaw_setup"] = "imu.reset_yaw()";
var code = `imu.get_yaw()`;
return [code, Blockly.Python.ORDER_NONE];
};
-Blockly.Python['xrp_roll'] = function (block) {
- PY.definitions_['import_imu'] = 'from XRPLib.imu import IMU';
- PY.definitions_[`imu_setup`] = `imu = IMU.get_default_imu()\nimu.calibrate(1)`;
- PY.definitions_['roll_setup'] = 'imu.reset_roll()'
+Blockly.Python["xrp_roll"] = function (block) {
+ PY.definitions_["import_imu"] = "from XRPLib.imu import IMU";
+ PY.definitions_[
+ `imu_setup`
+ ] = `imu = IMU.get_default_imu()\nimu.calibrate(1)`;
+ PY.definitions_["roll_setup"] = "imu.reset_roll()";
var code = `imu.get_roll()`;
return [code, Blockly.Python.ORDER_NONE];
};
-Blockly.Python['xrp_pitch'] = function (block) {
- PY.definitions_['import_imu'] = 'from XRPLib.imu import IMU';
- PY.definitions_[`imu_setup`] = `imu = IMU.get_default_imu()\nimu.calibrate(1)`;
- PY.definitions_['pitch_setup'] = 'imu.reset_pitch()'
+Blockly.Python["xrp_pitch"] = function (block) {
+ PY.definitions_["import_imu"] = "from XRPLib.imu import IMU";
+ PY.definitions_[
+ `imu_setup`
+ ] = `imu = IMU.get_default_imu()\nimu.calibrate(1)`;
+ PY.definitions_["pitch_setup"] = "imu.reset_pitch()";
var code = `imu.get_pitch()`;
return [code, Blockly.Python.ORDER_NONE];
};
//Accelerometer
-Blockly.Python['xrp_acc_x'] = function (block) {
- PY.definitions_['import_imu'] = 'from XRPLib.imu import IMU';
- PY.definitions_[`imu_setup`] = `imu = IMU.get_default_imu()\nimu.calibrate(1)`;
+Blockly.Python["xrp_acc_x"] = function (block) {
+ PY.definitions_["import_imu"] = "from XRPLib.imu import IMU";
+ PY.definitions_[
+ `imu_setup`
+ ] = `imu = IMU.get_default_imu()\nimu.calibrate(1)`;
var code = `imu.get_acc_x()`;
return [code, Blockly.Python.ORDER_NONE];
};
-Blockly.Python['xrp_acc_y'] = function (block) {
- PY.definitions_['import_imu'] = 'from XRPLib.imu import IMU';
- PY.definitions_[`imu_setup`] = `imu = IMU.get_default_imu()\nimu.calibrate(1)`;
+Blockly.Python["xrp_acc_y"] = function (block) {
+ PY.definitions_["import_imu"] = "from XRPLib.imu import IMU";
+ PY.definitions_[
+ `imu_setup`
+ ] = `imu = IMU.get_default_imu()\nimu.calibrate(1)`;
var code = `imu.get_acc_y()`;
return [code, Blockly.Python.ORDER_NONE];
};
-Blockly.Python['xrp_acc_z'] = function (block) {
- PY.definitions_['import_imu'] = 'from XRPLib.imu import IMU';
- PY.definitions_[`imu_setup`] = `imu = IMU.get_default_imu()\nimu.calibrate(1)`;
+Blockly.Python["xrp_acc_z"] = function (block) {
+ PY.definitions_["import_imu"] = "from XRPLib.imu import IMU";
+ PY.definitions_[
+ `imu_setup`
+ ] = `imu = IMU.get_default_imu()\nimu.calibrate(1)`;
var code = `imu.get_acc_z()`;
return [code, Blockly.Python.ORDER_NONE];
};
//Control Board
-Blockly.Python['xrp_led_on'] = function (block) {
- PY.definitions_['import_board'] = 'from XRPLib.board import Board';
+Blockly.Python["xrp_led_on"] = function (block) {
+ PY.definitions_["import_board"] = "from XRPLib.board import Board";
PY.definitions_[`board_setup`] = `board = Board.get_default_board()`;
var code = `board.led_on()\n`;
return code;
};
-Blockly.Python['xrp_led_off'] = function (block) {
- PY.definitions_['import_board'] = 'from XRPLib.board import Board';
+Blockly.Python["xrp_led_off"] = function (block) {
+ PY.definitions_["import_board"] = "from XRPLib.board import Board";
PY.definitions_[`board_setup`] = `board = Board.get_default_board()`;
var code = `board.led_off()\n`;
return code;
};
-Blockly.Python['xrp_button_pressed'] = function (block) {
- PY.definitions_['import_board'] = 'from XRPLib.board import Board';
+Blockly.Python["xrp_button_pressed"] = function (block) {
+ PY.definitions_["import_board"] = "from XRPLib.board import Board";
PY.definitions_[`board_setup`] = `board = Board.get_default_board()`;
var code = `board.is_button_pressed()`;
return [code, Blockly.Python.ORDER_NONE];
};
-Blockly.Python['xrp_wait_for_button_press'] = function (block) {
- PY.definitions_['import_board'] = 'from XRPLib.board import Board';
+Blockly.Python["xrp_wait_for_button_press"] = function (block) {
+ PY.definitions_["import_board"] = "from XRPLib.board import Board";
PY.definitions_[`board_setup`] = `board = Board.get_default_board()`;
- var code = `board.wait_for_button()\n`
+ var code = `board.wait_for_button()\n`;
return code;
};
//Web Server
var nextFunc = 0;
-function getFuncName(){
+function getFuncName() {
nextFunc++;
return "func" + nextFunc;
}
-Blockly.Python['xrp_ws_forward_button'] = function (block) {
- PY.definitions_['import_webserver'] = 'from XRPLib.webserver import Webserver';
- PY.definitions_[`webserver_setup`] = `webserver = Webserver.get_default_webserver()`;
- var func = Blockly.Python.statementToCode(block, 'func');
+Blockly.Python["xrp_ws_forward_button"] = function (block) {
+ PY.definitions_["import_webserver"] =
+ "from XRPLib.webserver import Webserver";
+ PY.definitions_[
+ `webserver_setup`
+ ] = `webserver = Webserver.get_default_webserver()`;
+ var func = Blockly.Python.statementToCode(block, "func");
var funcName = getFuncName();
- var code = `\ndef ${funcName}():\n${func}\n`
- code += `webserver.registerForwardButton(${funcName})\n`
+ var code = `\ndef ${funcName}():\n${func}\n`;
+ code += `webserver.registerForwardButton(${funcName})\n`;
return code;
};
-Blockly.Python['xrp_ws_back_button'] = function (block) {
- PY.definitions_['import_webserver'] = 'from XRPLib.webserver import Webserver';
- PY.definitions_[`webserver_setup`] = `webserver = Webserver.get_default_webserver()`;
- var func = Blockly.Python.statementToCode(block, 'func');
+Blockly.Python["xrp_ws_back_button"] = function (block) {
+ PY.definitions_["import_webserver"] =
+ "from XRPLib.webserver import Webserver";
+ PY.definitions_[
+ `webserver_setup`
+ ] = `webserver = Webserver.get_default_webserver()`;
+ var func = Blockly.Python.statementToCode(block, "func");
var funcName = getFuncName();
- var code = `\ndef ${funcName}():\n${func}\n`
- code += `webserver.registerBackwardButton(${funcName})\n`
+ var code = `\ndef ${funcName}():\n${func}\n`;
+ code += `webserver.registerBackwardButton(${funcName})\n`;
return code;
};
-Blockly.Python['xrp_ws_left_button'] = function (block) {
- PY.definitions_['import_webserver'] = 'from XRPLib.webserver import Webserver';
- PY.definitions_[`webserver_setup`] = `webserver = Webserver.get_default_webserver()`;
- var func = Blockly.Python.statementToCode(block, 'func');
+Blockly.Python["xrp_ws_left_button"] = function (block) {
+ PY.definitions_["import_webserver"] =
+ "from XRPLib.webserver import Webserver";
+ PY.definitions_[
+ `webserver_setup`
+ ] = `webserver = Webserver.get_default_webserver()`;
+ var func = Blockly.Python.statementToCode(block, "func");
var funcName = getFuncName();
- var code = `\ndef ${funcName}():\n${func}\n`
- code += `webserver.registerLeftButton(${funcName})\n`
+ var code = `\ndef ${funcName}():\n${func}\n`;
+ code += `webserver.registerLeftButton(${funcName})\n`;
return code;
};
-Blockly.Python['xrp_ws_right_button'] = function (block) {
- PY.definitions_['import_webserver'] = 'from XRPLib.webserver import Webserver';
- PY.definitions_[`webserver_setup`] = `webserver = Webserver.get_default_webserver()`;
- var func = Blockly.Python.statementToCode(block, 'func');
+Blockly.Python["xrp_ws_right_button"] = function (block) {
+ PY.definitions_["import_webserver"] =
+ "from XRPLib.webserver import Webserver";
+ PY.definitions_[
+ `webserver_setup`
+ ] = `webserver = Webserver.get_default_webserver()`;
+ var func = Blockly.Python.statementToCode(block, "func");
var funcName = getFuncName();
- var code = `\ndef ${funcName}():\n${func}\n`
- code += `webserver.registerRightButton(${funcName})\n`
+ var code = `\ndef ${funcName}():\n${func}\n`;
+ code += `webserver.registerRightButton(${funcName})\n`;
return code;
};
-Blockly.Python['xrp_ws_stop_button'] = function (block) {
- PY.definitions_['import_webserver'] = 'from XRPLib.webserver import Webserver';
- PY.definitions_[`webserver_setup`] = `webserver = Webserver.get_default_webserver()`;
- var func = Blockly.Python.statementToCode(block, 'func');
+Blockly.Python["xrp_ws_stop_button"] = function (block) {
+ PY.definitions_["import_webserver"] =
+ "from XRPLib.webserver import Webserver";
+ PY.definitions_[
+ `webserver_setup`
+ ] = `webserver = Webserver.get_default_webserver()`;
+ var func = Blockly.Python.statementToCode(block, "func");
var funcName = getFuncName();
- var code = `\ndef ${funcName}():\n${func}\n`
- code += `webserver.registerStopButton(${funcName})\n`
+ var code = `\ndef ${funcName}():\n${func}\n`;
+ code += `webserver.registerStopButton(${funcName})\n`;
return code;
};
-Blockly.Python['xrp_ws_add_button'] = function (block) {
- PY.definitions_['import_webserver'] = 'from XRPLib.webserver import Webserver';
- PY.definitions_[`webserver_setup`] = `webserver = Webserver.get_default_webserver()`;
+Blockly.Python["xrp_ws_add_button"] = function (block) {
+ PY.definitions_["import_webserver"] =
+ "from XRPLib.webserver import Webserver";
+ PY.definitions_[
+ `webserver_setup`
+ ] = `webserver = Webserver.get_default_webserver()`;
var name = block.getFieldValue("TEXT");
- var func = Blockly.Python.statementToCode(block, 'func');
+ var func = Blockly.Python.statementToCode(block, "func");
var funcName = getFuncName();
- var code = `\ndef ${funcName}():\n${func}\n`
- code += `webserver.add_button("${name}", ${funcName})\n`
+ var code = `\ndef ${funcName}():\n${func}\n`;
+ code += `webserver.add_button("${name}", ${funcName})\n`;
return code;
};
-Blockly.Python['xrp_ws_log_data'] = function (block) {
- PY.definitions_['import_webserver'] = 'from XRPLib.webserver import Webserver';
- PY.definitions_[`webserver_setup`] = `webserver = Webserver.get_default_webserver()`;
- data = Blockly.Python.valueToCode(block, 'DATA', Blockly.Python.ORDER_ATOMIC);
- var label = block.getInputTargetBlock("log_name").getFieldValue("TEXT");
- var code = `webserver.log_data("${label}", ${data})\n`
+Blockly.Python["xrp_ws_log_data"] = function (block) {
+ PY.definitions_["import_webserver"] =
+ "from XRPLib.webserver import Webserver";
+ PY.definitions_[
+ `webserver_setup`
+ ] = `webserver = Webserver.get_default_webserver()`;
+ data = Blockly.Python.valueToCode(block, "DATA", Blockly.Python.ORDER_ATOMIC);
+ var label = block.getInputTargetBlock("log_name").getFieldValue("TEXT");
+ var code = `webserver.log_data("${label}", ${data})\n`;
return code;
};
-
-Blockly.Python['xrp_ws_connect_server'] = function (block) {
- PY.definitions_['import_webserver'] = 'from XRPLib.webserver import Webserver';
- PY.definitions_[`webserver_setup`] = `webserver = Webserver.get_default_webserver()`;
+Blockly.Python["xrp_ws_connect_server"] = function (block) {
+ PY.definitions_["import_webserver"] =
+ "from XRPLib.webserver import Webserver";
+ PY.definitions_[
+ `webserver_setup`
+ ] = `webserver = Webserver.get_default_webserver()`;
var ssid = block.getInputTargetBlock("server_ssid").getFieldValue("TEXT");
- var pwd = block.getInputTargetBlock("server_pwd").getFieldValue("TEXT")
- var code = `webserver.connect_to_network(ssid="${ssid}", password="${pwd}")\nwebserver.start_server()\n`
+ var pwd = block.getInputTargetBlock("server_pwd").getFieldValue("TEXT");
+ var code = `webserver.connect_to_network(ssid="${ssid}", password="${pwd}")\nwebserver.start_server()\n`;
return code;
};
-Blockly.Python['xrp_ws_start_server'] = function (block) {
- PY.definitions_['import_webserver'] = 'from XRPLib.webserver import Webserver';
- PY.definitions_[`webserver_setup`] = `webserver = Webserver.get_default_webserver()`;
+Blockly.Python["xrp_ws_start_server"] = function (block) {
+ PY.definitions_["import_webserver"] =
+ "from XRPLib.webserver import Webserver";
+ PY.definitions_[
+ `webserver_setup`
+ ] = `webserver = Webserver.get_default_webserver()`;
var ssid = block.getInputTargetBlock("server_ssid").getFieldValue("TEXT");
- var pwd = block.getInputTargetBlock("server_pwd").getFieldValue("TEXT")
- var code = `webserver.start_network(ssid="${ssid}", password="${pwd}")\nwebserver.start_server()\n`
+ var pwd = block.getInputTargetBlock("server_pwd").getFieldValue("TEXT");
+ var code = `webserver.start_network(ssid="${ssid}", password="${pwd}")\nwebserver.start_server()\n`;
return code;
};
-
//Logic
-Blockly.Python['xrp_sleep'] = function (block) {
- PY.definitions_['import_time'] = 'import time';
- var number_time = Blockly.Python.valueToCode(block, 'TIME', Blockly.Python.ORDER_ATOMIC);
+Blockly.Python["xrp_sleep"] = function (block) {
+ PY.definitions_["import_time"] = "import time";
+ var number_time = Blockly.Python.valueToCode(
+ block,
+ "TIME",
+ Blockly.Python.ORDER_ATOMIC
+ );
var code = `time.sleep(${number_time})\n`;
return code;
};
-
-
diff --git a/lib/XRPLib/imu.py b/lib/XRPLib/imu.py
index 5c154ad..cd2b493 100644
--- a/lib/XRPLib/imu.py
+++ b/lib/XRPLib/imu.py
@@ -555,4 +555,18 @@ def _update_imu_readings(self):
self.running_pitch += delta_pitch
self.running_roll += delta_roll
self.running_yaw += delta_yaw
- enable_irq(state)
\ No newline at end of file
+ enable_irq(state)
+
+
+
+ def html_rgb(data):
+ """
+ Collect readings for [data] RGB
+
+ :param data: RGB
+ """
+ r, g, b, c = data
+ red = pow((int((r/c) * 256) / 255), 2.5) * 255
+ green = pow((int((g/c) * 256) / 255), 2.5) * 255
+ blue = pow((int((b/c) * 256) / 255), 2.5) * 255
+ return red, green, blue
\ No newline at end of file