@@ -1101,3 +1101,94 @@ Blockly.Python['coderbot_sonar_get_distance'] = function(block) {
11011101 return [ code , Blockly . Python . ORDER_ATOMIC ] ;
11021102} ;
11031103
1104+ Blockly . Blocks [ 'coderbot_mpu_get_accel' ] = {
1105+ /**
1106+ * Block for get_distance function.
1107+ * @this Blockly.Block
1108+ */
1109+ init : function ( ) {
1110+ this . setHelpUrl ( Blockly . Msg . LOGIC_BOOLEAN_HELPURL ) ;
1111+ this . setColour ( 240 ) ;
1112+ this . appendDummyInput ( )
1113+ . appendField ( Blockly . Msg . CODERBOT_MPU_GET_ACCEL )
1114+ . appendField ( new Blockly . FieldDropdown ( [ [ Blockly . Msg . CODERBOT_MPU_AXIS_X , "0" ] ,
1115+ [ Blockly . Msg . CODERBOT_MPU_AXIS_Y , "1" ] ,
1116+ [ Blockly . Msg . CODERBOT_MPU_AXIS_Z , "2" ] , 'AXIS' ) ;
1117+ this . setOutput ( true , 'Number' ) ;
1118+ this . setTooltip ( Blockly . Msg . LOGIC_BOOLEAN_TOOLTIP ) ;
1119+ }
1120+ } ;
1121+
1122+ Blockly . Python [ 'coderbot_mpu_get_accel '] = function ( block ) {
1123+ // Boolean values true and false.
1124+ var axis = block . getFieldValue ( 'AXIS' ) ;
1125+ var code = 'get_bot ( ) . get_mpu_accel ( ' + axis + ' ) ';
1126+ return [ code , Blockly . Python . ORDER_ATOMIC ] ;
1127+ } ;
1128+
1129+ Blockly . Blocks [ 'coderbot_mpu_get_gyro' ] = {
1130+ /**
1131+ * Block for get_distance function.
1132+ * @this Blockly.Block
1133+ */
1134+ init : function ( ) {
1135+ this . setHelpUrl ( Blockly . Msg . LOGIC_BOOLEAN_HELPURL ) ;
1136+ this . setColour ( 240 ) ;
1137+ this . appendDummyInput ( )
1138+ . appendField ( Blockly . Msg . CODERBOT_MPU_GET_GYRO )
1139+ . appendField ( new Blockly . FieldDropdown ( [ [ Blockly . Msg . CODERBOT_MPU_AXIS_X , "0" ] ,
1140+ [ Blockly . Msg . CODERBOT_MPU_AXIS_Y , "1" ] ,
1141+ [ Blockly . Msg . CODERBOT_MPU_AXIS_Z , "2" ] , 'AXIS' ) ;
1142+ this . setOutput ( true , 'Number' ) ;
1143+ this . setTooltip ( Blockly . Msg . LOGIC_BOOLEAN_TOOLTIP ) ;
1144+ }
1145+ } ;
1146+
1147+ Blockly . Python [ 'coderbot_mpu_get_gyro '] = function ( block ) {
1148+ // Boolean values true and false.
1149+ var axis = block . getFieldValue ( 'AXIS' ) ;
1150+ var code = 'get_bot ( ) . get_mpu_gyro ( ' + axis + ' ) ';
1151+ return [ code , Blockly . Python . ORDER_ATOMIC ] ;
1152+ } ;
1153+
1154+ Blockly . Blocks [ 'coderbot_mpu_get_heading' ] = {
1155+ /**
1156+ * Block for get_distance function.
1157+ * @this Blockly.Block
1158+ */
1159+ init : function ( ) {
1160+ this . setHelpUrl ( Blockly . Msg . LOGIC_BOOLEAN_HELPURL ) ;
1161+ this . setColour ( 240 ) ;
1162+ this . appendDummyInput ( )
1163+ . appendField ( Blockly . Msg . CODERBOT_MPU_GET_HEADING ) ;
1164+ this . setOutput ( true , 'Number' ) ;
1165+ this . setTooltip ( Blockly . Msg . LOGIC_BOOLEAN_TOOLTIP ) ;
1166+ }
1167+ } ;
1168+
1169+ Blockly . Python [ 'coderbot_mpu_get_heading' ] = function ( block ) {
1170+ // Boolean values true and false.
1171+ var code = 'get_bot().get_mpu_heading()' ;
1172+ return [ code , Blockly . Python . ORDER_ATOMIC ] ;
1173+ } ;
1174+
1175+ Blockly . Blocks [ 'coderbot_mpu_get_temp' ] = {
1176+ /**
1177+ * Block for get_distance function.
1178+ * @this Blockly.Block
1179+ */
1180+ init : function ( ) {
1181+ this . setHelpUrl ( Blockly . Msg . LOGIC_BOOLEAN_HELPURL ) ;
1182+ this . setColour ( 240 ) ;
1183+ this . appendDummyInput ( )
1184+ . appendField ( Blockly . Msg . CODERBOT_MPU_GET_TEMP ) ;
1185+ this . setOutput ( true , 'Number' ) ;
1186+ this . setTooltip ( Blockly . Msg . LOGIC_BOOLEAN_TOOLTIP ) ;
1187+ }
1188+ } ;
1189+
1190+ Blockly . Python [ 'coderbot_mpu_get_temp' ] = function ( block ) {
1191+ // Boolean values true and false.
1192+ var code = 'get_bot().get_mpu_temp()' ;
1193+ return [ code , Blockly . Python . ORDER_ATOMIC ] ;
1194+ } ;
0 commit comments