@@ -120,10 +120,11 @@ Blockly.Blocks.check_pin_input = {
120120 init : function ( ) {
121121 this . setTooltip ( Blockly . MSG_CHECK_PIN_INPUT_TOOLTIP ) ;
122122 this . setColour ( colorPalette . getColor ( 'io' ) ) ;
123- this . appendDummyInput ( "" )
124- . appendField ( "check PIN" ) ;
125123 this . appendValueInput ( 'PIN' )
126- . setCheck ( 'Number' ) ;
124+ . appendField ( "check PIN" )
125+ . setCheck ( 'Number' )
126+ . appendField ( 'A,' + profile . default . digital . toString ( ) , 'RANGEVALS0' ) ;
127+ this . getField ( 'RANGEVALS0' ) . setVisible ( false ) ;
127128 this . setOutput ( true , 'Number' ) ;
128129 this . setInputsInline ( true ) ;
129130 }
@@ -531,10 +532,12 @@ Blockly.Blocks.eeprom_read = {
531532 . setCheck ( "Number" )
532533 . appendField ( "EEPROM read" )
533534 . appendField ( new Blockly . FieldDropdown ( [ [ "number" , "NUMBER" ] , [ "text" , "TEXT" ] , [ "byte" , "BYTE" ] ] ) , "TYPE" )
535+ . appendField ( 'R,0,7675,0' , 'RANGEVALS0' )
534536 . appendField ( "from address" ) ;
535537 this . appendDummyInput ( )
536538 . appendField ( "store in" )
537539 . appendField ( new Blockly . FieldVariable ( Blockly . LANG_VARIABLES_GET_ITEM ) , 'VALUE' ) ;
540+ this . getField ( 'RANGEVALS0' ) . setVisible ( false ) ;
538541 this . setInputsInline ( true ) ;
539542 this . setPreviousStatement ( true , null ) ;
540543 this . setNextStatement ( true , null ) ;
@@ -716,7 +719,9 @@ Blockly.Blocks.ab_volt_out = {
716719 this . appendValueInput ( "VALUE" )
717720 . setCheck ( 'Number' )
718721 . setAlign ( Blockly . ALIGN_RIGHT )
722+ . appendField ( 'R,0,330,0' , 'RANGEVALS1' )
719723 . appendField ( "volt-100ths" ) ;
724+ this . getField ( 'RANGEVALS1' ) . setVisible ( false ) ;
720725 this . setInputsInline ( true ) ;
721726 this . setPreviousStatement ( true , null ) ;
722727 this . setNextStatement ( true , null ) ;
@@ -767,9 +772,10 @@ Blockly.Blocks.pwm_set = {
767772 . appendField ( "channel" )
768773 . appendField ( new Blockly . FieldDropdown ( [ [ "A" , "0" ] , [ "B" , "1" ] ] ) , "CHANNEL" ) ;
769774 this . appendValueInput ( "DUTY_CYCLE" , Number )
775+ . appendField ( 'R,0,100,0' , 'RANGEVALS1' )
770776 . setCheck ( 'Number' )
771- . appendField ( "duty cycle (0 - 100 )" ) ;
772-
777+ . appendField ( "duty cycle (% )" ) ;
778+ this . getField ( 'RANGEVALS1' ) . setVisible ( false ) ;
773779 this . setInputsInline ( true ) ;
774780 this . setPreviousStatement ( true , null ) ;
775781 this . setNextStatement ( true , null ) ;
@@ -862,7 +868,9 @@ Blockly.Blocks.wav_volume = {
862868 this . setTooltip ( Blockly . MSG_WAV_VOLUME_TOOLTIP ) ;
863869 this . setColour ( colorPalette . getColor ( 'io' ) ) ;
864870 this . appendValueInput ( 'VOLUME' )
865- . appendField ( "WAV volume (0 - 10)" ) ;
871+ . appendField ( "WAV volume (0 - 10)" )
872+ . appendField ( 'R,0,10,0' , 'RANGEVALS1' ) ;
873+ this . getField ( 'RANGEVALS1' ) . setVisible ( false ) ;
866874 this . setInputsInline ( true ) ;
867875 this . setPreviousStatement ( true , null ) ;
868876 this . setNextStatement ( true , null ) ;
@@ -874,13 +882,12 @@ Blockly.propc.wav_volume = function () {
874882
875883 Blockly . propc . definitions_ [ "include wavplayer" ] = '#include "wavplayer.h"' ;
876884
877- if ( Number ( volume ) < 0 ) {
878- volume = '0' ;
879- } else if ( Number ( volume ) > 10 ) {
880- volume = '10' ;
881- }
885+ var setup_code = '// Constrain Function\nint constrain(int __cVal, int __cMin, int __cMax) {' ;
886+ setup_code += 'if(__cVal < __cMin) __cVal = __cMin;\n' ;
887+ setup_code += 'if(__cVal > __cMax) __cVal = __cMax;\nreturn __cVal;\n}\n' ;
888+ Blockly . propc . global_vars_ [ "constrain_function" ] = setup_code ;
882889
883- var code = 'wav_volume(' + volume + ');\n' ;
890+ var code = 'wav_volume(constrain( ' + volume + ', 0, 10) );\n' ;
884891 return code ;
885892} ;
886893
@@ -1015,13 +1022,17 @@ Blockly.Blocks.ab_drive_goto = {
10151022 . appendField ( 'Robot drive distance in' )
10161023 . appendField ( new Blockly . FieldDropdown ( [ [ "ticks" , "TICK" ] , [ "centimeters" , "CM" ] , [ "inches" , "INCH" ] ] ) , "UNITS" ) ;
10171024 this . appendValueInput ( "LEFT" )
1025+ . appendField ( 'R,-4227330,4227330,0' , 'RANGEVALS0' )
10181026 . setCheck ( 'Number' )
10191027 . setAlign ( Blockly . ALIGN_RIGHT )
10201028 . appendField ( "left" ) ;
10211029 this . appendValueInput ( "RIGHT" )
1030+ . appendField ( 'R,-4227330,4227330,0' , 'RANGEVALS1' )
10221031 . setCheck ( 'Number' )
10231032 . setAlign ( Blockly . ALIGN_RIGHT )
10241033 . appendField ( "right" ) ;
1034+ this . getField ( 'RANGEVALS0' ) . setVisible ( false ) ;
1035+ this . getField ( 'RANGEVALS1' ) . setVisible ( false ) ;
10251036 this . setInputsInline ( false ) ;
10261037 this . setPreviousStatement ( true , null ) ;
10271038 this . setNextStatement ( true , null ) ;
0 commit comments