This repository has been archived by the owner on Sep 29, 2022. It is now read-only.
forked from google/blockly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharduino_compressed.js
167 lines (157 loc) · 51.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// Do not edit this file; automatically generated.
/* eslint-disable */
;(function(root, factory) {
if (typeof define === 'function' && define.amd) { // AMD
define(["./blockly_compressed.js"], factory);
} else if (typeof exports === 'object') { // Node.js
module.exports = factory(require("./blockly_compressed.js"));
} else { // Browser
var factoryExports = factory(root.Blockly);
root.Blockly.Arduino = factoryExports;
}
}(this, function(__parent__) {
var $=__parent__.__namespace__;
/*
Licensed under the Apache License, Version 2.0 (the "License"):
http://www.apache.org/licenses/LICENSE-2.0
*/
$.Blockly.Type=function(a){if(void 0===a.typeId||void 0===a.typeMsgName||void 0===a.compatibleTypes)throw Error("Creating a Type requires the following format:\n{\n typeId: string,\n typeMsgName: Blockly.Msg string member var name to\n identify the translatable Type name.\n compatibleTypes: [Blockly.Type,]\n}");if(!Array.isArray(a.compatibleTypes))throw Error("The compatible types for a Blockly Types needs to be an array of Blockly.Type items.");this.typeId=a.typeId;this.typeMsgName_=
a.typeMsgName;this.compatibleTypes_=a.compatibleTypes;this.compatibleTypes_.push(this);this.generatedCheckList_=[];this.generateCheckList_()};Object.defineProperty($.Blockly.Type.prototype,"typeName",{get:function(){return $.Blockly.Msg[this.typeMsgName_]||this.typeId},set:function(a){console.warn('"Blockly.Type" property "typeName" is not allowed to be set.')}});Object.defineProperty($.Blockly.Type.prototype,"output",{get:function(){return this.typeId},set:function(a){console.warn('"Blockly.Type" property "output" is not allowed to be set.')}});
Object.defineProperty($.Blockly.Type.prototype,"checkList",{get:function(){return this.generatedCheckList_},set:function(a){console.warn('"Blockly.Type" property "check" is not allowed to be set.')}});$.Blockly.Type.prototype.generateCheckList_=function(a){this.generatedCheckList_=[];for(a=0;a<this.compatibleTypes_.length;a++){for(var b=!0,c=0;c<this.generatedCheckList_.length;c++)this.generatedCheckList_[c]===this.compatibleTypes_[a].typeId&&(b=!1);b&&this.generatedCheckList_.push(this.compatibleTypes_[a].typeId)}};
$.Blockly.Type.prototype.addCompatibleType=function(a){if(!(a&&a.constructor&&a instanceof $.Blockly.Type))throw Error("To add a compatible type to "+this.typeId+" provide a Blockly.Type object.");this.compatibleTypes_.push(a);this.generateCheckList_()};
$.Blockly.Type.prototype.addCompatibleTypes=function(a){if(!Array.isArray(a))throw Error("To add compatible types to the Blockly Type "+this.typeId+" provide an array of Blockly.Type items.");for(var b=0;b<a.length;b++){if(!(a[b]&&a[b].constructor&&a[b]instanceof $.Blockly.Type))throw Error("To add a compatible type to "+this.typeId+" you must point to a Blockly.Type object.");this.compatibleTypes_.push(a[b])}this.generateCheckList_()};$.Blockly.Types={};$.Blockly.Types.CHARACTER=new $.Blockly.Type({typeId:"Character",typeMsgName:"ARD_TYPE_CHAR",compatibleTypes:[]});$.Blockly.Types.TEXT=new $.Blockly.Type({typeId:"Text",typeMsgName:"ARD_TYPE_TEXT",compatibleTypes:[$.Blockly.Types.CHARACTER]});$.Blockly.Types.BOOLEAN=new $.Blockly.Type({typeId:"Boolean",typeMsgName:"ARD_TYPE_BOOL",compatibleTypes:[]});$.Blockly.Types.SHORT_NUMBER=new $.Blockly.Type({typeId:"Short Number",typeMsgName:"ARD_TYPE_SHORT",compatibleTypes:[]});
$.Blockly.Types.NUMBER=new $.Blockly.Type({typeId:"Number",typeMsgName:"ARD_TYPE_NUMBER",compatibleTypes:[]});$.Blockly.Types.UNS_NUMBER=new $.Blockly.Type({typeId:"Unsigned number",typeMsgName:"ARD_TYPE_UNS_NUMBER",compatibleTypes:[$.Blockly.Types.SHORT_NUMBER,$.Blockly.Types.NUMBER]});$.Blockly.Types.VOLATIL_NUMBER=new $.Blockly.Type({typeId:"Volatil Number",typeMsgName:"ARD_TYPE_VOLATILE",compatibleTypes:[]});
$.Blockly.Types.LARGE_NUMBER=new $.Blockly.Type({typeId:"Large Number",typeMsgName:"ARD_TYPE_LONG",compatibleTypes:[]});$.Blockly.Types.LARGE_UNS_NUMBER=new $.Blockly.Type({typeId:"Unisgned Large Number",typeMsgName:"ARD_TYPE_UNS_LONG",compatibleTypes:[$.Blockly.Types.SHORT_NUMBER,$.Blockly.Types.NUMBER,$.Blockly.Types.LARGE_NUMBER]});
$.Blockly.Types.DECIMAL=new $.Blockly.Type({typeId:"Decimal",typeMsgName:"ARD_TYPE_DECIMAL",compatibleTypes:[$.Blockly.Types.BOOLEAN,$.Blockly.Types.SHORT_NUMBER,$.Blockly.Types.NUMBER,$.Blockly.Types.LARGE_NUMBER]});$.Blockly.Types.ARRAY=new $.Blockly.Type({typeId:"Array",typeMsgName:"ARD_TYPE_ARRAY",compatibleTypes:[]});$.Blockly.Types.ARRAY_CHAR=new $.Blockly.Type({typeId:"ArrayChar",typeMsgName:"ARD_TYPE_ARRAY_CHAR",compatibleTypes:[]});
$.Blockly.Types.NULL=new $.Blockly.Type({typeId:"Null",typeMsgName:"ARD_TYPE_NULL",compatibleTypes:[]});$.Blockly.Types.UNDEF=new $.Blockly.Type({typeId:"Undefined",typeMsgName:"ARD_TYPE_UNDEF",compatibleTypes:[]});$.Blockly.Types.CHILD_BLOCK_MISSING=new $.Blockly.Type({typeId:"ChildBlockMissing",typeMsgName:"ARD_TYPE_CHILDBLOCKMISSING",compatibleTypes:[]});$.Blockly.Types.NUMBER.addCompatibleTypes([$.Blockly.Types.BOOLEAN,$.Blockly.Types.SHORT_NUMBER,$.Blockly.Types.LARGE_NUMBER,$.Blockly.Types.DECIMAL]);
$.Blockly.Types.UNS_NUMBER.addCompatibleTypes([$.Blockly.Types.BOOLEAN,$.Blockly.Types.SHORT_NUMBER,$.Blockly.Types.NUMBER,$.Blockly.Types.DECIMAL]);$.Blockly.Types.SHORT_NUMBER.addCompatibleTypes([$.Blockly.Types.BOOLEAN,$.Blockly.Types.NUMBER,$.Blockly.Types.DECIMAL]);$.Blockly.Types.LARGE_NUMBER.addCompatibleTypes([$.Blockly.Types.BOOLEAN,$.Blockly.Types.SHORT_NUMBER,$.Blockly.Types.UNS_NUMBER,$.Blockly.Types.NUMBER,$.Blockly.Types.DECIMAL]);
$.Blockly.Types.LARGE_UNS_NUMBER.addCompatibleTypes([$.Blockly.Types.BOOLEAN,$.Blockly.Types.SHORT_NUMBER,$.Blockly.Types.UNS_NUMBER,$.Blockly.Types.NUMBER,$.Blockly.Types.LARGE_NUMBER,$.Blockly.Types.DECIMAL]);$.Blockly.Types.VOLATIL_NUMBER.addCompatibleTypes([$.Blockly.Types.SHORT_NUMBER,$.Blockly.Types.LARGE_NUMBER,$.Blockly.Types.UNS_NUMBER,$.Blockly.Types.NUMBER]);$.Blockly.Types.ARRAY_CHAR.addCompatibleTypes([$.Blockly.Types.CHARACTER,$.Blockly.Types.TEXT]);
$.Blockly.Types.addType=function(a,b,c){var d=a.toUpperCase().replace(/ /g,"_");if(void 0!==$.Blockly.Types[d])throw"The Blockly type "+d+" already exists.";$.Blockly.Types[d]=new $.Blockly.Type({typeId:a,typeName:b,compatibleTypes:c})};$.Blockly.Types.getValidTypeArray=function(){var a=[],b;for(b in $.Blockly.Types)"UNDEF"===b||"CHILD_BLOCK_MISSING"===b||"NULL"===b||"ARRAY"===b||"function"===typeof $.Blockly.Types[b]||$.Blockly.Types[b]instanceof RegExp||a.push([$.Blockly.Types[b].typeName,b]);return a};
$.Blockly.Types.getChildBlockType=function(a){for(var b=a;b&&void 0===b.getBlockType&&0<b.inputList.length&&null!=b.inputList[0].connection;)b=b.inputList[0].connection.targetBlock();return b===a?$.Blockly.Types.CHILD_BLOCK_MISSING:null===b?$.Blockly.Types.CHILD_BLOCK_MISSING:b.getBlockType?b.getBlockType():$.Blockly.Types.NULL};$.Blockly.Types.regExpInt_=new RegExp(/^-?\d+$/);$.Blockly.Types.regExpFloat_=new RegExp(/^-?[0-9]*[.][0-9]+$/);
$.Blockly.Types.identifyNumber=function(a){return $.Blockly.Types.regExpInt_.test(a)?(a=parseInt(a),isNaN(a)?$.Blockly.Types.NULL:32767<a||-32768>a?$.Blockly.Types.LARGE_NUMBER:$.Blockly.Types.NUMBER):$.Blockly.Types.regExpFloat_.test(a)?$.Blockly.Types.DECIMAL:$.Blockly.Types.NULL};$.Blockly.StaticTyping=function(){this.varTypeDict=Object.create(null);this.pendingVarTypeDict=Object.create(null)};
$.Blockly.StaticTyping.prototype.collectVarsWithTypes=function(a){this.varTypeDict=Object.create(null);this.pendingVarTypeDict=Object.create(null);a=$.Blockly.StaticTyping.getAllStatementsOrdered(a);for(var b=0;b<a.length;b++)for(var c=$.Blockly.StaticTyping.getBlockVars(a[b]),d=0;d<c.length;d++){var e=c[d][0],f=c[d][1];Array.isArray(f)&&("_AGI"==f[1].substr(f[1].lastIndexOf("_"))?(f=f[1].substr(0,f[1].lastIndexOf("_")),f=(f=this.varTypeDict[f])?f.arrayType&&2==f.arrayType.length?this.varTypeDict[f.arrayType[1]]:
f.arrayType:$.Blockly.Types.UNDEF):this.varTypeDict[f[1]]?f=this.varTypeDict[f[1]]:(Array.isArray(this.pendingVarTypeDict[f[1]])?this.pendingVarTypeDict[f[1]].push(e):this.pendingVarTypeDict[f[1]]=[e],f=$.Blockly.Types.UNDEF));this.assignTypeToVars(a[b],e,f)}return this.varTypeDict};
$.Blockly.StaticTyping.getAllStatementsOrdered=function(a){if(!a.getTopBlocks)throw"Not a valid workspace: "+a;var b=function(e){var f,g=[];do{g.push(e);var h=e.nextConnection;var k=e.getConnections_();e=null;for(var l=0;l<k.length;l++)k[l].type==$.Blockly.NEXT_STATEMENT&&(f=k[l].targetBlock())&&(k[l]===h?e=f:g=g.concat(b(f)))}while(e);return g},c=[];a=a.getTopBlocks(!0);for(var d=0;d<a.length;d++)c=c.concat(b(a[d]));return c};
$.Blockly.StaticTyping.getBlockVars=function(a){var b=[],c=a.getVars;if(c){c=c.call(a);for(var d=0;d<c.length;d++){var e=c[d],f=a.getVarType;f?(f=f.call(a,e),b.push([e,f])):b.push([e,$.Blockly.Types.NULL])}}return b};
$.Blockly.StaticTyping.prototype.assignTypeToVars=function(a,b,c){switch(this.varTypeDict[b]){case void 0:case $.Blockly.Types.UNDEF:this.varTypeDict[b]=c;if(c!=$.Blockly.Types.UNDEF&&void 0!==this.pendingVarTypeDict[b])for(var d=0;d<this.pendingVarTypeDict[b].length;d++)this.assignTypeToVars(a,this.pendingVarTypeDict[b][d],c);break;default:this.setBlockTypeWarning(a,c,b,this.varTypeDict[b])}};
$.Blockly.StaticTyping.prototype.setBlockTypeWarning=function(a,b,c){b==$.Blockly.Types.CHILD_BLOCK_MISSING||this.varTypeDict[c]==$.Blockly.Types.CHILD_BLOCK_MISSING?a.setWarningText(null,"varType"):this.varTypeDict[c]!==b&&b!==$.Blockly.Types.UNDEF?a.setWarningText(MSG.varText1+c+MSG.varText2+this.varTypeDict[c].typeName+MSG.varText3+MSG.varText4+b.typeName+MSG.varText5,"varType"):a.setWarningText(null,"varType")};
$.Blockly.StaticTyping.prototype.setProcedureArgs=function(a){a=a.getTopBlocks();for(var b=0,c=a.length;b<c;b++){var d=a[b].setArgsType;d&&d.call(a[b],this.varTypeDict)}};/*
Visual Blocks Language
Copyright 2012 Google Inc.
https://developers.google.com/blockly/
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var module$contents$Blockly$Arduino_Arduino=new $.Blockly.Generator("Arduino"),module$contents$Blockly$Arduino_StaticTyping=new $.Blockly.StaticTyping;module$contents$Blockly$Arduino_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");
module$contents$Blockly$Arduino_Arduino.ORDER_ATOMIC=0;module$contents$Blockly$Arduino_Arduino.ORDER_UNARY_POSTFIX=1;module$contents$Blockly$Arduino_Arduino.ORDER_UNARY_PREFIX=2;module$contents$Blockly$Arduino_Arduino.ORDER_MULTIPLICATIVE=3;module$contents$Blockly$Arduino_Arduino.ORDER_ADDITIVE=4;module$contents$Blockly$Arduino_Arduino.ORDER_SHIFT=5;module$contents$Blockly$Arduino_Arduino.ORDER_RELATIONAL=6;module$contents$Blockly$Arduino_Arduino.ORDER_EQUALITY=7;
module$contents$Blockly$Arduino_Arduino.ORDER_BITWISE_AND=8;module$contents$Blockly$Arduino_Arduino.ORDER_BITWISE_XOR=9;module$contents$Blockly$Arduino_Arduino.ORDER_BITWISE_OR=10;module$contents$Blockly$Arduino_Arduino.ORDER_LOGICAL_AND=11;module$contents$Blockly$Arduino_Arduino.ORDER_LOGICAL_OR=12;module$contents$Blockly$Arduino_Arduino.ORDER_CONDITIONAL=13;module$contents$Blockly$Arduino_Arduino.ORDER_ASSIGNMENT=14;module$contents$Blockly$Arduino_Arduino.ORDER_COMMA=15;
module$contents$Blockly$Arduino_Arduino.ORDER_UNARY_NEGATION=16;module$contents$Blockly$Arduino_Arduino.ORDER_MEMBER=17;module$contents$Blockly$Arduino_Arduino.ORDER_NONE=99;module$contents$Blockly$Arduino_Arduino.PinTypes={INPUT:"INPUT",OUTPUT:"OUTPUT",PWM:"PWM",SERVO:"SERVO",STEPPER:"STEPPER",SERIAL:"SERIAL",I2C:"I2C/TWI",SPI:"SPI"};
module$contents$Blockly$Arduino_Arduino.ORDER_OVERRIDES=[[module$contents$Blockly$Arduino_Arduino.ORDER_FUNCTION_CALL,module$contents$Blockly$Arduino_Arduino.ORDER_MEMBER],[module$contents$Blockly$Arduino_Arduino.ORDER_FUNCTION_CALL,module$contents$Blockly$Arduino_Arduino.ORDER_FUNCTION_CALL],[module$contents$Blockly$Arduino_Arduino.ORDER_MEMBER,module$contents$Blockly$Arduino_Arduino.ORDER_MEMBER],[module$contents$Blockly$Arduino_Arduino.ORDER_MEMBER,module$contents$Blockly$Arduino_Arduino.ORDER_FUNCTION_CALL],
[module$contents$Blockly$Arduino_Arduino.ORDER_LOGICAL_NOT,module$contents$Blockly$Arduino_Arduino.ORDER_LOGICAL_NOT],[module$contents$Blockly$Arduino_Arduino.ORDER_MULTIPLICATION,module$contents$Blockly$Arduino_Arduino.ORDER_MULTIPLICATION],[module$contents$Blockly$Arduino_Arduino.ORDER_ADDITION,module$contents$Blockly$Arduino_Arduino.ORDER_ADDITION],[module$contents$Blockly$Arduino_Arduino.ORDER_LOGICAL_AND,module$contents$Blockly$Arduino_Arduino.ORDER_LOGICAL_AND],[module$contents$Blockly$Arduino_Arduino.ORDER_LOGICAL_OR,
module$contents$Blockly$Arduino_Arduino.ORDER_LOGICAL_OR]];module$contents$Blockly$Arduino_Arduino.DEF_FUNC_NAME=module$contents$Blockly$Arduino_Arduino.FUNCTION_NAME_PLACEHOLDER_;
module$contents$Blockly$Arduino_Arduino.init=function(a){Object.getPrototypeOf(this).init.call(this);this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.module$exports$Blockly$Names.Names(this.RESERVED_WORDS_);module$contents$Blockly$Arduino_Arduino.nameDB_.setVariableMap(a.getVariableMap());module$contents$Blockly$Arduino_Arduino.includes_=Object.create(null);module$contents$Blockly$Arduino_Arduino.definitions_=Object.create(null);module$contents$Blockly$Arduino_Arduino.variables_=Object.create(null);
module$contents$Blockly$Arduino_Arduino.codeFunctions_=Object.create(null);module$contents$Blockly$Arduino_Arduino.userFunctions_=Object.create(null);module$contents$Blockly$Arduino_Arduino.functionNames_=Object.create(null);module$contents$Blockly$Arduino_Arduino.setups_=Object.create(null);module$contents$Blockly$Arduino_Arduino.pins_=Object.create(null);var b=module$contents$Blockly$Arduino_StaticTyping.collectVarsWithTypes(a);module$contents$Blockly$Arduino_StaticTyping.setProcedureArgs(a,b);
for(var c in b)b[c]?b[c].arrayType?(a=module$contents$Blockly$Arduino_Arduino.recurseArrayType(c,b),module$contents$Blockly$Arduino_Arduino.addVariable(c,a+" "+this.nameDB_.getName(c,$.module$exports$Blockly$Names.NameType.VARIABLE)+";")):module$contents$Blockly$Arduino_Arduino.addVariable(c,module$contents$Blockly$Arduino_Arduino.getArduinoType_(b[c])+" "+this.nameDB_.getName(c,$.module$exports$Blockly$Names.NameType.VARIABLE)+";"):module$contents$Blockly$Arduino_Arduino.addVariable(c,"undefined "+
this.nameDB_.getName(c,$.module$exports$Blockly$Names.NameType.VARIABLE)+";")};
module$contents$Blockly$Arduino_Arduino.recurseArrayType=function(a,b){if(!b[a].arrayType||b[a].arrayType instanceof $.Blockly.Type){var c="";if(b[a].arrayType){var d=b[a].arrayType;for(c="["+b[a].arraySize+"]";d.arrayType;)c+="["+d.arraySize+"]",d=d.arrayType;if(!(d instanceof $.Blockly.Type)&&(a=d[1],b[a].arrayType))return d=module$contents$Blockly$Arduino_Arduino.recurseArrayType(a,b),d.substr(0,d.indexOf("["))+c+d.substr(d.indexOf("["))}return module$contents$Blockly$Arduino_Arduino.getArduinoType_(b[a])+c}c=
b[a].arrayType[1];return c!=a&&b[c]?(d=module$contents$Blockly$Arduino_Arduino.recurseArrayType(c,b),module$contents$Blockly$Arduino_Arduino.insertParentArraySize(d,b[a].arraySize)):"undefined"};module$contents$Blockly$Arduino_Arduino.insertParentArraySize=function(a,b){return 0<=a.indexOf("[")?a.substr(0,a.indexOf("["))+"["+b+"]"+a.substr(a.indexOf("[")):a+"["+b+"]"};
module$contents$Blockly$Arduino_Arduino.finish=function(a){var b=[],c=[],d=[],e=[],f;for(f in module$contents$Blockly$Arduino_Arduino.includes_)b.push(module$contents$Blockly$Arduino_Arduino.includes_[f]);b.length&&b.push("\n");for(f in module$contents$Blockly$Arduino_Arduino.definitions_)c.push(module$contents$Blockly$Arduino_Arduino.definitions_[f]);c.length&&c.push("\n");for(f in module$contents$Blockly$Arduino_Arduino.variables_)d.push(module$contents$Blockly$Arduino_Arduino.variables_[f]);d.length&&
d.push("\n");for(f in module$contents$Blockly$Arduino_Arduino.codeFunctions_)e.push(module$contents$Blockly$Arduino_Arduino.codeFunctions_[f]);for(f in module$contents$Blockly$Arduino_Arduino.userFunctions_)e.push(module$contents$Blockly$Arduino_Arduino.userFunctions_[f]);e.length&&e.push("\n");var g=[""],h="";void 0!==module$contents$Blockly$Arduino_Arduino.setups_.userSetupCode&&(h="\n "+module$contents$Blockly$Arduino_Arduino.setups_.userSetupCode,delete module$contents$Blockly$Arduino_Arduino.setups_.userSetupCode);
for(f in module$contents$Blockly$Arduino_Arduino.setups_)g.push(module$contents$Blockly$Arduino_Arduino.setups_[f]);h&&g.push(h);delete module$contents$Blockly$Arduino_Arduino.includes_;delete module$contents$Blockly$Arduino_Arduino.definitions_;delete module$contents$Blockly$Arduino_Arduino.codeFunctions_;delete module$contents$Blockly$Arduino_Arduino.userFunctions_;delete module$contents$Blockly$Arduino_Arduino.functionNames_;delete module$contents$Blockly$Arduino_Arduino.setups_;delete module$contents$Blockly$Arduino_Arduino.pins_;
this.nameDB_.reset();b=b.join("\n")+c.join("\n")+d.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};module$contents$Blockly$Arduino_Arduino.addInclude=function(a,b){void 0===module$contents$Blockly$Arduino_Arduino.includes_[a]&&(module$contents$Blockly$Arduino_Arduino.includes_[a]=b)};
module$contents$Blockly$Arduino_Arduino.addDeclaration=function(a,b){void 0===module$contents$Blockly$Arduino_Arduino.definitions_[a]&&(module$contents$Blockly$Arduino_Arduino.definitions_[a]=b)};module$contents$Blockly$Arduino_Arduino.addVariable=function(a,b,c){var d=!1;if(c||void 0===module$contents$Blockly$Arduino_Arduino.variables_[a])module$contents$Blockly$Arduino_Arduino.variables_[a]=b,d=!0;return d};
module$contents$Blockly$Arduino_Arduino.addSetup=function(a,b,c){var d=!1;if(c||void 0===module$contents$Blockly$Arduino_Arduino.setups_[a])module$contents$Blockly$Arduino_Arduino.setups_[a]=b,d=!0;return d};
module$contents$Blockly$Arduino_Arduino.addFunction=function(a,b){if(void 0===module$contents$Blockly$Arduino_Arduino.codeFunctions_[a]){var c=this.nameDB_.getDistinctName(a,$.Blockly.Generator.NAME_TYPE);module$contents$Blockly$Arduino_Arduino.codeFunctions_[a]=b.replace(module$contents$Blockly$Arduino_Arduino.DEF_FUNC_NAME,c);module$contents$Blockly$Arduino_Arduino.functionNames_[a]=c}return module$contents$Blockly$Arduino_Arduino.functionNames_[a]};
module$contents$Blockly$Arduino_Arduino.reservePin=function(a,b,c,d){void 0!==module$contents$Blockly$Arduino_Arduino.pins_[b]?module$contents$Blockly$Arduino_Arduino.pins_[b]!=c?a.setWarningText($.Blockly.Msg.ARD_PIN_WARN1.replace("%1",b).replace("%2",d).replace("%3",c).replace("%4",module$contents$Blockly$Arduino_Arduino.pins_[b]),d):a.setWarningText(null,d):(module$contents$Blockly$Arduino_Arduino.pins_[b]=c,a.setWarningText(null,d))};
module$contents$Blockly$Arduino_Arduino.scrubNakedValue=function(a){return a+";\n"};module$contents$Blockly$Arduino_Arduino.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/\$/g,"\\$").replace(/'/g,"\\'");return'"'+a+'"'};
module$contents$Blockly$Arduino_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,"// "))}a=a.nextConnection&&a.nextConnection.targetBlock();a=this.blockToCode(a);return c+b+a};
module$contents$Blockly$Arduino_Arduino.getArduinoType_=function(a){switch(a.typeId){case $.Blockly.Types.VOLATIL_NUMBER.typeId:return"volatile int";case $.Blockly.Types.SHORT_NUMBER.typeId:return"byte";case $.Blockly.Types.NUMBER.typeId:return"int";case $.Blockly.Types.UNS_NUMBER.typeId:return"unsigned int";case $.Blockly.Types.LARGE_NUMBER.typeId:return"long";case $.Blockly.Types.LARGE_UNS_NUMBER.typeId:return"unsigned 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.ARRAY_CHAR.typeId:return"char*";case $.Blockly.Types.BOOLEAN.typeId:return"boolean";case $.Blockly.Types.NULL.typeId:return"double";case $.Blockly.Types.ARRAY.typeId:return module$contents$Blockly$Arduino_Arduino.getArduinoType_(a.arrayType);case $.Blockly.Types.UNDEF.typeId:return"undefined";case $.Blockly.Types.CHILD_BLOCK_MISSING.typeId:return"int";default:return"Invalid Blockly Type"}};
module$contents$Blockly$Arduino_Arduino.noGeneratorCodeInline=function(){return["",module$contents$Blockly$Arduino_Arduino.ORDER_ATOMIC]};module$contents$Blockly$Arduino_Arduino.noGeneratorCodeLine=function(){return""};$.Blockly.Arduino=module$contents$Blockly$Arduino_Arduino;/*
Copyright 2012 Google LLC
SPDX-License-Identifier: Apache-2.0
*/
var module$exports$Blockly$Arduino$text={};$.Blockly.Arduino.text=function(a){return[$.Blockly.Arduino.quote_(a.getFieldValue("TEXT")),$.Blockly.Arduino.ORDER_ATOMIC]};var module$exports$Blockly$Arduino$procedures={};
$.Blockly.Arduino.procedures_defreturn=function(a){var b=$.Blockly.Arduino.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE),c=$.Blockly.Arduino.statementToCode(a,"STACK");$.Blockly.Arduino.STATEMENT_PREFIX&&(c=$.Blockly.Arduino.prefixLines($.Blockly.Arduino.STATEMENT_PREFIX.replace(/%1/g,"'"+a.id+"'"),$.Blockly.Arduino.INDENT)+c);$.Blockly.Arduino.INFINITE_LOOP_TRAP&&(c=$.Blockly.Arduino.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+a.id+"'")+c);var d=$.Blockly.Arduino.valueToCode(a,
"RETURN",$.Blockly.Arduino.ORDER_NONE)||"";d&&(d=" return "+d+";\n");for(var e=[],f=0;f<a.arguments_.length;f++)e[f]="double "+$.Blockly.Arduino.nameDB_.getName(a.arguments_[f],$.module$exports$Blockly$Names.NameType.VARIABLE);f=$.Blockly.Types.NULL;a.getReturnType&&(f=a.getReturnType());f=$.Blockly.Arduino.getArduinoType_(f);c=f+" "+b+"("+e.join(", ")+") {\n"+c+d+"}";c=$.Blockly.Arduino.scrub_(a,c);$.Blockly.Arduino.userFunctions_[b]=c;return null};$.Blockly.Arduino.procedures_defnoreturn=$.Blockly.Arduino.procedures_defreturn;
$.Blockly.Arduino.procedures_callreturn=function(a){for(var b=$.Blockly.Arduino.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE),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.nameDB_.getName(a.getFieldValue("NAME"),$.module$exports$Blockly$Names.NameType.PROCEDURE),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+=" return "+a+";\n"):b+=" return;\n";return b+"}\n"};
$.Blockly.Arduino.arduino_functions=function(a){var b=$.Blockly.Arduino.statementToCode(a,"SETUP_FUNC");b&&$.Blockly.Arduino.addSetup("userSetupCode",b,!0);a=a.getInputTargetBlock("LOOP_FUNC");b=$.Blockly.Arduino.blockToCode(a);if(!$.goog.isString(b))throw'Expecting code from statement block "'+a.type+'".';return b};var module$exports$Blockly$Arduino$variables={};$.Blockly.Arduino.variables_get=function(a){return[$.Blockly.Arduino.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),$.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.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE)+" = "+b+";\n"};var module$exports$Blockly$Arduino$logic={};
$.Blockly.Arduino.controls_if=function(a){var b=0,c=$.Blockly.Arduino.valueToCode(a,"IF"+b,$.Blockly.Arduino.ORDER_NONE)||"false",d=$.Blockly.Arduino.statementToCode(a,"DO"+b),e="if ("+c+") {\n"+d+"}";for(b=1;b<=a.elseifCount_;b++)c=$.Blockly.Arduino.valueToCode(a,"IF"+b,$.Blockly.Arduino.ORDER_NONE)||"false",d=$.Blockly.Arduino.statementToCode(a,"DO"+b),e+=" else if ("+c+") {\n"+d+"}";a.elseCount_&&(d=$.Blockly.Arduino.statementToCode(a,"ELSE"),e+=" else {\n"+d+"}");return e+"\n"};
$.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)||"false";a=$.Blockly.Arduino.valueToCode(a,"B",c)||"false";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)||"false"),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]};var module$exports$Blockly$Arduino$loops={};$.Blockly.Arduino.controls_repeat=function(a){var b=Number(a.getFieldValue("TIMES")),c=$.Blockly.Arduino.statementToCode(a,"DO");c=$.Blockly.Arduino.addLoopTrap(c,a.id);a=$.Blockly.Arduino.nameDB_.getDistinctName("count",$.module$exports$Blockly$Names.NameType.VARIABLE);return"for (int "+a+" = 0; "+a+" < "+b+"; "+a+"++) {\n"+c+"}\n"};
$.Blockly.Arduino.controls_repeat_ext=function(a){var b=$.Blockly.Arduino.valueToCode(a,"TIMES",$.Blockly.Arduino.ORDER_ADDITIVE)||"0",c=$.Blockly.Arduino.statementToCode(a,"DO");c=$.Blockly.Arduino.addLoopTrap(c,a.id);a="";var d=$.Blockly.Arduino.nameDB_.getDistinctName("count",$.module$exports$Blockly$Names.NameType.VARIABLE),e=b;b.match(/^\w+$/)||$.Blockly.isNumber(b)||(e=$.Blockly.Arduino.nameDB_.getDistinctName("repeat_end",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="int "+e+" = "+
b+";\n");return a+("for (int "+d+" = 0; "+d+" < "+e+"; "+d+"++) {\n"+c+"}\n")};$.Blockly.Arduino.controls_repeat_forever=function(a){var b=$.Blockly.Arduino.statementToCode(a,"DO");b=$.Blockly.Arduino.addLoopTrap(b,a.id);return"while (true) {\n"+b+"}\n"};
$.Blockly.Arduino.controls_whileUntil=function(a){var b="UNTIL"==a.getFieldValue("MODE"),c=$.Blockly.Arduino.valueToCode(a,"BOOL",b?$.Blockly.Arduino.ORDER_LOGICAL_OR:$.Blockly.Arduino.ORDER_NONE)||"false",d=$.Blockly.Arduino.statementToCode(a,"DO");d=$.Blockly.Arduino.addLoopTrap(d,a.id);b&&(c.match(/^\w+$/)||(c="("+c+")"),c="!"+c);return"while ("+c+") {\n"+d+"}\n"};
$.Blockly.Arduino.controls_for=function(a){var b=$.Blockly.Arduino.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE),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.nameDB_.getDistinctName(b+"_start",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="int "+g+" = "+c+";\n"),c=d,d.match(/^\w+$/)||$.Blockly.isNumber(d)||(c=$.Blockly.Arduino.nameDB_.getDistinctName(b+
"_end",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="int "+c+" = "+d+";\n"),d=$.Blockly.Arduino.nameDB_.getDistinctName(b+"_inc",$.module$exports$Blockly$Names.NameType.VARIABLE),a+="int "+d+" = ",a=$.Blockly.isNumber(e)?a+(Math.abs(e)+";\n"):a+("abs("+e+");\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_forEach=$.Blockly.Arduino.noGeneratorCodeLine;$.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.";};var module$exports$Blockly$Arduino$math={};$.Blockly.Arduino.math_number=function(a){a=parseFloat(a.getFieldValue("NUM"));Infinity==a?a="INFINITY":-Infinity==a&&(a="-INFINITY");return[a,$.Blockly.Arduino.ORDER_ATOMIC]};
$.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]:["Math.pow("+d+", "+a+")",$.Blockly.Arduino.ORDER_UNARY_POSTFIX]};
$.Blockly.Arduino.math_single=function(a){var b=a.getFieldValue("OP");if("NEG"==b)return a=$.Blockly.Arduino.valueToCode(a,"NUM",$.Blockly.Arduino.ORDER_UNARY_PREFIX)||"0","-"==a[0]&&(a=" "+a),["-"+a,$.Blockly.Arduino.ORDER_UNARY_PREFIX];a="ABS"==b||"ROUND"==b.substring(0,5)?$.Blockly.Arduino.valueToCode(a,"NUM",$.Blockly.Arduino.ORDER_UNARY_POSTFIX)||"0":"SIN"==b||"COS"==b||"TAN"==b?$.Blockly.Arduino.valueToCode(a,"NUM",$.Blockly.Arduino.ORDER_MULTIPLICATIVE)||"0":$.Blockly.Arduino.valueToCode(a,
"NUM",$.Blockly.Arduino.ORDER_NONE)||"0";switch(b){case "ABS":var c="abs("+a+")";break;case "ROOT":c="sqrt("+a+")";break;case "LN":c="log("+a+")";break;case "EXP":c="exp("+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 * M_PI)";break;case "COS":c="cos("+a+" / 180 * M_PI)";break;case "TAN":c="tan("+a+" / 180 * M_PI)"}if(c)return[c,$.Blockly.Arduino.ORDER_UNARY_POSTFIX];
switch(b){case "LOG10":c="log("+a+") / log(10)";break;case "ASIN":c="asin("+a+") / M_PI * 180";break;case "ACOS":c="acos("+a+") / M_PI * 180";break;case "ATAN":c="atan("+a+") / M_PI * 180";break;default:throw"Unknown math operator: "+b;}return[c,$.Blockly.Arduino.ORDER_MULTIPLICATIVE]};
$.Blockly.Arduino.math_constant=function(a){return{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:["INFINITY",$.Blockly.Arduino.ORDER_ATOMIC]}[a.getFieldValue("CONSTANT")]};
$.Blockly.Arduino.math_number_property=function(a){var b=$.Blockly.Arduino.valueToCode(a,"NUMBER_TO_CHECK",$.Blockly.Arduino.ORDER_MULTIPLICATIVE)||"0",c=a.getFieldValue("PROPERTY");if("PRIME"==c)return a=$.Blockly.Arduino.addFunction("mathIsPrime",["boolean "+$.Blockly.Arduino.DEF_FUNC_NAME+"(int n) {"," // https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n if (n == 2 || n == 3) {\n return true;\n }\n // False if n is NaN, negative, is 1.\n // And false if n is divisible by 2 or 3.\n if (isnan(n) || (n <= 1) || (n == 1) || (n % 2 == 0) || (n % 3 == 0)) {\n return false;\n }\n // Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for (int x = 6; x <= sqrt(n) + 1; x += 6) {\n if (n % (x - 1) == 0 || n % (x + 1) == 0) {\n return false;\n }\n }\n return true;\n}"].join("\n")),
$.Blockly.Arduino.addInclude("math","#include <math.h>"),[a+"("+b+")",$.Blockly.Arduino.ORDER_UNARY_POSTFIX];switch(c){case "EVEN":var d=b+" % 2 == 0";break;case "ODD":d=b+" % 2 == 1";break;case "WHOLE":$.Blockly.Arduino.addInclude("math","#include <math.h>");d="(floor("+b+") == "+b+")";break;case "POSITIVE":d=b+" > 0";break;case "NEGATIVE":d=b+" < 0";break;case "DIVISIBLE_BY":a=$.Blockly.Arduino.valueToCode(a,"DIVISOR",$.Blockly.Arduino.ORDER_MULTIPLICATIVE)||"0",d=b+" % "+a+" == 0"}return[d,$.Blockly.Arduino.ORDER_EQUALITY]};
$.Blockly.Arduino.math_change=function(a){var b=$.Blockly.Arduino.valueToCode(a,"DELTA",$.Blockly.Arduino.ORDER_ADDITIVE)||"0";return $.Blockly.Arduino.nameDB_.getName(a.getFieldValue("VAR"),$.module$exports$Blockly$Names.NameType.VARIABLE)+" += "+b+";\n"};$.Blockly.Arduino.math_round=$.Blockly.Arduino.math_single;$.Blockly.Arduino.math_trig=$.Blockly.Arduino.math_single;$.Blockly.Arduino.math_on_list=$.Blockly.Arduino.noGeneratorCodeInline;
$.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)||"0";return["("+b+" < "+c+" ? "+c+" : ( "+b+" > "+a+" ? "+a+" : "+b+"))",$.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";var c=$.Blockly.Arduino.nameDB_.getDistinctName("math_random_int",$.Blockly.Generator.NAME_TYPE);$.Blockly.Arduino.math_random_int.random_function=c;return[$.Blockly.Arduino.addFunction("mathRandomInt",["int "+$.Blockly.Arduino.DEF_FUNC_NAME+"(int min, int max) {"," if (min > max) {\n // Swap min and max to ensure min is smaller.\n int temp = min;\n min = max;\n max = temp;\n }\n return min + (rand() % (max - min + 1));\n}"].join("\n"))+
"("+b+", "+a+")",$.Blockly.Arduino.ORDER_UNARY_POSTFIX]};$.Blockly.Arduino.math_random_float=function(a){return["(rand() / RAND_MAX)",$.Blockly.Arduino.ORDER_UNARY_POSTFIX]};var module$exports$Blockly$Arduino$arduino={};$.Blockly.Arduino.time_delay=function(a){return"delay("+($.Blockly.Arduino.valueToCode(a,"DELAY_TIME_MILI",$.Blockly.Arduino.ORDER_ATOMIC)||"0")+");\n"};var module$exports$Blockly$Arduino$leaphyExtra={},module$contents$Blockly$Arduino$leaphyExtra_includeDefinition='#include "Adafruit_TCS34725.h"',module$contents$Blockly$Arduino$leaphyExtra_variablesDefinition="Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_24MS, TCS34725_GAIN_16X);\nuint16_t RawColor_Red, RawColor_Green, RawColor_Blue, RawColor_Clear;\nbyte Color_Red, Color_Green, Color_Blue, Color_Clear;\n",module$contents$Blockly$Arduino$leaphyExtra_getColorDefinition="double getColor(int colorCode, bool isRaw) {\n tcs.getRawData(&RawColor_Red, &RawColor_Green, &RawColor_Blue, &RawColor_Clear);\n Color_Red = min(RawColor_Red/5,255); Color_Green = min(RawColor_Green/5,255); Color_Blue = min(RawColor_Blue/5,255);\n switch(colorCode) {\n case 0:\n return (isRaw) ? RawColor_Red : Color_Red;\n case 1:\n return (isRaw) ? RawColor_Green : Color_Green;\n case 2:\n return (isRaw) ? RawColor_Blue : Color_Blue;\n }\n}\n",
module$contents$Blockly$Arduino$leaphyExtra_rgbColorSetupCode='if (tcs.begin()) {\n Serial.println("RGB-sensor gevonden!");\n } else {\n Serial.println("Geen RGB-sensor gevonden... check je verbindingen...");\n }';
$.Blockly.Arduino.leaphy_rgb_color=function(a){$.Blockly.Arduino.definitions_.define_leaphy_rgb=module$contents$Blockly$Arduino$leaphyExtra_includeDefinition;$.Blockly.Arduino.definitions_.define_leaphy_rgb_var=module$contents$Blockly$Arduino$leaphyExtra_variablesDefinition;$.Blockly.Arduino.definitions_.define_get_color=module$contents$Blockly$Arduino$leaphyExtra_getColorDefinition;$.Blockly.Arduino.addSetup("rgb_color_setup",module$contents$Blockly$Arduino$leaphyExtra_rgbColorSetupCode,!1);return["getColor("+
a.getFieldValue("COLOR_TYPE")+", false)",$.Blockly.Arduino.ORDER_ATOMIC]};
$.Blockly.Arduino.leaphy_rgb_color_raw=function(a){$.Blockly.Arduino.definitions_.define_leaphy_rgb=module$contents$Blockly$Arduino$leaphyExtra_includeDefinition;$.Blockly.Arduino.definitions_.define_leaphy_rgb_var=module$contents$Blockly$Arduino$leaphyExtra_variablesDefinition;$.Blockly.Arduino.definitions_.define_get_color=module$contents$Blockly$Arduino$leaphyExtra_getColorDefinition;$.Blockly.Arduino.addSetup("rgb_color_setup",module$contents$Blockly$Arduino$leaphyExtra_rgbColorSetupCode,!1);
return["getColor("+a.getFieldValue("COLOR_TYPE_RAW")+", true)",$.Blockly.Arduino.ORDER_ATOMIC]};$.Blockly.Arduino.leaphy_rgb_raw_color_red=function(a){$.Blockly.Arduino.definitions_.define_leaphy_rgb=module$contents$Blockly$Arduino$leaphyExtra_includeDefinition;$.Blockly.Arduino.definitions_.define_leaphy_rgb_var=module$contents$Blockly$Arduino$leaphyExtra_variablesDefinition;return["RawColor_Red",$.Blockly.Arduino.ORDER_ATOMIC]};
$.Blockly.Arduino.leaphy_rgb_raw_color_green=function(a){$.Blockly.Arduino.definitions_.define_leaphy_rgb=module$contents$Blockly$Arduino$leaphyExtra_includeDefinition;$.Blockly.Arduino.definitions_.define_leaphy_rgb_var=module$contents$Blockly$Arduino$leaphyExtra_variablesDefinition;return["RawColor_Green",$.Blockly.Arduino.ORDER_ATOMIC]};
$.Blockly.Arduino.leaphy_rgb_raw_color_blue=function(a){$.Blockly.Arduino.definitions_.define_leaphy_rgb=module$contents$Blockly$Arduino$leaphyExtra_includeDefinition;$.Blockly.Arduino.definitions_.define_leaphy_rgb_var=module$contents$Blockly$Arduino$leaphyExtra_variablesDefinition;return["RawColor_Blue",$.Blockly.Arduino.ORDER_ATOMIC]};
$.Blockly.Arduino.leaphy_led_set_strip=function(a){a=$.Blockly.Arduino.valueToCode(this,"LED_SET_PIN",$.Blockly.Arduino.ORDER_ATOMIC)||"0";var b=$.Blockly.Arduino.valueToCode(this,"LED_SET_LEDS",$.Blockly.Arduino.ORDER_ATOMIC)||"0";$.Blockly.Arduino.definitions_.define_led_lib='#include "ledstrip.h"';$.Blockly.Arduino.definitions_.define_leds_pins="LEDSTRIP ledstrip("+a+", "+b+");";return""};
$.Blockly.Arduino.leaphy_led_set_basic=function(a){a=$.Blockly.Arduino.valueToCode(this,"LED_BASIC_LED",$.Blockly.Arduino.ORDER_ATOMIC)||"0";var b=$.Blockly.Arduino.valueToCode(this,"LED_BASIC_RED",$.Blockly.Arduino.ORDER_ATOMIC)||"0",c=$.Blockly.Arduino.valueToCode(this,"LED_BASIC_GREEN",$.Blockly.Arduino.ORDER_ATOMIC)||"0",d=$.Blockly.Arduino.valueToCode(this,"LED_BASIC_BLUE",$.Blockly.Arduino.ORDER_ATOMIC)||"0";return"ledstrip.basis("+a+", "+b+", "+c+", "+d+");\n"};
$.Blockly.Arduino.leaphy_led_set_speed=function(a){return"_snelHeid = "+($.Blockly.Arduino.valueToCode(this,"LED_SET_SPEEDVALUE",$.Blockly.Arduino.ORDER_ATOMIC)||"0")+";\n"};
$.Blockly.Arduino.leaphy_led_strip_demo=function(a){a=a.getFieldValue("DEMO_TYPE");var b=$.Blockly.Arduino.valueToCode(this,"LED_STRIP_DEMO_RED",$.Blockly.Arduino.ORDER_ATOMIC)||"0",c=$.Blockly.Arduino.valueToCode(this,"LED_STRIP_DEMO_GREEN",$.Blockly.Arduino.ORDER_ATOMIC)||"0",d=$.Blockly.Arduino.valueToCode(this,"LED_STRIP_DEMO_BLUE",$.Blockly.Arduino.ORDER_ATOMIC)||"0";return"ledstrip.runFunction("+a+", "+b+", "+c+", "+d+");\n"};
$.Blockly.Arduino.leaphy_servo_write=function(a){var b=a.getFieldValue("SERVO_PIN"),c=$.Blockly.Arduino.valueToCode(a,"SERVO_ANGLE",$.Blockly.Arduino.ORDER_ATOMIC)||"90",d="myServo"+b;$.Blockly.Arduino.reservePin(a,b,$.Blockly.Arduino.PinTypes.SERVO,"Servo Write");$.Blockly.Arduino.addInclude("servo","#include <Servo.h>");$.Blockly.Arduino.addDeclaration("servo_"+b,"Servo "+d+";");$.Blockly.Arduino.addSetup("servo_"+b,d+".attach("+b+");",!0);return d+".write("+c+");\n"};
$.Blockly.Arduino.leaphy_servo_read=function(a){var b=a.getFieldValue("SERVO_PIN"),c="myServo"+b;$.Blockly.Arduino.reservePin(a,b,$.Blockly.Arduino.PinTypes.SERVO,"Servo Read");$.Blockly.Arduino.addInclude("servo","#include <Servo.h>");$.Blockly.Arduino.addDeclaration("servo_"+b,"Servo "+c+";");$.Blockly.Arduino.addSetup("servo_"+b,c+".attach("+b+");",!0);return[c+".read()",$.Blockly.Arduino.ORDER_ATOMIC]};
$.Blockly.Arduino.leaphy_io_digitalwrite=function(a){var b=a.getFieldValue("PIN"),c=$.Blockly.Arduino.valueToCode(a,"STATE",$.Blockly.Arduino.ORDER_ATOMIC)||"LOW";$.Blockly.Arduino.reservePin(a,b,$.Blockly.Arduino.PinTypes.OUTPUT,"Digital Write");$.Blockly.Arduino.addSetup("io_"+b,"pinMode("+b+", OUTPUT);",!1);return"digitalWrite("+b+", "+c+");\n"};
$.Blockly.Arduino.leaphy_io_analogwrite=function(a){var b=a.getFieldValue("PIN"),c=$.Blockly.Arduino.valueToCode(a,"NUM",$.Blockly.Arduino.ORDER_ATOMIC)||"0";$.Blockly.Arduino.reservePin(a,b,$.Blockly.Arduino.PinTypes.OUTPUT,"Analogue Write");$.Blockly.Arduino.addSetup("io_"+b,"pinMode("+b+", OUTPUT);",!1);0>c||255<c?a.setWarningText("The analogue value set must be between 0 and 255","pwm_value"):a.setWarningText(null,"pwm_value");return"analogWrite("+b+", "+c+");\n"};
$.Blockly.Arduino.leaphy_sonar_read=function(a){$.Blockly.Arduino.addInclude("leaphy_extra",'#include "Leaphy_Extra.h"');var b=a.getFieldValue("TRIG_PIN");a=a.getFieldValue("ECHO_PIN");return["getDistanceSonar("+b+", "+a+")",$.Blockly.Arduino.ORDER_ATOMIC]};
var module$contents$Blockly$Arduino$leaphyExtra_displayInclude='#include "OLED_Display.h"',module$contents$Blockly$Arduino$leaphyExtra_displayDefinition="OLEDDISPLAY display;",module$contents$Blockly$Arduino$leaphyExtra_displaySetup='if(!display.begin())\n {\n Serial.println(F("Contact with the display failed: Check the connections"));\n }\n',module$contents$Blockly$Arduino$leaphyExtra_displaySerialSetup="Serial.begin(115200);",module$contents$Blockly$Arduino$leaphyExtra_addDisplaySetupCode=
function(){$.Blockly.Arduino.addInclude("include_display",module$contents$Blockly$Arduino$leaphyExtra_displayInclude);$.Blockly.Arduino.definitions_.define_display=module$contents$Blockly$Arduino$leaphyExtra_displayDefinition;$.Blockly.Arduino.addSetup("serial",module$contents$Blockly$Arduino$leaphyExtra_displaySerialSetup,!1);$.Blockly.Arduino.addSetup("oled",module$contents$Blockly$Arduino$leaphyExtra_displaySetup,!1)};
$.Blockly.Arduino.leaphy_display_clear=function(a){module$contents$Blockly$Arduino$leaphyExtra_addDisplaySetupCode();return"display.clearDisplay();\n"};
$.Blockly.Arduino.leaphy_display_print_line=function(a){module$contents$Blockly$Arduino$leaphyExtra_addDisplaySetupCode();var b=$.Blockly.Arduino.valueToCode(this,"VALUE",$.Blockly.Arduino.ORDER_ATOMIC)||"0";$.Blockly.Arduino.valueToCode(this,"DISPLAY_ROW",$.Blockly.Arduino.ORDER_ATOMIC);return"display.setCursor(0,"+12*a.getFieldValue("DISPLAY_ROW")+");\ndisplay.println("+b+");\n"};
$.Blockly.Arduino.leaphy_display_print_value=function(a){module$contents$Blockly$Arduino$leaphyExtra_addDisplaySetupCode();var b=$.Blockly.Arduino.valueToCode(this,"NAME",$.Blockly.Arduino.ORDER_ATOMIC)||"0",c=$.Blockly.Arduino.valueToCode(this,"VALUE",$.Blockly.Arduino.ORDER_ATOMIC)||"0";return"display.setCursor(0,"+12*a.getFieldValue("DISPLAY_ROW")+");\ndisplay.print("+b+');\ndisplay.print(" = ");\ndisplay.println('+c+");\n"};
$.Blockly.Arduino.leaphy_display_display=function(a){module$contents$Blockly$Arduino$leaphyExtra_addDisplaySetupCode();return"display.display();\n"};$.Blockly.Arduino.leaphy_update_lsm9ds1=function(a){return" lsm.read(); /* ask it to read in the data */ \n \n /* Get a new sensor event */ \n sensors_event_t a, m, g, temp; \n \n lsm.getEvent(&a, &m, &g, &temp);"};
$.Blockly.Arduino.leaphy_use_lsm9ds1=function(a){var b=a.getFieldValue("SENSOR");a=a.getFieldValue("AXIS");$.Blockly.Arduino.addInclude("adafruit_lsm9ds1","#include <Adafruit_LSM9DS1.h>");$.Blockly.Arduino.addDeclaration("lsm9ds1_declaration","Adafruit_LSM9DS1 lsm = Adafruit_LSM9DS1();\n");$.Blockly.Arduino.addFunction("lsm9ds1_setttings","void setupSettings()\n{\n lsm.setupAccel(lsm.LSM9DS1_ACCELRANGE_2G);\n lsm.setupMag(lsm.LSM9DS1_MAGGAIN_4GAUSS);\n lsm.setupGyro(lsm.LSM9DS1_GYROSCALE_245DPS);\n}\n");
$.Blockly.Arduino.addSetup("lsm9ds1_setup', 'void setup() \n{ \n Serial.begin(115200); \n \n while (!Serial) { \n delay(1); // will pause Zero, Leonardo, etc until serial console opens \n } \n \n Serial.println('LSM9DS1 data read demo'); \n \n // Try to initialise and warn if we couldn't detect the chip \n if (!lsm.begin()) \n { \n Serial.println('Oops ... unable to initialize the LSM9DS1. Check your wiring!'); \n while (1); \n } \n Serial.println('Found LSM9DS1 9DOF'); \n \n // helper to just set the default scaling we want, see above! \n setupSensor(); \n}");
return[b+a,$.Blockly.Arduino.ORDER_ATOMIC]};var module$exports$Blockly$Arduino$leaphyFlitz={};
$.Blockly.Arduino.leaphy_flitz_read_stomach_sensor=function(a){a=a.getFieldValue("SENSOR_TYPE");var b="",c="";"1"==a?(c="pinMode(8, OUTPUT);\n pinMode(9, OUTPUT);\n pinMode(10, INPUT);\n digitalWrite(8, LOW);\n digitalWrite(9, HIGH);\n",b="digitalRead(10)"):"2"==a&&(c="pinMode(8, INPUT);\n pinMode(9, OUTPUT);\n pinMode(10, OUTPUT);\n digitalWrite(8, LOW);\n digitalWrite(9, HIGH);\n",b="digitalRead(8)");$.Blockly.Arduino.setups_.setup_flitz_stomach=c;return[b,$.Blockly.Arduino.ORDER_ATOMIC]};
$.Blockly.Arduino.leaphy_flitz_read_hand_sensor=function(a){$.Blockly.Arduino.setups_.setup_flitz_stomach="pinMode(14, OUTPUT);\n pinMode(15, OUTPUT);\n pinMode(2, INPUT);\n digitalWrite(14, HIGH);\n digitalWrite(15, LOW);\n";return["analogRead(2)",$.Blockly.Arduino.ORDER_ATOMIC]};
$.Blockly.Arduino.leaphy_flitz_led=function(a){$.Blockly.Arduino.setups_.setup_flitz_led="";a=$.Blockly.Arduino.valueToCode(this,"FLITZ_LED_R",$.Blockly.Arduino.ORDER_ATOMIC)||"0";var b=$.Blockly.Arduino.valueToCode(this,"FLITZ_LED_G",$.Blockly.Arduino.ORDER_ATOMIC)||"0",c=$.Blockly.Arduino.valueToCode(this,"FLITZ_LED_B",$.Blockly.Arduino.ORDER_ATOMIC)||"0";return"analogWrite(3, "+a+");\nanalogWrite(5, "+b+");\nanalogWrite(6, "+c+");\n"};var module$exports$Blockly$Arduino$leaphyClick={};
$.Blockly.Arduino.leaphy_click_rgb_digitalwrite=function(a){var b=a.getFieldValue("PIN1"),c=$.Blockly.Arduino.valueToCode(a,"STATE1",$.Blockly.Arduino.ORDER_ATOMIC)||"LOW";$.Blockly.Arduino.reservePin(a,b,$.Blockly.Arduino.PinTypes.OUTPUT,"Digital Write");$.Blockly.Arduino.addSetup("io_"+b,"pinMode("+b+", OUTPUT);",!1);var d=a.getFieldValue("PIN2"),e=$.Blockly.Arduino.valueToCode(a,"STATE2",$.Blockly.Arduino.ORDER_ATOMIC)||"LOW";$.Blockly.Arduino.reservePin(a,d,$.Blockly.Arduino.PinTypes.OUTPUT,"Digital Write");
$.Blockly.Arduino.addSetup("io_"+d,"pinMode("+d+", OUTPUT);",!1);var f=a.getFieldValue("PIN3"),g=$.Blockly.Arduino.valueToCode(a,"STATE3",$.Blockly.Arduino.ORDER_ATOMIC)||"LOW";$.Blockly.Arduino.reservePin(a,f,$.Blockly.Arduino.PinTypes.OUTPUT,"Digital Write");$.Blockly.Arduino.addSetup("io_"+f,"pinMode("+f+", OUTPUT);",!1);return"digitalWrite("+b+", "+c+");\ndigitalWrite("+d+", "+e+");\ndigitalWrite("+f+", "+g+");\n"};var module$exports$Blockly$Arduino$leaphyOriginal={};$.Blockly.Arduino.leaphy_original_set_led=function(a){a=$.Blockly.Arduino.valueToCode(this,"LED_RED",$.Blockly.Arduino.ORDER_ATOMIC)||"0";var b=$.Blockly.Arduino.valueToCode(this,"LED_GREEN",$.Blockly.Arduino.ORDER_ATOMIC)||"0",c=$.Blockly.Arduino.valueToCode(this,"LED_BLUE",$.Blockly.Arduino.ORDER_ATOMIC)||"0";$.Blockly.Arduino.definitions_.define_leaphy_original='#include "Leaphyoriginal1.h"\n';return"setLed("+a+", "+b+", "+c+");\n"};
$.Blockly.Arduino.leaphy_original_set_motor=function(a){a=a.getFieldValue("MOTOR_TYPE");var b=$.Blockly.Arduino.valueToCode(this,"MOTOR_SPEED",$.Blockly.Arduino.ORDER_ATOMIC)||"100";$.Blockly.Arduino.definitions_.define_leaphy_original='#include "Leaphyoriginal1.h"\n';return"setMotor("+a+", "+b+");\n"};$.Blockly.Arduino.leaphy_click_set_motor=$.Blockly.Arduino.leaphy_original_set_motor;
$.Blockly.Arduino.leaphy_original_get_distance=function(a){$.Blockly.Arduino.definitions_.define_leaphy_original='#include "Leaphyoriginal1.h"\n';return["getDistance()",$.Blockly.Arduino.ORDER_ATOMIC]};
$.Blockly.Arduino.leaphy_original_move_motors=function(a){a=a.getFieldValue("MOTOR_DIRECTION");var b=$.Blockly.Arduino.valueToCode(this,"MOTOR_SPEED",$.Blockly.Arduino.ORDER_ATOMIC)||"100";$.Blockly.Arduino.definitions_.define_leaphy_original='#include "Leaphyoriginal1.h"\n';return"moveMotors("+a+", "+b+");\n"};$.Blockly.Arduino.leaphy_original_digital_read=function(a){a=a.getFieldValue("PIN");$.Blockly.Arduino.setups_["setup_input_"+a]="pinMode("+a+", INPUT);";return["digitalRead("+a+")",$.Blockly.Arduino.ORDER_ATOMIC]};
$.Blockly.Arduino.leaphy_original_analog_read=function(a){return["analogRead("+a.getFieldValue("PIN")+")",$.Blockly.Arduino.ORDER_ATOMIC]};
$.Blockly.Arduino.leaphy_original_buzz=function(a){$.Blockly.Arduino.addInclude("arduino","#include <Arduino.h>");$.Blockly.Arduino.addSetup("tone","pinMode(4, OUTPUT);",!1);a=$.Blockly.Arduino.valueToCode(this,"FREQUENCY",$.Blockly.Arduino.ORDER_ATOMIC)||"0";var b=$.Blockly.Arduino.valueToCode(this,"DURATION",$.Blockly.Arduino.ORDER_ATOMIC)||"0";return"tone(4, "+a+", "+b+");\n"};var module$exports$Blockly$Arduino$leaphyCommon={};
$.Blockly.Arduino.leaphy_start=function(a){var b=$.Blockly.Arduino.statementToCode(a,"STACK");if($.Blockly.Arduino.STATEMENT_PREFIX){var c=a.id.replace(/\$/g,"$$$$");b=$.Blockly.Arduino.prefixLines($.Blockly.Arduino.STATEMENT_PREFIX.replace(/%1/g,"'"+c+"'"),$.Blockly.Arduino.INDENT)+b}$.Blockly.Arduino.INFINITE_LOOP_TRAP&&(b=$.Blockly.Arduino.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+a.id+"'")+b);a=$.Blockly.Arduino.scrub_(a,"void leaphyProgram() {\n"+b+"}");$.Blockly.Arduino.userFunctions_.leaphyProgram=
a;$.Blockly.Arduino.addSetup("userSetupCode","leaphyProgram();",!1);return null};$.Blockly.Arduino.leaphy_serial_print_line=function(a){$.Blockly.Arduino.addSetup("serial","Serial.begin(115200);",!1);return"Serial.println("+($.Blockly.Arduino.valueToCode(this,"VALUE",$.Blockly.Arduino.ORDER_ATOMIC)||"0")+");\n"};
$.Blockly.Arduino.leaphy_serial_print_value=function(a){$.Blockly.Arduino.addSetup("serial","Serial.begin(115200);",!1);a=$.Blockly.Arduino.valueToCode(this,"NAME",$.Blockly.Arduino.ORDER_ATOMIC)||"0";var b=$.Blockly.Arduino.valueToCode(this,"VALUE",$.Blockly.Arduino.ORDER_ATOMIC)||"0";return"Serial.print("+a+');\nSerial.print(" = ");\nSerial.println('+b+");\n"};/*
Copyright 2021 Google LLC
SPDX-License-Identifier: Apache-2.0
*/
var module$exports$Blockly$Arduino$all={};
$.Blockly.Arduino.__namespace__=$;
return $.Blockly.Arduino;
}));
//# sourceMappingURL=arduino_compressed.js.map