mpy 外接传感增加旋转解码器

This commit is contained in:
Irene-Maxine
2025-09-17 21:45:18 +08:00
parent bdad0d0321
commit f9b7f4a13e
9 changed files with 236 additions and 0 deletions

View File

@@ -2415,4 +2415,41 @@ export const get_keboards_value = {
this.setOutput(true);
this.setInputsInline(true);
}
}
export const init_init_rotary_encoder = {
init:function(){
this.setColour(SENSOR_EXTERN_HUE);
this.appendValueInput('SUB')
.appendField(Blockly.Msg.MIXLY_SETUP)
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_AS + Blockly.Msg.MIXLY_ROTARY_ENCODER)
this.appendValueInput('PIN1')
.appendField('PINA#')
this.appendValueInput('PIN2')
.appendField('PINB#')
this.appendValueInput('KEY')
.appendField('KEY#')
this.appendValueInput('METHOD')
.appendField(Blockly.Msg.MIXLY_DO)
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setInputsInline(true);
}
}
export const rotary_key = {
init:function(){
this.setColour(SENSOR_EXTERN_HUE);
this.appendDummyInput()
.appendField(Blockly.Msg.MIXLY_ROTARY_ENCODER)
.appendField(new Blockly.FieldDropdown([
[Blockly.Msg.CLOCKWISE + Blockly.Msg.MIXLY_REVOLVE,"ROT_CW"],
[Blockly.Msg.ANTI_CLOCKWISE + Blockly.Msg.MIXLY_REVOLVE,"ROT_CCW"],
[Blockly.Msg.MIXLY_BUTTON2 + Blockly.Msg.MIXLY_BUTTON_PRESSED, "SW_PRESS"],
[Blockly.Msg.MIXLY_BUTTON2 + Blockly.Msg.MIXLY_BUTTON_RELEASED,"SW_RELEASE"]
]),"key")
this.setOutput(true);
this.setInputsInline(true);
}
}