forked from google/blockly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharduino_compressed.js
61 lines (60 loc) · 23.1 KB
/
arduino_compressed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Do not edit this file; automatically generated by build.py.
'use strict';
/*
Licensed under the Apache License, Version 2.0 (the "License"):
http://www.apache.org/licenses/LICENSE-2.0
*/
Blockly.Arduino=new Blockly.Generator("Arduino");Blockly.Arduino.addReservedWords("Blockly,setup,loop,if,else,for,switch,case,while,do,break,continue,return,goto,define,include,HIGH,LOW,INPUT,OUTPUT,INPUT_PULLUP,true,false,integer,constants,floating,point,void,boolean,char,unsigned,byte,int,word,long,float,double,string,String,array,static,volatile,const,sizeof,pinMode,digitalWrite,digitalRead,analogReference,analogRead,analogWrite,tone,noTone,shiftOut,shitIn,pulseIn,millis,micros,delay,delayMicroseconds,min,max,abs,constrain,map,pow,sqrt,sin,cos,tan,randomSeed,random,lowByte,highByte,bitRead,bitWrite,bitSet,bitClear,bit,attachInterrupt,detachInterrupt,interrupts,noInterrupts");
Blockly.Arduino.ORDER_ATOMIC=0;Blockly.Arduino.ORDER_UNARY_POSTFIX=1;Blockly.Arduino.ORDER_UNARY_PREFIX=2;Blockly.Arduino.ORDER_MULTIPLICATIVE=3;Blockly.Arduino.ORDER_ADDITIVE=4;Blockly.Arduino.ORDER_SHIFT=5;Blockly.Arduino.ORDER_RELATIONAL=6;Blockly.Arduino.ORDER_EQUALITY=7;Blockly.Arduino.ORDER_BITWISE_AND=8;Blockly.Arduino.ORDER_BITWISE_XOR=9;Blockly.Arduino.ORDER_BITWISE_OR=10;Blockly.Arduino.ORDER_LOGICAL_AND=11;Blockly.Arduino.ORDER_LOGICAL_OR=12;Blockly.Arduino.ORDER_CONDITIONAL=13;
Blockly.Arduino.ORDER_ASSIGNMENT=14;Blockly.Arduino.ORDER_NONE=99;Blockly.Arduino.DEF_FUNC_NAME=Blockly.Arduino.FUNCTION_NAME_PLACEHOLDER_;
Blockly.Arduino.init=function(a){Blockly.Arduino.includes_=Object.create(null);Blockly.Arduino.definitions_=Object.create(null);Blockly.Arduino.variables_=Object.create(null);Blockly.Arduino.codeFunctions_=Object.create(null);Blockly.Arduino.userFunctions_=Object.create(null);Blockly.Arduino.functionNames_=Object.create(null);Blockly.Arduino.setups_=Object.create(null);Blockly.Arduino.variableDB_?Blockly.Arduino.variableDB_.reset():Blockly.Arduino.variableDB_=new Blockly.Names(Blockly.Arduino.RESERVED_WORDS_)};
Blockly.Arduino.finish=function(a){var b=[],c=[],d=[],e=[],f;for(f in Blockly.Arduino.includes_)b.push(Blockly.Arduino.includes_[f]);b.length&&b.push("\n");for(f in Blockly.Arduino.variables_)d.push(Blockly.Arduino.variables_[f]);d.length&&d.push("\n");for(f in Blockly.Arduino.definitions_)c.push(Blockly.Arduino.definitions_[f]);c.length&&c.push("\n");for(f in Blockly.Arduino.codeFunctions_)e.push(Blockly.Arduino.codeFunctions_[f]);for(f in Blockly.Arduino.userFunctions_)e.push(Blockly.Arduino.userFunctions_[f]);
e.length&&e.push("\n");var g=[""],h="";void 0!==Blockly.Arduino.setups_.userSetupCode&&(h="\n"+Blockly.Arduino.setups_.userSetupCode,delete Blockly.Arduino.setups_.userSetupCode);for(f in Blockly.Arduino.setups_)g.push(Blockly.Arduino.setups_[f]);h&&g.push(h);delete Blockly.Arduino.includes_;delete Blockly.Arduino.definitions_;delete Blockly.Arduino.codeFunctions_;delete Blockly.Arduino.userFunctions_;delete Blockly.Arduino.functionNames_;delete Blockly.Arduino.setups_;Blockly.Arduino.variableDB_.reset();
b=b.join("\n")+d.join("\n")+c.join("\n")+e.join("\n\n");g="void setup() {"+g.join("\n ")+"\n}\n\n";a="void loop() {\n "+a.replace(/\n/g,"\n ")+"\n}";return b+g+a};Blockly.Arduino.addInclude=function(a,b){void 0===Blockly.Arduino.includes_[a]&&(Blockly.Arduino.includes_[a]=b)};Blockly.Arduino.addDeclaration=function(a,b){void 0===Blockly.Arduino.definitions_[a]&&(Blockly.Arduino.definitions_[a]=b)};
Blockly.Arduino.addVariable=function(a,b,c){var d=!1;if(c||void 0===Blockly.Arduino.variables_[a])Blockly.Arduino.variables_[a]=b,d=!0;return d};Blockly.Arduino.addSetup=function(a,b,c){var d=!1;if(c||void 0===Blockly.Arduino.setups_[a])Blockly.Arduino.setups_[a]=b,d=!0;return d};
Blockly.Arduino.addFunction=function(a,b){if(void 0===Blockly.Arduino.codeFunctions_[a]){var c=Blockly.Arduino.variableDB_.getDistinctName(a,Blockly.Generator.NAME_TYPE);Blockly.Arduino.codeFunctions_[a]=b.replace(Blockly.Arduino.DEF_FUNC_NAME,c);Blockly.Arduino.functionNames_[a]=c}return Blockly.Arduino.functionNames_[a]};Blockly.Arduino.scrubNakedValue=function(a){return a+";\n"};
Blockly.Arduino.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/\$/g,"\\$").replace(/'/g,"\\'");return'"'+a+'"'};
Blockly.Arduino.scrub_=function(a,b){if(null===b)return"";var c="";if(!a.outputConnection||!a.outputConnection.targetConnection){var d=a.getCommentText();d&&(c+=this.prefixLines(d,"// ")+"\n");for(var e=0;e<a.inputList.length;e++)a.inputList[e].type==Blockly.INPUT_VALUE&&(d=a.inputList[e].connection.targetBlock())&&(d=this.allNestedComments(d))&&(c+=this.prefixLines(d,"// "))}e=a.nextConnection&&a.nextConnection.targetBlock();e=this.blockToCode(e);return c+b+e};
Blockly.Arduino.getArduinoType_=function(a){switch(a.typeId){case Blockly.Types.SHORT_NUMBER.typeId:return"char";case Blockly.Types.NUMBER.typeId:return"int";case Blockly.Types.LARGE_NUMBER.typeId:return"long";case Blockly.Types.DECIMAL.typeId:return"float";case Blockly.Types.TEXT.typeId:return"String";case Blockly.Types.CHARACTER.typeId:return"char";case Blockly.Types.BOOLEAN.typeId:return"boolean";case Blockly.Types.NULL.typeId:return"void";case Blockly.Types.UNDEF.typeId:return"undefined";case Blockly.Types.CHILD_BLOCK_MISSING.typeId:return"int";
default:return"Invalid Blockly Type"}};Blockly.Arduino.noGeneratorCodeInline=function(){return["",Blockly.Arduino.ORDER_ATOMIC]};Blockly.Arduino.noGeneratorCodeLine=function(){return""};
Blockly.Arduino.basic={};Blockly.Arduino.basic_delay=function(a){return"delay("+Blockly.Arduino.valueToCode(a,"DELAY",Blockly.Arduino.ORDER_ATOMIC)+");\n"};Blockly.Arduino.basic_delaymicroseconds=function(a){return"delayMicroseconds("+Blockly.Arduino.valueToCode(a,"DELAY",Blockly.Arduino.ORDER_ATOMIC)+");\n"};Blockly.Arduino.basic_millis=function(a){return["millis()",Blockly.Arduino.ORDER_ATOMIC]};Blockly.Arduino.basic_infiniteloop=function(a){return"while(true);\n"};
Blockly.Arduino.basic_micros=function(a){return["micros()",Blockly.Arduino.ORDER_ATOMIC]};Blockly.Arduino.basic_map=function(a){var b=Blockly.Arduino.valueToCode(a,"NUM",Blockly.Arduino.ORDER_ATOMIC)||"0";a=Blockly.Arduino.valueToCode(a,"DMAX",Blockly.Arduino.ORDER_ATOMIC)||"0";return["map("+b+", 0, 1024, 0, "+a+")",Blockly.Arduino.ORDER_ATOMIC]};
Blockly.Arduino.basic_serialbegin=function(a){var b=a.getFieldValue("serial_port");a=a.getFieldValue("BAUDS");Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");Blockly.Arduino.addSetup("setup_"+b+"_Begin",b+".begin("+a+");",!0);return""};
Blockly.Arduino.basic_serialprint=function(a){var b=a.getFieldValue("serial_port"),c=a.getFieldValue("newline");a=Blockly.Arduino.valueToCode(a,"NAME",Blockly.Arduino.ORDER_ATOMIC)||"0";Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");Blockly.Arduino.addSetup("setup_"+b+"_Begin",b+".begin(9600);",!1);return b=b+("TRUE"==c?".println(":".print(")+(a+");\n")};
Blockly.Arduino.basic_serialavailable=function(a){a=a.getFieldValue("serial_port");Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");Blockly.Arduino.addSetup("setup_"+a+"_Begin",a+".begin(9600);",!1);return[a+".available()",Blockly.Arduino.ORDER_ATOMIC]};
Blockly.Arduino.basic_serialread=function(a){a=a.getFieldValue("serial_port");Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");Blockly.Arduino.addSetup("setup_"+a+"_Begin",a+".begin(9600);",!1);return[a+".read()",Blockly.Arduino.ORDER_ATOMIC]};Blockly.Arduino.brainzy={};Blockly.Arduino.brainzy_isbuttonledon=function(a){a=a.getFieldValue("state");Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");return["ON"==a?"Robby.isLedButtonOn()":"!Robby.isLedButtonOn()",Blockly.Arduino.ORDER_ATOMIC]};Blockly.Arduino.brainzy_isledon=function(a){a=a.getFieldValue("state");Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");return["ON"==a?"Robby.isLedOn()":"!Robby.isLedOn()",Blockly.Arduino.ORDER_ATOMIC]};
Blockly.Arduino.brainzy_turnled=function(a){a=a.getFieldValue("state");Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");return"Robby.led"+a+"();\n"};Blockly.Arduino.brainzy_turnbuttonled=function(a){a=a.getFieldValue("state");Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");return"Robby.ledButton"+a+"();\n"};Blockly.Arduino.brainzy_resetwheelangularpositions=function(a){Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");return"Robby.resetWheelAngularPositions();\n"};
Blockly.Arduino.brainzy_xpositionread=function(a){Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");return["Robby.xPositionRead()",Blockly.Arduino.ORDER_ATOMIC]};Blockly.Arduino.brainzy_ypositionread=function(a){Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");return["Robby.yPositionRead()",Blockly.Arduino.ORDER_ATOMIC]};
Blockly.Arduino.brainzy_angularpositionread=function(a){Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");return["Robby.angularPositionRead()",Blockly.Arduino.ORDER_ATOMIC]};
Blockly.Arduino.brainzy_positionwrite=function(a){var b=Blockly.Arduino.valueToCode(a,"xposition",Blockly.Arduino.ORDER_ATOMIC)||"0",c=Blockly.Arduino.valueToCode(a,"yposition",Blockly.Arduino.ORDER_ATOMIC)||"0";a=Blockly.Arduino.valueToCode(a,"angularposition",Blockly.Arduino.ORDER_ATOMIC)||"0";Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");return"Robby.xPositionWrite("+b+");\nRobby.yPositionWrite("+c+");\nRobby.angularPositionWrite("+a+");\n"};
Blockly.Arduino.brainzy_motorpositionread=function(a){a=a.getFieldValue("NAME");Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");return["Robby."+a+"MotorPositionRead()",Blockly.Arduino.ORDER_ATOMIC]};Blockly.Arduino.brainzy_setmode=function(a){a=a.getFieldValue("mode");Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");Blockly.Arduino.addSetup("setup_setMode","Robby.setMode("+a+");",!1);Blockly.Arduino.addSetup("setup_controlMode","Robby.noSlaved();",!1);return""};
Blockly.Arduino.brainzy_isbutton=function(a){a=a.getFieldValue("state");Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");return["Robby.isButton"+a+"()",Blockly.Arduino.ORDER_ATOMIC]};Blockly.Arduino.brainzy_blinkled=function(a){var b=a.getFieldValue("NAME");a=Blockly.Arduino.valueToCode(a,"time",Blockly.Arduino.ORDER_ATOMIC);Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");return"Robby."+b+"Blink("+a+");\n"};
Blockly.Arduino.brainzy_noblinkled=function(a){a=a.getFieldValue("NAME");Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");return"Robby."+a+"NoBlink();\n"};Blockly.Arduino.angle=function(a){return[a.getFieldValue("angle"),Blockly.Arduino.ORDER_ATOMIC]};Blockly.Arduino.brainzy_playnote=function(a){var b=a.getFieldValue("note");a=a.getFieldValue("octave");Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");return"Robby.playNote(NOTE_"+b+","+a+");\n"};
Blockly.Arduino.brainzy_stop=function(a){Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");return"Robby.stop();\n"};Blockly.Arduino.brainzy_translate=function(a){var b=Blockly.Arduino.valueToCode(a,"distance",Blockly.Arduino.ORDER_ATOMIC);a=a.getFieldValue("direction");Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");Blockly.Arduino.addSetup("setup_controlMode","Robby.slaved();",!0);return"Robby.translate("+b+","+a+");\nRobby.waitActionDone();\n"};
Blockly.Arduino.brainzy_turn=function(a){a=a.getFieldValue("direction");Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");Blockly.Arduino.addSetup("setup_controlMode","Robby.slaved();",!0);return"Robby.turn("+a+");\nRobby.waitActionDone();\n"};Blockly.Arduino.brainzy_pointto=function(a){a=a.getFieldValue("direction");Blockly.Arduino.addInclude("include_brainzy","#include <BRAINZY.h>");Blockly.Arduino.addSetup("setup_controlMode","Robby.slaved();",!0);return"Robby.pointTo("+a+");\nRobby.waitActionDone();\n"};Blockly.Arduino.logic={};Blockly.Arduino.controls_if=function(a){var b=0,c="";do{var d=Blockly.Arduino.valueToCode(a,"IF"+b,Blockly.Arduino.ORDER_NONE)||"false";var e=Blockly.Arduino.statementToCode(a,"DO"+b);c+=(0<b?"else ":"")+"if ("+d+") {\n"+e+"}";++b}while(a.getInput("IF"+b));a.getInput("ELSE")&&(e=Blockly.Arduino.statementToCode(a,"ELSE"),c+=" else {\n"+e+"}");return c+"\n"};Blockly.Arduino.controls_ifelse=Blockly.Arduino.controls_if;
Blockly.Arduino.logic_compare=function(a){var b={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c="=="==b||"!="==b?Blockly.Arduino.ORDER_EQUALITY:Blockly.Arduino.ORDER_RELATIONAL,d=Blockly.Arduino.valueToCode(a,"A",c)||"0";a=Blockly.Arduino.valueToCode(a,"B",c)||"0";return[d+" "+b+" "+a,c]};
Blockly.Arduino.logic_operation=function(a){var b="AND"==a.getFieldValue("OP")?"&&":"||",c="&&"==b?Blockly.Arduino.ORDER_LOGICAL_AND:Blockly.Arduino.ORDER_LOGICAL_OR,d=Blockly.Arduino.valueToCode(a,"A",c);a=Blockly.Arduino.valueToCode(a,"B",c);if(d||a){var e="&&"==b?"true":"false";d||(d=e);a||(a=e)}else a=d="false";return[d+" "+b+" "+a,c]};Blockly.Arduino.logic_negate=function(a){var b=Blockly.Arduino.ORDER_UNARY_PREFIX;return["!"+(Blockly.Arduino.valueToCode(a,"BOOL",b)||"true"),b]};
Blockly.Arduino.logic_boolean=function(a){return["TRUE"==a.getFieldValue("BOOL")?"true":"false",Blockly.Arduino.ORDER_ATOMIC]};Blockly.Arduino.logic_null=function(a){return["null",Blockly.Arduino.ORDER_ATOMIC]};
Blockly.Arduino.logic_ternary=function(a){var b=Blockly.Arduino.valueToCode(a,"IF",Blockly.Arduino.ORDER_CONDITIONAL)||"false",c=Blockly.Arduino.valueToCode(a,"THEN",Blockly.Arduino.ORDER_CONDITIONAL)||"null";a=Blockly.Arduino.valueToCode(a,"ELSE",Blockly.Arduino.ORDER_CONDITIONAL)||"null";return[b+" ? "+c+" : "+a,Blockly.Arduino.ORDER_CONDITIONAL]};Blockly.Arduino.loops={};
Blockly.Arduino.controls_repeat_ext=function(a){var b=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):Blockly.Arduino.valueToCode(a,"TIMES",Blockly.Arduino.ORDER_ASSIGNMENT)||"0",c=Blockly.Arduino.statementToCode(a,"DO");c=Blockly.Arduino.addLoopTrap(c,a.id);a="";var d=Blockly.Arduino.variableDB_.getDistinctName("count",Blockly.Variables.NAME_TYPE),e=b;b.match(/^\w+$/)||Blockly.isNumber(b)||(e=Blockly.Arduino.variableDB_.getDistinctName("repeat_end",Blockly.Variables.NAME_TYPE),a+="int "+
e+" = "+b+";\n");return a+("for (int "+d+" = 0; "+d+" < "+e+"; "+d+"++) {\n"+c+"}\n")};Blockly.Arduino.controls_repeat=Blockly.Arduino.controls_repeat_ext;Blockly.Arduino.controls_whileUntil=function(a){var b="UNTIL"==a.getFieldValue("MODE"),c=Blockly.Arduino.valueToCode(a,"BOOL",b?Blockly.Arduino.ORDER_UNARY_PREFIX:Blockly.Arduino.ORDER_NONE)||"false",d=Blockly.Arduino.statementToCode(a,"DO");d=Blockly.Arduino.addLoopTrap(d,a.id);b&&(c="!"+c);return"while ("+c+") {\n"+d+"}\n"};
Blockly.Arduino.controls_for=function(a){var b=Blockly.Arduino.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),c=Blockly.Arduino.valueToCode(a,"FROM",Blockly.Arduino.ORDER_ASSIGNMENT)||"0",d=Blockly.Arduino.valueToCode(a,"TO",Blockly.Arduino.ORDER_ASSIGNMENT)||"0",e=Blockly.Arduino.valueToCode(a,"BY",Blockly.Arduino.ORDER_ASSIGNMENT)||"1",f=Blockly.Arduino.statementToCode(a,"DO");f=Blockly.Arduino.addLoopTrap(f,a.id);if(Blockly.isNumber(c)&&Blockly.isNumber(d)&&Blockly.isNumber(e)){var g=
parseFloat(c)<=parseFloat(d);a="for ("+b+" = "+c+"; "+b+(g?" <= ":" >= ")+d+"; "+b;b=Math.abs(parseFloat(e));a=(1==b?a+(g?"++":"--"):a+((g?" += ":" -= ")+b))+(") {\n"+f+"}\n")}else a="",g=c,c.match(/^\w+$/)||Blockly.isNumber(c)||(g=Blockly.Arduino.variableDB_.getDistinctName(b+"_start",Blockly.Variables.NAME_TYPE),a+="int "+g+" = "+c+";\n"),c=d,d.match(/^\w+$/)||Blockly.isNumber(d)||(c=Blockly.Arduino.variableDB_.getDistinctName(b+"_end",Blockly.Variables.NAME_TYPE),a+="int "+c+" = "+d+";\n"),d=Blockly.Arduino.variableDB_.getDistinctName(b+
"_inc",Blockly.Variables.NAME_TYPE),a+="num "+d+" = ",a=Blockly.isNumber(e)?a+(Math.abs(e)+";\n"):a+("("+e+").abs();\n"),a=a+("if ("+g+" > "+c+") {\n")+(Blockly.Arduino.INDENT+d+" = -"+d+";\n"),a+="}\n",a+="for ("+b+" = "+g+";\n "+d+" >= 0 ? "+b+" <= "+c+" : "+b+" >= "+c+";\n "+b+" += "+d+") {\n"+f+"}\n";return a};
Blockly.Arduino.controls_flow_statements=function(a){switch(a.getFieldValue("FLOW")){case "BREAK":return"break;\n";case "CONTINUE":return"continue;\n"}throw"Unknown flow statement.";};Blockly.Arduino.math={};Blockly.Arduino.addReservedWords("Math");Blockly.Arduino.math_number=function(a){a=parseFloat(a.getFieldValue("NUM"));if(Infinity==a){a="NaN";var b=Blockly.Arduino.ORDER_UNARY_POSTFIX}else-Infinity==a?(a="NaN",b=Blockly.Arduino.ORDER_UNARY_PREFIX):b=0>a?Blockly.Arduino.ORDER_UNARY_PREFIX:Blockly.Arduino.ORDER_ATOMIC;return[a,b]};
Blockly.Arduino.math_arithmetic=function(a){var b={ADD:[" + ",Blockly.Arduino.ORDER_ADDITIVE],MINUS:[" - ",Blockly.Arduino.ORDER_ADDITIVE],MULTIPLY:[" * ",Blockly.Arduino.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",Blockly.Arduino.ORDER_MULTIPLICATIVE],POWER:[null,Blockly.Arduino.ORDER_NONE]}[a.getFieldValue("OP")],c=b[0];b=b[1];var d=Blockly.Arduino.valueToCode(a,"A",b)||"0";a=Blockly.Arduino.valueToCode(a,"B",b)||"0";return c?[d+c+a,b]:["pow("+d+", "+a+")",Blockly.Arduino.ORDER_UNARY_POSTFIX]};
Blockly.Arduino.math_single=function(a){var b=a.getFieldValue("OP");a=Blockly.Arduino.valueToCode(a,"NUM",Blockly.Arduino.ORDER_UNARY_PREFIX)||"0";if("NEG"==b)return"-"==a[0]&&(a=" "+a),["-"+a,Blockly.Arduino.ORDER_UNARY_PREFIX];switch(b){case "ABS":var c="abs("+a+")";break;case "ROOT":c="sqrt("+a+")";break;case "POW10":c="pow(10,"+a+")";break;case "ROUND":c="round("+a+")";break;case "ROUNDUP":c="ceil("+a+")";break;case "ROUNDDOWN":c="floor("+a+")";break;case "SIN":c="sin("+a+" / 180 * PI)";break;
case "COS":c="cos("+a+" / 180 * PI)";break;case "TAN":c="tan("+a+" / 180 * PI)";break;case "LN":Blockly.Arduino.includes_.include_Arduino_math="#include <math.h>";c="log("+a+")";break;case "EXP":Blockly.Arduino.includes_.include_Arduino_math="#include <math.h>",c="exp("+a+")"}if(c)return[c,Blockly.Arduino.ORDER_UNARY_POSTFIX];Blockly.Arduino.includes_.include_Arduino_math="#include <math.h>";switch(b){case "LOG10":c="log("+a+") / log(10)";break;case "ASIN":c="asin("+a+") / PI * 180";break;case "ACOS":c=
"acos("+a+") / PI * 180";break;case "ATAN":c="atan("+a+") / PI * 180";break;default:throw"Unknown math operator: "+b;}return[c,Blockly.Arduino.ORDER_MULTIPLICATIVE]};
Blockly.Arduino.math_constant=function(a){var b={PI:["M_PI",Blockly.Arduino.ORDER_UNARY_POSTFIX],E:["M_E",Blockly.Arduino.ORDER_UNARY_POSTFIX],GOLDEN_RATIO:["(1 + sqrt(5)) / 2",Blockly.Arduino.ORDER_MULTIPLICATIVE],SQRT2:["M_SQRT2",Blockly.Arduino.ORDER_UNARY_POSTFIX],SQRT1_2:["M_SQRT1_2",Blockly.Arduino.ORDER_UNARY_POSTFIX],INFINITY:[" __builtin_inf()",Blockly.Arduino.ORDER_ATOMIC]};Blockly.Arduino.includes_.include_Arduino_math="#include <math.h>";a=a.getFieldValue("CONSTANT");return b[a]};
Blockly.Arduino.math_change=function(a){var b=Blockly.Arduino.valueToCode(a,"DELTA",Blockly.Arduino.ORDER_ADDITIVE)||"0";a=Blockly.Arduino.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE);return a+" = ("+a+" is num ? "+a+" : 0) + "+b+";\n"};Blockly.Arduino.math_round=Blockly.Arduino.math_single;Blockly.Arduino.math_trig=Blockly.Arduino.math_single;
Blockly.Arduino.math_modulo=function(a){var b=Blockly.Arduino.valueToCode(a,"DIVIDEND",Blockly.Arduino.ORDER_MULTIPLICATIVE)||"0";a=Blockly.Arduino.valueToCode(a,"DIVISOR",Blockly.Arduino.ORDER_MULTIPLICATIVE)||"0";return[b+" % "+a,Blockly.Arduino.ORDER_MULTIPLICATIVE]};
Blockly.Arduino.math_constrain=function(a){var b=Blockly.Arduino.valueToCode(a,"VALUE",Blockly.Arduino.ORDER_NONE)||"0",c=Blockly.Arduino.valueToCode(a,"LOW",Blockly.Arduino.ORDER_NONE)||"0";a=Blockly.Arduino.valueToCode(a,"HIGH",Blockly.Arduino.ORDER_NONE)||"double.INFINITY";return["constrain("+b+", "+c+", "+a+")",Blockly.Arduino.ORDER_UNARY_POSTFIX]};
Blockly.Arduino.math_random_int=function(a){var b=Blockly.Arduino.valueToCode(a,"FROM",Blockly.Arduino.ORDER_NONE)||"0";a=Blockly.Arduino.valueToCode(a,"TO",Blockly.Arduino.ORDER_NONE)||"0";return["random("+b+", "+a+")",Blockly.Arduino.ORDER_UNARY_POSTFIX]};Blockly.Arduino.procedures={};
Blockly.Arduino.procedures_defreturn=function(a){var b=Blockly.Arduino.variableDB_.getName(a.getFieldValue("NAME"),Blockly.Procedures.NAME_TYPE),c=Blockly.Arduino.statementToCode(a,"STACK");if(Blockly.Arduino.STATEMENT_PREFIX){var d=a.id.replace(/\$/g,"$$$$");c=Blockly.Arduino.prefixLines(Blockly.Arduino.STATEMENT_PREFIX.replace(/%1/g,"'"+d+"'"),Blockly.Arduino.INDENT)+c}Blockly.Arduino.INFINITE_LOOP_TRAP&&(c=Blockly.Arduino.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+a.id+"'")+c);(d=Blockly.Arduino.valueToCode(a,
"RETURN",Blockly.Arduino.ORDER_NONE)||"")&&(d=Blockly.Arduino.INDENT+"return "+d+";\n");for(var e=d?"int":"void",f=[],g=0;g<a.arguments_.length;g++)f[g]=Blockly.Arduino.variableDB_.getName(a.arguments_[g],Blockly.Variables.NAME_TYPE);c=e+" "+b+"("+f.join(", ")+") {\n"+c+d+"}";c=Blockly.Arduino.scrub_(a,c);Blockly.Arduino.definitions_["%"+b]=c;return null};Blockly.Arduino.procedures_defnoreturn=Blockly.Arduino.procedures_defreturn;
Blockly.Arduino.procedures_callreturn=function(a){for(var b=Blockly.Arduino.variableDB_.getName(a.getFieldValue("NAME"),Blockly.Procedures.NAME_TYPE),c=[],d=0;d<a.arguments_.length;d++)c[d]=Blockly.Arduino.valueToCode(a,"ARG"+d,Blockly.Arduino.ORDER_NONE)||"null";return[b+"("+c.join(", ")+")",Blockly.Arduino.ORDER_UNARY_POSTFIX]};
Blockly.Arduino.procedures_callnoreturn=function(a){for(var b=Blockly.Arduino.variableDB_.getName(a.getFieldValue("NAME"),Blockly.Procedures.NAME_TYPE),c=[],d=0;d<a.arguments_.length;d++)c[d]=Blockly.Arduino.valueToCode(a,"ARG"+d,Blockly.Arduino.ORDER_NONE)||"null";return b+"("+c.join(", ")+");\n"};
Blockly.Arduino.procedures_ifreturn=function(a){var b="if ("+(Blockly.Arduino.valueToCode(a,"CONDITION",Blockly.Arduino.ORDER_NONE)||"false")+") {\n";a.hasReturnValue_?(a=Blockly.Arduino.valueToCode(a,"VALUE",Blockly.Arduino.ORDER_NONE)||"null",b+=Blockly.Arduino.INDENT+"return "+a+";\n"):b+=Blockly.Arduino.INDENT+"return;\n";return b+"}\n"};Blockly.Arduino.texts={};Blockly.Arduino.addReservedWords("Html,Math");Blockly.Arduino.text=function(a){return[Blockly.Arduino.quote_(a.getFieldValue("TEXT")),Blockly.Arduino.ORDER_ATOMIC]};
Blockly.Arduino.text_join=function(a){if(0==a.itemCount_)return["''",Blockly.Arduino.ORDER_ATOMIC];if(1==a.itemCount_)return[(Blockly.Arduino.valueToCode(a,"ADD0",Blockly.Arduino.ORDER_UNARY_POSTFIX)||"''")+".toString()",Blockly.Arduino.ORDER_UNARY_POSTFIX];var b=Array(a.itemCount_);for(var c=0;c<a.itemCount_;c++)b[c]=Blockly.Arduino.valueToCode(a,"ADD"+c,Blockly.Arduino.ORDER_NONE)||"''";b=b.join("+");return[b,Blockly.Arduino.ORDER_UNARY_POSTFIX]};
Blockly.Arduino.text_append=function(a){var b=Blockly.Arduino.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE);a=Blockly.Arduino.valueToCode(a,"TEXT",Blockly.Arduino.ORDER_NONE)||'""';return b+" += "+a+";\n"};Blockly.Arduino.text_length=function(a){return[(Blockly.Arduino.valueToCode(a,"VALUE",Blockly.Arduino.ORDER_UNARY_POSTFIX)||'""')+".length()",Blockly.Arduino.ORDER_UNARY_POSTFIX]};Blockly.Arduino.variables={};Blockly.Arduino.variables_get=function(a){return[Blockly.Arduino.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),Blockly.Arduino.ORDER_ATOMIC]};Blockly.Arduino.variables_set=function(a){var b=Blockly.Arduino.valueToCode(a,"VALUE",Blockly.Arduino.ORDER_ASSIGNMENT)||"0";return Blockly.Arduino.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE)+" = "+b+";\n"};