修改调整音量

This commit is contained in:
Irene-Maxine
2025-09-01 16:30:02 +08:00
parent 27ae6faf1e
commit 03d083b54f
9 changed files with 106 additions and 81 deletions

View File

@@ -127,6 +127,20 @@ export const esp32_music_stop = {
}
};
export const esp32_set_music_volume ={
init: function () {
this.setColour(ACTUATOR_EXTERN_HUE);
this.appendValueInput('SUB')
this.appendValueInput('percent')
.appendField(Blockly.Msg.MIXLY_MUSIC_VOLUME_SET);
this.appendDummyInput()
.appendField('%');
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setInputsInline(true);
}
};
export const actuator_extern_led_bright = {
init: function () {
this.setColour(ACTUATOR_EXTERN_HUE);

View File

@@ -107,6 +107,14 @@ export const esp32_music_stop = function (block, generator) {
return code;
}
export const esp32_set_music_volume = function (_,generator){
generator.definitions_['import_music'] = 'import music';
var v = generator.valueToCode(this, 'SUB', generator.ORDER_ATOMIC);
var p = generator.valueToCode(this, 'percent', generator.ORDER_ATOMIC);
var code = v+'.set_volume('+p+')\n';
return code;
}
export const esp32_music_set_tempo_extern = function (_, generator) {
generator.definitions_['import_music'] = 'import music';
var v = generator.valueToCode(this, 'SUB', generator.ORDER_ATOMIC);

View File

@@ -796,6 +796,6 @@ export const set_music_volume = function (_,generator){
var version = Boards.getSelectedBoardKey().split(':')[2]
generator.definitions_['import_' + version + '_onboard_music'] = 'from ' + version + ' import onboard_music';
var p = generator.valueToCode(this, 'percent', generator.ORDER_ATOMIC);
var code = 'onboard_music.volume('+p+')\n';
var code = 'onboard_music.set_volume('+p+')\n';
return code;
}

View File

@@ -1598,6 +1598,13 @@
</shadow>
</value>
</block>
<block type="set_music_volume">
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
<block type="esp32_onboard_music_play_list" m-hide='micropython:esp32:rm_e1'>
<value name="LIST">
<shadow type="pins_playlist"></shadow>
@@ -1709,13 +1716,6 @@
</shadow>
</value>
</block>
<block type="set_music_volume">
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
</category>
<category id="catOnBoardDisplay" name="catOnBoardDisplay" colour='#569A98'
m-show="micropython:esp32:mixgo micropython:esp32:mixgo_pe">

View File

@@ -94,8 +94,6 @@ export const inout_analog_atten = {
.appendField(Blockly.Msg.MIXLY_ESP32_REF_VOLTAGE + Blockly.Msg.MIXLY_STAT)
.appendField(new Blockly.FieldDropdown([
["3.3V", "machine.ADC.ATTN_11DB"],
["2.2V", "machine.ADC.ATTN_6DB"],
["1.5V", "machine.ADC.ATTN_2_5DB"],
["1.2V", "machine.ADC.ATTN_0DB"]
]), "atten");
this.setInputsInline(true);

View File

@@ -1608,6 +1608,13 @@
</shadow>
</value>
</block>
<block type="set_music_volume">
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
<block type="esp32_onboard_music_play_list">
<value name="LIST">
<shadow type="pins_playlist"></shadow>
@@ -1773,14 +1780,6 @@
</shadow>
</value>
</block>
<block type="set_music_volume">
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
</category>
<category id="catOnBoardDisplay" name="catOnBoardDisplay" colour='#569A98'
m-hide='micropython:esp32c3:generic micropython:esp32c3:mixgocar_c3'>
@@ -4298,6 +4297,18 @@
</shadow>
</value>
</block>
<block type="esp32_set_music_volume">
<value name="SUB">
<shadow type="variables_get">
<field name="VAR">midi</field>
</shadow>
</value>
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
<block type="esp32_music_play_list">
<value name="LIST">
<shadow type="pins_playlist_extern"></shadow>
@@ -4655,13 +4666,6 @@
</shadow>
</value>
</block>
<block type="set_music_volume">
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
</category>
</category>
<category id="catExternMonitor" colour='5BA5A5'>

View File

@@ -1608,6 +1608,13 @@
</shadow>
</value>
</block>
<block type="set_music_volume">
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
<block type="esp32_onboard_music_play_list">
<value name="LIST">
<shadow type="pins_playlist"></shadow>
@@ -1697,13 +1704,6 @@
</block>
<block type="actuator_onboard_neopixel_write">
</block>
<block type="set_music_volume">
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
</category>
<category id="catOnBoardDisplay" name="catOnBoardDisplay" colour='#569A98'
m-hide='micropython:esp32c3:generic micropython:esp32c3:mixgocar_c3'>
@@ -1827,13 +1827,6 @@
</block>
<block type="display_clear"></block>
<block type="set_music_volume">
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
</category>
<category id="catME_GO" colour="100"
@@ -4189,6 +4182,18 @@
</shadow>
</value>
</block>
<block type="esp32_set_music_volume">
<value name="SUB">
<shadow type="variables_get">
<field name="VAR">midi</field>
</shadow>
</value>
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
<block type="esp32_music_play_list" m-hide='micropython:esp32c3:mixgocar_c3'>
<value name="LIST">
<shadow type="pins_playlist_extern"></shadow>
@@ -4546,13 +4551,6 @@
</shadow>
</value>
</block>
<block type="set_music_volume">
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
</category>
</category>
<category id="catExternMonitor" colour='5BA5A5' m-hide='micropython:esp32c3:mixgocar_c3'>

View File

@@ -1559,6 +1559,13 @@
</shadow>
</value>
</block>
<block type="set_music_volume">
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
<block type="esp32_onboard_music_play_list">
<value name="LIST">
<shadow type="pins_playlist"></shadow>
@@ -1648,13 +1655,6 @@
</block>
<block type="actuator_onboard_neopixel_write">
</block>
<block type="set_music_volume">
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
</category>
<category id="catOnBoardDisplay" name="catOnBoardDisplay" colour='#569A98'
m-hide='micropython:esp32s2:generic'>
@@ -3915,6 +3915,18 @@
</shadow>
</value>
</block>
<block type="esp32_set_music_volume">
<value name="SUB">
<shadow type="variables_get">
<field name="VAR">midi</field>
</shadow>
</value>
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
<block type="esp32_music_play_list">
<value name="LIST">
<shadow type="pins_playlist_extern"></shadow>
@@ -4272,13 +4284,6 @@
</shadow>
</value>
</block>
<block type="set_music_volume">
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
</category>
</category>
<category id="catExternMonitor" colour='5BA5A5'>

View File

@@ -1671,6 +1671,13 @@
</shadow>
</value>
</block>
<block type="set_music_volume">
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
<block type="esp32_onboard_music_play_list" m-show='micropython:esp32s3:mixgo_sant'>
<value name="LIST">
<shadow type="pins_playlist"></shadow>
@@ -1823,13 +1830,6 @@
</shadow>
</value>
</block>
<block type="set_music_volume">
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
</category>
<category id="catOnBoardDisplay" colour='#78B5B4' m-hide='micropython:esp32s3:generic'>
<block type="display_image_builtins_all"></block>
@@ -4644,6 +4644,18 @@
</shadow>
</value>
</block>
<block type="esp32_set_music_volume">
<value name="SUB">
<shadow type="variables_get">
<field name="VAR">midi</field>
</shadow>
</value>
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
<block type="esp32_music_play_list">
<value name="LIST">
<shadow type="pins_playlist_extern"></shadow>
@@ -5001,20 +5013,6 @@
</shadow>
</value>
</block>
<block type="set_music_volume">
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
<block type="set_music_volume">
<value name="percent">
<shadow type="math_number">
<field name="NUM">100</field>
</shadow>
</value>
</block>
</category>
</category>
<category id="catNova_G1" colour='100' m-show="micropython:esp32s3:mixgo_nova">