192 lines
5.5 KiB
Diff
192 lines
5.5 KiB
Diff
From fe9c3c066fd2c7a19500209c1e552c5d64e96995 Mon Sep 17 00:00:00 2001
|
|
From: c0repwn3r <core@coredoes.dev>
|
|
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 = '<xml id="toolbox-categories" style="display: no
|
|
'<block type="hub_imu_roll" id="hub_imu_roll"></block>' +
|
|
'<block type="hub_imu_accel" id="hub_imu_accel"></block>' +
|
|
'<block type="hub_imu_avel" id="hub_imu_avel"></block>' +
|
|
+ '<block type="hub_imu_yaw" id="hub_imu_yaw"></block>' +
|
|
+ '<block type="hub_imu_reset_yaw" id="hub_imu_reset_yaw"></block>' +
|
|
+ '<block type="hub_imu_reset_yaw_to" id="hub_imu_reset_yaw_to">' +
|
|
+ '<value name="DEGREES">' +
|
|
+ '<shadow type="math_integer">' +
|
|
+ '<field name="NUM">90</field>' +
|
|
+ '</shadow>' +
|
|
+ '</value>' +
|
|
+ '</block>' +
|
|
+ '<block type="hub_imu_accel_t" id="hub_imu_accel_t"></block>' +
|
|
+ '<block type="hub_imu_avel_t" id="hub_imu_avel_t"></block>' +
|
|
+ '<block type="hub_imu_set_avel_t" id="hub_imu_set_avel_t">' +
|
|
+ '<value name="THRESHOLD">' +
|
|
+ '<shadow type="math_number">' +
|
|
+ '<field name="NUM">1.0</field>' +
|
|
+ '</shadow>' +
|
|
+ '</value>' +
|
|
+ '</block>' +
|
|
+ '<block type="hub_imu_set_accel_t" id="hub_imu_set_accel_t">' +
|
|
+ '<value name="THRESHOLD">' +
|
|
+ '<shadow type="math_number">' +
|
|
+ '<field name="NUM">1.0</field>' +
|
|
+ '</shadow>' +
|
|
+ '</value>' +
|
|
+ '</block>' +
|
|
'</category>' +
|
|
'<category name="%{BKY_CATEGORY_SOUND}" id="sound" colour="#FFBF00" secondaryColour="#3373CC">' +
|
|
'</category>' +
|
|
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
|
|
|