Skip to content

Commit 6d15568

Browse files
committed
fixed buzzer bug
1 parent bd657b1 commit 6d15568

2 files changed

Lines changed: 115 additions & 43 deletions

File tree

blocks/webduino.js

Lines changed: 114 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -891,15 +891,15 @@ Blockly.Blocks['led_new'] = {
891891
.appendField(Blockly.Msg.WEBDUINO_LED_PIN, "pin")
892892
.appendField(new Blockly.FieldDropdown([
893893
["2", "2"],
894-
["3", "3"],
894+
["3~", "3"],
895895
["4", "4"],
896-
["5", "5"],
897-
["6", "6"],
896+
["5~", "5"],
897+
["6~", "6"],
898898
["7", "7"],
899899
["8", "8"],
900-
["9", "9"],
901-
["10", "10"],
902-
["11", "11"],
900+
["9~", "9"],
901+
["10~", "10"],
902+
["11~", "11"],
903903
["12", "12"],
904904
["13", "13"],
905905
["14 ( A0 )", "14"],
@@ -1023,30 +1023,66 @@ Blockly.Blocks['rgbled_new'] = {
10231023
.appendField(Blockly.Msg.WEBDUINO_RGBLED, "RGBLed")
10241024
.appendField(Blockly.Msg.WEBDUINO_RGBLED_RED, "red")
10251025
.appendField(new Blockly.FieldDropdown([
1026-
["3", "3"],
1027-
["5", "5"],
1028-
["6", "6"],
1029-
["9", "9"],
1030-
["10", "10"],
1031-
["11", "11"]
1026+
["2", "2"],
1027+
["3~", "3"],
1028+
["4", "4"],
1029+
["5~", "5"],
1030+
["6~", "6"],
1031+
["7", "7"],
1032+
["8", "8"],
1033+
["9~", "9"],
1034+
["10~", "10"],
1035+
["11~", "11"],
1036+
["12", "12"],
1037+
["13", "13"],
1038+
["14 ( A0 )", "14"],
1039+
["15 ( A1 )", "15"],
1040+
["16 ( A2 )", "16"],
1041+
["17 ( A3 )", "17"],
1042+
["18 ( A4 )", "18"],
1043+
["19 ( A5 )", "19"]
10321044
]), "red_")
10331045
.appendField(Blockly.Msg.WEBDUINO_RGBLED_GREEN, "green")
10341046
.appendField(new Blockly.FieldDropdown([
1035-
["3", "3"],
1036-
["5", "5"],
1037-
["6", "6"],
1038-
["9", "9"],
1039-
["10", "10"],
1040-
["11", "11"]
1047+
["2", "2"],
1048+
["3~", "3"],
1049+
["4", "4"],
1050+
["5~", "5"],
1051+
["6~", "6"],
1052+
["7", "7"],
1053+
["8", "8"],
1054+
["9~", "9"],
1055+
["10~", "10"],
1056+
["11~", "11"],
1057+
["12", "12"],
1058+
["13", "13"],
1059+
["14 ( A0 )", "14"],
1060+
["15 ( A1 )", "15"],
1061+
["16 ( A2 )", "16"],
1062+
["17 ( A3 )", "17"],
1063+
["18 ( A4 )", "18"],
1064+
["19 ( A5 )", "19"]
10411065
]), "green_")
10421066
.appendField(Blockly.Msg.WEBDUINO_RGBLED_BLUE, "blue")
10431067
.appendField(new Blockly.FieldDropdown([
1044-
["3", "3"],
1045-
["5", "5"],
1046-
["6", "6"],
1047-
["9", "9"],
1048-
["10", "10"],
1049-
["11", "11"]
1068+
["2", "2"],
1069+
["3~", "3"],
1070+
["4", "4"],
1071+
["5~", "5"],
1072+
["6~", "6"],
1073+
["7", "7"],
1074+
["8", "8"],
1075+
["9~", "9"],
1076+
["10~", "10"],
1077+
["11~", "11"],
1078+
["12", "12"],
1079+
["13", "13"],
1080+
["14 ( A0 )", "14"],
1081+
["15 ( A1 )", "15"],
1082+
["16 ( A2 )", "16"],
1083+
["17 ( A3 )", "17"],
1084+
["18 ( A4 )", "18"],
1085+
["19 ( A5 )", "19"]
10501086
]), "blue_");
10511087
this.setOutput(true);
10521088
this.setColour(230);
@@ -1061,30 +1097,66 @@ Blockly.Blocks['rgbled_new_cathode'] = {
10611097
.appendField(Blockly.Msg.WEBDUINO_RGBLED_CATHODE, "RGBLed")
10621098
.appendField(Blockly.Msg.WEBDUINO_RGBLED_RED, "red")
10631099
.appendField(new Blockly.FieldDropdown([
1064-
["3", "3"],
1065-
["5", "5"],
1066-
["6", "6"],
1067-
["9", "9"],
1068-
["10", "10"],
1069-
["11", "11"]
1100+
["2", "2"],
1101+
["3~", "3"],
1102+
["4", "4"],
1103+
["5~", "5"],
1104+
["6~", "6"],
1105+
["7", "7"],
1106+
["8", "8"],
1107+
["9~", "9"],
1108+
["10~", "10"],
1109+
["11~", "11"],
1110+
["12", "12"],
1111+
["13", "13"],
1112+
["14 ( A0 )", "14"],
1113+
["15 ( A1 )", "15"],
1114+
["16 ( A2 )", "16"],
1115+
["17 ( A3 )", "17"],
1116+
["18 ( A4 )", "18"],
1117+
["19 ( A5 )", "19"]
10701118
]), "red_")
10711119
.appendField(Blockly.Msg.WEBDUINO_RGBLED_GREEN, "green")
10721120
.appendField(new Blockly.FieldDropdown([
1073-
["3", "3"],
1074-
["5", "5"],
1075-
["6", "6"],
1076-
["9", "9"],
1077-
["10", "10"],
1078-
["11", "11"]
1121+
["2", "2"],
1122+
["3~", "3"],
1123+
["4", "4"],
1124+
["5~", "5"],
1125+
["6~", "6"],
1126+
["7", "7"],
1127+
["8", "8"],
1128+
["9~", "9"],
1129+
["10~", "10"],
1130+
["11~", "11"],
1131+
["12", "12"],
1132+
["13", "13"],
1133+
["14 ( A0 )", "14"],
1134+
["15 ( A1 )", "15"],
1135+
["16 ( A2 )", "16"],
1136+
["17 ( A3 )", "17"],
1137+
["18 ( A4 )", "18"],
1138+
["19 ( A5 )", "19"]
10791139
]), "green_")
10801140
.appendField(Blockly.Msg.WEBDUINO_RGBLED_BLUE, "blue")
10811141
.appendField(new Blockly.FieldDropdown([
1082-
["3", "3"],
1083-
["5", "5"],
1084-
["6", "6"],
1085-
["9", "9"],
1086-
["10", "10"],
1087-
["11", "11"]
1142+
["2", "2"],
1143+
["3~", "3"],
1144+
["4", "4"],
1145+
["5~", "5"],
1146+
["6~", "6"],
1147+
["7", "7"],
1148+
["8", "8"],
1149+
["9~", "9"],
1150+
["10~", "10"],
1151+
["11~", "11"],
1152+
["12", "12"],
1153+
["13", "13"],
1154+
["14 ( A0 )", "14"],
1155+
["15 ( A1 )", "15"],
1156+
["16 ( A2 )", "16"],
1157+
["17 ( A3 )", "17"],
1158+
["18 ( A4 )", "18"],
1159+
["19 ( A5 )", "19"]
10881160
]), "blue_");
10891161
this.setOutput(true);
10901162
this.setColour(230);

generators/webduino.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ function _buzzer_music(m) {
967967
var musicNotes = {};
968968
musicNotes.notes = [];
969969
musicNotes.tempos = [];
970-
if (m.length > 1) {
970+
if (m[0].notes.length > 1) {
971971
for (var i = 0; i < m.length; i++) {
972972
if (Array.isArray(m[i].notes)) {
973973
var cn = musicNotes.notes.concat(m[i].notes);

0 commit comments

Comments
 (0)