diff --git a/source/blocks/adam_common.js b/source/blocks/adam_common.js index 767cc39..6b57ea1 100644 --- a/source/blocks/adam_common.js +++ b/source/blocks/adam_common.js @@ -2007,7 +2007,7 @@ Blockly.defineBlocksWithJsonArray([ */ { "type": "common_comment", - "message0": "коментарий %1", + "message0": "комментарий %1", "args0": [ { "type": "field_input", diff --git a/source/blocks/adam_three.js b/source/blocks/adam_three.js index ebc7165..f1e1785 100644 --- a/source/blocks/adam_three.js +++ b/source/blocks/adam_three.js @@ -894,4 +894,235 @@ Blockly.defineBlocksWithJsonArray([ "colour": 220, "tooltip": "", "helpUrl": "" -}]); \ No newline at end of file +}, + +/** + * adam_two_seven_sensor_temperature + * + */ +{ + "type": "adam_two_seven_sensor_temperature", + "message0": "датчик температуры %1 переменная класса датчика %2", + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "field_variable", + "name": "sensor_variable", + "variable": "item" + } + ], + "output": null, + "colour": 160, + "tooltip": "", + "helpUrl": "" +}, + +/** + * adam_two_seven_sensor_acceleration + * + */ +{ + "type": "adam_two_seven_sensor_acceleration", + "message0": "датчик ускорения %1 переменная класса датчика %2", + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "field_variable", + "name": "sensor_variable", + "variable": "item" + } + ], + "output": null, + "colour": 160, + "tooltip": "", + "helpUrl": "" +}, + +/** + * adam_two_seven_sensor_gyro + * + */ +{ + "type": "adam_two_seven_sensor_gyro", + "message0": "гироскоп %1 переменная класса датчика %2", + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "field_variable", + "name": "sensor_variable", + "variable": "item" + } + ], + "output": null, + "colour": 160, + "tooltip": "", + "helpUrl": "" +}, + +/** + * adam_two_seven_sensor_magnetometer + * + */ +{ + "type": "adam_two_seven_sensor_magnetometer", + "message0": "магнитометр %1 переменная класса датчика %2", + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "field_variable", + "name": "sensor_variable", + "variable": "item" + } + ], + "output": null, + "colour": 160, + "tooltip": "", + "helpUrl": "" +}, + +/** + * adam_two_seven_sensor_pressure + * + */ +{ + "type": "adam_two_seven_sensor_pressure", + "message0": "давление %1 переменная класса датчика %2", + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "field_variable", + "name": "sensor_variable", + "variable": "item" + } + ], + "output": null, + "colour": 160, + "tooltip": "", + "helpUrl": "" +}, + +/** + * adam_two_seven_sensor_altitude + * + */ +{ + "type": "adam_two_seven_sensor_altitude", + "message0": "высота над уровнем моря %1 переменная класса датчика %2", + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "field_variable", + "name": "sensor_variable", + "variable": "item" + } + ], + "output": null, + "colour": 160, + "tooltip": "", + "helpUrl": "" +}, + +/** + * adam_two_seven_sensor_declaration_extended + * + */ +{ + "type": "adam_two_seven_sensor_declaration_extended", + "message0": "инициализация датчика bmp280 %1 переменная шины i2c %2 %3 адрес устройства i2c %4", + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "field_variable", + "name": "i2c_variable", + "variable": "item" + }, + { + "type": "input_dummy" + }, + { + "type": "input_value", + "name": "sensor_address" + } + ], + "output": null, + "colour": 160, + "tooltip": "", + "helpUrl": "" +}, + +{ + "type": "adam_two_seven_bmp280_addr_const", + "message0": "адрес датчика bmp280 %1", + "args0": [ + { + "type": "field_dropdown", + "name": "addr_variable", + "options": [ + [ + "0x76", + "0x76" + ], + [ + "0x77", + "0x77" + ] + ] + } + ], + "output": null, + "colour": 160, + "tooltip": "", + "helpUrl": "" +}, + +{ + "type": "adam_two_seven_sensor_set_pressure", + "message0": "поправка для атмосферного давления %1 переменная класса датчика %2 %3 текущее атмосферное давление %4", + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "field_variable", + "name": "sensor_variable", + "variable": "item" + }, + { + "type": "input_dummy" + }, + { + "type": "field_number", + "name": "current_atmospheric_pressure_variable", + "value": 1000 + } + ], + "previousStatement": null, + "nextStatement": null, + "colour": 160, + "tooltip": "", + "helpUrl": "" +}, + +{ + "type": "adam_two_seven_sensor_mpu_9250_declaration", + "message0": "инициализация датчика mpu9250", + "output": null, + "colour": 160, + "tooltip": "", + "helpUrl": "" +} +]); \ No newline at end of file diff --git a/source/generators/python/adam_common.js b/source/generators/python/adam_common.js index ddb4127..f4ba186 100644 --- a/source/generators/python/adam_common.js +++ b/source/generators/python/adam_common.js @@ -299,7 +299,6 @@ Blockly.Python['common_music_mixer_init'] = function(block) { */ Blockly.Python['common_music_mixer_load'] = function(block) { var value_path = Blockly.Python.valueToCode(block, 'path', Blockly.Python.ORDER_NONE); - // TODO: Assemble Python into code variable. var code = 'pygame.mixer.music.load(' + value_path + ')\n'; return code; }; @@ -399,7 +398,6 @@ Blockly.Python['common_music_fraction'] = function(block) { Blockly.Python['common_say_native'] = function(block) { Blockly.Python.definitions_['import_subprocess'] = 'import subprocess'; var value_text = Blockly.Python.valueToCode(block, 'text', Blockly.Python.ORDER_ATOMIC); - // TODO: Assemble Python into code variable. var code = 'subprocess.call("echo ' + value_text + ' | RHVoice-test --profile \'aleksandr-hq\' 2>/dev/null", shell=True)'; return code; }; @@ -412,7 +410,6 @@ Blockly.Python['common_say_native_with_voice_param'] = function(block) { Blockly.Python.definitions_['import_subprocess'] = 'import subprocess'; var value_text = Blockly.Python.valueToCode(block, 'text', Blockly.Python.ORDER_ATOMIC); var value_voice = Blockly.Python.valueToCode(block, 'voice', Blockly.Python.ORDER_ATOMIC); - // TODO: Assemble Python into code variable. var code = 'subprocess.call("echo ' + value_text + ' | RHVoice-test --profile ' + value_voice + ' 2>/dev/null", shell=True)'; return code; }; diff --git a/source/generators/python/adam_three.js b/source/generators/python/adam_three.js index bce2f33..b38d778 100644 --- a/source/generators/python/adam_three.js +++ b/source/generators/python/adam_three.js @@ -265,4 +265,69 @@ Blockly.Python['controller_const_left_foot'] = function(block) { Blockly.Python['controller_const_right_foot'] = function(block) { var code = "'right_foot'"; return [code, Blockly.Python.ORDER_ATOMIC]; -}; \ No newline at end of file +}; + +Blockly.Python['adam_two_seven_sensor_temperature'] = function(block) { + var variable_sensor_variable = Blockly.Python.nameDB_.getName(block.getFieldValue('sensor_variable'), Blockly.Variables.NAME_TYPE); + var code = variable_sensor_variable + '.temperature'; + return [code, Blockly.Python.ORDER_NONE]; +}; + +Blockly.Python['adam_two_seven_sensor_pressure'] = function(block) { + var variable_sensor_variable = Blockly.Python.nameDB_.getName(block.getFieldValue('sensor_variable'), Blockly.Variables.NAME_TYPE); + var code = variable_sensor_variable + '.pressure'; + return [code, Blockly.Python.ORDER_NONE]; +}; + +Blockly.Python['adam_two_seven_sensor_altitude'] = function(block) { + var variable_sensor_variable = Blockly.Python.nameDB_.getName(block.getFieldValue('sensor_variable'), Blockly.Variables.NAME_TYPE); + var code = variable_sensor_variable + '.altitude'; + return [code, Blockly.Python.ORDER_NONE]; +}; +Blockly.Python['adam_two_seven_sensor_acceleration'] = function(block) { + var variable_sensor_variable = Blockly.Python.nameDB_.getName(block.getFieldValue('sensor_variable'), Blockly.Variables.NAME_TYPE); + var code = variable_sensor_variable + '.readAccel()'; + return [code, Blockly.Python.ORDER_NONE]; +}; + +Blockly.Python['adam_two_seven_sensor_gyro'] = function(block) { + var variable_sensor_variable = Blockly.Python.nameDB_.getName(block.getFieldValue('sensor_variable'), Blockly.Variables.NAME_TYPE); + var code = variable_sensor_variable + '.readGyro()'; + return [code, Blockly.Python.ORDER_NONE]; +}; + +Blockly.Python['adam_two_seven_sensor_magnetometer'] = function(block) { + var variable_sensor_variable = Blockly.Python.nameDB_.getName(block.getFieldValue('sensor_variable'), Blockly.Variables.NAME_TYPE); + var code = variable_sensor_variable + '.readMagnet()'; + return [code, Blockly.Python.ORDER_NONE]; +}; + + +Blockly.Python['adam_two_seven_sensor_declaration_extended'] = function(block) { + Blockly.Python.definitions_['import_adafruit_bmp280'] = 'import adafruit_bmp280'; + var variable_i2c_variable = Blockly.Python.nameDB_.getName(block.getFieldValue('i2c_variable'), Blockly.Variables.NAME_TYPE); + var value_sensor_address = Blockly.Python.valueToCode(block, 'sensor_address', Blockly.Python.ORDER_NONE); + var code = 'adafruit_bmp280.Adafruit_BMP280_I2C(' + variable_i2c_variable + ', ' + value_sensor_address + ')'; + return [code, Blockly.Python.ORDER_NONE]; +}; + +Blockly.Python['adam_two_seven_bmp280_addr_const'] = function(block) { + var dropdown_addr_variable = block.getFieldValue('addr_variable'); + var code = dropdown_addr_variable; + return [code, Blockly.Python.ORDER_NONE]; +}; + +Blockly.Python['adam_two_seven_sensor_set_pressure'] = function(block) { + var variable_sensor_variable = Blockly.Python.nameDB_.getName(block.getFieldValue('sensor_variable'), Blockly.Variables.NAME_TYPE); + var number_current_atmospheric_pressure_variable = block.getFieldValue('current_atmospheric_pressure_variable'); + var code = variable_sensor_variable + '.sea_level_pressure = ' + number_current_atmospheric_pressure_variable + '\n'; + return code; +}; + +Blockly.Python['adam_two_seven_sensor_mpu_9250_declaration'] = function(block) { + Blockly.Python.definitions_['import_FaBo9Axis_MPU9250'] = 'import FaBo9Axis_MPU9250'; + var code = 'FaBo9Axis_MPU9250.MPU9250()'; + return [code, Blockly.Python.ORDER_NONE]; +}; + + diff --git a/source/generators/python/adam_two.js b/source/generators/python/adam_two.js index f7ba0c7..085c318 100644 --- a/source/generators/python/adam_two.js +++ b/source/generators/python/adam_two.js @@ -662,4 +662,5 @@ Blockly.Python['common_sensor_gravity'] = function(block) { var variable_sensor_variable = Blockly.Python.nameDB_.getName(block.getFieldValue('sensor_variable'), Blockly.Variables.NAME_TYPE); var code = variable_sensor_variable + '.gravity'; return [code, Blockly.Python.ORDER_NONE]; -}; \ No newline at end of file +}; +