元控增加称重传感器、检查mini 英语字库

This commit is contained in:
Irene-Maxine
2025-01-23 13:25:42 +08:00
parent 4eaf8cbbe0
commit e992afef06
9 changed files with 91 additions and 7 deletions

View File

@@ -2201,4 +2201,34 @@ export const camera_sensor_result = {
this.setOutput(true);
this.setInputsInline(true);
}
};
};
export const sensor_weigh_init = {
init: function () {
this.setColour(SENSOR_EXTERN_HUE);
this.appendValueInput('SUB')
.appendField(Blockly.Msg.MIXLY_SETUP + 'HX711/720' + Blockly.Msg.MIXLY_WEIGH_SENSOR);
this.appendValueInput('sck')
.appendField('#SCK');
this.appendValueInput('dat')
.appendField('#DAT');
this.appendValueInput('pc')
.appendField(Blockly.Msg.MIXLY_Calibration_ratio);
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip('');
}
};
export const weigh_sensor_get_weight = {
init: function () {
this.setColour(SENSOR_EXTERN_HUE);
this.appendValueInput('SUB')
.appendField(Blockly.Msg.MIXLY_GET + Blockly.Msg.MIXLY_WEIGH_SENSOR)
this.appendDummyInput()
.appendField(Blockly.Msg.blockpy_set_of + Blockly.Msg.MIXLY_DATA)
this.setOutput(true);
this.setInputsInline(true);
}
}

View File

@@ -1055,4 +1055,21 @@ export const camera_sensor_result = function (_, generator) {
var sub = generator.valueToCode(this, 'SUB', generator.ORDER_ATOMIC);
var code = sub+'.result()';
return [code, generator.ORDER_ATOMIC];
}
export const sensor_weigh_init = function (_, generator) {
generator.definitions_['import_hx270'] = 'import hx270';
var sck = generator.valueToCode(this, 'sck', generator.ORDER_ATOMIC);
var dat = generator.valueToCode(this, 'dat', generator.ORDER_ATOMIC);
var pc = generator.valueToCode(this, 'pc', generator.ORDER_ATOMIC);
var sub = generator.valueToCode(this, 'SUB', generator.ORDER_ATOMIC);
var code = sub + ' = hx270.HX270(' + sck + ', ' + dat + ', ' + pc + ')\n';
return code;
}
export const weigh_sensor_get_weight = function (_, generator) {
generator.definitions_['import_hx270'] = 'import hx270';
var v = generator.valueToCode(this, 'SUB', generator.ORDER_ATOMIC);
var code = v + ".read_weight(10)";
return [code, generator.ORDER_ATOMIC];
}

View File

@@ -3537,7 +3537,7 @@
</block>
</next>
</block>
<block type="sensor_mpu9250_get_acceleration" m-hide='micropython:esp32c3:mixgocar_c3'>
<block type="sensor_mpu9250_get_acceleration" m-hide='micropython:esp32c3:mixgocar_c3'>
<value name="SUB">
<shadow type="variables_get">
<field name="VAR">xsensor</field>
@@ -4050,7 +4050,7 @@
<field name="VAR">zsensor</field>
</shadow>
</value>
</block>
</block>
</category>
<category id="catExternActuator" colour='#74A55B'>
<block type="servo_move" m-show='micropython:esp32c3:mixgocar_c3'>

View File

@@ -4379,6 +4379,35 @@
</shadow>
</value>
</block>
<block type="sensor_weigh_init">
<value name="SUB">
<shadow type="variables_get">
<field name="VAR">weight</field>
</shadow>
</value>
<value name="sck">
<shadow type="pins_digital_pin">
<field name="PIN">1</field>
</shadow>
</value>
<value name="dat">
<shadow type="pins_digital_pin">
<field name="PIN">2</field>
</shadow>
</value>
<value name="pc">
<shadow type="math_number">
<field name="NUM">-500</field>
</shadow>
</value>
</block>
<block type="weigh_sensor_get_weight">
<value name="SUB">
<shadow type="variables_get">
<field name="VAR">weight</field>
</shadow>
</value>
</block>
</category>
<category id="catExternActuator" colour='#74A55B'>
<block type="esp32_music_pitch_init">