@@ -1303,6 +1303,58 @@ Blockly.Blocks['buzzer_notes_tempos'] = {
13031303 }
13041304} ;
13051305
1306+ Blockly . Blocks [ 'buzzer_single' ] = {
1307+ init : function ( ) {
1308+ this . appendDummyInput ( )
1309+ . appendField ( Blockly . Msg . WEBDUINO_BUZZER_SINGLE , "使用" )
1310+ . appendField ( new Blockly . FieldVariable ( "buzzer" ) , "var_" )
1311+ . appendField ( Blockly . Msg . WEBDUINO_BUZZER_SINGLE_TONE , "播放單音,音調" )
1312+ . appendField ( new Blockly . FieldDropdown ( [
1313+ [ "C" , "C" ] ,
1314+ [ "CS" , "CS" ] ,
1315+ [ "D" , "D" ] ,
1316+ [ "DS" , "DS" ] ,
1317+ [ "E" , "E" ] ,
1318+ [ "F" , "F" ] ,
1319+ [ "FS" , "FS" ] ,
1320+ [ "G" , "G" ] ,
1321+ [ "GS" , "GS" ] ,
1322+ [ "A" , "A" ] ,
1323+ [ "AS" , "AS" ] ,
1324+ [ "B" , "B" ]
1325+ ] ) , "tone_" )
1326+ . appendField ( Blockly . Msg . WEBDUINO_BUZZER_SINGLE_PITCH , "音高" )
1327+ . appendField ( new Blockly . FieldDropdown ( [
1328+ [ "1" , "1" ] ,
1329+ [ "2" , "2" ] ,
1330+ [ "3" , "3" ] ,
1331+ [ "4" , "4" ] ,
1332+ [ "5" , "5" ] ,
1333+ [ "6" , "6" ] ,
1334+ [ "7" , "7" ]
1335+ ] ) , "pitch_" )
1336+ . appendField ( Blockly . Msg . WEBDUINO_BUZZER_SINGLE_TEMPOS , "節奏" )
1337+ . appendField ( new Blockly . FieldDropdown ( [
1338+ [ "1" , "1" ] ,
1339+ [ "2" , "2" ] ,
1340+ [ "3" , "3" ] ,
1341+ [ "4" , "4" ] ,
1342+ [ "5" , "5" ] ,
1343+ [ "6" , "6" ] ,
1344+ [ "7" , "7" ] ,
1345+ [ "8" , "8" ] ,
1346+ [ "9" , "9" ] ,
1347+ [ "10" , "10" ]
1348+ ] ) , "tempos_" ) ;
1349+ this . setInputsInline ( false ) ;
1350+ this . setPreviousStatement ( true ) ;
1351+ this . setNextStatement ( true ) ;
1352+ this . setTooltip ( '' ) ;
1353+ this . setColour ( 65 ) ;
1354+ this . setHelpUrl ( 'http://www.example.com/' ) ;
1355+ }
1356+ } ;
1357+
13061358// https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#vnhdso
13071359Blockly . Blocks [ 'buzzer_play' ] = {
13081360 init : function ( ) {
@@ -2490,3 +2542,108 @@ Blockly.Blocks['joystick_off'] = {
24902542 this . setHelpUrl ( 'http://www.example.com/' ) ;
24912543 }
24922544} ;
2545+
2546+
2547+ Blockly . Blocks [ 'document_onkeydown' ] = {
2548+ init : function ( ) {
2549+ this . appendDummyInput ( )
2550+ . appendField ( Blockly . Msg . WEBDUINO_KEYBOARD , "偵測鍵盤行為" ) ;
2551+ this . appendStatementInput ( "do_" ) ;
2552+ this . setInputsInline ( false ) ;
2553+ this . setPreviousStatement ( true ) ;
2554+ this . setNextStatement ( true ) ;
2555+ this . setTooltip ( '' ) ;
2556+ this . setColour ( 15 ) ;
2557+ this . setHelpUrl ( 'http://www.example.com/' ) ;
2558+ }
2559+ } ;
2560+
2561+ Blockly . Blocks [ 'document_alphabet_keycode' ] = {
2562+ init : function ( ) {
2563+ this . appendStatementInput ( "do_" )
2564+ . appendField ( Blockly . Msg . WEBDUINO_KEYBOARD_KEYDOWN , "如果按下" )
2565+ . appendField ( new Blockly . FieldDropdown ( [
2566+ [ "A" , "65" ] ,
2567+ [ "B" , "66" ] ,
2568+ [ "C" , "67" ] ,
2569+ [ "D" , "68" ] ,
2570+ [ "E" , "69" ] ,
2571+ [ "F" , "70" ] ,
2572+ [ "G" , "71" ] ,
2573+ [ "H" , "72" ] ,
2574+ [ "I" , "73" ] ,
2575+ [ "J" , "74" ] ,
2576+ [ "K" , "75" ] ,
2577+ [ "L" , "76" ] ,
2578+ [ "M" , "77" ] ,
2579+ [ "N" , "78" ] ,
2580+ [ "O" , "79" ] ,
2581+ [ "P" , "80" ] ,
2582+ [ "Q" , "81" ] ,
2583+ [ "R" , "82" ] ,
2584+ [ "S" , "83" ] ,
2585+ [ "T" , "84" ] ,
2586+ [ "U" , "85" ] ,
2587+ [ "V" , "86" ] ,
2588+ [ "W" , "87" ] ,
2589+ [ "X" , "88" ] ,
2590+ [ "Y" , "89" ] ,
2591+ [ "Z" , "90" ]
2592+ ] ) , "keycode_" )
2593+ . appendField ( Blockly . Msg . WEBDUINO_KEYBOARD_DO , ",執行:" ) ;
2594+ this . setInputsInline ( false ) ;
2595+ this . setPreviousStatement ( true ) ;
2596+ this . setNextStatement ( true ) ;
2597+ this . setTooltip ( '' ) ;
2598+ this . setColour ( 35 ) ;
2599+ this . setHelpUrl ( 'http://www.example.com/' ) ;
2600+ }
2601+ } ;
2602+
2603+ Blockly . Blocks [ 'document_other_keycode' ] = {
2604+ init : function ( ) {
2605+ this . appendStatementInput ( "do_" )
2606+ . appendField ( Blockly . Msg . WEBDUINO_KEYBOARD_KEYDOWN , "如果按下" )
2607+ . appendField ( new Blockly . FieldDropdown ( [
2608+ [ Blockly . Msg . WEBDUINO_KEYBOARD_SPACE , "32" ] ,
2609+ [ "enter" , "13" ] ,
2610+ [ Blockly . Msg . WEBDUINO_KEYBOARD_UP , , "38" ] ,
2611+ [ Blockly . Msg . WEBDUINO_KEYBOARD_DOWN , , "40" ] ,
2612+ [ Blockly . Msg . WEBDUINO_KEYBOARD_LEFT , , "37" ] ,
2613+ [ Blockly . Msg . WEBDUINO_KEYBOARD_RIGHT , , "39" ] ,
2614+ [ "0" , "48" ] ,
2615+ [ "1" , "49" ] ,
2616+ [ "2" , "50" ] ,
2617+ [ "3" , "51" ] ,
2618+ [ "4" , "52" ] ,
2619+ [ "5" , "53" ] ,
2620+ [ "6" , "54" ] ,
2621+ [ "7" , "55" ] ,
2622+ [ "8" , "56" ] ,
2623+ [ "9" , "57" ] ,
2624+ [ "shift" , "16" ] ,
2625+ [ "alt" , "18" ] ,
2626+ [ "ctrl" , "17" ] ,
2627+ [ "command(R)" , "93" ] ,
2628+ [ "command(L)" , "91" ] ,
2629+ [ "tab" , "9" ] ,
2630+ [ "+ -" , "187" ] ,
2631+ [ "- _" , "189" ] ,
2632+ [ "{ [" , "219" ] ,
2633+ [ "} ]" , "221" ] ,
2634+ [ "|" , "220" ] ,
2635+ [ "; :" , "186" ] ,
2636+ [ "\' \"" , "222" ] ,
2637+ [ "< ," , "188" ] ,
2638+ [ "> ." , "190" ] ,
2639+ [ "? /" , "191" ]
2640+ ] ) , "keycode_" )
2641+ . appendField ( Blockly . Msg . WEBDUINO_KEYBOARD_DO , ",執行:" ) ;
2642+ this . setInputsInline ( false ) ;
2643+ this . setPreviousStatement ( true ) ;
2644+ this . setNextStatement ( true ) ;
2645+ this . setTooltip ( '' ) ;
2646+ this . setColour ( 35 ) ;
2647+ this . setHelpUrl ( 'http://www.example.com/' ) ;
2648+ }
2649+ } ;
0 commit comments