元控增加称重传感器、检查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];
}