@@ -38,30 +38,35 @@ Blockly.Blocks.debug_lcd_init = {
3838 . appendField ( "baud" )
3939 . appendField ( new Blockly . FieldDropdown ( [ [ "2400" , "2400" ] , [ "9600" , "9600" ] , [ "19200" , "19200" ] ] ) , "BAUD" ) ;
4040
41+ this . setInputsInline ( true ) ;
4142 this . setPreviousStatement ( true , null ) ;
4243 this . setNextStatement ( true , null ) ;
4344 }
4445} ;
4546
46- //Blockly.Blocks.debug_lcd_clear = {
47- // init: function () {
48- // this.setColour(colorPalette.getColor('protocols'));
49- // this.appendDummyInput()
50- // .appendField("LCD clear");
51- //
52- // this.setPreviousStatement(true, null);
53- // this.setNextStatement(true, null);
54- // }
55- //};
47+ Blockly . Blocks . debug_lcd_music_note = {
48+ init : function ( ) {
49+ this . setColour ( colorPalette . getColor ( 'protocols' ) ) ;
50+ this . appendDummyInput ( )
51+ . appendField ( "LCD play note" )
52+ . appendField ( new Blockly . FieldDropdown ( [ [ "C" , "223" ] , [ "C#" , "224" ] , [ "D" , "225" ] , [ "D#" , "226" ] , [ "E" , "227" ] , [ "F" , "228" ] , [ "F#" , "229" ] , [ "G" , "230" ] , [ "G#" , "231" ] , [ "A" , "220" ] , [ "A#" , "221" ] , [ "B" , "222" ] , [ "no note (rest)" , "232" ] ] ) , "NOTE" )
53+ . appendField ( "octave" )
54+ . appendField ( new Blockly . FieldDropdown ( [ [ "3rd" , "215" ] , [ "4th" , "216" ] , [ "5th" , "217" ] , [ "6th" , "218" ] , [ "7th" , "219" ] ] ) , "OCTAVE" )
55+ . appendField ( "length" )
56+ . appendField ( new Blockly . FieldDropdown ( [ [ "whole (2 s)" , "214" ] , [ "half (1 s)" , "213" ] , [ "quarter (500 ms)" , "212" ] , [ "eigth (250 ms)" , "211" ] , [ "sixteenth (125 ms)" , "210" ] , [ "thirty-second (63 ms)" , "209" ] , [ "sixty-fourth (31 ms)" , "208" ] ] ) , "LENGTH" ) ;
57+
58+ this . setPreviousStatement ( true , null ) ;
59+ this . setNextStatement ( true , null ) ;
60+ }
61+ } ;
5662
5763Blockly . Blocks . debug_lcd_print = {
58- init : function ( ) {
64+ init : function ( ) {
5965 this . setColour ( colorPalette . getColor ( 'protocols' ) ) ;
60- this . appendDummyInput ( "" )
61- . appendField ( "LCD print" )
62- . appendField ( quotes . newQuote_ ( true ) )
63- . appendField ( new Blockly . FieldTextInput ( '' ) , 'TEXT' )
64- . appendField ( quotes . newQuote_ ( false ) ) ;
66+ this . appendValueInput ( 'MESSAGE' )
67+ . setCheck ( 'String' )
68+ . appendField ( "LCD print text " ) ;
69+ this . setInputsInline ( true ) ;
6570 this . setPreviousStatement ( true , null ) ;
6671 this . setNextStatement ( true , null ) ;
6772 }
@@ -70,12 +75,16 @@ Blockly.Blocks.debug_lcd_print = {
7075Blockly . Blocks . debug_lcd_number = {
7176 init : function ( ) {
7277 this . setColour ( colorPalette . getColor ( 'protocols' ) ) ;
78+ this . appendValueInput ( 'VALUE' )
79+ . appendField ( "LCD print number" ) ;
7380 this . appendDummyInput ( )
74- . appendField ( "LCD print" ) ;
75- this . appendValueInput ( 'NUMBER' , Number )
76- . appendField ( "number" )
77- . setCheck ( 'Number' ) ;
78-
81+ . appendField ( "as" )
82+ . appendField ( new Blockly . FieldDropdown ( [
83+ [ 'Decimal' , 'DEC' ] ,
84+ [ 'Hexadecimal' , 'HEX' ] ,
85+ [ 'Binary' , 'BIN' ]
86+ ] ) , "FORMAT" ) ;
87+ this . setInputsInline ( true ) ;
7988 this . setPreviousStatement ( true , null ) ;
8089 this . setNextStatement ( true , null ) ;
8190 }
@@ -120,16 +129,40 @@ Blockly.propc.debug_lcd_init = function () {
120129// return 'writeChar(debug_lcd, 12);\npause(5);\n';
121130//};
122131
132+ Blockly . propc . debug_lcd_music_note = function ( ) {
133+ var dropdown_note = this . getFieldValue ( 'NOTE' ) ;
134+ var dropdown_octave = this . getFieldValue ( 'OCTAVE' ) ;
135+ var dropdown_length = this . getFieldValue ( 'LENGTH' ) ;
136+
137+ var code = 'writeChar(debug_lcd, ' + dropdown_octave + ');\n' ;
138+ code += 'writeChar(debug_lcd, ' + dropdown_length + ');\n' ;
139+ code += 'writeChar(debug_lcd, ' + dropdown_note + ');\n' ;
140+
141+ return code ;
142+ } ;
143+
123144Blockly . propc . debug_lcd_print = function ( ) {
124- var text = this . getFieldValue ( 'TEXT' ) ;
145+ var msg = Blockly . propc . valueToCode ( this , 'MESSAGE' , Blockly . propc . ORDER_NONE ) ;
146+ var code = 'dprint(debug_lcd, ' + msg + ');' ;
125147
126- return 'dprint(debug_lcd, "' + text + '");\n' ;
148+ return code ;
127149} ;
128150
129151Blockly . propc . debug_lcd_number = function ( ) {
130- var number = Blockly . propc . valueToCode ( this , 'NUMBER' , Blockly . propc . ORDER_UNARY_PREFIX ) || '0' ;
131-
132- return 'dprint(debug_lcd, "' + number + '");\n' ;
152+ var value = Blockly . propc . valueToCode ( this , 'VALUE' , Blockly . propc . ORDER_ATOMIC ) ;
153+ var format = this . getFieldValue ( 'FORMAT' ) ;
154+
155+ var code = 'dprint(debug_lcd, ' ;
156+ if ( format === 'BIN' ) {
157+ code += '"%b"' ;
158+ } else if ( format === 'HEX' ) {
159+ code += '"%x"' ;
160+ } else {
161+ code += '"%d"' ;
162+ }
163+
164+ code += ', ' + value + ');' ;
165+ return code ;
133166} ;
134167
135168Blockly . propc . debug_lcd_action = function ( ) {
0 commit comments