From fe9c3c066fd2c7a19500209c1e552c5d64e96995 Mon Sep 17 00:00:00 2001 From: c0repwn3r Date: Tue, 23 May 2023 11:55:18 -0400 Subject: [PATCH] imu blocks --- blocks_vertical/default_toolbox.js | 25 ++++++ blocks_vertical/imu.js | 124 ++++++++++++++++++++++++++++- 2 files changed, 147 insertions(+), 2 deletions(-) diff --git a/blocks_vertical/default_toolbox.js b/blocks_vertical/default_toolbox.js index 8516e0db..781a5f46 100644 --- a/blocks_vertical/default_toolbox.js +++ b/blocks_vertical/default_toolbox.js @@ -64,6 +64,31 @@ Blockly.Blocks.defaultToolbox = '' + '' + '' + + '' + + '' + + '' + + '' + + '' + + '90' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '1.0' + + '' + + '' + + '' + + '' + + '' + + '' + + '1.0' + + '' + + '' + + '' + '' + '' + '' + diff --git a/blocks_vertical/imu.js b/blocks_vertical/imu.js index 0e09a248..9215efdd 100644 --- a/blocks_vertical/imu.js +++ b/blocks_vertical/imu.js @@ -87,7 +87,7 @@ Blockly.Blocks['hub_imu_accel'] = { } ], "category": Blockly.Categories.imu, - "extensions": ["colours_imu", "output_boolean"] + "extensions": ["colours_imu", "output_number"] }); } }; @@ -112,7 +112,127 @@ Blockly.Blocks['hub_imu_avel'] = { } ], "category": Blockly.Categories.imu, - "extensions": ["colours_imu", "output_boolean"] + "extensions": ["colours_imu", "output_number"] + }); + } +}; + +Blockly.Blocks['hub_imu_yaw'] = { + /** + * Block to get the approximate yaw angle + * @this Blockly.Block + */ + init: function() { + this.jsonInit({ + "message0": Blockly.Msg.HUB_IMU_YAW, + "args0": [], + "category": Blockly.Categories.imu, + "extensions": ["colours_imu", "output_number"] + }); + } +}; + +Blockly.Blocks['hub_imu_reset_yaw'] = { + /** + * Block to reset the yaw angle to 0 + * @this Blockly.Block + */ + init: function() { + this.jsonInit({ + "message0": Blockly.Msg.HUB_IMU_RESET_YAW, + "args0": [], + "category": Blockly.Categories.imu, + "extensions": ["colours_imu", "shape_statement"] + }); + } +}; + +Blockly.Blocks['hub_imu_reset_yaw_to'] = { + /** + * Block to reset the yaw angle to given degrees + * @this Blockly.Block + */ + init: function() { + this.jsonInit({ + "message0": Blockly.Msg.HUB_IMU_RESET_YAW_TO, + "args0": [ + { + "name": "DEGREES", + "type": "input_value" + } + ], + "category": Blockly.Categories.imu, + "extensions": ["colours_imu", "shape_statement"] + }); + } +}; + +Blockly.Blocks['hub_imu_accel_t'] = { + /** + * Block to get the acceleration stillness threshold + * @this Blockly.Block + */ + init: function() { + this.jsonInit({ + "message0": Blockly.Msg.HUB_IMU_ACCE_THRESHOLD, + "args0": [], + "category": Blockly.Categories.imu, + "extensions": ["colours_imu", "output_number"] + }); + } +}; + +Blockly.Blocks['hub_imu_avel_t'] = { + /** + * Block to get the angular velocity stillness threshold + * @this Blockly.Block + */ + init: function() { + this.jsonInit({ + "message0": Blockly.Msg.HUB_IMU_AVEL_THRESHOLD, + "args0": [], + "category": Blockly.Categories.imu, + "extensions": ["colours_imu", "output_number"] + }); + } +}; + +Blockly.Blocks['hub_imu_set_accel_t'] = { + /** + * Block to set the acceleration stillness threshold to a different value + * @this Blockly.Block + */ + init: function() { + this.jsonInit({ + "message0": Blockly.Msg.HUB_IMU_SET_ACCE_THRESHOLD, + "args0": [ + { + "name": "THRESHOLD", + "type": "input_value" + } + ], + "category": Blockly.Categories.imu, + "extensions": ["colours_imu", "shape_statement"] + }); + } +}; + +Blockly.Blocks['hub_imu_set_avel_t'] = { + /** + * Block to set the angular velocity stillness threshold to a different value + * @this Blockly.Block + */ + init: function() { + this.jsonInit({ + "message0": Blockly.Msg.HUB_IMU_SET_AVEL_THRESHOLD, + "args0": [ + { + "name": "THRESHOLD", + "type": "input_value" + } + ], + "category": Blockly.Categories.imu, + "extensions": ["colours_imu", "shape_statement"] }); } }; -- 2.40.1