diff --git a/src/main/webapp/cdn/blockly/generators/arduino.js b/src/main/webapp/cdn/blockly/generators/arduino.js
deleted file mode 100644
index b51ff22f..00000000
--- a/src/main/webapp/cdn/blockly/generators/arduino.js
+++ /dev/null
@@ -1,212 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2012 Google Inc.
- * http://code.google.com/p/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.
- */
-
-/**
- * @fileoverview Helper functions for generating Arduino for blocks.
- * @author gasolin@gmail.com (Fred Lin)
- */
-'use strict';
-
-Blockly.Arduino = Blockly.Generator.get('Arduino');
-
-/**
- * List of illegal variable names.
- * This is not intended to be a security feature. Blockly is 100% client-side,
- * so bypassing this list is trivial. This is intended to prevent users from
- * accidentally clobbering a built-in object or function.
- * @private
- */
-if (!Blockly.Arduino.RESERVED_WORDS_) {
- Blockly.Arduino.RESERVED_WORDS_ = '';
-}
-
-Blockly.Arduino.RESERVED_WORDS_ +=
- // http://arduino.cc/en/Reference/HomePage
-'setup,loop,if,else,for,switch,case,while,do,break,continue,return,goto,define,include,HIGH,LOW,INPUT,OUTPUT,INPUT_PULLUP,true,false,interger, constants,floating,point,void,bookean,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'
-;
-
-/**
- * Order of operation ENUMs.
- *
- */
-Blockly.Arduino.ORDER_ATOMIC = 0; // 0 "" ...
-Blockly.Arduino.ORDER_UNARY_POSTFIX = 1; // expr++ expr-- () [] .
-Blockly.Arduino.ORDER_UNARY_PREFIX = 2; // -expr !expr ~expr ++expr --expr
-Blockly.Arduino.ORDER_MULTIPLICATIVE = 3; // * / % ~/
-Blockly.Arduino.ORDER_ADDITIVE = 4; // + -
-Blockly.Arduino.ORDER_SHIFT = 5; // << >>
-Blockly.Arduino.ORDER_RELATIONAL = 6; // is is! >= > <= <
-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; // expr ? expr : expr
-Blockly.Arduino.ORDER_ASSIGNMENT = 14; // = *= /= ~/= %= += -= <<= >>= &= ^= |=
-Blockly.Arduino.ORDER_NONE = 99; // (...)
-
-/*
- * Arduino Board profiles
- *
- */
-var profile = {
- arduino: {
- description: "Arduino standard-compatible board",
- digital : [["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["A0", "A0"], ["A1", "A1"], ["A2", "A2"], ["A3", "A3"], ["A4", "A4"], ["A5", "A5"]],
- analog : [["A0", "A0"], ["A1", "A1"], ["A2", "A2"], ["A3", "A3"], ["A4", "A4"], ["A5", "A5"]],
- serial : 9600,
- },
- arduino_mega:{
- description: "Arduino Mega-compatible board",
- //53 digital
- //15 analog
- },
-}
-//set default profile to arduino standard-compatible board
-profile["default"] = profile["arduino"];
-//alert(profile.default.digital[0]);
-
-/**
- * Initialise the database of variable names.
- */
-Blockly.Arduino.init = function() {
- // Create a dictionary of definitions to be printed before setups.
- Blockly.Arduino.definitions_ = {};
- // Create a dictionary of setups to be printed before the code.
- Blockly.Arduino.setups_ = {};
-
- if (Blockly.Variables) {
- if (!Blockly.Arduino.variableDB_) {
- Blockly.Arduino.variableDB_ =
- new Blockly.Names(Blockly.Arduino.RESERVED_WORDS_);
- } else {
- Blockly.Arduino.variableDB_.reset();
- }
-
- var defvars = [];
- var variables = Blockly.Variables.allVariables();
- for (var x = 0; x < variables.length; x++) {
- defvars[x] = 'int ' +
- Blockly.Arduino.variableDB_.getDistinctName(variables[x],
- Blockly.Variables.NAME_TYPE) + ';\n';
- }
- Blockly.Arduino.definitions_['variables'] = defvars.join('\n');
- }
-};
-
-/**
- * Prepend the generated code with the variable definitions.
- * @param {string} code Generated code.
- * @return {string} Completed code.
- */
-Blockly.Arduino.finish = function(code) {
- // Indent every line.
- code = ' ' + code.replace(/\n/g, '\n ');
- code = code.replace(/\n\s+$/, '\n');
- code = 'void loop() \n{\n' + code + '\n}';
-
- // Convert the definitions dictionary into a list.
- var imports = [];
- var definitions = [];
- for (var name in Blockly.Arduino.definitions_) {
- var def = Blockly.Arduino.definitions_[name];
- if (def.match(/^#include/)) {
- imports.push(def);
- } else {
- definitions.push(def);
- }
- }
-
- // Convert the setups dictionary into a list.
- var setups = [];
- for (var name in Blockly.Arduino.setups_) {
- setups.push(Blockly.Arduino.setups_[name]);
- }
-
- var allDefs = imports.join('\n') + '\n\n' + definitions.join('\n') + '\nvoid setup() \n{\n '+setups.join('\n ') + '\n}'+ '\n\n';
- return allDefs.replace(/\n\n+/g, '\n\n').replace(/\n*$/, '\n\n\n') + code;
-};
-
-/**
- * Naked values are top-level blocks with outputs that aren't plugged into
- * anything. A trailing semicolon is needed to make this legal.
- * @param {string} line Line of generated code.
- * @return {string} Legal line of code.
- */
-Blockly.Arduino.scrubNakedValue = function(line) {
- return line + ';\n';
-};
-
-/**
- * Encode a string as a properly escaped Arduino string, complete with quotes.
- * @param {string} string Text to encode.
- * @return {string} Arduino string.
- * @private
- */
-Blockly.Arduino.quote_ = function(string) {
- // TODO: This is a quick hack. Replace with goog.string.quote
- string = string.replace(/\\/g, '\\\\')
- .replace(/\n/g, '\\\n')
- .replace(/\$/g, '\\$')
- .replace(/'/g, '\\\'');
- return '\"' + string + '\"';
-};
-
-/**
- * Common tasks for generating Arduino from blocks.
- * Handles comments for the specified block and any connected value blocks.
- * Calls any statements following this block.
- * @param {!Blockly.Block} block The current block.
- * @param {string} code The Arduino code created for this block.
- * @return {string} Arduino code with comments and subsequent blocks added.
- * @this {Blockly.CodeGenerator}
- * @private
- */
-Blockly.Arduino.scrub_ = function(block, code) {
- if (code === null) {
- // Block has handled code generation itself.
- return '';
- }
- var commentCode = '';
- // Only collect comments for blocks that aren't inline.
- if (!block.outputConnection || !block.outputConnection.targetConnection) {
- // Collect comment for this block.
- var comment = block.getCommentText();
- if (comment) {
- commentCode += Blockly.Generator.prefixLines(comment, '// ') + '\n';
- }
- // Collect comments for all value arguments.
- // Don't collect comments for nested statements.
- for (var x = 0; x < block.inputList.length; x++) {
- if (block.inputList[x].type == Blockly.INPUT_VALUE) {
- var childBlock = block.inputList[x].connection.targetBlock();
- if (childBlock) {
- var comment = Blockly.Generator.allNestedComments(childBlock);
- if (comment) {
- commentCode += Blockly.Generator.prefixLines(comment, '// ');
- }
- }
- }
- }
- }
- var nextBlock = block.nextConnection && block.nextConnection.targetBlock();
- var nextCode = this.blockToCode(nextBlock);
- return commentCode + code + nextCode;
-};
diff --git a/src/main/webapp/cdn/blockly/generators/javascript/scribbler.js b/src/main/webapp/cdn/blockly/generators/javascript/scribbler.js
deleted file mode 100644
index c4c3159e..00000000
--- a/src/main/webapp/cdn/blockly/generators/javascript/scribbler.js
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2014 Creating Future.
- * http://www.creatingfuture.eu/
- *
- * 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.
- */
-
-/**
- * @fileoverview Generating Javascript for Scribbler blocks.
- * @author michel@creatingfuture.eu (Michel Lampo)
- */
-'use strict';
-
-Blockly.Javascript = Blockly.Generator.get('Javascript');
-
-Blockly.Javascript.move = function() {
- var code = 'MOTORS.move()';
- return code + '\n';
-};
\ No newline at end of file
diff --git a/src/main/webapp/cdn/blockly/generators/propc.js b/src/main/webapp/cdn/blockly/generators/propc.js
index ac4c8d77..02f83099 100644
--- a/src/main/webapp/cdn/blockly/generators/propc.js
+++ b/src/main/webapp/cdn/blockly/generators/propc.js
@@ -22,6 +22,64 @@
* @author michel@creatingfuture.eu (Michel Lampo)
*/
'use strict';
+
+/**
+ * Quotes - Created by Vale Tolpegin on 29-5-2016.
+ */
+
+var quotes = {
+
+ /**
+ * Create an image of an open or closed quote.
+ * @param {boolean} open True if open quote, false if closed.
+ * @return {!Blockly.FieldImage} The field image of the quote.
+ * @this Blockly.Block
+ */
+ newQuote_: function(open) {
+ if (open === this.RTL) {
+ var file = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==';
+ } else {
+ var file = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC';
+ }
+ return new Blockly.FieldImage(file, 12, 12, '"');
+ }
+
+};
+
+/**
+ * Color Palette - Created by Michel on 30-4-2016.
+ */
+
+var colorPalette = {
+ defaultColors: {
+ 'input': 140,
+ 'output': 165,
+ 'io': 185,
+ 'programming': 205,
+ 'functions': 225,
+ 'variables': 250,
+ 'math': 275,
+ 'binary': 275,
+ 'robot': 295,
+ 'heb': 295,
+ 'ab': 320,
+ 'protocols': 340
+ },
+ activePalette: null,
+ getColor: function (type) {
+ if (colorPalette.activePalette && colorPalette.activePalette[type] !== undefined) {
+ return colorPalette.activePalette[type];
+ }
+ console.log("Missing color type: " + type);
+ return '#000000';
+ }
+
+};
+
+colorPalette.activePalette = colorPalette.defaultColors;
+
+
+
Blockly.propc = new Blockly.Generator('propc');
Blockly.HSV_SATURATION = 0.75;
Blockly.HSV_VALUE = 0.60;
@@ -39,7 +97,7 @@ if (!Blockly.propc.RESERVED_WORDS_) {
Blockly.propc.RESERVED_WORDS_ +=
// http://arduino.cc/en/Reference/HomePage
- 'wait,cogid,if,else,elseif,repeat,switch,case,while,do,break,continue,return,goto,define,include,HIGH,LOW,INPUT,OUTPUT,INPUT_PULLUP,true,false,interger, constants,floating,point,void,bookean,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'
+ 'wait,cogid,if,else,elseif,repeat,switch,case,while,do,break,continue,return,goto,define,include,HIGH,LOW,INPUT,OUTPUT,INPUT_PULLUP,true,false,interger, 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'
;
/**
* Order of operation ENUMs.
@@ -68,7 +126,7 @@ Blockly.propc.ORDER_NONE = 99; // (...)
*/
var profile = {
"activity-board": {
- description: "Parallax propeller Activity board",
+ description: "Propeller Activity Board",
digital: [["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["26", "26"], ["27", "27"]],
servo: [["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"]],
analog: [["A0", "A0"], ["A1", "A1"], ["A2", "A2"], ["A3", "A3"], ["A4", "A4"], ["A5", "A5"]],
@@ -85,10 +143,10 @@ var profile = {
baudrate: 115200
},
"s3": {
- description: "Parallax propeller C3",
- digital: [["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"]],
- servo: [["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"]],
- analog: [["A0", "A0"], ["A1", "A1"], ["A2", "A2"], ["A3", "A3"], ["A4", "A4"], ["A5", "A5"]],
+ description: "Scribbler Robot",
+ digital: [["P0", "0"], ["P1", "1"], ["P2", "2"], ["P3", "3"], ["P4", "4"], ["P5", "5"]],
+ servo: [["P0", "0"], ["P1", "1"], ["P2", "2"], ["P3", "3"], ["P4", "4"], ["P5", "5"]],
+ analog: [["A0", "A0"], ["A1", "A1"]],
eeprom: [["0", "32768"], ["1", "32769"], ["2", "32770"], ["3", "32771"], ["4", "32772"], ["5", "32773"], ["6", "32774"], ["7", "32775"], ["8", "32776"], ["9", "32777"], ["10", "32778"], ["11", "32779"],
["12", "32780"], ["13", "32781"], ["14", "32782"], ["15", "32783"], ["16", "32784"], ["17", "32785"], ["18", "32786"], ["19", "32787"], ["20", "32788"], ["21", "32789"], ["22", "32790"],
["23", "32791"], ["24", "32792"], ["25", "32793"], ["26", "32794"], ["27", "32795"], ["28", "32796"], ["29", "32797"], ["30", "32798"], ["31", "32799"], ["32", "32800"], ["33", "32801"],
@@ -102,7 +160,7 @@ var profile = {
baudrate: 9600
},
"heb": {
- description: "Parallax propeller proto board",
+ description: "Hackable Electronic Badge",
digital: [["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"]],
servo: [["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"]],
analog: [["A0", "A0"], ["A1", "A1"], ["A2", "A2"], ["A3", "A3"], ["A4", "A4"], ["A5", "A5"]],
@@ -118,8 +176,25 @@ var profile = {
["99", "32868"], ["100", "32869"]],
baudrate: 115200
},
+ "flip": {
+ description: "Propeller Flip Board",
+ digital: [["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"]],
+ servo: [["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"]],
+ analog: [["A0", "A0"], ["A1", "A1"], ["A2", "A2"], ["A3", "A3"], ["A4", "A4"], ["A5", "A5"]],
+ eeprom: [["0", "32768"], ["1", "32769"], ["2", "32770"], ["3", "32771"], ["4", "32772"], ["5", "32773"], ["6", "32774"], ["7", "32775"], ["8", "32776"], ["9", "32777"], ["10", "32778"], ["11", "32779"],
+ ["12", "32780"], ["13", "32781"], ["14", "32782"], ["15", "32783"], ["16", "32784"], ["17", "32785"], ["18", "32786"], ["19", "32787"], ["20", "32788"], ["21", "32789"], ["22", "32790"],
+ ["23", "32791"], ["24", "32792"], ["25", "32793"], ["26", "32794"], ["27", "32795"], ["28", "32796"], ["29", "32797"], ["30", "32798"], ["31", "32799"], ["32", "32800"], ["33", "32801"],
+ ["34", "32802"], ["35", "32803"], ["36", "32804"], ["37", "32805"], ["38", "32806"], ["39", "32807"], ["40", "32808"], ["41", "32809"], ["42", "32810"], ["43", "32811"], ["44", "32812"],
+ ["45", "32813"], ["46", "32814"], ["47", "32815"], ["48", "32816"], ["49", "32817"], ["50", "32818"], ["51", "32819"], ["52", "32820"], ["53", "32821"], ["54", "32822"], ["55", "32823"],
+ ["56", "32824"], ["57", "32825"], ["58", "32826"], ["59", "32827"], ["60", "32828"], ["61", "32829"], ["62", "32830"], ["63", "32831"], ["64", "32832"], ["65", "32833"], ["66", "32834"],
+ ["67", "32835"], ["68", "32836"], ["69", "32837"], ["70", "32838"], ["71", "32839"], ["72", "32840"], ["73", "32841"], ["74", "32842"], ["75", "32843"], ["76", "32844"], ["77", "32845"],
+ ["78", "32846"], ["79", "32847"], ["80", "32848"], ["81", "32849"], ["82", "32850"], ["83", "32851"], ["84", "32852"], ["85", "32853"], ["86", "32854"], ["87", "32855"], ["88", "32856"],
+ ["89", "32857"], ["90", "32858"], ["91", "32859"], ["92", "32860"], ["92", "32861"], ["93", "32862"], ["94", "32863"], ["95", "32864"], ["96", "32865"], ["97", "32866"], ["98", "32867"],
+ ["99", "32868"], ["100", "32869"]],
+ baudrate: 115200
+ },
"other": {
- description: "Other propeller boards",
+ description: "Other Propeller Boards",
digital: [["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"]],
servo: [["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"]],
analog: [["A0", "A0"], ["A1", "A1"], ["A2", "A2"], ["A3", "A3"], ["A4", "A4"], ["A5", "A5"]],
@@ -307,4 +382,4 @@ Blockly.propc.scrub_ = function (block, code) {
var nextBlock = block.nextConnection && block.nextConnection.targetBlock();
var nextCode = this.blockToCode(nextBlock);
return commentCode + code + nextCode;
-};
+};
\ No newline at end of file
diff --git a/src/main/webapp/cdn/blockly/generators/propc/GPS.js b/src/main/webapp/cdn/blockly/generators/propc/GPS.js
deleted file mode 100644
index 459221e6..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/GPS.js
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- This file support GPS modules
-
- Author: Vale Tolpegin ( valetolpegin@gmail.com )
-
- *Copyright 2014 Vale Tolpegin.
- *
- *
- * 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.
-
- */
-
-'use strict';
-
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-Blockly.Blocks.PAM_7Q_Init = {
- init: function () {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("PAM7Q GPS Module");
- this.appendDummyInput()
- .appendField("RX pin#")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "RXPIN");
- this.appendDummyInput()
- .appendField("TX pin#")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "TXPIN");
- this.appendDummyInput()
- .appendField("baud")
- .appendField(new Blockly.FieldDropdown([["2400", "2400"], ["9600", "9600"], ["19200", "19200"]]), "BAUD");
-
- this.setNextStatement(true, null);
- this.setPreviousStatement(true, null);
- }
-};
-
-Blockly.Blocks.PAM_7Q_Latitude = {
- init: function () {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("get latitude");
-
- this.setOutput(true, 'Number');
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- }
-};
-
-Blockly.Blocks.PAM_7Q_Longitude = {
- init: function () {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("get longitude");
-
- this.setOutput(true, 'Number');
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- }
-};
-
-Blockly.Blocks.PAM_7Q_Heading = {
- init: function () {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("get heading");
-
- this.setOutput(true, 'Number');
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- }
-};
-
-Blockly.Blocks.PAM_7Q_Altitude = {
- init: function () {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("get altitude");
-
- this.setOutput(true, 'Number');
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- }
-};
-
-Blockly.Blocks.PAM_7Q_SatsTracked = {
- init: function () {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("get # of satellites tracked");
-
- this.setOutput(true, 'Number');
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- }
-};
-
-Blockly.Blocks.PAM_7Q_Velocity = {
- init: function () {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("get velocity in units")
- .appendField(new Blockly.FieldDropdown([["mph", "MPH"], ["knots", "KNOTS"]]), "VELOCITYUNITS");
-
- this.setOutput(true, 'Number');
- this.setNextStatement(false, null);
- this.setPreviousStatement(false, null);
- }
-};
-
-Blockly.propc.PAM_7Q_Init = function() {
- var rx_pin = this.getFieldValue('RXPIN');
- var tx_pin = this.getFieldValue('TXPIN');
- var baud = this.getFieldValue('BAUD');
-
- Blockly.propc.definitions_["include PAM7Q"] = '#include "gps.h"';
-
- var code = 'gps_open(' + rx_pin + ', ' + tx_pin + ', ' + baud + ');\n\npause(100)';
- return code;
-};
-
-Blockly.propc.PAM_7Q_Latitude = function() {
- Blockly.propc.definitions_["include PAM7Q"] = '#include "gps.h"';
-
- var code = 'gps_latitude()';
- return code;
-};
-
-Blockly.propc.PAM_7Q_Longitude = function() {
- Blockly.propc.definitions_["include PAM7Q"] = '#include "gps.h"';
-
- var code = 'gps_longitude()';
- return code;
-};
-
-Blockly.propc.PAM_7Q_Heading = function() {
- Blockly.propc.definitions_["include PAM7Q"] = '#include "gps.h"';
-
- var code = '(int)gps_heading()';
- return code;
-};
-
-Blockly.propc.PAM_7Q_Altitude = function() {
- Blockly.propc.definitions_["include PAM7Q"] = '#include "gps.h"';
-
- var code = 'gps_altitude()';
- return code;
-};
-
-Blockly.propc.PAM_7Q_SatsTracked = function() {
- Blockly.propc.definitions_["include PAM7Q"] = '#include "gps.h"';
-
- var code = 'gps_satsTracked()';
- return code;
-};
-
-Blockly.propc.PAM_7Q_Velocity = function() {
- var velocity_units = this.getFieldValue('VELOCITYUNITS');
-
- Blockly.propc.definitions_["include PAM7Q"] = '#include "gps.h"';
-
- var code = 'gps_velocity(' + velocity_units + ')';
- return code;
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/TiltandAcceleration.js b/src/main/webapp/cdn/blockly/generators/propc/TiltandAcceleration.js
deleted file mode 100644
index fb5e8832..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/TiltandAcceleration.js
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
-
- This file contains support for the Tilt and Acceleration sensors
-
- Author: valetolpegin@gmail.com
-
- *Copyright 2014 Vale Tolpegin.
- *
- *
- * 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.
- */
-'use strict';
-
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-
-Blockly.Blocks.MX2125_acceleration_xaxis = {
- helpUrl: Blockly.MSG_MEMSIC_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_MX2125_ACCELERATION_XAXIS_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("Memsic acceleration x-axis PIN")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINX");
-
- this.setNextStatement(false, null);
- this.setPreviousStatement(false, null);
- this.setOutput(true, 'Number');
- }
-};
-
-Blockly.Blocks.MX2125_acceleration_yaxis = {
- helpUrl: Blockly.MSG_MEMSIC_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_MX2125_ACCELERATION_YAXIS_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("Memsic acceleration y-axis PIN")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINY");
-
- this.setNextStatement(false, null);
- this.setPreviousStatement(false, null);
- this.setOutput(true, 'Number');
- }
-};
-
-Blockly.Blocks.MX2125_rotation = {
- helpUrl: Blockly.MSG_MEMSIC_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_MX2125_ROTATION_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("Memsic rotation x-axis PIN")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINX")
- .appendField("y-axis PIN")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINY");
-
- this.setInputsInline(true);
- this.setNextStatement(false, null);
- this.setPreviousStatement(false, null);
- this.setOutput(true, 'Number');
- }
-};
-
-Blockly.Blocks.MX2125_tilt_xaxis = {
- helpUrl: Blockly.MSG_MEMSIC_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_MX2125_TILT_XAXIS_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("Memsic tilt x-axis PIN")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINX");
-
- this.setNextStatement(false, null);
- this.setPreviousStatement(false, null);
- this.setOutput(true, 'Number');
- }
-};
-
-Blockly.Blocks.MX2125_tilt_yaxis = {
- helpUrl: Blockly.MSG_MEMSIC_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_MX2125_TILT_YAXIS_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("Memsic tilt y-axis PIN")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINY");
-
- this.setNextStatement(false, null);
- this.setPreviousStatement(false, null);
- this.setOutput(true, 'Number');
- }
-};
-
-Blockly.Blocks.MMA7455_init = {
- helpUrl: Blockly.MSG_ACCELEROMETER_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_MMA7455_INIT_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("Accelerometer initialize CS")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINZ")
- .appendField("DATA")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINX")
- .appendField("CLK")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINY");
-
- this.setInputsInline(false);
- this.setNextStatement(true, null);
- this.setPreviousStatement(true, null);
- }
-};
-
-Blockly.Blocks.MMA7455_acceleration = {
- helpUrl: Blockly.MSG_ACCELEROMETER_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_MMA7455_ACCELERATION_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("Accelerometer store x-axis in")
- .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'X_VAR')
- .appendField(" y-axis in")
- .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'Y_VAR')
- .appendField(" z-axis in")
- .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'Z_VAR');
-
- this.setInputsInline(false);
- this.setNextStatement(true, null);
- this.setPreviousStatement(true, null);
- },
- getVars: function () {
- return [this.getFieldValue('X_VAR'), this.getFieldValue('Y_VAR'), this.getFieldValue('Z_VAR')];
- },
- renameVar: function (oldName, newName) {
- if (Blockly.Names.equals(oldName, this.getFieldValue('X_VAR'))) {
- this.setTitleValue(newName, 'X_VAR');
- } else if (Blockly.Names.equals(oldName, this.getFieldValue('Y_VAR'))) {
- this.setTitleValue(newName, 'Y_VAR');
- } else if (Blockly.Names.equals(oldName, this.getFieldValue('Z_VAR'))) {
- this.setTitleValue(newName, 'Z_VAR');
- }
- }
-};
-
-Blockly.Blocks.HMC5883L_init = {
- helpUrl: Blockly.MSG_COMPASS_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_HMC5883L_INIT_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("Compass initialize SCL")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "SCL");
- this.appendDummyInput()
- .appendField("SDA")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "SDA");
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.HMC5883L_read = {
- helpUrl: Blockly.MSG_COMPASS_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_HMC5883L_READ_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("Compass heading store in")
- .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'HEADING');
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- },
- getVars: function () {
- return [this.getFieldValue('HEADING')];
- },
- renameVar: function (oldName, newName) {
- if (Blockly.Names.equals(oldName, this.getFieldValue('HEADING'))) {
- this.setTitleValue(newName, 'HEADING');
- }
- }
-};
-
-Blockly.propc.MX2125_acceleration_xaxis = function () {
- var pin = this.getFieldValue('PINX');
-
- Blockly.propc.definitions_["include_mx2125"] = '#include "mx2125.h"';
-
- var code = 'mx_accel(' + pin + ')';
- return [code, Blockly.propc.ORDER_NONE];
-};
-
-Blockly.propc.MX2125_acceleration_yaxis = function () {
- Blockly.propc.definitions_["include_mx2125"] = '#include "mx2125.h"';
-
- var pin = this.getFieldValue('PINY');
- var code = 'mx_accel(' + pin + ')';
-
- return [code, Blockly.propc.ORDER_NONE];
-};
-
-Blockly.propc.MX2125_rotation = function () {
- var pinx = this.getFieldValue('PINX');
- var piny = this.getFieldValue('PINY');
-
- Blockly.propc.definitions_["include_mx2125"] = '#include "mx2125.h"';
-
- var code = 'mx_rotate(' + pinx + ', ' + piny + ')';
- return [code, Blockly.propc.ORDER_NONE];
-};
-
-Blockly.propc.MX2125_tilt_xaxis = function () {
- var pin = this.getFieldValue('PINX');
-
- Blockly.propc.definitions_["include_mx2125"] = '#include "mx2125.h"';
-
- var code = 'mx_tilt(' + pin + ')';
- return [code, Blockly.propc.ORDER_NONE];
-};
-
-Blockly.propc.MX2125_tilt_yaxis = function () {
- var pin = this.getFieldValue('PINY');
-
- Blockly.propc.definitions_["include_mx2125"] = '#include "mx2125.h"';
-
- var code = 'mx_tilt(' + pin + ')';
- return [code, Blockly.propc.ORDER_NONE];
-};
-
-Blockly.propc.MMA7455_acceleration = function () {
-
- var xstorage = Blockly.propc.variableDB_.getName(this.getFieldValue('X_VAR'), Blockly.Variables.NAME_TYPE);
- var ystorage = Blockly.propc.variableDB_.getName(this.getFieldValue('Y_VAR'), Blockly.Variables.NAME_TYPE);
- var zstorage = Blockly.propc.variableDB_.getName(this.getFieldValue('Z_VAR'), Blockly.Variables.NAME_TYPE);
-
- return 'MMA7455_getxyz10(&' + xstorage + ', &' + ystorage + ', &' + zstorage + ');\n';
-};
-
-Blockly.propc.MMA7455_init = function () {
- var pinx = this.getFieldValue('PINX');
- var piny = this.getFieldValue('PINY');
- var pinz = this.getFieldValue('PINZ');
-
- Blockly.propc.definitions_["include_mma7455"] = '#include "mma7455.h"';
- Blockly.propc.setups_["mma_7455"] = 'MMA7455_init(' + pinx + ', ' + piny + ', ' + pinz + ');\n';
-
- return '';
-};
-
-Blockly.propc.HMC5883L_init = function () {
- var scl = this.getFieldValue("SCL");
- var sda = this.getFieldValue("SDA");
-
- Blockly.propc.definitions_["HMC5883L"] = '#include "compass3d.h"';
- Blockly.propc.setups_["HMC5883L"] = 'int compX, compY, compZ;\n\ti2c *bus = i2c_newbus(' + scl + ', ' + sda + ', 0);\n\tcompass_init(bus);';
-
- return '';
-};
-
-Blockly.propc.HMC5883L_read = function () {
- var storage = Blockly.propc.variableDB_.getName(this.getFieldValue('HEADING'), Blockly.Variables.NAME_TYPE);
-
- return 'compass_read(bus, &compX, &compY, &compZ);\n\tfloat fy = (float) compY;\n\tfloat fx = (float) compX;\n\tfloat heading = atan2(fy, fx) * 180.0/PI;\n\tif(heading < 0.0)\n\t\theading = (360.0 + heading);\n\t' + storage + ' = (int) heading;\n';
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/abdrive.js b/src/main/webapp/cdn/blockly/generators/propc/abdrive.js
deleted file mode 100644
index 9c8f4986..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/abdrive.js
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2014 Michel Lampo.
- *
- *
- * 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.
- */
-
-/**
- * @fileoverview Generating Prop-C for basic blocks.
- * @author michel@creatingfuture.eu (Michel Lampo)
- */
-'use strict';
-
-//define blocks
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-Blockly.Blocks.ab_drive_goto = {
- init: function() {
- this.setColour(colorPalette.getColor('robot'));
- this.appendDummyInput()
- .appendField('Drive goto')
- .appendField('Left')
- .appendField(new Blockly.FieldTextInput('64',
- Blockly.FieldTextInput.numberValidator), 'LEFT')
- .appendField('Right')
- .appendField(new Blockly.FieldTextInput('64',
- Blockly.FieldTextInput.numberValidator), 'RIGHT');
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.ab_drive_speed = {
- init: function() {
- this.setColour(colorPalette.getColor('robot'));
- this.appendDummyInput()
- .appendField('Drive speed')
- .appendField('Left')
- .appendField(new Blockly.FieldTextInput('64',
- Blockly.FieldTextInput.numberValidator), 'LEFT')
- .appendField('Right')
- .appendField(new Blockly.FieldTextInput('64',
- Blockly.FieldTextInput.numberValidator), 'RIGHT');
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.ab_drive_ramp = {
- init: function() {
- this.setColour(colorPalette.getColor('output'));
- this.appendDummyInput()
- .appendField("Drive ramp step")
- .appendField("Left speed")
- .appendField(new Blockly.FieldDropdown([["-1", "-1"], ["-2", "-2"], ["-3", "-3"], ["-4", "-4"], ["-5", "-5"], ["-6", "-6"], ["-7", "-7"], ["-8", "-8"], ["-9", "-9"], ["-10", "-10"], ["-11", "-11"], ["-12", "-12"], ["-13", "-13"], ["-14", "-14"], ["-15", "-15"], ["-16", "-16"], ["-17", "-17"], ["-18", "-18"], ["-19", "-19"], ["-20", "-20"], ["-21", "-21"], ["-22", "-22"], ["-23", "-23"], ["-24", "-24"], ["-25", "-25"], ["-26", "-26"], ["-27", "-27"], ["-28", "-28"], ["-29", "-29"], ["-30", "-30"], ["-31", "-31"], [ "-32", "-32"], ["-33", "-33"], ["-34", "-34"], ["-35", "-35"], ["-36", "-36"], ["-37", "-37"], ["-38", "-38"], ["-39", "-39"], ["-40", "-40"], ["-41", "-41"], ["-42", "-42"], ["-43", "-43"], ["-44", "-44"], ["-45", "-45"], ["-46", "-46"], ["-47", "-47"], ["-48", "-48"], ["-49", "-49"], ["-50", "-50"], ["-51", "-51"], ["-52", "-52"], ["-53", "-53"], ["-54", "-54"], ["-55", "-55"], ["-56", "-56"], ["-57", "-57"], ["-58", "-58"], ["-59", "-59"], ["-60", "-60"], ["-61", "-61"], ["-62", "-62"], ["-63", "-63"], ["-64", "-64"], ["-65", "-65"], ["-66", "-66"], ["-67", "-67"], ["-68", "-68"], ["-69", "-69"], ["-70", "-70"], ["-71", "-71"], ["-72", "-72"], ["-73", "-73"], ["-74", "-74"], ["-75", "-75"], ["-76", "-76"], ["-77", "-77"], ["-78", "-78"], ["-79", "-79"], ["-80", "-80"], ["-81", "-81"], ["-82", "-82"], ["-83", "-83"], ["-84", "-84"], ["-85", "-85"], ["-86", "-86"], ["-87", "-87"], ["-88", "-88"], ["-89", "-89"], ["-90", "-90"], ["-91", "-91"], ["-92", "-92"], ["-93", "-93"], ["-94", "-94"], ["-95", "-95"], ["-96", "-96"], ["-97", "-97"], ["-98", "-98"], ["-99", "-99"], ["-100", "-100"], ["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"], [ "32", "32"], ["33", "33"], ["34", "34"], ["35", "35"], ["36", "36"], ["37", "37"], ["38", "38"], ["39", "39"], ["40", "40"], ["41", "41"], ["42", "42"], ["43", "43"], ["44", "44"], ["45", "45"], ["46", "46"], ["47", "47"], ["48", "48"], ["49", "49"], ["50", "50"], ["51", "51"], ["52", "52"], ["53", "53"], ["54", "54"], ["55", "55"], ["56", "56"], ["57", "57"], ["58", "58"], ["59", "59"], ["60", "60"], ["61", "61"], ["62", "62"], ["63", "63"], ["64", "64"], ["65", "65"], ["66", "66"], ["67", "67"], ["68", "68"], ["69", "69"], ["70", "70"], ["71", "71"], ["72", "72"], ["73", "73"], ["74", "74"], ["75", "75"], ["76", "76"], ["77", "77"], ["78", "78"], ["79", "79"], ["80", "80"], ["81", "81"], ["82", "82"], ["83", "83"], ["84", "84"], ["85", "85"], ["86", "86"], ["87", "87"], ["88", "88"], ["89", "89"], ["90", "90"], ["91", "91"], ["92", "92"], ["93", "93"], ["94", "94"], ["95", "95"], ["96", "96"], ["97", "97"], ["98", "98"], ["99", "99"], ["100", "100"]]), 'LEFT_SPEED');
- this.appendDummyInput()
- .appendField("Right speed")
- .appendField(new Blockly.FieldDropdown([["-1", "-1"], ["-2", "-2"], ["-3", "-3"], ["-4", "-4"], ["-5", "-5"], ["-6", "-6"], ["-7", "-7"], ["-8", "-8"], ["-9", "-9"], ["-10", "-10"], ["-11", "-11"], ["-12", "-12"], ["-13", "-13"], ["-14", "-14"], ["-15", "-15"], ["-16", "-16"], ["-17", "-17"], ["-18", "-18"], ["-19", "-19"], ["-20", "-20"], ["-21", "-21"], ["-22", "-22"], ["-23", "-23"], ["-24", "-24"], ["-25", "-25"], ["-26", "-26"], ["-27", "-27"], ["-28", "-28"], ["-29", "-29"], ["-30", "-30"], ["-31", "-31"], [ "-32", "-32"], ["-33", "-33"], ["-34", "-34"], ["-35", "-35"], ["-36", "-36"], ["-37", "-37"], ["-38", "-38"], ["-39", "-39"], ["-40", "-40"], ["-41", "-41"], ["-42", "-42"], ["-43", "-43"], ["-44", "-44"], ["-45", "-45"], ["-46", "-46"], ["-47", "-47"], ["-48", "-48"], ["-49", "-49"], ["-50", "-50"], ["-51", "-51"], ["-52", "-52"], ["-53", "-53"], ["-54", "-54"], ["-55", "-55"], ["-56", "-56"], ["-57", "-57"], ["-58", "-58"], ["-59", "-59"], ["-60", "-60"], ["-61", "-61"], ["-62", "-62"], ["-63", "-63"], ["-64", "-64"], ["-65", "-65"], ["-66", "-66"], ["-67", "-67"], ["-68", "-68"], ["-69", "-69"], ["-70", "-70"], ["-71", "-71"], ["-72", "-72"], ["-73", "-73"], ["-74", "-74"], ["-75", "-75"], ["-76", "-76"], ["-77", "-77"], ["-78", "-78"], ["-79", "-79"], ["-80", "-80"], ["-81", "-81"], ["-82", "-82"], ["-83", "-83"], ["-84", "-84"], ["-85", "-85"], ["-86", "-86"], ["-87", "-87"], ["-88", "-88"], ["-89", "-89"], ["-90", "-90"], ["-91", "-91"], ["-92", "-92"], ["-93", "-93"], ["-94", "-94"], ["-95", "-95"], ["-96", "-96"], ["-97", "-97"], ["-98", "-98"], ["-99", "-99"], ["-100", "-100"], ["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"], [ "32", "32"], ["33", "33"], ["34", "34"], ["35", "35"], ["36", "36"], ["37", "37"], ["38", "38"], ["39", "39"], ["40", "40"], ["41", "41"], ["42", "42"], ["43", "43"], ["44", "44"], ["45", "45"], ["46", "46"], ["47", "47"], ["48", "48"], ["49", "49"], ["50", "50"], ["51", "51"], ["52", "52"], ["53", "53"], ["54", "54"], ["55", "55"], ["56", "56"], ["57", "57"], ["58", "58"], ["59", "59"], ["60", "60"], ["61", "61"], ["62", "62"], ["63", "63"], ["64", "64"], ["65", "65"], ["66", "66"], ["67", "67"], ["68", "68"], ["69", "69"], ["70", "70"], ["71", "71"], ["72", "72"], ["73", "73"], ["74", "74"], ["75", "75"], ["76", "76"], ["77", "77"], ["78", "78"], ["79", "79"], ["80", "80"], ["81", "81"], ["82", "82"], ["83", "83"], ["84", "84"], ["85", "85"], ["86", "86"], ["87", "87"], ["88", "88"], ["89", "89"], ["90", "90"], ["91", "91"], ["92", "92"], ["93", "93"], ["94", "94"], ["95", "95"], ["96", "96"], ["97", "97"], ["98", "98"], ["99", "99"], ["100", "100"]]), 'RIGHT_SPEED');
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.ab_drive_set_ramp_step = {
- init: function() {
- this.setColour(colorPalette.getColor('output'));
- this.appendDummyInput()
- .appendField("Drive set ramp step")
- .appendField("Left rampstep")
- .appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"], ["20", "20"]]), 'LEFT_RAMP_STEP');
- this.appendDummyInput()
- .appendField("Right rampstep")
- .appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"], ["20", "20"]]), 'RIGHT_RAMP_STEP');
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.propc.ab_drive_goto = function() {
- var left = Number(this.getFieldValue('LEFT'));
- var right = Number(this.getFieldValue('RIGHT'));
-
- Blockly.propc.definitions_["include abdrive"] = '#include "abdrive.h"';
-
- return 'drive_goto(' + left + ', ' + right + ');\n';
-};
-
-Blockly.propc.ab_drive_speed = function() {
- var left = Number(this.getFieldValue('LEFT'));
- var right = Number(this.getFieldValue('RIGHT'));
-
- Blockly.propc.definitions_["include abdrive"] = '#include "abdrive.h"';
-
- return 'drive_speed(' + left + ', ' + right + ');\n';
-};
-
-Blockly.propc.ab_drive_ramp = function() {
- var left_speed = this.getFieldValue('LEFT_SPEED');
- var right_speed = this.getFieldValue('RIGHT_SPEED');
-
- Blockly.propc.definitions_["include abdrive"] = '#include "abdrive.h"';
-
- return 'drive_ramp(' + left_speed + ', ' + right_speed + ');\n';
-};
-
-Blockly.propc.ab_drive_set_ramp_step = function() {
- var left_ramp_speed = this.getFieldValue('LEFT_RAMP_STEP');
- var right_ramp_speed = this.getFieldValue('RIGHT_RAMP_STEP');
-
- Blockly.propc.definitions_["include abdrive"] = '#include "abdrive.h"';
-
- return 'drive_rampStep(' + left_ramp_speed + ', ' + right_ramp_speed + ');\n';
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/abvolts.js b/src/main/webapp/cdn/blockly/generators/propc/abvolts.js
deleted file mode 100644
index 2c363188..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/abvolts.js
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2014 Michel Lampo
- *
- * 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.
- */
-
-/**
- * @fileoverview Generating C for ActivityBoard ADC
- * @author michel@creatingfuture.eu (Michel Lampo)
- */
-'use strict';
-
-//define blocks
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-Blockly.Blocks.ab_volt_in = {
- helpUrl: Blockly.MSG_ANALOG_PULSES_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_AB_VOLT_IN_TOOLTIP);
- this.setColour(colorPalette.getColor('io'));
- this.appendDummyInput()
- .appendField("A/D channel")
- .appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"]]), "CHANNEL")
- .appendField("read (0-5V) in volt-100ths");
- this.setOutput(true, 'Number');
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- }
-};
-
-Blockly.Blocks.ab_volt_out = {
- helpUrl: Blockly.MSG_ANALOG_PULSES_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_AB_VOLT_OUT_TOOLTIP);
- this.setColour(colorPalette.getColor('io'));
- this.appendDummyInput()
- .appendField("D/A channel")
- .appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"]]), "CHANNEL")
- .appendField("output (0-3.3V)");
- this.appendValueInput("VALUE")
- .setCheck('Number')
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("volt-100ths");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.propc.ab_volt_in = function() {
- var dropdown_channel = this.getFieldValue('CHANNEL');
-
- Blockly.propc.definitions_["include abvolt"] = '#include "abvolts.h"';
- if (Blockly.propc.setups_['setup_abvolt'] === undefined) {
- Blockly.propc.setups_['setup_abvolt'] = 'ad_init(21, 20, 19, 18);';
- }
-
- var code = '(ad_in(' + dropdown_channel + ') * 500 / 4096)';
- return [code, Blockly.propc.ORDER_NONE];
-};
-
-Blockly.propc.ab_volt_out = function() {
- var dropdown_channel = this.getFieldValue('CHANNEL');
- var value = Blockly.propc.valueToCode(this, 'VALUE', Blockly.propc.ORDER_NONE) || '0';
-
- Blockly.propc.definitions_["include abvolt"] = '#include "abvolts.h"';
- if (Blockly.propc.setups_['setup_abvolt_out'] === undefined) {
- Blockly.propc.setups_['setup_abvolt_out'] = 'da_init(26, 27);';
- }
-
- var code = 'da_out(' + dropdown_channel + ', (' + value + '* 256 / 330));\n';
- return code;
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/activitybot.js b/src/main/webapp/cdn/blockly/generators/propc/activitybot.js
deleted file mode 100644
index 64b09f8d..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/activitybot.js
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2016 Vale Tolpegin
- * https://github.com/gasolin/BlocklyDuino
- *
- * 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.
- */
-
-/**
- * @fileoverview Generating C for ActivityBot Blocks
- * @author valetolpegin@gmail.com (Vale Tolpegin)
- */
-'use strict';
-
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-Blockly.Blocks.activitybot_calibrate = {
- init: function() {
- this.setColour(colorPalette.getColor('output'));
- this.appendDummyInput()
- .appendField("Calibrate");
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.activitybot_display_calibration = {
- init: function() {
- this.setColour(colorPalette.getColor('output'));
- this.appendDummyInput()
- .appendField("Display calibration");
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.propc.activitybot_calibrate = function() {
- Blockly.propc.definitions_["activitybot_calibrate"] = '#include "abcalibrate.h"';
- Blockly.propc.setups_["activitybot_calibrate"] = 'cal_servoPins(12, 13);\n\tcal_encoderPins(14, 15);';
-
- return 'cal_activityBot();\n';
-};
-
-Blockly.propc.activitybot_display_calibration = function() {
- return 'drive_displayInterpolation();\n';
-}
diff --git a/src/main/webapp/cdn/blockly/generators/propc/base.js b/src/main/webapp/cdn/blockly/generators/propc/base.js
index 9245f6c0..ac01cdce 100644
--- a/src/main/webapp/cdn/blockly/generators/propc/base.js
+++ b/src/main/webapp/cdn/blockly/generators/propc/base.js
@@ -1,8 +1,7 @@
/**
* Visual Blocks Language
*
- * Copyright 2014 Michel Lampo.
- *
+ * Copyright 2014 Michel Lampo, Vale Tolpegin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,8 +17,13 @@
*/
/**
- * @fileoverview Generating Prop-C for basic blocks.
+ * @fileoverview Generating C for sensor blocks
* @author michel@creatingfuture.eu (Michel Lampo)
+ * valetolpegin@gmail.com (Vale Tolpegin)
+ * jewald@parallax.com (Jim Ewald)
+ * mmatz@parallax.com (Matthew Matz)
+ * kgracey@parallax.com (Ken Gracey)
+ * carsongracey@gmail.com (Carson Gracey)
*/
'use strict';
@@ -28,89 +32,195 @@ if (!Blockly.Blocks)
Blockly.Blocks = {};
-Blockly.propc.make_pin = function () {
- var dropdown_pin = this.getFieldValue('PIN');
- var dropdown_action = this.getFieldValue('ACTION');
- switch (dropdown_action) {
- case "HIGH":
- return 'high(' + dropdown_pin + ');\n';
- case "LOW":
- return 'low(' + dropdown_pin + ');\n';
- case "TOGGLE":
- return 'toggle(' + dropdown_pin + ');\n\tset_direction(' + dropdown_pin + ', 1);\n';
- case "INPUT":
- return 'set_direction(' + dropdown_pin + ', 0);\n';
- case "REVERSE":
- return 'reverse(' + dropdown_pin + ');\n';
- }
-};
-
-Blockly.propc.make_pin_input = function () {
- var pin = Blockly.propc.valueToCode(this, 'PIN', Blockly.propc.ORDER_ATOMIC) || 0;
- var dropdown_action = this.getFieldValue('ACTION');
- switch (dropdown_action) {
- case "HIGH":
- return 'high(' + pin + ');\n';
- case "LOW":
- return 'low(' + pin + ');\n';
- case "TOGGLE":
- return 'toggle(' + pin + ');\n\tset_direction(' + pin + ', 1);\n';
- case "INPUT":
- return 'set_direction(' + pin + ', 0);\n';
- case "REVERSE":
- return 'reverse(' + pin + ');\n';
- }
-};
-
-Blockly.propc.check_pin = function () {
- var dropdown_pin = this.getFieldValue('PIN');
-
- var code = 'input(' + dropdown_pin + ')';
- return [code, Blockly.propc.ORDER_ATOMIC];
+Blockly.Blocks.math_number = {
+ helpUrl: Blockly.MSG_VALUES_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_MATH_NUMBER_TOOLTIP);
+ this.setColour(colorPalette.getColor('programming'));
+ this.appendDummyInput()
+ .appendField(new Blockly.FieldTextInput('0',
+ Blockly.FieldTextInput.numberValidator), 'NUM');
+ this.setOutput(true, 'Number');
+ }
};
-Blockly.propc.check_pin_input = function () {
- var dropdown_pin = Blockly.propc.valueToCode(this, 'PIN', Blockly.propc.ORDER_UNARY_PREFIX) || '0';
+Blockly.propc.math_number = function() {
+ // Numeric value.
+ var code = window.parseInt(this.getFieldValue('NUM'));
+ // -4.abs() returns -4 in Dart due to strange order of operation choices.
+ // -4 is actually an operator and a number. Reflect this in the order.
+ var order = code < 0 ?
+ Blockly.propc.ORDER_UNARY_PREFIX : Blockly.propc.ORDER_ATOMIC;
+ return [code, order];
+};
- var code = 'input(' + dropdown_pin + ')';
- return [code, Blockly.propc.ORDER_ATOMIC];
+Blockly.Blocks.math_arithmetic = {
+ init: function() {
+ if(profile.default.description === "Scribbler Robot") {
+ this.setHelpUrl(Blockly.MSG_S3_MATH_HELPURL);
+ } else {
+ this.setHelpUrl(Blockly.MSG_NUMBERS_HELPURL);
+ }
+ this.setTooltip(Blockly.MSG_MATH_ARITHMETIC_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.setOutput(true, 'Number');
+ this.appendValueInput('A')
+ .setCheck('Number');
+ this.appendValueInput('B')
+ .setCheck('Number')
+ .appendField(new Blockly.FieldDropdown([
+ ["+", ' + '],
+ ["-", ' - '],
+ ["×", ' * '],
+ ["÷", ' / '],
+ ["% (remainder after division)", ' % '],
+ ["^ (raise to the power of)", ' p ']]), 'OP');
+ this.setInputsInline(true);
+ }
};
-Blockly.propc.set_pins = function () {
- var code = '';
- var action = this.getFieldValue('ACTION');
- var dropdown_pin_count = Number(this.getFieldValue('PIN_COUNT'));
- var dropdown_start_pin = Number(this.getFieldValue('START_PIN'));
- if (action === 'STATE') {
- code = 'set_outputs(';
- } else if (action === 'DIRECTION') {
- code = 'set_directions(';
- }
- //var highestPin = dropdown_start_pin + dropdown_pin_count - 1;
-
- code += dropdown_pin_count;
- code += ', ';
- code += dropdown_start_pin;
- code += ', 0b';
- for (var i = dropdown_pin_count; i >= dropdown_start_pin; i--) {
- code += this.getFieldValue('P' + i);
+Blockly.propc.math_arithmetic = function() {
+ var operator = this.getFieldValue('OP');
+ var order = Blockly.propc.ORDER_MULTIPLICATIVE;
+ if(operator === ' + ' || operator === ' - ') {
+ order = Blockly.propc.ORDER_ADDITIVE;
+ }
+ var argument0 = Blockly.propc.valueToCode(this, 'A', order) || '0';
+ var argument1 = Blockly.propc.valueToCode(this, 'B', order) || '0';
+ var code;
+ if(operator === ' p ') {
+ code = 'pow(' + argument0 + ', ' + argument1 + ')';
+ } else {
+ code = argument0 + operator + argument1;
}
- return code + ');\n';
+ return [code, order];
};
-Blockly.propc.base_delay = function () {
- var delay_time = Blockly.propc.valueToCode(this, 'DELAY_TIME', Blockly.propc.ORDER_ATOMIC) || '1000';
- var code = 'pause(' + delay_time + ');\n';
+Blockly.Blocks.math_limit = {
+ helpUrl: Blockly.MSG_NUMBERS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_MATH_LIMIT_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.appendValueInput('A')
+ .setCheck('Number')
+ .appendField(new Blockly.FieldDropdown([["highest of", " #> "], ["lowest of", " <# "]]), 'OP');
+ this.appendValueInput('B')
+ .setCheck('Number')
+ .appendField("and");
+
+ this.setInputsInline(true);
+ this.setOutput(true, 'Number');
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ }
+};
+
+Blockly.propc.math_limit = function() {
+ var operator = this.getFieldValue('OP');
+ var argument0 = Blockly.propc.valueToCode(this, 'A', Blockly.propc.ORDER_ASSIGNMENT) || '0';
+ var argument1 = Blockly.propc.valueToCode(this, 'B', Blockly.propc.ORDER_ASSIGNMENT) || '0';
+ var code;
+
+ code = argument0 + operator + argument1;
+ return [code, Blockly.propc.ORDER_ASSIGNMENT];
+};
+
+Blockly.Blocks.math_crement = {
+ // Increment/decrement
+ helpUrl: Blockly.MSG_NUMBERS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_MATH_CREMENT_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.appendValueInput('VAR')
+ .setCheck('Number')
+ .appendField(new Blockly.FieldDropdown([["decrement", "--"], ["increment", "++"]]), "OP");
+ this.setPreviousStatement(true);
+ this.setNextStatement(true);
+ }
+};
+
+Blockly.propc.math_crement = function() {
+ var operator = this.getFieldValue('OP');
+ var variable = Blockly.propc.valueToCode(this, 'VAR', Blockly.propc.ORDER_UNARY_PREFIX) || '0';
+
+ var code = variable + operator + ';\n';
return code;
};
-Blockly.propc.base_freqout = function () {
- var dropdown_pin = this.getFieldValue('PIN');
- var duration = Blockly.propc.valueToCode(this, 'DURATION', Blockly.propc.ORDER_ATOMIC) || 1000;
- var frequency = Blockly.propc.valueToCode(this, 'FREQUENCY', Blockly.propc.ORDER_ATOMIC) || 3000;
+Blockly.Blocks.math_random = {
+ helpUrl: Blockly.MSG_NUMBERS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_MATH_RANDOM_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.appendValueInput("A")
+ .setCheck("Number")
+ .appendField("random number from");
+ this.appendValueInput("B")
+ .setCheck("Number")
+ .appendField("to");
+ this.setInputsInline(true);
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ this.setOutput(true, 'Number');
+ }
+};
+
+Blockly.propc.math_random = function() {
+ Blockly.propc.setups_["random_seed"] = "srand(INA + CNT);\n";
+ var arg1 = Blockly.propc.valueToCode(this, 'A', Blockly.propc.ORDER_ATOMIC) || '0';
+ var arg2 = Blockly.propc.valueToCode(this, 'B', Blockly.propc.ORDER_ATOMIC) || '99';
+
+ var code = '(' + arg1 + ' + rand() % (' + arg2 + ' - ' + arg1 + ' + 1))';
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.math_bitwise = {
+ helpUrl: Blockly.MSG_NUMBERS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_MATH_BITWISE_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.appendValueInput('A');
+ this.appendDummyInput()
+ .appendField(new Blockly.FieldDropdown([
+ ["& (bitwise AND)", " & "],
+ ["| (bitwise OR)", " | "],
+ ["^ (bitwise XOR)", " ^ "],
+ [">> (bitwise right shift)", " >> "],
+ ["<< (bitwise left shift)", " << "]]), "OP");
+ this.appendValueInput('B');
+
+ this.setOutput(true, 'Number');
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ }
+};
+
+Blockly.propc.math_bitwise = function() {
+ var argument0 = Blockly.propc.valueToCode(this, 'A', Blockly.propc.ORDER_NONE);
+ var argument1 = Blockly.propc.valueToCode(this, 'B', Blockly.propc.ORDER_NONE);
+ var operator = this.getFieldValue('OP');
- var code = 'freqout(' + dropdown_pin + ', ' + duration + ', ' + frequency + ');\n';
+ var code = argument0 + operator + argument1;
+ return [code, Blockly.propc.ORDER_NONE];
+};
+Blockly.Blocks.base_delay = {
+ helpUrl: Blockly.MSG_CONTROL_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_BASE_DELAY_TOOLTIP);
+ this.setColour(colorPalette.getColor('programming'));
+ this.appendValueInput("DELAY_TIME", 'Number')
+ .appendField("pause (ms)")
+ .setCheck('Number');
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.base_delay = function () {
+ var delay_time = Blockly.propc.valueToCode(this, 'DELAY_TIME', Blockly.propc.ORDER_ATOMIC) || '1000';
+ var code = 'pause(' + delay_time + ');\n';
return code;
};
@@ -237,7 +347,11 @@ Blockly.Blocks.char_type_block = {
["123 - {", "123"],
["124 - |", "124"],
["125 - }", "125"],
- ["126 - ~", "126"]]), "CHAR");
+ ["126 - ~", "126"],
+ ["10 - line feed", "10"],
+ ["11 - tab", "11"],
+ ["13 - ccarriage return", "13"],
+ ["127 - delete", "127"]]), "CHAR");
this.setPreviousStatement(false, null);
this.setNextStatement(false, null);
this.setOutput(true, 'Number');
@@ -305,29 +419,6 @@ Blockly.propc.high_low_value = function() {
return [code, Blockly.propc.ORDER_ATOMIC];
};
-Blockly.propc.pulse_in = function() {
- var pin = this.getFieldValue("PIN");
- var state = this.getFieldValue("STATE");
-
- var code = 'pulse_in(' + pin + ', ' + state + ')';
- return [code, Blockly.propc.ORDER_NONE];
-};
-
-Blockly.propc.pulse_out = function() {
- var pin = this.getFieldValue("PIN");
- var pulse_length = Blockly.propc.valueToCode(this, 'PULSE_LENGTH', Blockly.propc.ORDER_ATOMIC);
-
- return 'pulse_out(' + pin + ', ' + pulse_length + ');\n';
-};
-
-Blockly.propc.rc_charge_discharge = function() {
- var pin = this.getFieldValue("PIN");
- var state = this.getFieldValue("STATE");
-
- var code = 'rc_time(' + pin + ', ' + state + ')';
- return [code, Blockly.propc.ORDER_NONE];
-};
-
Blockly.Blocks.comment = {
helpUrl: Blockly.MSG_CONTROL_HELPURL,
init: function() {
@@ -348,6 +439,9 @@ Blockly.propc.comment = function() {
return '// ' + text + '\n';
};
+/*
+ * Casting Blocks are not currently used (Everything is a string or an int)
+
Blockly.Blocks.cast = {
init: function() {
this.setColour(colorPalette.getColor('math'));
@@ -370,6 +464,7 @@ Blockly.propc.cast = function() {
var code = "" + type + item;
return [code, Blockly.propc.ORDER_NONE];
};
+*/
Blockly.Blocks.color_picker = {
helpUrl: Blockly.MSG_VALUES_HELPURL,
@@ -480,3 +575,598 @@ Blockly.propc.compare_colors = function() {
var code = 'compareRRGGBB(' + color1 + ', ' + color2 + ')';
return [code];
};
+
+Blockly.Blocks.logic_compare = {
+ // Comparison operator.
+ category: Blockly.LANG_CATEGORY_LOGIC,
+ init: function() {
+ if(profile.default.description === "Scribbler Robot") {
+ this.setHelpUrl(Blockly.MSG_S3_MATH_HELPURL);
+ } else {
+ this.setHelpUrl(Blockly.MSG_NUMBERS_HELPURL);
+ }
+ this.setTooltip(Blockly.MSG_LOGIC_COMPARE_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.setOutput(true, 'Number');
+ this.appendValueInput('A')
+ .setCheck("Number");
+ this.appendValueInput('B')
+ .setCheck("Number")
+ .appendField(new Blockly.FieldDropdown([['=', '=='], ['\u2260', '!='], ['<', '<'], ['\u2264', '<='], ['>', '>'], ['\u2265', '>=']]), 'OP');
+ this.setInputsInline(true);
+ }
+};
+
+Blockly.propc.logic_compare = function() {
+ // Comparison operator.
+ var operator = this.getFieldValue('OP');
+ var order = (operator === '==' || operator === '!=') ?
+ Blockly.propc.ORDER_EQUALITY : Blockly.propc.ORDER_RELATIONAL;
+ var argument0 = Blockly.propc.valueToCode(this, 'A', order) || '0';
+ var argument1 = Blockly.propc.valueToCode(this, 'B', order) || '0';
+ var code = argument0 + ' ' + operator + ' ' + argument1;
+ return [code, order];
+};
+
+Blockly.Blocks.logic_operation = {
+ // Logical operations: 'and', 'or'.
+ category: Blockly.LANG_CATEGORY_LOGIC,
+ init: function() {
+ if(profile.default.description === "Scribbler Robot") {
+ this.setHelpUrl(Blockly.MSG_S3_MATH_HELPURL);
+ } else {
+ this.setHelpUrl(Blockly.MSG_NUMBERS_HELPURL);
+ }
+ this.setTooltip(Blockly.MSG_LOGIC_OPERATION_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.setOutput(true, 'Number');
+ this.appendValueInput('A')
+ .setCheck('Number');
+ this.appendValueInput('B')
+ .setCheck('Number')
+ .appendField(new Blockly.FieldDropdown([['and', ' && '], ['or', ' || '], ['and not', ' && !'], ['or not', ' || !']]), 'OP');
+ this.setInputsInline(true);
+ }
+};
+
+Blockly.propc.logic_operation = function() {
+ // Operations 'and', 'or'.
+ var operator = this.getFieldValue('OP');
+ var order = Blockly.propc.ORDER_LOGICAL_AND;
+ if(operator === ' || ' || operator === ' || !') {
+ order = Blockly.propc.ORDER_LOGICAL_OR;
+ }
+ var argument0 = Blockly.propc.valueToCode(this, 'A', order) || '0';
+ var argument1 = Blockly.propc.valueToCode(this, 'B', order) || '0';
+ var code = argument0 + ' ' + operator + argument1;
+ return [code, order];
+};
+
+Blockly.Blocks.logic_negate = {
+ // Negation.
+ //category: Blockly.LANG_CATEGORY_LOGIC,
+ init: function() {
+ if(profile.default.description === "Scribbler Robot") {
+ this.setHelpUrl(Blockly.MSG_S3_MATH_HELPURL);
+ } else {
+ this.setHelpUrl(Blockly.MSG_NUMBERS_HELPURL);
+ }
+ this.setTooltip(Blockly.MSG_LOGIC_NEGATE_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.setOutput(true, 'Number');
+ this.appendValueInput('BOOL')
+ .setCheck('Number')
+ .appendField(new Blockly.FieldDropdown([["not", '!'], ["negate", '-'], ["abs", 'abs(']]), 'OP');
+ }
+};
+
+Blockly.propc.logic_negate = function() {
+ // Negation.
+ var order = Blockly.propc.ORDER_UNARY_PREFIX;
+ var operator = this.getFieldValue('OP');
+ var argument0 = Blockly.propc.valueToCode(this, 'BOOL', order) || '0';
+ var code = operator + argument0;
+ if(operator === 'abs(') {
+ code += ')';
+ order = Blockly.propc.ORDER_NONE;
+ }
+ return [code, order];
+};
+
+Blockly.Blocks.logic_boolean = {
+ // Boolean data type: true and false.
+ //category: Blockly.LANG_CATEGORY_LOGIC,
+ helpUrl: Blockly.MSG_VALUES_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_LOGIC_BOOLEAN_TOOLTIP);
+ this.setColour(colorPalette.getColor('programming'));
+ this.setOutput(true, 'Number');
+ this.appendDummyInput()
+ .appendField(new Blockly.FieldDropdown([["true", 'TRUE'], ["false", 'FALSE']]), 'BOOL');
+ }
+};
+
+Blockly.propc.logic_boolean = function() {
+ // Boolean values true and false.
+ var code = (this.getFieldValue('BOOL') === 'TRUE') ? '1' : '0';
+ return [code, Blockly.propc.ORDER_ATOMIC];
+};
+
+Blockly.Blocks.cog_new = {
+ helpUrl: Blockly.MSG_CONTROL_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_COG_NEW_TOOLTIP);
+ this.setColour(colorPalette.getColor('programming'));
+ this.appendDummyInput()
+ .appendField("new processor");
+ this.appendStatementInput("METHOD")
+ .appendField("function");
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.cog_new = function() {
+ var method = Blockly.propc.statementToCode(this, 'METHOD');
+ method = method.replace(" ", "").replace("\n", "").replace("()", "").replace(";", "");
+
+ var code = 'cog_run(' + method + ', 128);\n';
+ return code;
+};
+
+Blockly.Blocks.combine_strings = {
+ helpUrl: Blockly.MSG_STRINGS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_COMBINE_STRINGS_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.appendValueInput("STRA")
+ .setCheck("String")
+ .appendField("combine string");
+ this.appendValueInput("STRB")
+ .setCheck("String")
+ .appendField("with string");
+ this.appendDummyInput()
+ .appendField("store in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VALUE');
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ },
+
+ getVars: function () {
+ return [this.getFieldValue('VALUE')];
+ },
+
+ renameVar: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
+ this.setTitleValue(newName, 'VALUE');
+ }
+ }
+};
+
+Blockly.propc.combine_strings = function () {
+ var strA = Blockly.propc.valueToCode(this, 'STRA', Blockly.propc.ORDER_ATOMIC) || '';
+ var strB = Blockly.propc.valueToCode(this, 'STRB', Blockly.propc.ORDER_ATOMIC) || '';
+ var data = Blockly.propc.variableDB_.getName(this.getFieldValue('VALUE'), Blockly.Variables.NAME_TYPE);
+ var code = '';
+
+ Blockly.propc.vartype_[data] = 'char *';
+
+ if(strA !== '' && strB !== '') {
+ Blockly.propc.definitions_['str_Buffer'] = 'char *__scBfr;';
+
+ code += 'sprint(__scBfr, "%s%s", ' + strA + ', ' + strB + ');\n';
+ code += 'strcpy(' + data + ', __scBfr);\n';
+ } else if(strA !== ''){
+ code += 'strcpy(' + data + ', ' + strB + ');\n';
+ } else if(strB !== ''){
+ code += 'strcpy(' + data + ', ' + strA + ');\n';
+ } else {
+ code += '// Both of the strings to combine are blank!\n';
+ }
+ return code;
+};
+
+Blockly.Blocks.find_substring = {
+ helpUrl: Blockly.MSG_STRINGS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_FIND_SUBSTRING_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.appendValueInput("SUBSTR")
+ .setCheck("String")
+ .appendField("find location of text");
+ this.appendValueInput("STR")
+ .setCheck("String")
+ .appendField("in string");
+ this.setInputsInline(true);
+ this.setOutput(true, "Number");
+ }
+};
+
+Blockly.propc.find_substring = function () {
+ var subs = Blockly.propc.valueToCode(this, 'SUBSTR', Blockly.propc.ORDER_ATOMIC) || '';
+ var strs = Blockly.propc.valueToCode(this, 'STR', Blockly.propc.ORDER_ATOMIC) || '';
+
+ Blockly.propc.definitions_['find_sub'] = 'int find_sub(char *__strS, char *__subS) { char* __pos = strstr(__strS, __subS); return (__pos - __strS + 1); }\n';
+
+ var code = '';
+
+ if(subs !== '' && strs !== '') {
+ code += 'find_sub(' + strs + ', ' + subs + ')';
+ } else {
+ code += '0';
+ }
+
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.get_char_at_position = {
+ helpUrl: Blockly.MSG_STRINGS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_GET_CHAR_AT_POSITION_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.appendValueInput("POSITION")
+ .setCheck("Number")
+ .appendField("get character at position");
+ this.appendDummyInput()
+ .appendField("of")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VALUE');
+ this.setInputsInline(true);
+ this.setOutput(true, "Number");
+ },
+
+ getVars: function () {
+ return [this.getFieldValue('VALUE')];
+ },
+
+ renameVar: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
+ this.setTitleValue(newName, 'VALUE');
+ }
+ }
+};
+
+Blockly.propc.get_char_at_position = function () {
+ var pos = Blockly.propc.valueToCode(this, 'POSITION', Blockly.propc.ORDER_ATOMIC) || '1';
+ var data = Blockly.propc.variableDB_.getName(this.getFieldValue('VALUE'), Blockly.Variables.NAME_TYPE);
+
+ var code = '0';
+
+ if(Blockly.propc.vartype_[data] === 'char *')
+ {
+ code = data + '[(' + pos + '>strlen(' + data + ')?strlen(' + data + '):' + pos + ')-1]';
+ }
+
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.set_char_at_position = {
+ helpUrl: Blockly.MSG_STRINGS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_SET_CHAR_AT_POSITION_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.appendValueInput("POSITION")
+ .setCheck("Number")
+ .appendField("set character at position");
+ this.appendDummyInput()
+ .appendField("of string")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VALUE');
+ this.appendValueInput("CHAR")
+ .setCheck("Number")
+ .appendField("to");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.set_char_at_position = function () {
+ var pos = Blockly.propc.valueToCode(this, 'POSITION', Blockly.propc.ORDER_ATOMIC) || '1';
+ var chr = Blockly.propc.valueToCode(this, 'CHAR', Blockly.propc.ORDER_ATOMIC) || '32';
+ var data = Blockly.propc.variableDB_.getName(this.getFieldValue('VALUE'), Blockly.Variables.NAME_TYPE);
+
+ return data + '[(' + pos + '>strlen(' + data + ')?strlen(' + data + '):' + pos + ')-1] = (' + chr + ' & 0xFF)\n;';
+};
+
+Blockly.Blocks.get_substring = {
+ helpUrl: Blockly.MSG_STRINGS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_GET_SUBSTRING_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.appendDummyInput()
+ .appendField("get part of string")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'FROM_STR');
+ this.appendValueInput("START")
+ .setCheck("Number")
+ .appendField("from position");
+ this.appendValueInput("END")
+ .setCheck("Number")
+ .appendField("to position");
+ this.appendDummyInput()
+ .appendField("store in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'TO_STR');
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.get_substring = function () {
+ var sst = Blockly.propc.valueToCode(this, 'START', Blockly.propc.ORDER_ATOMIC) || '1';
+ var snd = Blockly.propc.valueToCode(this, 'END', Blockly.propc.ORDER_ATOMIC) || '2';
+ var frStr = Blockly.propc.variableDB_.getName(this.getFieldValue('FROM_STR'), Blockly.Variables.NAME_TYPE);
+ var toStr = Blockly.propc.variableDB_.getName(this.getFieldValue('TO_STR'), Blockly.Variables.NAME_TYPE);
+
+ Blockly.propc.vartype_[toStr] = 'char *';
+ Blockly.propc.definitions_['str_Buffer'] = 'char *__scBfr;';
+
+ var code = '';
+
+ if(Blockly.propc.vartype_[frStr] === 'char *')
+ {
+ Blockly.propc.definitions_['__ssIdx'] = 'int __ssIdx, __stIdx;';
+
+ code += '__stIdx = 0;\nfor(__ssIdx = (' + sst + '-1); __ssIdx <= (' + snd +' <= strlen(' + frStr + ')?' + snd +':strlen(' + frStr + '))-1; __ssIdx++) {\n__scBfr[__stIdx] = ' + frStr + '[__ssIdx]; __stIdx++; }\n';
+ code += '__scBfr[__stIdx] = 0;\n';
+ code += 'strcpy(' + toStr + ', __scBfr);\n';
+ }
+
+ return code;
+};
+
+Blockly.Blocks.string_compare = {
+ helpUrl: Blockly.MSG_STRINGS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_STRING_COMPARE_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.appendValueInput("STRA")
+ .setCheck("String")
+ .appendField("string");
+ this.appendValueInput("STRB")
+ .setCheck("String")
+ .appendField(new Blockly.FieldDropdown([["is the same as", "=="], ["is not the same as", "!="], ["is alphabetically before", "<"], ["is alphabetically after", ">"]]), "COMP");
+ this.setInputsInline(true);
+ this.setOutput(true, "Number");
+ }
+};
+
+Blockly.propc.string_compare = function () {
+ var strA = Blockly.propc.valueToCode(this, 'STRA', Blockly.propc.ORDER_ATOMIC) || '';
+ var strB = Blockly.propc.valueToCode(this, 'STRB', Blockly.propc.ORDER_ATOMIC) || '';
+ var comp = this.getFieldValue('COMP');
+
+ Blockly.propc.definitions_['str_comp'] = 'int str_comp(char *__strA, char *__strB) { return strcmp(__strA, __strB); }';
+
+ var code = '';
+
+ if(strA !== '' && strB !== '') {
+ code += 'str_comp(' + strA + ', ' + strB + ') ' + comp + ' 0';
+ } else {
+ code += '0';
+ }
+
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.string_to_number = {
+ helpUrl: Blockly.MSG_STRINGS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_STRING_TO_NUMBER_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.appendValueInput("STRING")
+ .setCheck("String")
+ .appendField("string");
+ this.appendDummyInput()
+ .appendField(new Blockly.FieldDropdown([["in decimal", "%d"], ["in hexadecimal", "%x"], ["in binary", "%b"]]), "TYPE")
+ .appendField("to integer store in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), "VAR");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.string_to_number = function () {
+ var str = Blockly.propc.valueToCode(this, 'STRING', Blockly.propc.ORDER_ATOMIC) || '0';
+ var type = this.getFieldValue('TYPE');
+ var store = Blockly.propc.variableDB_.getName(this.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE);
+
+ Blockly.propc.definitions_['s2i_Buffer'] = 'char __s2iBfr[64];';
+
+ var code = '';
+ code += 'strcpy(__s2iBfr, ' + str + ');\n';
+ code += 'sscan(__s2iBfr, "' + type + '", &' + store + ');\n';
+
+ return code;
+};
+
+Blockly.Blocks.number_to_string = {
+ helpUrl: Blockly.MSG_STRINGS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_NUMBER_TO_STRING_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.appendValueInput("NUMBER")
+ .setCheck("Number")
+ .appendField("integer");
+ this.appendDummyInput()
+ .appendField("to string in")
+ .appendField(new Blockly.FieldDropdown([["decimal", "%d"], ["hexadecimal", "%x"], ["binary", "%b"]]), "TYPE")
+ .appendField("store in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), "VAR");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.number_to_string = function () {
+ var str = Blockly.propc.valueToCode(this, 'NUMBER', Blockly.propc.ORDER_ATOMIC) || '0';
+ var type = this.getFieldValue('TYPE');
+ var store = Blockly.propc.variableDB_.getName(this.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE);
+
+ Blockly.propc.vartype_[str] = 'char *';
+
+ return 'sprint(' + store + ', "' + type + '", ' + str + ');\n';
+};
+
+Blockly.Blocks.number_binary = {
+ helpUrl: Blockly.MSG_VALUES_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_NUMBER_BINARY_TOOLTIP);
+ this.setColour(colorPalette.getColor('programming'));
+ this.appendDummyInput()
+ .appendField(new Blockly.FieldTextInput("0101"), "NUMBER")
+ .appendField("binary");
+ this.setOutput(true, "Number");
+ }
+};
+
+Blockly.propc.number_binary = function() {
+ var code = '0b' + this.getFieldValue("NUMBER");
+
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.number_hex = {
+ helpUrl: Blockly.MSG_VALUES_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_NUMBER_HEX_TOOLTIP);
+ this.setColour(colorPalette.getColor('programming'));
+ this.appendDummyInput()
+ .appendField(new Blockly.FieldTextInput("7F"), "NUMBER")
+ .appendField("hexadecimal");
+ this.setOutput(true, "Number");
+ }
+};
+
+Blockly.propc.number_hex = function() {
+ var code = '0x' + this.getFieldValue("NUMBER");
+
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.constrain_value = {
+ helpUrl: Blockly.MSG_NUMBERS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_CONSTRAIN_VALUE_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.appendValueInput("NUMBER")
+ .setCheck("Number")
+ .appendField("constrain");
+ this.appendDummyInput()
+ .appendField("from")
+ .appendField(new Blockly.FieldTextInput("0"), "MIN")
+ .appendField("(min) to")
+ .appendField(new Blockly.FieldTextInput("100"), "MAX")
+ .appendField("(max)");
+ this.setInputsInline(true);
+ this.setOutput(true, "Number");
+ }
+};
+
+Blockly.propc.constrain_value = function() {
+ var num = Blockly.propc.valueToCode(this, 'NUMBER', Blockly.propc.ORDER_ATOMIC) || '0';
+ var min = window.parseInt(this.getFieldValue('MIN'));
+ var max = window.parseInt(this.getFieldValue('MAX'));
+
+ var setup_code = '// Constrain Function\nint constrain(int __cVal, int __cMin, int __cMax) {';
+ setup_code += 'if(__cVal < __cMin) __cVal = __cMin;\n';
+ setup_code += 'if(__cVal > __cMax) __cVal = __cMax;\nreturn __cVal;\n}\n';
+ Blockly.propc.global_vars_["constrain_function"] = setup_code;
+
+ var code = 'constrain(' + num + ', ' + min + ', ' + max + ')';
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.math_advanced = {
+ helpUrl: Blockly.MSG_NUMBERS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_MATH_ADVANCED_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.appendValueInput("ARG1")
+ .setCheck("Number");
+ this.appendValueInput("ARG2")
+ .setCheck("Number")
+ .appendField(new Blockly.FieldDropdown([
+ ["× the cosine of", "cos"],
+ ["× the sine of", "sin"],
+ ["× the tangent of", "tan"],
+ ["× the square root of", "sqrt"],
+ ["× e raised to the power of", "exp"],
+ ["× the logarithm (base 10) of", "log10"],
+ ["× the natural logarithm of", "log"]]), "OP");
+ this.appendDummyInput("")
+ .appendField("store in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'STORE');
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ },
+ getVars: function () {
+ return [this.getFieldValue('STORE')];
+ },
+ renameVar: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getFieldValue('STORE'))) {
+ this.setTitleValue(newName, 'STORE');
+ }
+ }
+};
+
+Blockly.propc.math_advanced = function() {
+ var store = Blockly.propc.variableDB_.getName(this.getFieldValue('STORE'), Blockly.Variables.NAME_TYPE);
+ var arg1 = Blockly.propc.valueToCode(this, 'ARG1', Blockly.propc.ORDER_ATOMIC) || '1';
+ var arg2 = Blockly.propc.valueToCode(this, 'ARG2', Blockly.propc.ORDER_ATOMIC) || '1';
+ var operator = this.getFieldValue('OP');
+ var opTrig = '';
+ if(operator === 'sin' || operator === 'cos' || operator === 'tan') opTrig = ' * PI/180.0';
+
+ var code = store + ' = (int) (((float)' + arg1 + ') * ' + operator + '(((float) ' + arg2 + ')' + opTrig + ') + 0.5);\n';
+
+ return code;
+};
+
+Blockly.Blocks.math_inv_trig = {
+ helpUrl: Blockly.MSG_NUMBERS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_MATH_INV_TRIG_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.appendValueInput("ARG1")
+ .setCheck("Number")
+ .appendField(new Blockly.FieldDropdown([
+ ["arcsine of (", "asin"],
+ ["arccosine of (", "acos"],
+ ["arctangent of (", "atan2"]]), "OP");
+ this.appendValueInput("ARG2")
+ .setCheck("Number")
+ .appendField("÷");
+ this.appendDummyInput()
+ .appendField(") store in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'STORE');
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ },
+ getVars: function () {
+ return [this.getFieldValue('STORE')];
+ },
+ renameVar: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getFieldValue('STORE'))) {
+ this.setTitleValue(newName, 'STORE');
+ }
+ }
+};
+
+Blockly.propc.math_inv_trig = function() {
+ var store = Blockly.propc.variableDB_.getName(this.getFieldValue('STORE'), Blockly.Variables.NAME_TYPE);
+ var arg1 = Blockly.propc.valueToCode(this, 'ARG1', Blockly.propc.ORDER_ATOMIC) || '1';
+ var arg2 = Blockly.propc.valueToCode(this, 'ARG2', Blockly.propc.ORDER_ATOMIC) || '1';
+ var operator = this.getFieldValue('OP');
+ var opTrig = '/';
+ if(operator === 'atan2') opTrig = ',';
+
+ var code = store + ' = (int) (180.0 * ' + operator + '(((float) ' + arg1 + ')' + opTrig + '((float) ' + arg2 + ')) / PI + 0.5);\n';
+
+ return code;
+};
\ No newline at end of file
diff --git a/src/main/webapp/cdn/blockly/generators/propc/bit_math.js b/src/main/webapp/cdn/blockly/generators/propc/bit_math.js
deleted file mode 100644
index 558fd7fd..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/bit_math.js
+++ /dev/null
@@ -1,166 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2014 Michel Lampo.
- * https://github.com/gasolin/BlocklyDuino
- *
- * 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.
- */
-
-/**
- * @fileoverview Generating Prop-C for control blocks.
- * @author michel@creatingfuture.eu (Michel Lampo)
- */
-'use strict';
-
-//define blocks
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-Blockly.Blocks.bit_math_shift = {
- init: function () {
- this.setColour(colorPalette.getColor('binary'));
- this.setOutput(true, 'Number');
- this.appendValueInput('A')
- .setCheck('Number');
- this.appendValueInput('B')
- .setCheck('Number')
- .appendField(new Blockly.FieldDropdown(this.OPERATORS), 'OP');
-
- this.setInputsInline(true);
- this.setTooltip("");
- }
-};
-
-Blockly.Blocks.bit_math_shift.OPERATORS = [
- ["Shift left", 'LEFT'],
- ["Shift right", 'RIGHT']
-];
-
-Blockly.propc.bit_math_shift = function() {
- // Basic arithmetic operators, and power.
- var mode = this.getFieldValue('OP');
- var tuple = Blockly.propc.bit_math_shift.OPERATORS[mode];
- var operator = tuple[0];
- var order = tuple[1];
- var argument0 = Blockly.propc.valueToCode(this, 'A', order) || '0';
- var argument1 = Blockly.propc.valueToCode(this, 'B', order) || '0';
-
- var code = argument0 + operator + argument1;
- return [code, order];
-};
-
-Blockly.propc.bit_math_shift.OPERATORS = {
- LEFT: [' << ', Blockly.propc.ORDER_UNARY_PREFIX],
- RIGHT: [' >> ', Blockly.propc.ORDER_UNARY_PREFIX]
-};
-
-// Rotate
-Blockly.Blocks.bit_math_rotate = {
- init: function () {
- this.setColour(colorPalette.getColor('binary'));
- this.setOutput(true, 'Number');
- this.appendValueInput('A')
- .setCheck('Number');
- this.appendValueInput('B')
- .setCheck('Number')
- .appendField(new Blockly.FieldDropdown(this.OPERATORS), 'OP');
- this.setInputsInline(true);
- this.setTooltip("");
- }
-};
-
-Blockly.Blocks.bit_math_rotate.OPERATORS = [
- ["Rotate left", 'LEFT'],
- ["Rotate right", 'RIGHT']
-];
-
-Blockly.propc.bit_math_rotate = function() {
- // Basic arithmetic operators, and power.
- var mode = this.getFieldValue('OP');
- var tuple = Blockly.propc.bit_math_rotate.OPERATORS[mode];
- var operator = tuple[0];
- var order = tuple[1];
- var argument0 = Blockly.propc.valueToCode(this, 'A', order) || '0';
- var argument1 = Blockly.propc.valueToCode(this, 'B', order) || '0';
-
- var code = argument0 + operator + argument1;
- return [code, order];
-};
-
-Blockly.propc.bit_math_rotate.OPERATORS = {
- LEFT: [' <- ', Blockly.propc.ORDER_UNARY_PREFIX],
- RIGHT: [' -> ', Blockly.propc.ORDER_UNARY_PREFIX]
-};
-
-// BIT-wise operations
-Blockly.Blocks.bit_math_operations = {
- init: function () {
- this.setColour(colorPalette.getColor('binary'));
- this.setOutput(true, 'Number');
- this.appendValueInput('A')
- .setCheck('Number');
- this.appendValueInput('B')
- .setCheck('Number')
- .appendField(new Blockly.FieldDropdown(this.OPERATORS), 'OP');
-
- this.setInputsInline(true);
- this.setTooltip("");
- }
-};
-
-Blockly.Blocks.bit_math_operations.OPERATORS = [
- ["Bit AND", 'AND'],
- ["Bit OR", 'OR'],
- ["Bit XOR", 'XOR']
-];
-
-Blockly.propc.bit_math_operations = function() {
- // Basic arithmetic operators, and power.
- var mode = this.getFieldValue('OP');
- var tuple = Blockly.propc.bit_math_operations.OPERATORS[mode];
- var operator = tuple[0];
- var order = tuple[1];
- var argument0 = Blockly.propc.valueToCode(this, 'A', order) || '0';
- var argument1 = Blockly.propc.valueToCode(this, 'B', order) || '0';
-
- var code = argument0 + operator + argument1;
- return [code, order];
-};
-
-Blockly.propc.bit_math_operations.OPERATORS = {
- AND: [' & ', Blockly.propc.ORDER_UNARY_PREFIX],
- OR: [' | ', Blockly.propc.ORDER_UNARY_PREFIX],
- XOR: [' ^ ', Blockly.propc.ORDER_UNARY_PREFIX]
-};
-
-// NOT
-Blockly.Blocks.bit_math_not = {
- init: function () {
- this.setColour(colorPalette.getColor('binary'));
- this.appendValueInput('VAR')
- .setCheck('Number')
- .appendField('Bit NOT');
-
- this.setOutput(true, 'Number');
- this.setTooltip("");
- }
-};
-
-Blockly.propc.bit_math_not = function() {
- var variable = Blockly.propc.valueToCode(this, 'VAR', Blockly.propc.ORDER_UNARY_PREFIX) || '0';
-
- var code = '~' + variable;
- return [code, Blockly.propc.ORDER_UNARY_PREFIX];
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/cog.js b/src/main/webapp/cdn/blockly/generators/propc/cog.js
deleted file mode 100644
index b1f1f59e..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/cog.js
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-
- This file contains support for multi cog use in Propeller C
-
- Author: valetolpegin@gmail.com ( Vale Tolpegin )
-
- *Copyright 2014 Vale Tolpegin.
- *
- *
- * 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.
-
- */
-'use strict';
-
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-Blockly.Blocks.cog_new = {
- helpUrl: Blockly.MSG_CONTROL_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_COG_NEW_TOOLTIP);
- this.setColour(colorPalette.getColor('programming'));
- this.appendDummyInput()
- .appendField("new processor");
- this.appendStatementInput("METHOD")
- .appendField("function");
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.propc.cog_new = function() {
- var method = Blockly.propc.statementToCode(this, 'METHOD');
- method = method.replace(" ", "").replace("\n", "").replace("()", "").replace(";", "");
-
- var code = 'cog_run(' + method + ', 128);\n';
- return code;
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/communicate.js b/src/main/webapp/cdn/blockly/generators/propc/communicate.js
new file mode 100644
index 00000000..608fb791
--- /dev/null
+++ b/src/main/webapp/cdn/blockly/generators/propc/communicate.js
@@ -0,0 +1,1655 @@
+/**
+ * Visual Blocks Language
+ *
+ * Copyright 2014 Michel Lampo, Vale Tolpegin
+ *
+ * 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.
+ */
+
+/**
+ * @fileoverview Generating C for communicate blocks
+ * @author michel@creatingfuture.eu (Michel Lampo)
+ * valetolpegin@gmail.com (Vale Tolpegin)
+ * jewald@parallax.com (Jim Ewald)
+ * mmatz@parallax.com (Matthew Matz)
+ * kgracey@parallax.com (Ken Gracey)
+ * carsongracey@gmail.com (Carson Gracey)
+ */
+
+'use strict';
+
+//define blocks
+if (!Blockly.Blocks)
+ Blockly.Blocks = {};
+
+// ------------------ Terminal Console Blocks ----------------------------------
+Blockly.Blocks.console_print = {
+ helpUrl: Blockly.MSG_TERMINAL_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_CONSOLE_PRINT_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendValueInput('MESSAGE')
+ .setCheck('String')
+ .appendField("Terminal print text");
+ this.appendDummyInput()
+ .appendField("then a new line")
+ .appendField(new Blockly.FieldCheckbox("FALSE"), "ck_nl");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.console_print = function () {
+ var text = Blockly.propc.valueToCode(this, 'MESSAGE', Blockly.propc.ORDER_ATOMIC);
+ var checkbox = this.getFieldValue('ck_nl');
+
+ Blockly.propc.serial_terminal_ = true;
+
+ var code = 'print(' + text.replace("%","%%") + ');\n';
+ if (checkbox === 'TRUE') { code += 'print("\\r");\n'; }
+ return code;
+};
+
+Blockly.Blocks.console_print_variables = {
+ helpUrl: Blockly.MSG_TERMINAL_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_CONSOLE_PRINT_VARIABLES_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendValueInput('VALUE')
+ .appendField("Terminal print number");
+ this.appendDummyInput()
+ .appendField("as")
+ .appendField(new Blockly.FieldDropdown([
+ ['Decimal','DEC'],
+ ['Hexadecimal','HEX'],
+ ['Binary', 'BIN'],
+ ['ASCII Character', 'CHAR']
+ ]), "FORMAT");
+ this.appendDummyInput()
+ .appendField("then a new line")
+ .appendField(new Blockly.FieldCheckbox("FALSE"), "ck_nl");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.console_print_variables = function () {
+ var value = Blockly.propc.valueToCode(this, 'VALUE', Blockly.propc.ORDER_ATOMIC);
+ var format = this.getFieldValue('FORMAT');
+ var checkbox = this.getFieldValue('ck_nl');
+ Blockly.propc.serial_terminal_ = true;
+
+ var code = 'print(';
+ if (checkbox !== 'TRUE') {
+ if (format === 'BIN') {
+ code += '"%b"';
+ } else if (format === 'HEX') {
+ code += '"%x"';
+ } else if (format === 'DEC') {
+ code += '"%d"';
+ } else {
+ code += '"%c"';
+ }
+ } else {
+ if (format === 'BIN') {
+ code += '"%b\\r"';
+ } else if (format === 'HEX') {
+ code += '"%x\\r"';
+ } else if (format === 'DEC') {
+ code += '"%d\\r"';
+ } else {
+ code += '"%c\\r"';
+ }
+ }
+ if (format === 'CHAR') {
+ code += ', (' + value + ' & 0xFF));\n';
+ } else {
+ code += ', ' + value + ');\n';
+ }
+ return code;
+};
+
+Blockly.Blocks.console_scan_text = {
+ helpUrl: Blockly.MSG_TERMINAL_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_CONSOLE_SCAN_TEXT_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("Terminal receive text store in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VALUE');
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ },
+ getVars: function () {
+ return [this.getFieldValue('VALUE')];
+ },
+ renameVar: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
+ this.setTitleValue(newName, 'VALUE');
+ }
+ }
+
+};
+
+Blockly.propc.console_scan_text = function () {
+ var data = Blockly.propc.variableDB_.getName(this.getFieldValue('VALUE'), Blockly.Variables.NAME_TYPE);
+ Blockly.propc.vartype_[data] = 'char *';
+ Blockly.propc.serial_terminal_ = true;
+
+ if(data !== '') {
+ var code = 'getStr(' + data + ', 128);\n';
+
+ return code;
+ } else {
+ return '';
+ }
+};
+
+Blockly.Blocks.console_scan_number = {
+ helpUrl: Blockly.MSG_TERMINAL_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_CONSOLE_SCAN_NUMBER_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("Terminal receive")
+ .appendField(new Blockly.FieldDropdown([["number (32-bit integer)", "NUMBER"], ["byte (ASCII character)", "BYTE"]]), "TYPE")
+ .appendField("store in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VALUE');
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ },
+ getVars: function () {
+ return [this.getFieldValue('VALUE')];
+ },
+ renameVar: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
+ this.setTitleValue(newName, 'VALUE');
+ }
+ }
+
+};
+
+Blockly.propc.console_scan_number = function () {
+ var type = this.getFieldValue('TYPE');
+ var data = Blockly.propc.variableDB_.getName(this.getFieldValue('VALUE'), Blockly.Variables.NAME_TYPE);
+
+ Blockly.propc.serial_terminal_ = true;
+ var code = '';
+
+ if(data !== '') {
+ if (type === 'NUMBER') {
+ code += 'scan("%d\\n", &' + data + ');\n';
+ } else {
+ code += data + ' = getChar();\n';
+ }
+ return code;
+ } else {
+ return '';
+ }
+};
+
+Blockly.Blocks.console_newline = {
+ helpUrl: Blockly.MSG_TERMINAL_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_CONSOLE_NEWLINE_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("Terminal new line");
+
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.console_newline = function () {
+ Blockly.propc.serial_terminal_ = true;
+ return 'term_cmd(CR);\n';
+};
+
+Blockly.Blocks.console_clear = {
+ helpUrl: Blockly.MSG_TERMINAL_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_CONSOLE_CLEAR_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("Terminal clear screen");
+
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.console_clear = function () {
+ Blockly.propc.serial_terminal_ = true;
+ return 'term_cmd(CLS);\n';
+};
+
+Blockly.Blocks.console_move_to_position = {
+ helpUrl: Blockly.MSG_TERMINAL_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_CONSOLE_MOVE_TO_POSITION_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("Terminal set cursor to row");
+ this.appendValueInput('ROW')
+ .setCheck('Number');
+ this.appendDummyInput()
+ .appendField("column");
+ this.appendValueInput('COLUMN')
+ .setCheck('Number');
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.console_move_to_position = function () {
+ Blockly.propc.serial_terminal_ = true;
+ var row = Blockly.propc.valueToCode(this, 'ROW', Blockly.propc.ORDER_NONE);
+ var column = Blockly.propc.valueToCode(this, 'COLUMN', Blockly.propc.ORDER_NONE);
+
+ if (Number(row) < 0) {
+ row = 0;
+ } else if (Number(row) > 255) {
+ row = 255;
+ }
+
+ if (Number(column) < 0) {
+ column = 0;
+ } else if (Number(column) > 255) {
+ column = 255;
+ }
+
+ return 'term_cmd(CRSRXY, ' + column + ', ' + row + ');\n';
+};
+
+// ----------------------- Serial Protocol Blocks ------------------------------
+Blockly.Blocks.serial_open = {
+ helpUrl: Blockly.MSG_PROTOCOLS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_SERIAL_OPEN_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("Serial initialize RX")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "RXPIN")
+ .appendField("TX")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "TXPIN");
+ this.appendDummyInput()
+ .appendField("baud")
+ .appendField(new Blockly.FieldDropdown([["2400", "2400"], ["4800", "4800"], ["9600", "9600"], ["19200", "19200"], ["57600", "57600"], ["115200", "115200"]]), "BAUD");
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.serial_open = function () {
+ var dropdown_rx_pin = this.getFieldValue('RXPIN');
+ var dropdown_tx_pin = this.getFieldValue('TXPIN');
+ var baud = this.getFieldValue('BAUD');
+
+ Blockly.propc.definitions_["include fdserial"] = '#include "fdserial.h"';
+ Blockly.propc.definitions_["var fdserial"] = 'fdserial *fdser;';
+ Blockly.propc.setups_['setup_fdserial'] = 'fdser = fdserial_open(' + dropdown_rx_pin + ', ' + dropdown_tx_pin + ', 0, ' + baud + ');';
+
+ return '';
+};
+
+Blockly.Blocks.serial_tx = {
+ helpUrl: Blockly.MSG_PROTOCOLS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_SERIAL_TX_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("Serial transmit")
+ .appendField(new Blockly.FieldDropdown([
+ ["number (32-bit integer)", "INT"],
+ ["byte (ASCII character)", "BYTE"]
+ ]), "TYPE");
+ this.appendValueInput('VALUE', Number)
+ .setCheck(null);
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.serial_tx = function () {
+ var type = this.getFieldValue('TYPE');
+ var data = Blockly.propc.valueToCode(this, 'VALUE', Blockly.propc.ORDER_ATOMIC) || '0';
+
+ if (Blockly.propc.setups_["setup_fdserial"] === undefined)
+ {
+ return '//Missing serial port initialize block\n';
+ } else {
+ if(type === "BYTE") {
+ return 'fdserial_txChar(fdser, (' + data + ' & 0xFF) );\n';
+ } else {
+ var code = 'fdserial_txChar(fdser, (' + data + ' >> 24) & 255);\n';
+ code += 'fdserial_txChar(fdser, (' + data + ' >> 16) & 255);\n';
+ code += 'fdserial_txChar(fdser, (' + data + ' >> 8 ) & 255);\n';
+ code += 'fdserial_txChar(fdser, ' + data + ' & 255);\n';
+
+ return code;
+ }
+ }
+};
+
+Blockly.Blocks.serial_send_text = {
+ helpUrl: Blockly.MSG_PROTOCOLS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_SERIAL_SEND_TEXT_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendValueInput('VALUE')
+ .appendField("Serial transmit text")
+ .setCheck('String');
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.serial_send_text = function () {
+ var text = Blockly.propc.valueToCode(this, 'VALUE', Blockly.propc.ORDER_NONE);
+
+ if (Blockly.propc.setups_['setup_fdserial'] === undefined) {
+ return '//Missing serial port initialize block\n';
+ } else {
+ var code = 'dprint(fdser, ' + text.replace("%","%%") + ');\n';
+ code += 'while(!fdserial_txEmpty(fdser));\n';
+ code += 'pause(5);\n';
+
+ return code;
+ }
+};
+
+Blockly.Blocks.serial_rx = {
+ helpUrl: Blockly.MSG_PROTOCOLS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_SERIAL_RX_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("Serial receive")
+ .appendField(new Blockly.FieldDropdown([
+ ["number (32-bit integer)", "INT"],
+ ["byte (ASCII character)", "BYTE"]
+ ]), "TYPE")
+ .appendField("store in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VALUE');
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ },
+ getVars: function () {
+ return [this.getFieldValue('VALUE')];
+ },
+ renameVar: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
+ this.setTitleValue(newName, 'VALUE');
+ }
+ }
+};
+
+Blockly.propc.serial_rx = function () {
+ var type = this.getFieldValue('TYPE');
+ var data = Blockly.propc.variableDB_.getName(this.getFieldValue('VALUE'), Blockly.Variables.NAME_TYPE);
+
+ if (Blockly.propc.setups_["setup_fdserial"] === undefined)
+ {
+ return '//Missing serial port initialize block\n';
+ } else {
+ if(data !== '') {
+ if(type === "BYTE") {
+ return data + ' = fdserial_rxChar(fdser);\n';
+ } else {
+ return data + ' = (fdserial_rxChar(fdser) << 24) | (fdserial_rxChar(fdser) << 16) | (fdserial_rxChar(fdser) << 8) | fdserial_rxChar(fdser);\n';
+ }
+ } else {
+ return '';
+ }
+ }
+};
+
+Blockly.Blocks.serial_receive_text = {
+ helpUrl: Blockly.MSG_PROTOCOLS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_SERIAL_RECEIVE_TEXT_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("Serial receive text store in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VALUE');
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ },
+ getVars: function () {
+ return [this.getFieldValue('VALUE')];
+ },
+ renameVar: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
+ this.setTitleValue(newName, 'VALUE');
+ }
+ }
+};
+
+Blockly.propc.serial_receive_text = function () {
+ var data = Blockly.propc.variableDB_.getName(this.getFieldValue('VALUE'), Blockly.Variables.NAME_TYPE);
+
+ Blockly.propc.global_vars_["ser_rx"] = "int __idx;";
+ Blockly.propc.vartype_[data] = 'char *';
+
+ if (Blockly.propc.setups_["setup_fdserial"] === undefined)
+ {
+ return '//Missing serial port initialize block\n';
+ } else {
+ if(data !== '') {
+ var code = '__idx = 0;\n';
+ code += 'do {\n';
+ code += ' ' + data + '[__idx] = fdserial_rxChar(fdser);\n';
+ code += ' __idx++;\n';
+ code += '} while(fdserial_rxPeek(fdser) != 0);\n';
+ code += data + '[__idx] = 0;\nfdserial_rxFlush(fdser);\n';
+
+ return code;
+ } else {
+ return '';
+ }
+ }
+};
+
+//--------------- Serial LCD Blocks --------------------------------------------
+Blockly.Blocks.debug_lcd_init = {
+ helpUrl: Blockly.MSG_SERIAL_LCD_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_DEBUG_LCD_INIT_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("LCD initialize PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
+ this.appendDummyInput()
+ .appendField("baud")
+ .appendField(new Blockly.FieldDropdown([["2400", "2400"], ["9600", "9600"], ["19200", "19200"]]), "BAUD");
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.debug_lcd_init = function () {
+ var dropdown_pin = this.getFieldValue('PIN');
+ var baud = this.getFieldValue('BAUD');
+
+ Blockly.propc.setups_['setup_debug_lcd'] = 'serial *debug_lcd = serial_open(' + dropdown_pin + ', ' + dropdown_pin + ', 0, ' + baud + ');\n';
+
+ var code = 'writeChar(debug_lcd, 22);\npause(5);\n';
+ return code;
+};
+
+Blockly.Blocks.debug_lcd_music_note = {
+ helpUrl: Blockly.MSG_SERIAL_LCD_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_DEBUG_LCD_MUSIC_NOTE_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("LCD play note")
+ .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")
+ .appendField("octave")
+ .appendField(new Blockly.FieldDropdown([["3rd", "215"], ["4th", "216"], ["5th", "217"], ["6th", "218"], ["7th", "219"]]), "OCTAVE")
+ .appendField("length")
+ .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");
+
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.debug_lcd_music_note = function () {
+ var dropdown_note = this.getFieldValue('NOTE');
+ var dropdown_octave = this.getFieldValue('OCTAVE');
+ var dropdown_length = this.getFieldValue('LENGTH');
+
+ var code = '';
+
+ if(Blockly.propc.setups_['setup_debug_lcd'] === undefined) {
+ code += '//Missing Serial LCD initialize block\n';
+ } else {
+ code += 'writeChar(debug_lcd, ' + dropdown_octave + ');\n';
+ code += 'writeChar(debug_lcd, ' + dropdown_length + ');\n';
+ code += 'writeChar(debug_lcd, ' + dropdown_note + ');\n';
+ }
+
+ return code;
+};
+
+Blockly.Blocks.debug_lcd_print = {
+ helpUrl: Blockly.MSG_SERIAL_LCD_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_DEBUG_LCD_PRINT_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendValueInput('MESSAGE')
+ .setCheck('String')
+ .appendField("LCD print text ");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.debug_lcd_print = function () {
+ var msg = Blockly.propc.valueToCode(this, 'MESSAGE', Blockly.propc.ORDER_NONE);
+
+ if(Blockly.propc.setups_['setup_debug_lcd'] === undefined) {
+ return '//Missing Serial LCD initialize block\n';
+ } else {
+ return 'dprint(debug_lcd, ' + msg.replace("%","%%") + ');\n';
+ }
+};
+
+Blockly.Blocks.debug_lcd_number = {
+ helpUrl: Blockly.MSG_SERIAL_LCD_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_DEBUG_LCD_NUMBER_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendValueInput('VALUE')
+ .appendField("LCD print number");
+ this.appendDummyInput()
+ .appendField("as")
+ .appendField(new Blockly.FieldDropdown([['Decimal','DEC'], ['Hexadecimal','HEX'], ['Binary', 'BIN']]), "FORMAT");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.debug_lcd_number = function () {
+ var value = Blockly.propc.valueToCode(this, 'VALUE', Blockly.propc.ORDER_ATOMIC);
+ var format = this.getFieldValue('FORMAT');
+
+ var code = '';
+
+ if(Blockly.propc.setups_['setup_debug_lcd'] === undefined) {
+ code += '//Missing Serial LCD initialize block\n';
+ } else {
+ code += 'dprint(debug_lcd, ';
+ if (format === 'BIN') {
+ code += '"%b"';
+ }else if (format === 'HEX') {
+ code += '"%x"';
+ }else {
+ code += '"%d"';
+ }
+
+ code += ', ' + value + ');';
+ }
+ return code;
+};
+
+Blockly.Blocks.debug_lcd_action = {
+ helpUrl: Blockly.MSG_SERIAL_LCD_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_DEBUG_LCD_ACTION_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("LCD command")
+ .appendField(new Blockly.FieldDropdown([
+ ["clear screen", "12"],
+ ["move cursor right", "9"],
+ ["move cursor left", "8"],
+ ["move cursor down", "10"],
+ ["carriage return", "13"],
+ ["backlight on", "17"],
+ ["backlight off", "18"],
+ ["display off", "21"],
+ ["display on, cursor off", "22"],
+ ["display on, cursor off, blink", "23"],
+ ["display on, cursor on", "24"],
+ ["display on, cursor on, blink", "25"]
+ ]), "ACTION");
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.debug_lcd_action = function () {
+ var action = this.getFieldValue('ACTION');
+ var code = '';
+
+ if(Blockly.propc.setups_['setup_debug_lcd'] === undefined) {
+ code += '//Missing Serial LCD initialization\n';
+ } else {
+ code += 'writeChar(debug_lcd, ' + action + ');\n';
+ //if(action === '12') {
+ code += 'pause(5);\n';
+ //}
+ }
+ return code;
+};
+
+Blockly.Blocks.debug_lcd_set_cursor = {
+ helpUrl: Blockly.MSG_SERIAL_LCD_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_DEBUG_LCD_SET_CURSOR_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendValueInput('ROW')
+ .appendField("LCD set cursor row")
+ .setCheck('Number');
+ this.appendValueInput('COLUMN')
+ .appendField("column")
+ .setCheck('Number');
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.debug_lcd_set_cursor = function () {
+ var row = Blockly.propc.valueToCode(this, 'ROW', Blockly.propc.ORDER_NONE);
+ var column = Blockly.propc.valueToCode(this, 'COLUMN', Blockly.propc.ORDER_NONE);
+
+ var setup_code = '// Constrain Function\nint constrain(int __cVal, int __cMin, int __cMax) {';
+ setup_code += 'if(__cVal < __cMin) __cVal = __cMin;\n';
+ setup_code += 'if(__cVal > __cMax) __cVal = __cMax;\nreturn __cVal;\n}\n';
+ Blockly.propc.global_vars_["constrain_function"] = setup_code;
+
+ if(Blockly.propc.setups_['setup_debug_lcd'] === undefined) {
+ return '//Missing Serial LCD initialize block\n';
+ } else {
+ return 'writeChar(debug_lcd, (128 + (constrain(' + row + ', 0, 3) * 20) + constrain(' + column + ', 0, 19)));\n';
+ }
+};
+
+//--------------- XBee Blocks --------------------------------------------------
+Blockly.Blocks.xbee_setup = {
+ helpUrl: Blockly.MSG_XBEE_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_XBEE_SETUP_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("XBee initialize DI")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), 'DO_PIN')
+ .appendField("DO")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), 'DI_PIN')
+ .appendField("baud")
+ .appendField(new Blockly.FieldDropdown([["9600", "9600"], ["2400", "2400"], ["4800", "4800"], ["19200", "19200"], ["57600", "57600"], ["115200", "115200"]]), "BAUD");
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.xbee_setup = function () {
+ var do_pin = this.getFieldValue('DO_PIN');
+ var di_pin = this.getFieldValue('DI_PIN');
+ var baud = this.getFieldValue('BAUD');
+
+ Blockly.propc.definitions_["include fdserial"] = '#include "fdserial.h"';
+
+ Blockly.propc.global_vars_["xbee"] = "fdserial *xbee;";
+ Blockly.propc.setups_["xbee"] = 'xbee = fdserial_open(' + di_pin + ', ' + do_pin + ', 0, ' + baud + ');\n';
+
+ return '';
+};
+
+Blockly.Blocks.xbee_transmit = {
+ helpUrl: Blockly.MSG_XBEE_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_XBEE_TRANSMIT_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("XBee transmit")
+ .appendField(new Blockly.FieldDropdown([["text", "TEXT"], ["number (32-bit integer)", "INT"], ["byte (ASCII character)", "BYTE"]]), "TYPE");
+ this.appendValueInput('VALUE', Number)
+ .setCheck(null);
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.xbee_transmit = function () {
+ var type = this.getFieldValue('TYPE');
+ var data = Blockly.propc.valueToCode(this, 'VALUE', Blockly.propc.ORDER_ATOMIC) || '0';
+
+ if (Blockly.propc.setups_["xbee"] === undefined)
+ {
+ return '//Missing xbee initialize block\n';
+ } else {
+ if(type === "BYTE") {
+ return 'fdserial_txChar(xbee, (' + data + ' & 0xFF) );\n';
+ } else if(type === "INT") {
+ return 'dprint(xbee, "%d\\r", ' + data + ');\n';
+ } else {
+ var code = 'dprint(xbee, "%s\\r", ' + data.replace("%","%%") + ');\n';
+ code += 'while(!fdserial_txEmpty(xbee));\n';
+ code += 'pause(5);\n';
+
+ return code;
+ }
+ }
+};
+
+Blockly.Blocks.xbee_receive = {
+ helpUrl: Blockly.MSG_XBEE_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_XBEE_RECEIVE_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("XBee receive")
+ .appendField(new Blockly.FieldDropdown([["text", "TEXT"], ["number (32-bit integer)", "INT"], ["byte (ASCII character)", "BYTE"]]), "TYPE")
+ .appendField("store in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VALUE');
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ },
+ getVars: function () {
+ return [this.getFieldValue('VALUE')];
+ },
+ renameVar: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
+ this.setTitleValue(newName, 'VALUE');
+ }
+ }
+};
+
+Blockly.propc.xbee_receive = function () {
+ var data = Blockly.propc.variableDB_.getName(this.getFieldValue('VALUE'), Blockly.Variables.NAME_TYPE);
+ var type = this.getFieldValue('TYPE');
+
+ if (Blockly.propc.setups_["xbee"] === undefined)
+ {
+ return '//Missing xbee initialize block\n';
+ } else {
+ if(type === "BYTE") {
+ return data + ' = fdserial_rxChar(xbee);\n';
+ } else if(type === "INT") {
+ return 'dscan(xbee, "%d", &' + data + ');\n';
+ } else {
+ Blockly.propc.global_vars_["xbee_rx"] = "int __XBidx;";
+ Blockly.propc.vartype_[data] = 'char *';
+
+ var code = '__XBidx = 0;\n';
+ code += 'while(1) {\n';
+ code += ' ' + data + '[__XBidx] = fdserial_rxChar(xbee);\n';
+ code += ' if(' + data + '[__XBidx] == 13 || ' + data + '[__XBidx] == 10) break;\n';
+ code += ' __XBidx++;\n';
+ code += '}\n';
+ code += data + '[__XBidx] = 0;\nfdserial_rxFlush(xbee);\n';
+ return code;
+ }
+ }
+};
+
+// -------------- OLED Display blocks ------------------------------------------
+Blockly.Blocks.oled_initialize = {
+ helpUrl: Blockly.MSG_OLED_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_OLED_INITIALIZE_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ // Field order DIN, CLK, CS, D/C, RES
+ this.appendDummyInput()
+ .appendField("OLED initialize")
+ .appendField("DIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "DIN")
+ .appendField("CLK")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "CLK")
+ .appendField("CS")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "CS")
+ .appendField("D/C")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "DC")
+ .appendField("RES")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "RES");
+
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.oled_initialize = function () {
+ var cs_pin = this.getFieldValue("CS");
+ var dc_pin = this.getFieldValue("DC");
+ var din_pin = this.getFieldValue("DIN");
+ var clk_pin = this.getFieldValue("CLK");
+ var res_pin = this.getFieldValue("RES");
+
+ Blockly.propc.definitions_["oledtools"] = '#include "oledc.h"';
+ Blockly.propc.setups_["oled"] = 'oledc_init(' + din_pin + ', ' + clk_pin + ', ' + cs_pin + ', ' + dc_pin + ', ' + res_pin + ', 2);';
+
+ return '';
+};
+
+Blockly.Blocks.oled_font_loader = {
+ helpUrl: Blockly.MSG_OLED_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_OLED_FONT_LOADER_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("OLED font loader (EEPROM only)");
+ }
+};
+
+Blockly.propc.oled_font_loader = function () {
+ Blockly.propc.serial_terminal_ = true;
+ Blockly.propc.definitions_["oledfonts"] = '#include "oledc_fontLoader.h"';
+
+ var code = 'oledc_fontLoader();';
+ return code;
+};
+
+Blockly.Blocks.oled_clear_screen = {
+ helpUrl: Blockly.MSG_OLED_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_OLED_CLEAR_SCREEN_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("OLED command")
+ .appendField(new Blockly.FieldDropdown([["clear screen", "CLS"], ["sleep", "SLEEP"], ["wake", "WAKE"], ["invert", "INV"]]), "CMD");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.oled_clear_screen = function() {
+ var cmd = this.getFieldValue("CMD");
+
+ var code = '';
+ if (Blockly.propc.setups_["oled"] === undefined)
+ {
+ code += '//Missing OLED initialize block\n';
+ } else {
+ if(cmd === 'CLS') {
+ code += 'oledc_clear(0, 0, oledc_getWidth(), oledc_getHeight() );\n';
+ } else if(cmd === 'WAKE') {
+ code += 'oledc_wake();\n';
+ } else if(cmd === 'SLEEP') {
+ code += 'oledc_sleep();\n';
+ } else if(cmd === 'INV') {
+ code += 'oledc_invertDisplay();\n';
+ }
+ }
+ return code;
+};
+
+Blockly.Blocks.oled_draw_circle = {
+ helpUrl: Blockly.MSG_OLED_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_OLED_DRAW_CIRCLE_TOOLTIP);
+ // First x/y coordinates
+ this.appendValueInput("POINT_X")
+ .setCheck("Number")
+ .appendField("OLED draw circle at (x)");
+ this.appendValueInput("POINT_Y")
+ .setCheck(null)
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("(y)");
+ this.appendValueInput("RADIUS")
+ .setCheck("Number")
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("radius");
+ // Color picker control
+ this.appendValueInput('COLOR')
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .setCheck('Number')
+ .appendField("color");
+ this.appendDummyInput()
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("fill")
+ .appendField(new Blockly.FieldCheckbox("TRUE"), "ck_fill");
+
+ // Other details
+ this.setInputsInline(false);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('protocols'));
+ }
+};
+
+Blockly.propc.oled_draw_circle = function() {
+ // Ensure header file is included
+ Blockly.propc.definitions_["colormath"] = '#include "colormath.h"';
+
+ var point_x0 = Blockly.propc.valueToCode(this, 'POINT_X', Blockly.propc.ORDER_NONE);
+ var point_y0 = Blockly.propc.valueToCode(this, 'POINT_Y', Blockly.propc.ORDER_NONE);
+ var radius = Blockly.propc.valueToCode(this, 'RADIUS', Blockly.propc.ORDER_NONE);
+ var color = Blockly.propc.valueToCode(this, 'COLOR', Blockly.propc.ORDER_NONE);
+
+ var checkbox = this.getFieldValue('ck_fill');
+ var code;
+
+ if (Blockly.propc.setups_["oled"] === undefined)
+ {
+ code += '//Missing OLED initialize block\n';
+ } else {
+ if (checkbox === 'TRUE') {
+ code = 'oledc_fillCircle(';
+ } else {
+ code = 'oledc_drawCircle(';
+ }
+ code += point_x0 + ', ' + point_y0 + ', ';
+ code += radius + ', ';
+ code += 'oledc_color565(get8bitColor(' + color + ', "RED"), get8bitColor(' + color + ', "GREEN"), get8bitColor(' + color + ', "BLUE")) ';
+ code += ');';
+ }
+ return code;
+};
+
+Blockly.Blocks.oled_draw_line = {
+ helpUrl: Blockly.MSG_OLED_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_OLED_DRAW_LINE_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendValueInput("X_ONE")
+ .setCheck('Number')
+ .appendField("OLED draw line from 1 (x)");
+ this.appendValueInput("Y_ONE")
+ .setCheck('Number')
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("(y)");
+ this.appendValueInput("X_TWO")
+ .setCheck('Number')
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("to 2 (x)");
+ this.appendValueInput("Y_TWO")
+ .setCheck('Number')
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("(y)");
+ this.appendValueInput('COLOR')
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .setCheck('Number')
+ .appendField("color");
+
+ this.setInputsInline(false);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.oled_draw_line = function () {
+ // Ensure header file is included
+ Blockly.propc.definitions_["colormath"] = '#include "colormath.h"';
+
+ var x_one = Blockly.propc.valueToCode(this, "X_ONE", Blockly.propc.ORDER_NONE);
+ var y_one = Blockly.propc.valueToCode(this, "Y_ONE", Blockly.propc.ORDER_NONE);
+ var x_two = Blockly.propc.valueToCode(this, "X_TWO", Blockly.propc.ORDER_NONE);
+ var y_two = Blockly.propc.valueToCode(this, "Y_TWO", Blockly.propc.ORDER_NONE);
+ var color = Blockly.propc.valueToCode(this, 'COLOR', Blockly.propc.ORDER_NONE);
+
+ var code = '';
+ if (Blockly.propc.setups_["oled"] === undefined)
+ {
+ code += '//Missing OLED initialize block\n';
+ } else {
+ code += 'oledc_drawLine(' + x_one + ', ' + y_one + ', ' + x_two + ', ' + y_two + ', ';
+ code += 'oledc_color565(get8bitColor(' + color + ', "RED"), get8bitColor(' + color + ', "GREEN"), get8bitColor(' + color + ', "BLUE")));';
+ }
+ return code;
+};
+
+Blockly.Blocks.oled_draw_pixel = {
+ helpUrl: Blockly.MSG_OLED_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_OLED_DRAW_PIXEL_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendValueInput("X_AXIS")
+ .setCheck('Number')
+ .appendField("OLED draw pixel at");
+ this.appendValueInput("Y_AXIS")
+ .setCheck('Number')
+ .appendField(",");
+ this.appendValueInput('COLOR')
+ .setCheck('Number')
+ .appendField("color");
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.oled_draw_pixel = function() {
+ Blockly.propc.definitions_["colormath"] = '#include "colormath.h"';
+
+ var point_x = Blockly.propc.valueToCode(this, 'X_AXIS', Blockly.propc.ORDER_ATOMIC);
+ var point_y = Blockly.propc.valueToCode(this, 'Y_AXIS', Blockly.propc.ORDER_ATOMIC);
+ var color = Blockly.propc.valueToCode(this, 'COLOR', Blockly.propc.ORDER_NONE);
+
+ var code = '';
+ if (Blockly.propc.setups_["oled"] === undefined)
+ {
+ code += '//Missing OLED initialize block\n';
+ } else {
+ code += 'oledc_drawPixel(' + point_x + ', ' + point_y + ', ';
+ code += 'oledc_color565(get8bitColor(' + color + ', "RED"), get8bitColor(' + color + ', "GREEN"), get8bitColor(' + color + ', "BLUE")));';
+ }
+ return code;
+};
+
+Blockly.Blocks.oled_draw_triangle = {
+ helpUrl: Blockly.MSG_OLED_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_OLED_DRAW_TRIANGLE_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ // First x/y coordinates
+ this.appendValueInput("POINT_X0")
+ .setCheck(null)
+ .appendField("OLED draw triangle at 1 (x)");
+ this.appendValueInput("POINT_Y0")
+ .setCheck(null)
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("(y)");
+ // Second x/y coordinates
+ this.appendValueInput("POINT_X1")
+ .setCheck(null)
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("2 (x)");
+ this.appendValueInput("POINT_Y1")
+ .setCheck(null)
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("(y)");
+ // Third x/y coordinates
+ this.appendValueInput("POINT_X2")
+ .setCheck(null)
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("3 (x)");
+ this.appendValueInput("POINT_Y2")
+ .setCheck(null)
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("(y)");
+ // Color picker control
+ this.appendValueInput('COLOR')
+ .setCheck('Number')
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("color");
+ this.appendDummyInput()
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("fill")
+ .appendField(new Blockly.FieldCheckbox("TRUE"), "ck_fill");
+
+ // Other details
+ this.setInputsInline(false);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.oled_draw_triangle = function() {
+ Blockly.propc.definitions_["colormath"] = '#include "colormath.h"';
+
+ var point_x0 = Blockly.propc.valueToCode(this, 'POINT_X0', Blockly.propc.ORDER_NONE);
+ var point_y0 = Blockly.propc.valueToCode(this, 'POINT_Y0', Blockly.propc.ORDER_NONE);
+ var point_x1 = Blockly.propc.valueToCode(this, 'POINT_X1', Blockly.propc.ORDER_NONE);
+ var point_y1 = Blockly.propc.valueToCode(this, 'POINT_Y1', Blockly.propc.ORDER_NONE);
+ var point_x2 = Blockly.propc.valueToCode(this, 'POINT_X2', Blockly.propc.ORDER_NONE);
+ var point_y2 = Blockly.propc.valueToCode(this, 'POINT_Y2', Blockly.propc.ORDER_NONE);
+ var color = Blockly.propc.valueToCode(this, 'COLOR', Blockly.propc.ORDER_NONE);
+
+ var checkbox = this.getFieldValue('ck_fill');
+ var code;
+ if (Blockly.propc.setups_["oled"] === undefined)
+ {
+ code += '//Missing OLED initialize block\n';
+ } else {
+ if (checkbox === 'TRUE') {
+ code = 'oledc_fillTriangle(';
+ } else {
+ code = 'oledc_drawTriangle(';
+ }
+
+ code += point_x0 + ', ' + point_y0 + ', ';
+ code += point_x1 + ', ' + point_y1 + ', ';
+ code += point_x2 + ', ' + point_y2 + ', ';
+ code += 'oledc_color565(get8bitColor(' + color + ', "RED"), get8bitColor(' + color + ', "GREEN"), get8bitColor(' + color + ', "BLUE")));';
+ }
+ return code;
+};
+
+Blockly.Blocks.oled_draw_rectangle = {
+ helpUrl: Blockly.MSG_OLED_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_OLED_DRAW_RECTANGLE_TOOLTIP);
+ this.appendValueInput("POINT_X")
+ .setCheck("Number")
+ .appendField("OLED draw rectangle at (x)");
+ this.appendValueInput("POINT_Y")
+ .setCheck("Number")
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("(y)");
+ this.appendValueInput("RECT_WIDTH")
+ .setCheck(null)
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("width");
+ this.appendValueInput("RECT_HEIGHT")
+ .setCheck(null)
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("height");
+ this.appendValueInput("RECT_ROUND")
+ .setCheck(null)
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("roundness");
+ // Color picker control
+ this.appendValueInput('COLOR')
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .setCheck('Number')
+ .appendField("color");
+ this.appendDummyInput()
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("fill")
+ .appendField(new Blockly.FieldCheckbox("TRUE"), "ck_fill");
+
+ // Other details
+ this.setInputsInline(false);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('protocols'));
+ }
+};
+
+Blockly.propc.oled_draw_rectangle = function() {
+ Blockly.propc.definitions_["colormath"] = '#include "colormath.h"';
+
+ var point_x = Blockly.propc.valueToCode(this, 'POINT_X', Blockly.propc.ORDER_NONE);
+ var point_y = Blockly.propc.valueToCode(this, 'POINT_Y', Blockly.propc.ORDER_NONE);
+ var width = Blockly.propc.valueToCode(this, 'RECT_WIDTH', Blockly.propc.ORDER_NONE);
+ var height = Blockly.propc.valueToCode(this, 'RECT_HEIGHT', Blockly.propc.ORDER_NONE);
+ var corners = Blockly.propc.valueToCode(this, 'RECT_ROUND', Blockly.propc.ORDER_NONE);
+ var color = Blockly.propc.valueToCode(this, 'COLOR', Blockly.propc.ORDER_NONE);
+
+ var checkbox = this.getFieldValue('ck_fill');
+ var code;
+
+ if (Blockly.propc.setups_["oled"] === undefined)
+ {
+ code += '//Missing OLED initialize block\n';
+ } else {
+ if (corners === '0') {
+ if (checkbox === 'TRUE') {
+ code = 'oledc_fillRect(';
+ } else {
+ code = 'oledc_drawRect(';
+ }
+ code += point_x + ', ' + point_y + ', ' + width + ', ' + height + ', ';
+ } else {
+ // Rounded rectangle
+ if (checkbox === 'TRUE') {
+ code = 'oledc_fillRoundRect(';
+ }
+ else {
+ code = 'oledc_drawRoundRect(';
+ }
+ code += point_x + ', ' + point_y + ', ' + width + ', ' + height + ', ' + corners + ', ';
+ }
+ code += 'oledc_color565(get8bitColor(' + color + ', "RED"), get8bitColor(' + color + ', "GREEN"), get8bitColor(' + color + ', "BLUE")));\n';
+ }
+ return code;
+};
+
+Blockly.Blocks.oled_text_size = {
+ helpUrl: Blockly.MSG_OLED_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_OLED_TEXT_SIZE_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("OLED text size")
+ .appendField(new Blockly.FieldDropdown([["small", "SMALL"], ["medium", "MEDIUM"], ["large", "LARGE"]]), "size_select")
+ .appendField("font")
+ .appendField(new Blockly.FieldDropdown([["sans", "FONT_SANS"], ["serif", "FONT_SERIF"], ["script", "FONT_SCRIPT"], ["bubble", "FONT_BUBBLE"]]), "font_select");
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.oled_text_size = function() {
+ var size = this.getFieldValue('size_select');
+ var font = this.getFieldValue('font_select');
+
+ var code = '';
+ if (Blockly.propc.setups_["oled"] === undefined)
+ {
+ code += '//Missing OLED initialize block\n';
+ } else {
+ // TODO: Update constants when new oledc library is published
+ code += 'oledc_setTextSize(' + size + ');\n';
+ code += 'oledc_setTextFont(' + font + ');\n';
+ }
+ return code;
+};
+
+Blockly.Blocks.oled_text_color = {
+ helpUrl: Blockly.MSG_OLED_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_OLED_TEXT_COLOR_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendValueInput('FONT_COLOR')
+ .setCheck('Number')
+ .appendField("OLED font color");
+ this.appendValueInput('BACKGROUND_COLOR')
+ .setCheck('Number')
+ .appendField("font background color");
+
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.oled_text_color = function() {
+ Blockly.propc.definitions_["colormath"] = '#include "colormath.h"';
+
+ var font_color = Blockly.propc.valueToCode(this, 'FONT_COLOR', Blockly.propc.ORDER_NONE);
+ var background_color = Blockly.propc.valueToCode(this, 'BACKGROUND_COLOR', Blockly.propc.ORDER_NONE);
+
+ var code = '';
+ if (Blockly.propc.setups_["oled"] === undefined)
+ {
+ code += '//Missing OLED initialize block\n';
+ } else {
+ code += 'oledc_setTextColor(';
+
+ // TO DO: Try this - it's shorter but slightly slower:
+ // code += 'remapColor(' + font_color + ', "8R8G8B", "5R6G5B"), remapColor(' + background_color + ', "8R8G8B", "5R6G5B"));\n';
+
+ code += 'oledc_color565(get8bitColor(' + font_color + ', "RED"), get8bitColor(' + font_color + ', "GREEN"), get8bitColor(' + font_color + ', "BLUE")), ';
+ code += 'oledc_color565(get8bitColor(' + background_color + ', "RED"), get8bitColor(' + background_color + ', "GREEN"), get8bitColor(' + background_color + ', "BLUE")));';
+ }
+ return code;
+};
+
+Blockly.Blocks.oled_get_max_height = {
+ helpUrl: Blockly.MSG_OLED_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_OLED_GET_MAX_HEIGHT_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("OLED max height");
+
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ this.setOutput(true, "Number");
+ }
+};
+
+Blockly.propc.oled_get_max_height = function() {
+ if (Blockly.propc.setups_["oled"] === undefined)
+ {
+ return ['0', Blockly.propc.ORDER_NONE];
+ } else {
+ return ['oledc_getHeight()', Blockly.propc.ORDER_NONE];
+ }
+};
+
+Blockly.Blocks.oled_get_max_width = {
+ helpUrl: Blockly.MSG_OLED_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_OLED_GET_MAX_WIDTH_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("OLED max width");
+
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ this.setOutput(true, "Number");
+ }
+};
+
+Blockly.propc.oled_get_max_width = function() {
+ if (Blockly.propc.setups_["oled"] === undefined)
+ {
+ return ['0', Blockly.propc.ORDER_NONE];
+ } else {
+ return ['oledc_getWidth()', Blockly.propc.ORDER_NONE];
+ }
+};
+
+Blockly.Blocks.oled_set_cursor = {
+ helpUrl: Blockly.MSG_OLED_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_OLED_SET_CURSOR_TOOLTIP);
+ this.appendValueInput('X_POS')
+ .setCheck('Number')
+ .appendField("OLED set cursor at (x)");
+ this.appendValueInput('Y_POS')
+ .setCheck('Number')
+ .appendField("(y)");
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('protocols'));
+ }
+};
+
+Blockly.propc.oled_set_cursor = function() {
+
+ // Get user input
+ var x = Blockly.propc.valueToCode(this, 'X_POS', Blockly.propc.ORDER_NONE);
+ var y = Blockly.propc.valueToCode(this, 'Y_POS', Blockly.propc.ORDER_NONE);
+
+ if (Blockly.propc.setups_["oled"] === undefined) {
+ return '//Missing OLED initialize block\n';
+ } else {
+ return 'oledc_setCursor(' + x + ', ' + y + ',0);';
+ }
+
+};
+
+Blockly.Blocks.oled_print_text = {
+ helpUrl: Blockly.MSG_OLED_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_OLED_PRINT_TEXT_TOOLTIP);
+ this.appendValueInput('MESSAGE')
+ .setCheck('String')
+ .appendField("OLED print text ");
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('protocols'));
+ }
+};
+
+Blockly.propc.oled_print_text = function() {
+ var msg = Blockly.propc.valueToCode(this, 'MESSAGE', Blockly.propc.ORDER_NONE);
+
+ if (Blockly.propc.setups_["oled"] === undefined) {
+ return '//Missing OLED initialize block\n';
+ } else {
+ return 'oledc_drawText(' + msg + ');';
+ }
+};
+
+Blockly.Blocks.oled_print_number = {
+ helpUrl: Blockly.MSG_OLED_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_OLED_PRINT_NUMBER_TOOLTIP);
+ this.appendValueInput('NUMIN')
+ .setCheck('Number')
+ .appendField("OLED print number ");
+ this.appendDummyInput()
+ .appendField(new Blockly.FieldDropdown([["Decimal", "DEC"], ["Hexadecimal", "HEX"], ["Binary", "BIN"]]), "type");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('protocols'));
+ }
+};
+
+Blockly.propc.oled_print_number = function() {
+ var num = Blockly.propc.valueToCode(this, 'NUMIN', Blockly.propc.ORDER_NONE);
+ var type = this.getFieldValue('type');
+
+ if (Blockly.propc.setups_["oled"] === undefined) {
+ return '//Missing OLED initialize block\n';
+ } else {
+ return 'oledc_drawNumber(' + num + ', ' + type + ');';
+ }
+};
+
+// -------------- RGB LEDs (WS2812B module) blocks -----------------------------
+Blockly.Blocks.ws2812b_init = {
+ helpUrl: Blockly.MSG_WS2812B_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_WS2812B_INIT_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("RGB-LED initialize PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN")
+ .appendField("number of LEDs")
+ .appendField(new Blockly.FieldTextInput('4', Blockly.FieldTextInput.numberValidator), "LEDNUM")
+ .appendField("type")
+ .appendField(new Blockly.FieldDropdown([["WS2812", "WS2812"]]), "TYPE");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.ws2812b_init = function() {
+ var pin = this.getFieldValue('PIN');
+ var num = window.parseInt(this.getFieldValue('LEDNUM'));
+
+ if(num < 1) num = 1;
+ if(num > 1500) num = 1500;
+
+ Blockly.propc.definitions_["ws2812b_def"] = '#include "ws2812.h"\n\n#define LED_PIN ' + pin + '\n#define LED_COUNT ' + num + '\n';
+ Blockly.propc.global_vars_["ws2812b_array"] = 'ws2812 *__ws2812b;\nint RGBleds[' + num + '];\nint __rgbTemp;\n';
+ Blockly.propc.setups_["ws2812b_init"] = '__ws2812b = ws2812b_open();\n';
+
+ return '';
+};
+
+Blockly.Blocks.ws2812b_set = {
+ helpUrl: Blockly.MSG_WS2812B_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_WS2812B_SET_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendValueInput("LED")
+ .setCheck("Number")
+ .appendField("RGB-LED set LED number");
+ this.appendValueInput("COLOR")
+ .setCheck("Number")
+ .appendField("to color");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.ws2812b_set = function() {
+ var led = Blockly.propc.valueToCode(this, 'LED', Blockly.propc.ORDER_NONE);
+ var color = Blockly.propc.valueToCode(this, 'COLOR', Blockly.propc.ORDER_NONE);
+
+ var code = '';
+ if (Blockly.propc.setups_["ws2812b_init"] === undefined) {
+ code += '//Missing RGB-LED initialize block\n';
+ } else {
+ code += '__rgbTemp = ' + led + ';\nif(__rgbTemp < 1) __rgbTemp = 1;\nif(__rgbTemp > LED_COUNT) __rgbTemp = LED_COUNT;\n';
+ code += 'RGBleds[(__rgbTemp - 1)] = ' + color + ';\n';
+ }
+ return code;
+};
+
+Blockly.Blocks.ws2812b_update = {
+ helpUrl: Blockly.MSG_WS2812B_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_WS2812B_UPDATE_TOOLTIP);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("RGB-LED update LEDs");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.ws2812b_update = function() {
+ if (Blockly.propc.setups_["ws2812b_init"] === undefined) {
+ return '//Missing RGB-LED initialize block\n';
+ } else {
+ return 'ws2812_set(__ws2812b, LED_PIN, RGBleds, LED_COUNT);\n';
+ }
+};
+
+// --------------------- Simple WX Module --------------------------------------
+Blockly.Blocks.wx_set_widget = {
+ init: function() {
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput("SET_1")
+ .appendField("Simple WX set widget")
+ .appendField(new Blockly.FieldDropdown([["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"]]), "WIDGET")
+ .appendField("to a")
+ .appendField(new Blockly.FieldDropdown([
+ ["Button \u2794", '0'],
+ ["Switch \u2794", '1'],
+ ["Slider \u2794", '2'],
+ ["Send Value \u2794", '3'],
+ ["Pick Color \u2794", '4'],
+ ["\u2794 Show Value", '5'],
+ ["\u2794 Gauge", '6'],
+ ["\u2794 Bar Graph", '7'],
+ ["\u2794 Show Color", '8'],
+ ["\u2794 Light Bulb", '9'],
+ ["Clear Widget", '10']], function (type) {
+ this.sourceBlock_.updateShape_({"TYPE": type});
+ }), "TYPE");
+ this.appendDummyInput("SET_2")
+ .appendField("widget color")
+ .appendField(new Blockly.FieldColour("#ffffff"), "COLOR")
+ .appendField(" minimum")
+ .appendField(new Blockly.FieldTextInput('0', Blockly.FieldTextInput.numberValidator), 'MIN')
+ .appendField(" maximum")
+ .appendField(new Blockly.FieldTextInput('10', Blockly.FieldTextInput.numberValidator), 'MAX')
+ .appendField(" initial value")
+ .appendField(new Blockly.FieldTextInput('5', Blockly.FieldTextInput.numberValidator), 'INITIAL');
+ this.setInputsInline(false);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ },
+ mutationToDom: function () {
+ var container = document.createElement('mutation');
+ var type = this.getFieldValue('TYPE');
+ container.setAttribute('TYPE', type);
+ return container;
+ },
+ domToMutation: function (xmlElement) {
+ var type = xmlElement.getAttribute('TYPE');
+ this.updateShape_({"TYPE": type});
+ },
+ updateShape_: function (details) {
+ var type = details['TYPE'];
+ if (details['TYPE'] === undefined) {
+ type = this.getFieldValue('TYPE');
+ }
+
+ if (this.getInput('SET_2') !== undefined) {
+ this.removeInput('SET_2');
+ }
+ var inputPins;
+ if (type !== '10') {
+ this.appendDummyInput("SET_2");
+ inputPins = this.getInput('SET_2');
+ }
+ if (type === '2' || type === '6' || type === '7') {
+ inputPins.appendField("widget color")
+ .appendField(new Blockly.FieldColour("#ffffff"), "COLOR")
+ .appendField(" minimum")
+ .appendField(new Blockly.FieldTextInput('0', Blockly.FieldTextInput.numberValidator), 'MIN')
+ .appendField(" maximum")
+ .appendField(new Blockly.FieldTextInput('10', Blockly.FieldTextInput.numberValidator), 'MAX')
+ .appendField(" initial value")
+ .appendField(new Blockly.FieldTextInput('5', Blockly.FieldTextInput.numberValidator), 'INITIAL');
+ } else if (type === '1') {
+ inputPins.appendField("widget color")
+ .appendField(new Blockly.FieldColour("#ffffff"), "COLOR")
+ .appendField(" minimum")
+ .appendField(new Blockly.FieldTextInput('0', Blockly.FieldTextInput.numberValidator), 'MIN')
+ .appendField(" maximum")
+ .appendField(new Blockly.FieldTextInput('10', Blockly.FieldTextInput.numberValidator), 'MAX');
+ } else if (type === '0' || type === '5' || type === '9') {
+ inputPins.appendField("widget color")
+ .appendField(new Blockly.FieldColour("#ffffff"), "COLOR")
+ .appendField(" initial value")
+ .appendField(new Blockly.FieldTextInput('5', Blockly.FieldTextInput.numberValidator), 'INITIAL');
+ } else if (type === '8') {
+ inputPins.appendField("widget color")
+ .appendField(new Blockly.FieldColour("#ffffff"), "COLOR")
+ .appendField(" initial color shown")
+ .appendField(new Blockly.FieldColour("#ffffff"), "INITIAL_COLOR");
+ } else if (type === '3' || type === '4') {
+ inputPins.appendField("widget color")
+ .appendField(new Blockly.FieldColour("#ffffff"), "COLOR");
+ }
+ }
+};
+
+Blockly.propc.wx_set_widget = function() {
+ var widget = this.getFieldValue('WIDGET');
+ var type = this.getFieldValue('TYPE');
+ var color = this.getFieldValue('COLOR').substr(1).toUpperCase();
+ var min = window.parseInt(this.getFieldValue('MIN') || '0');
+ var max = window.parseInt(this.getFieldValue('MAX') || '10');
+ var initial;
+ if (type !== '8') {
+ initial = window.parseInt(this.getFieldValue('INITIAL') || '5');
+ } else {
+ initial = window.parseInt((this.getFieldValue('INITIAL_COLOR') || '#FFFFFF').substr(1), 16);
+ }
+
+ var code = '';
+ code += 'wx_print("s' + widget + ',' + type + ',' + color + ',';
+ code += min + ',' + max + ',' + initial + '");\n';
+
+ return code;
+};
+
+Blockly.Blocks.wx_send_widget = {
+ init: function() {
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendValueInput("NUM")
+ .setCheck(null)
+ .appendField("Simple WX send");
+ this.appendDummyInput()
+ .appendField(new Blockly.FieldDropdown([["as text", "%s"], ["as an ASCII character", "%c"], ["as a decimal integer", "%d"], ["as a hexadecimal integer", "%x"], ["as a binary integer", "%b"]]), "TYPE")
+ .appendField("to widget")
+ .appendField(new Blockly.FieldDropdown([["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"]]), "WIDGET");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.wx_send_widget = function() {
+ var num = Blockly.propc.valueToCode(this, 'NUM', Blockly.propc.ORDER_NONE);
+ var widget = this.getFieldValue('WIDGET');
+ var type = this.getFieldValue('TYPE');
+
+ var code = '';
+ code += 'wx_print("t' + widget + ',' + type + '", ' + num + ');\n';
+
+ return code;
+};
+
+Blockly.Blocks.wx_read_widget = {
+ init: function() {
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput()
+ .appendField("Simple WX read")
+ .appendField(new Blockly.FieldDropdown([["text", "%s"], ["an ASCII character", "%c"], ["a decimal integer", "%d"], ["a hexadecimal integer", "%x"], ["a binary integer", "%b"]]), "TYPE")
+ .appendField("from widget")
+ .appendField(new Blockly.FieldDropdown([["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"]]), "WIDGET")
+ .appendField("store in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), "VAR");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.wx_read_widget = function() {
+ var value = Blockly.propc.valueToCode(this, 'VAR', Blockly.propc.ORDER_NONE);
+ var widget = this.getFieldValue('WIDGET');
+ var type = this.getFieldValue('TYPE');
+
+ var code = '';
+ code += 'wx_scan("r' + widget + ',' + type + '", &' + value + ');\n';
+
+ return code;
+};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/console.js b/src/main/webapp/cdn/blockly/generators/propc/console.js
deleted file mode 100644
index 3b8d8cf2..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/console.js
+++ /dev/null
@@ -1,304 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2014 Michel Lampo.
- *
- *
- * 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.
- */
-
-/**
- * @fileoverview Generating Prop-C for basic blocks.
- * @author michel@creatingfuture.eu (Michel Lampo)
- * @author valetolpegin@gmail.com ( Vale Tolpegin )
- */
-'use strict';
-
-//define blocks
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-Blockly.Blocks.console_print = {
- helpUrl: Blockly.MSG_TERMINAL_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_CONSOLE_PRINT_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendValueInput('MESSAGE')
- .setCheck('String')
- .appendField("Terminal print text");
- this.appendDummyInput()
- .appendField("then a new line")
- .appendField(new Blockly.FieldCheckbox("FALSE"), "ck_nl");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.console_print_variables = {
- helpUrl: Blockly.MSG_TERMINAL_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_CONSOLE_PRINT_VARIABLES_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendValueInput('VALUE')
- .appendField("Terminal print number");
- this.appendDummyInput()
- .appendField("as")
- .appendField(new Blockly.FieldDropdown([
- ['Decimal','DEC'],
- ['Hexadecimal','HEX'],
- ['Binary', 'BIN'],
- ['ASCII Character', 'CHAR']
- ]), "FORMAT");
- this.appendDummyInput()
- .appendField("then a new line")
- .appendField(new Blockly.FieldCheckbox("FALSE"), "ck_nl");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.console_scan_text = {
- helpUrl: Blockly.MSG_TERMINAL_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_CONSOLE_SCAN_TEXT_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("Terminal receive text store in")
- .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VALUE');
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- },
- getVars: function () {
- return [this.getFieldValue('VALUE')];
- },
- renameVar: function (oldName, newName) {
- if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
- this.setTitleValue(newName, 'VALUE');
- }
- }
-
-};
-
-Blockly.propc.console_scan_text = function () {
- var data = Blockly.propc.variableDB_.getName(this.getFieldValue('VALUE'), Blockly.Variables.NAME_TYPE);
- Blockly.propc.vartype_[data] = 'char *';
- Blockly.propc.serial_terminal_ = true;
-
- if(data !== '') {
- var code = 'getStr(' + data + ', 128);\n';
-
- return code;
- } else {
- return '';
- }
-};
-
-Blockly.Blocks.console_scan_number = {
- helpUrl: Blockly.MSG_TERMINAL_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_CONSOLE_SCAN_NUMBER_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("Terminal receive")
- .appendField(new Blockly.FieldDropdown([["number (32-bit integer)", "NUMBER"], ["byte (ASCII character)", "BYTE"]]), "TYPE")
- .appendField("store in")
- .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VALUE');
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- },
- getVars: function () {
- return [this.getFieldValue('VALUE')];
- },
- renameVar: function (oldName, newName) {
- if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
- this.setTitleValue(newName, 'VALUE');
- }
- }
-
-};
-
-Blockly.propc.console_scan_number = function () {
- var type = this.getFieldValue('TYPE');
- var data = Blockly.propc.variableDB_.getName(this.getFieldValue('VALUE'), Blockly.Variables.NAME_TYPE);
-
- Blockly.propc.serial_terminal_ = true;
- var code = '';
-
- if(data !== '') {
- if (type === 'NUMBER') {
- code += 'scan("%d\\n", &' + data + ');\n';
- } else {
- code += data + ' = getChar();\n';
- }
- return code;
- } else {
- return '';
- }
-};
-
-// Terminal print text
-Blockly.propc.console_print = function () {
- var text = Blockly.propc.valueToCode(this, 'MESSAGE', Blockly.propc.ORDER_ATOMIC);
- var checkbox = this.getFieldValue('ck_nl');
-
- Blockly.propc.serial_terminal_ = true;
-
- var code = 'print(' + text + ');\n';
- if (checkbox === 'TRUE') { code += 'print("\\r");\n'; }
- return code;
-};
-
-Blockly.propc.console_print_variables = function () {
- var value = Blockly.propc.valueToCode(this, 'VALUE', Blockly.propc.ORDER_ATOMIC);
- var format = this.getFieldValue('FORMAT');
- var checkbox = this.getFieldValue('ck_nl');
- Blockly.propc.serial_terminal_ = true;
-
- var code = 'print(';
- if (checkbox !== 'TRUE') {
- if (format === 'BIN') {
- code += '"%b"';
- } else if (format === 'HEX') {
- code += '"%x"';
- } else if (format === 'DEC') {
- code += '"%d"';
- } else {
- code += '"%c"';
- }
- } else {
- if (format === 'BIN') {
- code += '"%b\\r"';
- } else if (format === 'HEX') {
- code += '"%x\\r"';
- } else if (format === 'DEC') {
- code += '"%d\\r"';
- } else {
- code += '"%c\\r"';
- }
- }
- if (format === 'CHAR') {
- code += ', (' + value + ' & 0xFF));\n';
- } else {
- code += ', ' + value + ');\n';
- }
- return code;
-};
-
-Blockly.Blocks.console_newline = {
- helpUrl: Blockly.MSG_TERMINAL_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_CONSOLE_NEWLINE_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("Terminal new line");
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.console_clear = {
- helpUrl: Blockly.MSG_TERMINAL_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_CONSOLE_CLEAR_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("Terminal clear screen");
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.console_move_to_column = {
- init: function () {
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("Terminal move to column");
- this.appendValueInput('COLUMNS')
- .setCheck('Number');
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.console_move_to_row = {
- init: function () {
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("Terminal move to row");
- this.appendValueInput('ROWS')
- .setCheck('Number');
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.console_move_to_position = {
- helpUrl: Blockly.MSG_TERMINAL_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_CONSOLE_MOVE_TO_POSITION_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("Terminal set cursor to row");
- this.appendValueInput('ROW')
- .setCheck('Number');
- this.appendDummyInput()
- .appendField("column");
- this.appendValueInput('COLUMN')
- .setCheck('Number');
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.propc.console_newline = function () {
- Blockly.propc.serial_terminal_ = true;
- return 'term_cmd(CR);\n';
-};
-
-Blockly.propc.console_clear = function () {
- Blockly.propc.serial_terminal_ = true;
- return 'term_cmd(CLS);\n';
-};
-
-Blockly.propc.console_move_to_position = function () {
- Blockly.propc.serial_terminal_ = true;
- var row = Blockly.propc.valueToCode(this, 'ROW', Blockly.propc.ORDER_NONE);
- var column = Blockly.propc.valueToCode(this, 'COLUMN', Blockly.propc.ORDER_NONE);
-
- if (Number(row) < 0) {
- row = 0;
- } else if (Number(row) > 255) {
- row = 255;
- }
-
- if (Number(column) < 0) {
- column = 0;
- } else if (Number(column) > 255) {
- column = 255;
- }
-
- return 'term_cmd(CRSRXY, ' + column + ', ' + row + ');\n';
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/control.js b/src/main/webapp/cdn/blockly/generators/propc/control.js
index 2a6fd2b3..247d0f4e 100644
--- a/src/main/webapp/cdn/blockly/generators/propc/control.js
+++ b/src/main/webapp/cdn/blockly/generators/propc/control.js
@@ -1,8 +1,7 @@
/**
* Visual Blocks Language
*
- * Copyright 2012 Google Inc.
- * http://blockly.googlecode.com/
+ * Copyright 2014 Michel Lampo, Vale Tolpegin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,8 +17,13 @@
*/
/**
- * @fileoverview Generating Prop-C for control blocks.
+ * @fileoverview Generating C for control blocks
* @author michel@creatingfuture.eu (Michel Lampo)
+ * valetolpegin@gmail.com (Vale Tolpegin)
+ * jewald@parallax.com (Jim Ewald)
+ * mmatz@parallax.com (Matthew Matz)
+ * kgracey@parallax.com (Ken Gracey)
+ * carsongracey@gmail.com (Carson Gracey)
*/
'use strict';
@@ -27,6 +31,70 @@ if (!Blockly.Blocks)
Blockly.Blocks = {};
+Blockly.Blocks.controls_repeat = {
+ init: function() {
+ if(profile.default.description === "Scribbler Robot") {
+ this.setHelpUrl(Blockly.MSG_S3_CONTROL_HELPURL);
+ } else {
+ this.setHelpUrl(Blockly.MSG_CONTROL_HELPURL);
+ }
+ this.setTooltip(Blockly.MSG_CONTROLS_REPEAT_TOOLTIP);
+ this.setColour(colorPalette.getColor('programming'));
+ // ["with", "WITH"]
+ var PROPERTIES = [["forever", "FOREVER"], ["x times", "TIMES"], ["until", "UNTIL"], ["while", "WHILE"]];
+ var fieldDropdown = new Blockly.FieldDropdown(PROPERTIES, function (type) {
+ this.sourceBlock_.updateShape_(type);
+ });
+ this.appendDummyInput()
+ .appendField("repeat");
+ this.appendDummyInput("REPEAT")
+ .appendField(fieldDropdown, "TYPE");
+ this.appendStatementInput("DO")
+ .appendField(Blockly.LANG_CONTROLS_REPEAT_INPUT_DO);
+ this.setPreviousStatement(true);
+ this.setNextStatement(true);
+ this.setInputsInline(true);
+ },
+ mutationToDom: function () {
+ var container = document.createElement('mutation');
+ var type = this.getFieldValue('TYPE');
+ container.setAttribute('type', type);
+ return container;
+ },
+ domToMutation: function (xmlElement) {
+ var type = xmlElement.getAttribute('type');
+ //var type = this.getFieldValue('TYPE');
+ this.updateShape_(type);
+ },
+ updateShape_: function (type) {
+ // Add or remove a Value Input.
+ var inputTimes = this.getInput('TIMES');
+ if (type === 'TIMES') {
+ if (!inputTimes) {
+ this.appendValueInput('TIMES')
+ .setCheck('Number');
+ this.moveInputBefore('TIMES', 'REPEAT');
+ }
+ } else {
+ if (inputTimes) {
+ this.removeInput('TIMES');
+ }
+ }
+ var inputCondition = this.getInput('REPEAT_CONDITION');
+ if (type === 'WHILE' || type === 'UNTIL') {
+ if (!inputCondition) {
+ this.appendValueInput('REPEAT_CONDITION')
+ .setCheck('Number');
+ this.moveInputBefore('REPEAT_CONDITION', 'DO');
+ }
+ } else {
+ if (inputCondition) {
+ this.removeInput('REPEAT_CONDITION');
+ }
+ }
+ }
+};
+
Blockly.propc.controls_repeat = function() {
var type = this.getFieldValue('TYPE');
var branch = Blockly.propc.statementToCode(this, 'DO');
@@ -59,6 +127,188 @@ Blockly.propc.controls_repeat = function() {
return code;
};
+Blockly.Blocks.controls_if = {
+ // If/elseif/else condition.
+ category: Blockly.LANG_CATEGORY_CONTROLS,
+ init: function() {
+ if(profile.default.description === "Scribbler Robot") {
+ this.setHelpUrl(Blockly.MSG_S3_CONTROL_HELPURL);
+ } else {
+ this.setHelpUrl(Blockly.MSG_CONTROL_HELPURL);
+ }
+ this.setTooltip(Blockly.MSG_CONTROLS_IF_TOOLTIP);
+ this.setColour(colorPalette.getColor('programming'));
+ this.appendValueInput('IF0')
+ .setCheck('Number')
+ .appendField(Blockly.LANG_CONTROLS_IF_MSG_IF);
+ this.appendStatementInput('DO0')
+ .appendField(Blockly.LANG_CONTROLS_IF_MSG_THEN);
+ this.setPreviousStatement(true);
+ this.setNextStatement(true);
+ this.setMutator(new Blockly.Mutator(['controls_if_elseif',
+ 'controls_if_else']));
+ this.elseifCount_ = 0;
+ this.elseCount_ = 0;
+ },
+ mutationToDom: function () {
+ if (!this.elseifCount_ && !this.elseCount_) {
+ return null;
+ }
+ var container = document.createElement('mutation');
+ if (this.elseifCount_) {
+ container.setAttribute('elseif', this.elseifCount_);
+ }
+ if (this.elseCount_) {
+ container.setAttribute('else', 1);
+ }
+ return container;
+ },
+ domToMutation: function (xmlElement) {
+ this.elseifCount_ = window.parseInt(xmlElement.getAttribute('elseif'), 10);
+ this.elseCount_ = window.parseInt(xmlElement.getAttribute('else'), 10);
+ for (var x = 1; x <= this.elseifCount_; x++) {
+ this.appendValueInput('IF' + x)
+ .setCheck('Number')
+ .appendField(Blockly.LANG_CONTROLS_IF_MSG_ELSEIF);
+ this.appendStatementInput('DO' + x)
+ .appendField(Blockly.LANG_CONTROLS_IF_MSG_THEN);
+ }
+ if (this.elseCount_) {
+ this.appendStatementInput('ELSE')
+ .appendField(Blockly.LANG_CONTROLS_IF_MSG_ELSE);
+ }
+ },
+ decompose: function (workspace) {
+ var containerBlock = Blockly.Block.obtain(workspace, 'controls_if_if');
+ containerBlock.initSvg();
+ var connection = containerBlock.getInput('STACK').connection;
+ for (var x = 1; x <= this.elseifCount_; x++) {
+ var elseifBlock = Blockly.Block.obtain(workspace, 'controls_if_elseif');
+ elseifBlock.initSvg();
+ connection.connect(elseifBlock.previousConnection);
+ connection = elseifBlock.nextConnection;
+ }
+ if (this.elseCount_) {
+ var elseBlock = Blockly.Block.obtain(workspace, 'controls_if_else');
+ elseBlock.initSvg();
+ connection.connect(elseBlock.previousConnection);
+ }
+ return containerBlock;
+ },
+ compose: function (containerBlock) {
+ // Disconnect the else input blocks and remove the inputs.
+ if (this.elseCount_) {
+ this.removeInput('ELSE');
+ }
+ this.elseCount_ = 0;
+ // Disconnect all the elseif input blocks and remove the inputs.
+ for (var x = this.elseifCount_; x > 0; x--) {
+ this.removeInput('IF' + x);
+ this.removeInput('DO' + x);
+ }
+ this.elseifCount_ = 0;
+ // Rebuild the block's optional inputs.
+ var clauseBlock = containerBlock.getInputTargetBlock('STACK');
+ while (clauseBlock) {
+ switch (clauseBlock.type) {
+ case 'controls_if_elseif':
+ this.elseifCount_++;
+ var ifInput = this.appendValueInput('IF' + this.elseifCount_)
+ .setCheck('Number')
+ .appendField(Blockly.LANG_CONTROLS_IF_MSG_ELSEIF);
+ var doInput = this.appendStatementInput('DO' + this.elseifCount_);
+ doInput.appendField(Blockly.LANG_CONTROLS_IF_MSG_THEN);
+ // Reconnect any child blocks.
+ if (clauseBlock.valueConnection_) {
+ ifInput.connection.connect(clauseBlock.valueConnection_);
+ }
+ if (clauseBlock.statementConnection_) {
+ doInput.connection.connect(clauseBlock.statementConnection_);
+ }
+ break;
+ case 'controls_if_else':
+ this.elseCount_++;
+ var elseInput = this.appendStatementInput('ELSE');
+ elseInput.appendField(Blockly.LANG_CONTROLS_IF_MSG_ELSE);
+ // Reconnect any child blocks.
+ if (clauseBlock.statementConnection_) {
+ elseInput.connection.connect(clauseBlock.statementConnection_);
+ }
+ break;
+ default:
+ throw 'Unknown block type.';
+ }
+ clauseBlock = clauseBlock.nextConnection &&
+ clauseBlock.nextConnection.targetBlock();
+ }
+ },
+ saveConnections: function (containerBlock) {
+ // Store a pointer to any connected child blocks.
+ var clauseBlock = containerBlock.getInputTargetBlock('STACK');
+ var x = 1;
+ while (clauseBlock) {
+ switch (clauseBlock.type) {
+ case 'controls_if_elseif':
+ var inputIf = this.getInput('IF' + x);
+ var inputDo = this.getInput('DO' + x);
+ clauseBlock.valueConnection_ =
+ inputIf && inputIf.connection.targetConnection;
+ clauseBlock.statementConnection_ =
+ inputDo && inputDo.connection.targetConnection;
+ x++;
+ break;
+ case 'controls_if_else':
+ var inputDo = this.getInput('ELSE');
+ clauseBlock.statementConnection_ =
+ inputDo && inputDo.connection.targetConnection;
+ break;
+ default:
+ throw 'Unknown block type.';
+ }
+ clauseBlock = clauseBlock.nextConnection &&
+ clauseBlock.nextConnection.targetBlock();
+ }
+ }
+};
+
+
+Blockly.Blocks.controls_if_if = {
+ // If condition.
+ init: function () {
+ this.setColour(colorPalette.getColor('programming'));
+ this.appendDummyInput()
+ .appendField(Blockly.LANG_CONTROLS_IF_IF_TITLE_IF);
+ this.appendStatementInput('STACK');
+ this.setTooltip(Blockly.LANG_CONTROLS_IF_IF_TOOLTIP);
+ this.contextMenu = false;
+ }
+};
+
+Blockly.Blocks.controls_if_elseif = {
+ // Else-If condition.
+ init: function () {
+ this.setColour(colorPalette.getColor('programming'));
+ this.appendDummyInput()
+ .appendField(Blockly.LANG_CONTROLS_IF_ELSEIF_TITLE_ELSEIF);
+ this.setPreviousStatement(true);
+ this.setNextStatement(true);
+ this.setTooltip(Blockly.LANG_CONTROLS_IF_ELSEIF_TOOLTIP);
+ this.contextMenu = false;
+ }
+};
+
+Blockly.Blocks.controls_if_else = {
+ // Else condition.
+ init: function () {
+ this.setColour(colorPalette.getColor('programming'));
+ this.appendDummyInput()
+ .appendField(Blockly.LANG_CONTROLS_IF_ELSE_TITLE_ELSE);
+ this.setPreviousStatement(true);
+ this.setTooltip(Blockly.LANG_CONTROLS_IF_ELSE_TOOLTIP);
+ this.contextMenu = false;
+ }
+};
+
Blockly.propc.controls_if = function() {
// If/elseif/else condition.
var n = 0;
@@ -79,6 +329,9 @@ Blockly.propc.controls_if = function() {
return code + '\n';
};
+/*
+ * Disabled/Unused
+
Blockly.Blocks.controls_if_return = {
init: function () {
this.setColour(colorPalette.getColor('programming'));
@@ -97,6 +350,46 @@ Blockly.propc.controls_if_return = function () {
return 'if (' + argument + ') {return;}\n';
};
+*/
+
+Blockly.Blocks.control_repeat_for_loop = {
+ //helpUrl: Blockly.MSG_CONTROL_HELPURL,
+ init: function() {
+ if(profile.default.description === "Scribbler Robot") {
+ this.setHelpUrl(Blockly.MSG_S3_CONTROL_HELPURL);
+ } else {
+ this.setHelpUrl(Blockly.MSG_CONTROL_HELPURL);
+ }
+ this.setTooltip(Blockly.MSG_CONTROL_REPEAT_FOR_LOOP_TOOLTIP);
+ this.setColour(colorPalette.getColor('programming'));
+ this.appendDummyInput()
+ .appendField("repeat")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VAR');
+ this.appendValueInput('START')
+ .setCheck('Number')
+ .appendField("from");
+ this.appendValueInput('END')
+ .setCheck('Number')
+ .appendField("to");
+ this.appendValueInput('STEP')
+ .setCheck('Number')
+ .appendField("by");
+ this.appendStatementInput("DO")
+ .appendField("do");
+
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setInputsInline(true);
+ },
+ getVars: function () {
+ return [this.getFieldValue('VAR')];
+ },
+ renameVar: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
+ this.setTitleValue(newName, 'VAR');
+ }
+ }
+};
Blockly.propc.control_repeat_for_loop = function () {
var start = Blockly.propc.valueToCode(this, 'START', Blockly.propc.ORDER_NONE) || '1';
diff --git a/src/main/webapp/cdn/blockly/generators/propc/debug_LCD.js b/src/main/webapp/cdn/blockly/generators/propc/debug_LCD.js
deleted file mode 100644
index 4f2ddb5d..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/debug_LCD.js
+++ /dev/null
@@ -1,209 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2014 Michel Lampo.
- * https://github.com/gasolin/BlocklyDuino
- *
- * 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.
- */
-
-/**
- * @fileoverview Generating Spin for the debug lcd.
- * @author valetolpegin@gmail.com ( Vale Tolpegin )
- */
-'use strict';
-
-//define blocks
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-Blockly.Blocks.debug_lcd_init = {
- helpUrl: Blockly.MSG_SERIAL_LCD_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_DEBUG_LCD_INIT_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("LCD initialize PIN")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
- this.appendDummyInput()
- .appendField("baud")
- .appendField(new Blockly.FieldDropdown([["2400", "2400"], ["9600", "9600"], ["19200", "19200"]]), "BAUD");
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.debug_lcd_music_note = {
- helpUrl: Blockly.MSG_SERIAL_LCD_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_DEBUG_LCD_MUSIC_NOTE_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("LCD play note")
- .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")
- .appendField("octave")
- .appendField(new Blockly.FieldDropdown([["3rd", "215"], ["4th", "216"], ["5th", "217"], ["6th", "218"], ["7th", "219"]]), "OCTAVE")
- .appendField("length")
- .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");
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.debug_lcd_print = {
- helpUrl: Blockly.MSG_SERIAL_LCD_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_DEBUG_LCD_PRINT_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendValueInput('MESSAGE')
- .setCheck('String')
- .appendField("LCD print text ");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.debug_lcd_number = {
- helpUrl: Blockly.MSG_SERIAL_LCD_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_DEBUG_LCD_NUMBER_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendValueInput('VALUE')
- .appendField("LCD print number");
- this.appendDummyInput()
- .appendField("as")
- .appendField(new Blockly.FieldDropdown([
- ['Decimal','DEC'],
- ['Hexadecimal','HEX'],
- ['Binary', 'BIN']
- ]), "FORMAT");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.debug_lcd_action = {
- helpUrl: Blockly.MSG_SERIAL_LCD_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_DEBUG_LCD_ACTION_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("LCD command")
- .appendField(new Blockly.FieldDropdown([
- ["clear screen", "12"],
- ["move cursor right", "9"],
- ["move cursor left", "8"],
- ["move cursor down", "10"],
- ["carriage return", "13"],
- ["backlight on", "17"],
- ["backlight off", "18"],
- ["display off", "21"],
- ["display on, cursor off", "22"],
- ["display on, cursor off, blink", "23"],
- ["display on, cursor on", "24"],
- ["display on, cursor on, blink", "25"]
- ]), "ACTION");
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.debug_lcd_set_cursor = {
- helpUrl: Blockly.MSG_SERIAL_LCD_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_DEBUG_LCD_SET_CURSOR_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("LCD set cursor row")
- .appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"]]), "ROW")
- .appendField("column")
- .appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"]]), "COLUMN");
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.propc.debug_lcd_init = function () {
- var dropdown_pin = this.getFieldValue('PIN');
- var baud = this.getFieldValue('BAUD');
-
- Blockly.propc.setups_['setup_debug_lcd'] = 'serial *debug_lcd = serial_open(' + dropdown_pin + ', ' + dropdown_pin + ', 0, ' + baud + ');\n';
-
- var code = 'writeChar(debug_lcd, 22);\n';
- return code;
-};
-
-//Blockly.propc.debug_lcd_clear = function () {
-// return 'writeChar(debug_lcd, 12);\npause(5);\n';
-//};
-
-Blockly.propc.debug_lcd_music_note = function () {
- var dropdown_note = this.getFieldValue('NOTE');
- var dropdown_octave = this.getFieldValue('OCTAVE');
- var dropdown_length = this.getFieldValue('LENGTH');
-
- var code = 'writeChar(debug_lcd, ' + dropdown_octave + ');\n';
- code += 'writeChar(debug_lcd, ' + dropdown_length + ');\n';
- code += 'writeChar(debug_lcd, ' + dropdown_note + ');\n';
-
- return code;
-};
-
-Blockly.propc.debug_lcd_print = function () {
- var msg = Blockly.propc.valueToCode(this, 'MESSAGE', Blockly.propc.ORDER_NONE);
- var code = 'dprint(debug_lcd, ' + msg + ');';
-
- return code;
-};
-
-Blockly.propc.debug_lcd_number = function () {
- var value = Blockly.propc.valueToCode(this, 'VALUE', Blockly.propc.ORDER_ATOMIC);
- var format = this.getFieldValue('FORMAT');
-
- var code = 'dprint(debug_lcd, ';
- if (format === 'BIN') {
- code += '"%b"';
- }else if (format === 'HEX') {
- code += '"%x"';
- }else {
- code += '"%d"';
- }
-
- code += ', ' + value + ');';
- return code;
-};
-
-Blockly.propc.debug_lcd_action = function () {
-var action = this.getFieldValue('ACTION');
-var code = '';
-if(action === '12') {
- code = 'pause(5);\n';
-}
-code += 'writeChar(debug_lcd, ' + action + ');\n';
-return code;
-};
-
-
-Blockly.propc.debug_lcd_set_cursor = function () {
-var row = this.getFieldValue('ROW');
-var column = this.getFieldValue('COLUMN');
-
-return 'writeChar(debug_lcd, (128 + (' + row + ' * 20) + ' + column + '));\n';
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/eeprom.js b/src/main/webapp/cdn/blockly/generators/propc/eeprom.js
deleted file mode 100644
index 99fc8353..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/eeprom.js
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- This file contains support for writing text/numbers to EEPROM
- Author: Vale Tolpegin (valetolpegin@gmail.com)
- *Copyright 2016 Vale Tolpegin.
- *
- *
- * 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.
-*/
-'use strict';
-
-if ( !Blockly.Blocks )
- Blockly.Blocks = {};
-
-Blockly.Blocks.eeprom_int_to = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("save an int to EEPROM");
- this.appendValueInput('VALUE')
- .appendField("value");
- this.appendDummyInput()
- .appendField("address")
- .appendField(new Blockly.FieldDropdown(profile.default.eeprom), "ADDRESS");
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.eeprom_int_from = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("get an int from EEPROM")
- .appendField("address")
- .appendField(new Blockly.FieldDropdown(profile.default.eeprom), "ADDRESS");
-
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- this.setOutput(true, 'Number');
- }
-};
-
-Blockly.Blocks.eeprom_float_to = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("save a float to EEPROM");
- this.appendValueInput('VALUE')
- .appendField("value");
- this.appendDummyInput()
- .appendField("address")
- .appendField(new Blockly.FieldDropdown(profile.default.eeprom), "ADDRESS");
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.eeprom_float_from = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("get a float from EEPROM")
- .appendField("address")
- .appendField(new Blockly.FieldDropdown(profile.default.eeprom), "ADDRESS");
-
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- this.setOutput(true, 'Number');
- }
-};
-
-Blockly.Blocks.eeprom_text_to = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("save text to EEPROM")
- .appendField("text")
- .appendField(quotes.newQuote_(true))
- .appendField(new Blockly.FieldTextInput(''), 'TEXT')
- .appendField(quotes.newQuote_(false));
- this.appendValueInput('VALUE')
- .appendField("text length");
- this.appendDummyInput()
- .appendField("address")
- .appendField(new Blockly.FieldDropdown(profile.default.eeprom), "ADDRESS");
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.eeprom_text_from = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("get text from EEPROM");
- this.appendValueInput('VALUE')
- .appendField("text length");
- this.appendDummyInput()
- .appendField("address")
- .appendField(new Blockly.FieldDropdown(profile.default.eeprom), "ADDRESS");
-
- this.setInputsInline(true);
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- this.setOutput(true, 'Number');
- }
-};
-
-Blockly.propc.eeprom_int_to = function() {
- var value = Blockly.propc.valueToCode(this, 'VALUE', Blockly.propc.ORDER_NONE) || '0';
- var address = this.getFieldValue('ADDRESS');
-
- return 'ee_putInt(' + value + ', ' + address + ');\n';
-};
-
-Blockly.propc.eeprom_int_from = function() {
- var address = this.getFieldValue('ADDRESS');
-
- return 'ee_getInt(' + address + ')';
-};
-
-Blockly.propc.eeprom_float_to = function() {
- var value = Blockly.propc.valueToCode(this, 'VALUE', Blockly.ORDER_NONE) || '0';
- var address = this.getFieldValue('ADDRESS');
-
- return 'ee_putFloat32(' + value + ', ' + address + ')';
-};
-
-Blockly.propc.eeprom_float_from = function() {
- var address = this.getFieldValue('ADDRESS');
-
- return 'ee_getFloat32(' + address + ')';
-};
-
-Blockly.propc.eeprom_text_to = function() {
- var text = this.getFieldValue('TEXT');
- var value = Blockly.propc.valueToCode(this, 'VALUE', Blockly.ORDER_NONE) || '0';
- var address = this.getFieldValue('ADDRESS');
-
- return 'ee_putStr(' + value + ', ' + address + ')';
-};
-
-Blockly.propc.eeprom_text_from = function() {
- var address = this.getFieldValue('ADDRESS');
-
- return 'ee_getStr(' + address + ')';
-};
-
-Blockly.Blocks.eeprom_write = {
- helpUrl: Blockly.MSG_EEPROM_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_EEPROM_WRITE_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendValueInput("DATA")
- .setCheck(null)
- .appendField("EEPROM write")
- .appendField(new Blockly.FieldDropdown([["number", "NUMBER"], ["text", "TEXT"], ["byte", "BYTE"]]), "TYPE");
- this.appendValueInput("ADDRESS")
- .setCheck("Number")
- .appendField("to address");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.propc.eeprom_write = function () {
- var type = this.getFieldValue('TYPE');
- var address = Blockly.propc.valueToCode(this, 'ADDRESS', Blockly.propc.ORDER_ATOMIC);
- var data = Blockly.propc.valueToCode(this, 'DATA', Blockly.propc.ORDER_ATOMIC) || '';
-
- Blockly.propc.global_vars_["i2c_eepromAddr"] = 'int __eeAddr;';
- //Blockly.propc.global_vars_["i2c_new_eebus"] = 'i2c *eeBus;';
- //Blockly.propc.setups_["i2c_eebus"] = 'eeBus = i2c_newbus(28, 29, 0);\n';
-
- var code = '// Make sure that the eeprom address does not overwrite the program memory.\n';
- code += '__eeAddr = ' + address + ';\n';
- code += 'if(__eeAddr < 0) __eeAddr = 0;\n';
- code += 'if(__eeAddr > 7675) __eeAddr = 7675;\n';
-
- if(data !== '') {
-
- if (type === 'BYTE') {
- code += 'ee_putByte((' + data + ' & 255), (32768 + __eeAddr) );\n';
- } else if (type === 'NUMBER') {
- code += 'ee_putInt(' + data + ', (32768 + __eeAddr) );\n';
- } else {
- code += 'ee_putStr(' + data + ', (strlen(' + data + ') + 1), (32768 + __eeAddr) );\n';
- }
- }
-
- return code;
-};
-
-Blockly.Blocks.eeprom_read = {
- helpUrl: Blockly.MSG_EEPROM_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_EEPROM_READ_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendValueInput("ADDRESS")
- .setCheck("Number")
- .appendField("EEPROM read")
- .appendField(new Blockly.FieldDropdown([["number", "NUMBER"], ["text", "TEXT"], ["byte", "BYTE"]]), "TYPE")
- .appendField("from address");
- this.appendDummyInput()
- .appendField("store in")
- .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VALUE');
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- },
- getVars: function () {
- return [this.getFieldValue('VALUE')];
- },
- renameVar: function (oldName, newName) {
- if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
- this.setTitleValue(newName, 'VALUE');
- }
- }
-};
-
-Blockly.propc.eeprom_read = function () {
- var type = this.getFieldValue('TYPE');
- var address = Blockly.propc.valueToCode(this, 'ADDRESS', Blockly.propc.ORDER_ATOMIC);
- var data = Blockly.propc.variableDB_.getName(this.getFieldValue('VALUE'), Blockly.Variables.NAME_TYPE);
-
- Blockly.propc.global_vars_["i2c_eepromAddr"] = 'int __eeAddr;';
-
- var code = '__eeAddr = ' + address + ';\n';
- code += 'if(__eeAddr < 0) __eeAddr = 0;\n';
- code += 'if(__eeAddr > 7675) __eeAddr = 7675;\n';
-
- if(data !== '') {
- if (type === 'BYTE') {
- code += data + ' = ee_getByte( 32768 + __eeAddr ) & 255;\n';
- } else if (type === 'NUMBER') {
- code += data + ' = ee_getInt( 32768 + __eeAddr );\n';
- } else {
- Blockly.propc.global_vars_["i2c_eeBffr"] = 'char __eeBffr[1];';
- Blockly.propc.global_vars_["i2c_eeIdx"] = 'int __eeIdx = 0;';
- Blockly.propc.vartype_[data] = 'char *';
- code += '// Get the string from EEPROM one character at a time until it finds the end of the string.\n';
- code += '__eeIdx = 0;\n';
- code += 'while(__eeIdx < 128) {\n ee_getStr(__eeBffr, 1, (32768 + __eeAddr) + __eeIdx);\n';
- code += ' ' + data + '[__eeIdx] = __eeBffr[0];\n';
- code += ' if(' + data + '[__eeIdx] == 0) break;\n __eeIdx++;\n}\n';
- code += ' if(__eeIdx >= 128) ' + data + '[127] = 0;\n';
- }
- }
-
- return code;
-};
\ No newline at end of file
diff --git a/src/main/webapp/cdn/blockly/generators/propc/file.js b/src/main/webapp/cdn/blockly/generators/propc/file.js
deleted file mode 100644
index 9f419e88..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/file.js
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2014 Michel Lampo.
- *
- *
- * 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.
- */
-
-/**
- * @fileoverview Generating Prop-C for file blocks.
- * @author michel@creatingfuture.eu (Michel Lampo)
- */
-'use strict';
-
-//define blocks
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-Blockly.Blocks.file_open = {
- init: function() {
- this.setColour(colorPalette.getColor('io'));
- this.appendDummyInput()
- .appendField("Open file")
- .appendField(new Blockly.FieldTextInput('file.txt'), 'FILE')
- .appendField("mode")
- .appendField(new Blockly.FieldDropdown([["read", "r"], ["write", "w"]]), "MODE");
-
- this.setOutput(true, 'Pointer');
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- }
-};
-
-Blockly.Blocks.file_close = {
- init: function() {
- this.setColour(colorPalette.getColor('io'));
- this.appendDummyInput()
- .appendField("Close file");
- this.appendValueInput('FILE');
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.propc.file_open = function() {
- var file = this.getFieldValue('FILE');
- var mode = this.getFieldValue('MODE');
-
- var code = 'fopen("' + file + '", "' + mode + '")';
- return [code, Blockly.propc.ORDER_ATOMIC];
-};
-
-
-Blockly.propc.file_close = function() {
- var file = Blockly.propc.valueToCode(this, 'FILE', Blockly.propc.ORDER_UNARY_PREFIX);
-
- if (file) {
- return 'fclose(' + file + ');\n'
- } else {
- return '// Missing file pointer';
- }
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/gpio.js b/src/main/webapp/cdn/blockly/generators/propc/gpio.js
new file mode 100644
index 00000000..68ee6880
--- /dev/null
+++ b/src/main/webapp/cdn/blockly/generators/propc/gpio.js
@@ -0,0 +1,1066 @@
+/**
+ * Visual Blocks Language
+ *
+ * Copyright 2014 Michel Lampo, Vale Tolpegin
+ *
+ * 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.
+ */
+
+/**
+ * @fileoverview Generating C for gpio blocks
+ * @author michel@creatingfuture.eu (Michel Lampo)
+ * valetolpegin@gmail.com (Vale Tolpegin)
+ * jewald@parallax.com (Jim Ewald)
+ * mmatz@parallax.com (Matthew Matz)
+ * kgracey@parallax.com (Ken Gracey)
+ * carsongracey@gmail.com (Carson Gracey)
+ */
+'use strict';
+
+if (!Blockly.Blocks)
+ Blockly.Blocks = {};
+
+Blockly.Blocks.make_pin = {
+ helpUrl: Blockly.MSG_PINS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_MAKE_PIN_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.appendDummyInput("")
+ .appendField("make PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN")
+ .appendField(new Blockly.FieldDropdown([["high", "HIGH"], ["low", "LOW"], ["toggle", "TOGGLE"], ["input", "INPUT"], ["reverse", "REVERSE"]]), "ACTION");
+ }
+};
+
+Blockly.propc.make_pin = function () {
+ var dropdown_pin = this.getFieldValue('PIN');
+ var dropdown_action = this.getFieldValue('ACTION');
+ switch (dropdown_action) {
+ case "HIGH":
+ return 'high(' + dropdown_pin + ');\n';
+ case "LOW":
+ return 'low(' + dropdown_pin + ');\n';
+ case "TOGGLE":
+ return 'toggle(' + dropdown_pin + ');\n\tset_direction(' + dropdown_pin + ', 1);\n';
+ case "INPUT":
+ return 'set_direction(' + dropdown_pin + ', 0);\n';
+ case "REVERSE":
+ return 'reverse(' + dropdown_pin + ');\n';
+ }
+};
+
+Blockly.Blocks.make_pin_input = {
+ helpUrl: Blockly.MSG_PINS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_MAKE_PIN_INPUT_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.appendDummyInput("")
+ .appendField("make PIN");
+ this.appendValueInput('PIN')
+ .setCheck('Number');
+ this.appendDummyInput("")
+ .appendField(new Blockly.FieldDropdown([["high", "HIGH"], ["low", "LOW"], ["toggle", "TOGGLE"], ["input", "INPUT"], ["reverse", "REVERSE"]]), "ACTION");
+ }
+};
+
+Blockly.propc.make_pin_input = function () {
+ var pin = Blockly.propc.valueToCode(this, 'PIN', Blockly.propc.ORDER_ATOMIC) || 0;
+ var dropdown_action = this.getFieldValue('ACTION');
+ switch (dropdown_action) {
+ case "HIGH":
+ return 'high(' + pin + ');\n';
+ case "LOW":
+ return 'low(' + pin + ');\n';
+ case "TOGGLE":
+ return 'toggle(' + pin + ');\n\tset_direction(' + pin + ', 1);\n';
+ case "INPUT":
+ return 'set_direction(' + pin + ', 0);\n';
+ case "REVERSE":
+ return 'reverse(' + pin + ');\n';
+ }
+};
+
+Blockly.Blocks.check_pin = {
+ helpUrl: Blockly.MSG_PINS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_CHECK_PIN_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.appendDummyInput("")
+ .appendField("check PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
+ this.setOutput(true, 'Number');
+ }
+};
+
+Blockly.propc.check_pin = function () {
+ var dropdown_pin = this.getFieldValue('PIN');
+
+ var code = 'input(' + dropdown_pin + ')';
+ return [code, Blockly.propc.ORDER_ATOMIC];
+};
+
+Blockly.Blocks.check_pin_input = {
+ helpUrl: Blockly.MSG_PINS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_CHECK_PIN_INPUT_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.appendDummyInput("")
+ .appendField("check PIN");
+ this.appendValueInput('PIN')
+ .setCheck('Number');
+ this.setOutput(true, 'Number');
+ this.setInputsInline(true);
+ }
+};
+
+Blockly.propc.check_pin_input = function () {
+ var dropdown_pin = Blockly.propc.valueToCode(this, 'PIN', Blockly.propc.ORDER_UNARY_PREFIX) || '0';
+
+ var code = 'input(' + dropdown_pin + ')';
+ return [code, Blockly.propc.ORDER_ATOMIC];
+};
+
+Blockly.Blocks.set_pins = {
+ helpUrl: Blockly.MSG_PINS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_SET_PINS_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ var start_pin = [];
+ for (var i = 0; i < 14; i++) {
+ start_pin.push([i.toString(), i.toString()]);
+ }
+ var pin_count = [];
+ for (var i = 0; i < 14; i++) {
+ pin_count.push([i.toString(), i.toString()]);
+ }
+ this.appendDummyInput("")
+ .appendField("set the")
+ .appendField(new Blockly.FieldDropdown([["states", "STATE"], ["directions", "DIRECTION"]], function (action) {
+ this.sourceBlock_.updateShape_({"ACTION": action});
+ }), "ACTION")
+ .appendField("from PIN")
+ .appendField(new Blockly.FieldDropdown(pin_count, function (startPin) {
+ this.sourceBlock_.updateShape_({"START_PIN": startPin});
+ }), "START_PIN")
+ .appendField("to PIN")
+ .appendField(new Blockly.FieldDropdown(start_pin, function (pinCount) {
+ this.sourceBlock_.updateShape_({"PIN_COUNT": pinCount});
+ }), "PIN_COUNT");
+ this.appendDummyInput("PINS")
+ .appendField("values:")
+ .appendField("P0:")
+ .appendField(new Blockly.FieldDropdown([["HIGH", "1"], ["LOW", "0"]]), "P0");
+ },
+ mutationToDom: function () {
+ var container = document.createElement('mutation');
+ var action = this.getFieldValue('ACTION');
+ container.setAttribute('action', action);
+ var pinCount = this.getFieldValue('PIN_COUNT');
+ container.setAttribute('pin_count', pinCount);
+ var startPin = this.getFieldValue('START_PIN');
+ container.setAttribute('start_pin', startPin);
+ return container;
+ },
+ domToMutation: function (xmlElement) {
+ var action = xmlElement.getAttribute('action');
+ var pinCount = xmlElement.getAttribute('pin_count');
+ var startPin = xmlElement.getAttribute('start_pin');
+ //var type = this.getFieldValue('TYPE');
+ this.updateShape_({"ACTION": action, "PIN_COUNT": pinCount, "START_PIN": startPin});
+ },
+ updateShape_: function (details) {
+ var data = [];
+ for (var i = 0; i < 32; i++) {
+ data.push(this.getFieldValue('P' + i));
+ }
+
+ var action = details['ACTION'];
+ if (details['ACTION'] === undefined) {
+ action = this.getFieldValue('ACTION');
+ }
+ var pinCount = details['PIN_COUNT'];
+ if (details['PIN_COUNT'] === undefined) {
+ pinCount = this.getFieldValue('PIN_COUNT');
+ }
+ var startPin = details['START_PIN'];
+ if (details['START_PIN'] === undefined) {
+ startPin = this.getFieldValue('START_PIN');
+ }
+ pinCount = Number(pinCount);
+ startPin = Number(startPin);
+
+ this.removeInput('PINS');
+ this.appendDummyInput("PINS")
+ .appendField("Values:");
+ var inputPins = this.getInput('PINS');
+ for (var i = 0; i < (pinCount - startPin + 1); i++) {
+ var pin = startPin + i;
+ if (action === 'STATE') {
+ inputPins.appendField("P" + pin + ":")
+ .appendField(new Blockly.FieldDropdown([["HIGH", "1"], ["LOW", "0"]]), "P" + pin);
+ } else if (action === 'DIRECTION') {
+ inputPins.appendField("P" + pin + ":")
+ .appendField(new Blockly.FieldDropdown([["OUT", "1"], ["IN", "0"]]), "P" + pin);
+ }
+ }
+
+ for (var i = 0; i < 32; i++) {
+ if (this.getField('P' + i) && data[i] !== null) {
+ this.setFieldValue(data[i], 'P' + i);
+ }
+ }
+ }
+};
+
+Blockly.propc.set_pins = function () {
+ var code = '';
+ var action = this.getFieldValue('ACTION');
+ var dropdown_pin_count = Number(this.getFieldValue('PIN_COUNT'));
+ var dropdown_start_pin = Number(this.getFieldValue('START_PIN'));
+ if (action === 'STATE') {
+ code = 'set_outputs(';
+ } else if (action === 'DIRECTION') {
+ code = 'set_directions(';
+ }
+ //var highestPin = dropdown_start_pin + dropdown_pin_count - 1;
+
+ code += dropdown_pin_count;
+ code += ', ';
+ code += dropdown_start_pin;
+ code += ', 0b';
+ for (var i = dropdown_pin_count; i >= dropdown_start_pin; i--) {
+ code += this.getFieldValue('P' + i);
+ }
+ return code + ');\n';
+};
+
+Blockly.Blocks.base_freqout = {
+ helpUrl: Blockly.MSG_AUDIO_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_BASE_FREQOUT_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.appendDummyInput("")
+ .appendField("frequency PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
+ this.appendValueInput("DURATION", 'Number')
+ .appendField("duration (ms)")
+ .setCheck('Number');
+ this.appendValueInput("FREQUENCY", 'Number')
+ .appendField("frequency (Hz)")
+ .setCheck('Number');
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.base_freqout = function () {
+ var dropdown_pin = this.getFieldValue('PIN');
+ var duration = Blockly.propc.valueToCode(this, 'DURATION', Blockly.propc.ORDER_ATOMIC) || 1000;
+ var frequency = Blockly.propc.valueToCode(this, 'FREQUENCY', Blockly.propc.ORDER_ATOMIC) || 3000;
+
+ var code = 'freqout(' + dropdown_pin + ', ' + duration + ', ' + frequency + ');\n';
+
+ return code;
+};
+
+Blockly.Blocks.base_count = {
+ helpUrl: Blockly.MSG_ANALOG_PULSE_IN_OUT_HELPURL,
+ init: function() {
+ //this.setTooltip(Blockly.MSG_BASE_FREQOUT_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.appendDummyInput("")
+ .appendField("count pulses PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
+ this.appendValueInput("DURATION", 'Number')
+ .appendField("duration (ms)")
+ .setCheck('Number');
+ this.setInputsInline(true);
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ this.setOutput(true, 'Number');
+ }
+};
+
+Blockly.propc.base_count = function () {
+ var dropdown_pin = this.getFieldValue('PIN');
+ var duration = Blockly.propc.valueToCode(this, 'DURATION', Blockly.propc.ORDER_ATOMIC) || '1';
+
+ var code = 'count(' + dropdown_pin + ', ' + duration + ')';
+
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.pulse_in = {
+ helpUrl: Blockly.MSG_ANALOG_PULSE_IN_OUT_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_PULSE_IN_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.appendDummyInput()
+ .appendField("pulse-in PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
+ this.appendDummyInput()
+ .appendField("read")
+ .appendField(new Blockly.FieldDropdown([["negative/low pulses", "0"], ["positive/high pulses", "1"]]), "STATE");
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ this.setOutput(true, 'Number');
+ }
+};
+
+Blockly.propc.pulse_in = function() {
+ var pin = this.getFieldValue("PIN");
+ var state = this.getFieldValue("STATE");
+
+ var code = 'pulse_in(' + pin + ', ' + state + ')';
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.pulse_out = {
+ helpUrl: Blockly.MSG_ANALOG_PULSE_IN_OUT_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_PULSE_OUT_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.appendDummyInput()
+ .appendField("pulse-out PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
+ this.appendValueInput('PULSE_LENGTH')
+ .appendField("pulse length (" + "\u00B5" + "s)");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.pulse_out = function() {
+ var pin = this.getFieldValue("PIN");
+ var pulse_length = Blockly.propc.valueToCode(this, 'PULSE_LENGTH', Blockly.propc.ORDER_ATOMIC);
+
+ return 'pulse_out(' + pin + ', ' + pulse_length + ');\n';
+};
+
+Blockly.Blocks.rc_charge_discharge = {
+ helpUrl: Blockly.MSG_ANALOG_RC_TIME_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_RC_CHARGE_DISCHARGE_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.appendDummyInput("")
+ .appendField("RC")
+ .appendField(new Blockly.FieldDropdown([["charge", "0"], ["discharge", "1"]]), "STATE");
+ this.appendDummyInput("")
+ .appendField("PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
+ this.setInputsInline(true);
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ this.setOutput(true, 'Number');
+ }
+};
+
+Blockly.propc.rc_charge_discharge = function() {
+ var pin = this.getFieldValue("PIN");
+ var state = this.getFieldValue("STATE");
+
+ var code = 'rc_time(' + pin + ', ' + state + ')';
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+// --------------- EEPROM Memory Blocks ----------------------------------------
+Blockly.Blocks.eeprom_write = {
+ helpUrl: Blockly.MSG_EEPROM_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_EEPROM_WRITE_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendValueInput("DATA")
+ .setCheck(null)
+ .appendField("EEPROM write")
+ .appendField(new Blockly.FieldDropdown([["number", "NUMBER"], ["text", "TEXT"], ["byte", "BYTE"]]), "TYPE");
+ this.appendValueInput("ADDRESS")
+ .setCheck("Number")
+ .appendField("to address");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.eeprom_write = function () {
+ var type = this.getFieldValue('TYPE');
+ var address = Blockly.propc.valueToCode(this, 'ADDRESS', Blockly.propc.ORDER_ATOMIC);
+ var data = Blockly.propc.valueToCode(this, 'DATA', Blockly.propc.ORDER_ATOMIC) || '';
+
+ var setup_code = '// Constrain Function\nint constrain(int __cVal, int __cMin, int __cMax) {';
+ setup_code += 'if(__cVal < __cMin) __cVal = __cMin;\n';
+ setup_code += 'if(__cVal > __cMax) __cVal = __cMax;\nreturn __cVal;\n}\n';
+ Blockly.propc.global_vars_["constrain_function"] = setup_code;
+
+ var code = '';
+ if(data !== '') {
+ if (type === 'BYTE') {
+ code += 'ee_putByte((' + data + ' & 255), (32768 + constrain(' + address + ', 0, 7675)) );\n';
+ } else if (type === 'NUMBER') {
+ code += 'ee_putInt(' + data + ', (32768 + constrain(' + address + ', 0, 7675)) );\n';
+ } else {
+ code += 'ee_putStr(' + data + ', (strlen(' + data + ') + 1), (32768 + constrain(' + address + ', 0, 7675)) );\n';
+ }
+ }
+
+ return code;
+};
+
+Blockly.Blocks.eeprom_read = {
+ helpUrl: Blockly.MSG_EEPROM_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_EEPROM_READ_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendValueInput("ADDRESS")
+ .setCheck("Number")
+ .appendField("EEPROM read")
+ .appendField(new Blockly.FieldDropdown([["number", "NUMBER"], ["text", "TEXT"], ["byte", "BYTE"]]), "TYPE")
+ .appendField("from address");
+ this.appendDummyInput()
+ .appendField("store in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VALUE');
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ },
+ getVars: function () {
+ return [this.getFieldValue('VALUE')];
+ },
+ renameVar: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
+ this.setTitleValue(newName, 'VALUE');
+ }
+ }
+};
+
+Blockly.propc.eeprom_read = function () {
+ var type = this.getFieldValue('TYPE');
+ var address = Blockly.propc.valueToCode(this, 'ADDRESS', Blockly.propc.ORDER_ATOMIC);
+ var data = Blockly.propc.variableDB_.getName(this.getFieldValue('VALUE'), Blockly.Variables.NAME_TYPE);
+
+ Blockly.propc.global_vars_["i2c_eepromAddr"] = 'int __eeAddr;';
+
+ var code = '__eeAddr = ' + address + ';\n';
+ code += 'if(__eeAddr < 0) __eeAddr = 0;\n';
+ code += 'if(__eeAddr > 7675) __eeAddr = 7675;\n';
+
+ if(data !== '') {
+ if (type === 'BYTE') {
+ code += data + ' = ee_getByte( 32768 + __eeAddr ) & 255;\n';
+ } else if (type === 'NUMBER') {
+ code += data + ' = ee_getInt( 32768 + __eeAddr );\n';
+ } else {
+ Blockly.propc.global_vars_["i2c_eeBffr"] = 'char __eeBffr[1];';
+ Blockly.propc.global_vars_["i2c_eeIdx"] = 'int __eeIdx = 0;';
+ Blockly.propc.vartype_[data] = 'char *';
+ code += '// Get the string from EEPROM one character at a time until it finds the end of the string.\n';
+ code += '__eeIdx = 0;\n';
+ code += 'while(__eeIdx < 128) {\n ee_getStr(__eeBffr, 1, (32768 + __eeAddr) + __eeIdx);\n';
+ code += ' ' + data + '[__eeIdx] = __eeBffr[0];\n';
+ code += ' if(' + data + '[__eeIdx] == 0) break;\n __eeIdx++;\n}\n';
+ code += ' if(__eeIdx >= 128) ' + data + '[127] = 0;\n';
+ }
+ }
+
+ return code;
+};
+
+// ------------------ Servo motor blocks ---------------------------------------
+Blockly.Blocks.servo_move = {
+ helpUrl: Blockly.MSG_SERVO_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_SERVO_MOVE_TOOLTIP);
+ this.setColour(colorPalette.getColor('output'));
+ this.appendDummyInput()
+ .appendField("Servo PIN")
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
+ this.appendValueInput("ANGLE")
+ .appendField("set angle (0-180\u00B0)")
+ .setCheck("Number");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.servo_move = function () {
+ var dropdown_pin = this.getFieldValue('PIN');
+ var degrees = Blockly.propc.valueToCode(this, 'ANGLE', Blockly.propc.ORDER_NONE);
+
+ Blockly.propc.definitions_["include servo"] = '#include "servo.h"';
+ if (degrees < 0) {
+ degrees = 0;
+ }
+ if (degrees > 180) {
+ degrees = 180;
+ }
+ var code = 'servo_angle(' + dropdown_pin + ', ' + degrees + ' * 10);\n';
+ return code;
+};
+
+Blockly.Blocks.servo_speed = {
+ helpUrl: Blockly.MSG_SERVO_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_SERVO_SPEED_TOOLTIP);
+ this.setColour(colorPalette.getColor('output'));
+ this.appendDummyInput()
+ .appendField("CR Servo PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), 'PIN');
+ this.appendValueInput("SPEED")
+ .appendField("speed")
+ .setCheck("Number");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.servo_speed = function () {
+ var pin = this.getFieldValue('PIN');
+ var speed = Blockly.propc.valueToCode(this, 'SPEED', Blockly.propc.ORDER_NONE);
+
+ Blockly.propc.definitions_["include servo"] = '#include "servo.h"';
+
+ return 'servo_speed(' + pin + ', ' + speed + ');\n';
+};
+
+Blockly.Blocks.servo_set_ramp = {
+ helpUrl: Blockly.MSG_SERVO_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_SERVO_SET_RAMP_TOOLTIP);
+ this.setColour(colorPalette.getColor('output'));
+ this.appendDummyInput()
+ .appendField("CR Servo set ramp PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), 'PIN');
+ this.appendValueInput('RAMPSTEP')
+ .appendField("rampstep (0 - 100)")
+ .setCheck('Number');
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.servo_set_ramp = function () {
+ var pin = this.getFieldValue('PIN');
+ var ramp_step = Blockly.propc.valueToCode(this, 'RAMPSTEP', Blockly.propc.ORDER_NONE);
+
+ if (Number(ramp_step) < 0) {
+ ramp_step = "0";
+ } else if (Number(ramp_step) > 100) {
+ ramp_step = "100";
+ }
+
+ Blockly.propc.definitions_["include servo"] = '#include "servo.h"';
+
+ return 'servo_setramp(' + pin + ', ' + ramp_step + ');\n';
+};
+
+// --------- ActivityBoard A/D and D/A voltage measurement/generation blocks ---
+Blockly.Blocks.ab_volt_in = {
+ helpUrl: Blockly.MSG_ANALOG_PULSES_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_AB_VOLT_IN_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.appendDummyInput()
+ .appendField("A/D channel")
+ .appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"]]), "CHANNEL")
+ .appendField("read (0-5V) in volt-100ths");
+ this.setOutput(true, 'Number');
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ }
+};
+
+Blockly.propc.ab_volt_in = function() {
+ var dropdown_channel = this.getFieldValue('CHANNEL');
+
+ Blockly.propc.definitions_["include abvolt"] = '#include "abvolts.h"';
+ if (Blockly.propc.setups_['setup_abvolt'] === undefined) {
+ Blockly.propc.setups_['setup_abvolt'] = 'ad_init(21, 20, 19, 18);';
+ }
+
+ var code = '(ad_in(' + dropdown_channel + ') * 500 / 4096)';
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.ab_volt_out = {
+ helpUrl: Blockly.MSG_ANALOG_PULSES_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_AB_VOLT_OUT_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.appendDummyInput()
+ .appendField("D/A channel")
+ .appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"]]), "CHANNEL")
+ .appendField("output (0-3.3V)");
+ this.appendValueInput("VALUE")
+ .setCheck('Number')
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("volt-100ths");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.ab_volt_out = function() {
+ var dropdown_channel = this.getFieldValue('CHANNEL');
+ var value = Blockly.propc.valueToCode(this, 'VALUE', Blockly.propc.ORDER_NONE) || '0';
+
+ Blockly.propc.definitions_["include abvolt"] = '#include "abvolts.h"';
+ if (Blockly.propc.setups_['setup_abvolt_out'] === undefined) {
+ Blockly.propc.setups_['setup_abvolt_out'] = 'da_init(26, 27);';
+ }
+
+ var code = 'da_out(' + dropdown_channel + ', (' + value + '* 256 / 330));\n';
+ return code;
+};
+
+// ------------- PWM (Pulse-width modulation) Blocks ---------------------------
+Blockly.Blocks.pwm_start = {
+ helpUrl: Blockly.MSG_ANALOG_PWM_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_PWM_START_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.appendDummyInput()
+ .appendField("PWM initialize");
+
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.pwm_start = function () {
+ var code = 'pwm_start(100);\n';
+ return code;
+};
+
+Blockly.Blocks.pwm_set = {
+ helpUrl: Blockly.MSG_ANALOG_PWM_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_PWM_SET_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.appendDummyInput()
+ .appendField("PWM set PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
+ this.appendDummyInput()
+ .appendField("channel")
+ .appendField(new Blockly.FieldDropdown([["A", "0"], ["B", "1"]]), "CHANNEL");
+ this.appendValueInput("DUTY_CYCLE", Number)
+ .setCheck('Number')
+ .appendField("duty cycle (0 - 100)");
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.pwm_set = function () {
+ var pin = this.getFieldValue("PIN");
+ var channel = this.getFieldValue("CHANNEL");
+ var duty_cycle = Blockly.propc.valueToCode(this, "DUTY_CYCLE", Blockly.propc.ORDER_NONE);
+
+ if (Number(duty_cycle) < 0) {
+ duty_cycle = '0';
+ } else if (Number(duty_cycle) > 100) {
+ duty_cycle = '100';
+ }
+
+ var code = 'pwm_set(' + pin + ', ' + channel + ', ' + duty_cycle + ');\n';
+ return code;
+};
+
+Blockly.Blocks.pwm_stop = {
+ helpUrl: Blockly.MSG_ANALOG_PWM_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_PWM_STOP_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.appendDummyInput()
+ .appendField("PWM stop");
+
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.pwm_stop = function () {
+ var code = 'pwm_stop();\n';
+ return code;
+};
+
+// ----------------- .WAV file audio player blocks -----------------------------
+Blockly.Blocks.wav_play = {
+ helpUrl: Blockly.MSG_AUDIO_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_WAV_PLAY_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.appendDummyInput()
+ .appendField("WAV play file")
+ .appendField(new Blockly.FieldTextInput('File_name'), 'FILENAME');
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.wav_play = function() {
+ var filename = this.getFieldValue('FILENAME');
+
+ Blockly.propc.definitions_["include wavplayer"] = '#include "wavplayer.h"';
+ Blockly.propc.setups_["sd_card"] = 'int DO = 22, CLK = 23, DI = 24, CS = 25;\n\tsd_mount(DO, CLK, DI, CS);\n';
+
+ var code = 'wav_play("' + filename + '.wav");\n';
+ return code;
+};
+
+Blockly.Blocks.wav_status = {
+ helpUrl: Blockly.MSG_AUDIO_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_WAV_STATUS_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.appendDummyInput()
+ .appendField("WAV status");
+
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ this.setOutput(true, 'Number');
+ }
+};
+
+Blockly.propc.wav_status = function() {
+ Blockly.propc.definitions_["include wavplayer"] = '#include "wavplayer.h"';
+
+ var code = 'wav_playing()';
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.wav_volume = {
+ helpUrl: Blockly.MSG_AUDIO_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_WAV_VOLUME_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.appendValueInput('VOLUME')
+ .appendField("WAV volume (0 - 10)");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.wav_volume = function() {
+ var volume = Blockly.propc.valueToCode(this, 'VOLUME', Blockly.propc.ORDER_NONE) || '0';
+
+ Blockly.propc.definitions_["include wavplayer"] = '#include "wavplayer.h"';
+
+ if (Number(volume) < 0) {
+ volume = '0';
+ } else if (Number(volume) > 10) {
+ volume = '10';
+ }
+
+ var code = 'wav_volume(' + volume + ');\n';
+ return code;
+};
+
+Blockly.Blocks.wav_stop = {
+ helpUrl: Blockly.MSG_AUDIO_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_WAV_STOP_TOOLTIP);
+ this.setColour(colorPalette.getColor('io'));
+ this.appendDummyInput()
+ .appendField("WAV stop");
+
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.wav_stop = function() {
+ var code = 'wav_stop();\n';
+ return code;
+};
+
+// ----------------- Robot (drive) blocks --------------------------------------
+Blockly.Blocks.ab_drive_init = {
+ helpUrl: Blockly.MSG_ROBOT_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_ROBOT_DRIVE_INIT_TOOLTIP);
+ this.setColour(colorPalette.getColor('robot'));
+ this.appendDummyInput()
+ .appendField("Robot")
+ .appendField(new Blockly.FieldDropdown([["ActivityBot", "abdrive.h"], ["Arlo", "arlodrive.h"], ["Servo Differential Drive", "servodiffdrive.h"]], function (bot) {
+ this.sourceBlock_.updateShape_({"BOT": bot});
+ }), "BOT")
+ .appendField("initialize");
+ this.appendDummyInput("PINS")
+ .appendField(" ramping")
+ .appendField(new Blockly.FieldDropdown([["none", "64"], ["light", "8"], ["medium", "4"], ["heavy", "2"], ["maximum", "1"]]), "RAMPING");
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+
+ },
+ mutationToDom: function () {
+ var container = document.createElement('mutation');
+ var bot = this.getFieldValue('BOT');
+ container.setAttribute('BOT', bot);
+ return container;
+ },
+ domToMutation: function (xmlElement) {
+ var bot = xmlElement.getAttribute('BOT');
+ this.updateShape_({"BOT": bot});
+ },
+ updateShape_: function (details) {
+
+ var bot = details['BOT'];
+ if (details['BOT'] === undefined) {
+ bot = this.getFieldValue('BOT');
+ }
+
+ this.removeInput('PINS');
+ this.appendDummyInput("PINS");
+ var inputPins = this.getInput('PINS');
+ if (bot === 'servodiffdrive.h') {
+ inputPins.appendField(" left PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "LEFT")
+ .appendField("right PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "RIGHT")
+ .appendField(" ramping")
+ .appendField(new Blockly.FieldDropdown([["none", "64"], ["light", "8"], ["medium", "4"], ["heavy", "2"], ["maximum", "1"]]), "RAMPING");
+ } else {
+ inputPins.appendField(" ramping")
+ .appendField(new Blockly.FieldDropdown([["none", "64"], ["light", "8"], ["medium", "4"], ["heavy", "2"], ["maximum", "1"]]), "RAMPING");
+ }
+ }
+};
+
+Blockly.propc.ab_drive_init = function() {
+ var bot = this.getFieldValue('BOT');
+ var left = Number(this.getFieldValue('LEFT'));
+ var right = Number(this.getFieldValue('RIGHT'));
+ var ramping = Number(this.getFieldValue('RAMPING'));
+
+ Blockly.propc.definitions_["include abdrive"] = '#include "' + bot + '"';
+
+ if(Blockly.propc.definitions_["include abdrive"] === '#include "servodiffdrive.h"') {
+ Blockly.propc.setups_["servodiffdrive"] = 'drive_pins(' + left + ',' + right + ');\n';
+ Blockly.propc.setups_["sdd_ramping"] = 'drive_setramp(' + ramping + ',' + ramping + ');\n';
+ } else {
+ Blockly.propc.setups_["abd_ramping"] = 'drive_setRampStep(' + ramping + ');\n';
+ }
+
+ return '';
+};
+
+Blockly.Blocks.ab_drive_goto = {
+ helpUrl: Blockly.MSG_ROBOT_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_ROBOT_DRIVE_DISTANCE_TOOLTIP);
+ this.setColour(colorPalette.getColor('robot'));
+ this.appendDummyInput()
+ .appendField('Robot drive distance in')
+ .appendField(new Blockly.FieldDropdown([["ticks", "TICK"], ["centimeters", "CM"], ["inches", "INCH"]]), "UNITS");
+ this.appendValueInput("LEFT")
+ .setCheck('Number')
+ .appendField("left");
+ this.appendValueInput("RIGHT")
+ .setCheck('Number')
+ .appendField("right");
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.ab_drive_goto = function() {
+ var left = Blockly.propc.valueToCode(this, 'LEFT', Blockly.propc.ORDER_NONE);
+ var right = Blockly.propc.valueToCode(this, 'RIGHT', Blockly.propc.ORDER_NONE);
+ var units = this.getFieldValue('UNITS');
+ var bot = Blockly.propc.definitions_["include abdrive"];
+
+ var code = '';
+
+ if(bot === '#include "servodiffdrive.h"') {
+ code += '// Servo Differential Drive does not support "Drive Distance"\n';
+ } else if(bot === '#include "abdrive.h"') {
+ if(units === 'TICK') {
+ code += 'drive_goto(' + left + ', ' + right + ');\n';
+ } else if(units === 'CM') {
+ code += 'drive_goto((' + left + ' * 40)/13, (' + right + ' * 40)/13);\n';
+ } else {
+ code += 'drive_goto((' + left + ' * 508)/65, (' + right + ' * 508)/65);\n';
+ }
+ } else {
+ if(units === 'TICK') {
+ code += 'drive_goto(' + left + ', ' + right + ');\n';
+ } else if(units === 'CM') {
+ code += 'drive_goto((' + left + ' * 253)/90, (' + right + ' * 253)/90);\n';
+ } else {
+ code += 'drive_goto((' + left + ' * 50)/7, (' + right + ' * 50)/7);\n';
+ }
+ }
+
+ if(bot === undefined) {
+ return '// Robot drive system is not initialized!\n';
+ } else {
+ return code;
+ }
+};
+
+Blockly.Blocks.ab_drive_speed = {
+ helpUrl: Blockly.MSG_ROBOT_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_ROBOT_DRIVE_SPEED_TOOLTIP);
+ this.setColour(colorPalette.getColor('robot'));
+ this.appendValueInput("LEFT")
+ .setCheck('Number')
+ .appendField("Robot drive speed left");
+ this.appendValueInput("RIGHT")
+ .setCheck('Number')
+ .appendField("right");
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.ab_drive_speed = function() {
+ var left = Blockly.propc.valueToCode(this, 'LEFT', Blockly.propc.ORDER_NONE);
+ var right = Blockly.propc.valueToCode(this, 'RIGHT', Blockly.propc.ORDER_NONE);
+ var bot = Blockly.propc.definitions_["include abdrive"];
+
+ var code = '';
+
+ if(bot === '#include "servodiffdrive.h"') {
+ code = 'drive_speeds(' + left + ', ' + right + ');\n';
+ } else {
+ if(Blockly.propc.setups_["abd_ramping"] === 'drive_setRampStep(64);\n') {
+ code = 'drive_speed(' + left + ', ' + right + ');\n';
+ } else {
+ code = 'drive_ramp(' + left + ', ' + right + ');\n';
+ }
+ }
+
+ if(bot === undefined) {
+ return '// Robot drive system is not initialized!\n';
+ } else {
+ return code;
+ }
+};
+
+Blockly.Blocks.ab_drive_stop = {
+ helpUrl: Blockly.MSG_ROBOT_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_ROBOT_DRIVE_STOP_TOOLTIP);
+ this.setColour(colorPalette.getColor('robot'));
+ this.appendDummyInput()
+ .appendField("Robot drive stop");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.ab_drive_stop = function() {
+ var left = Blockly.propc.valueToCode(this, 'LEFT', Blockly.propc.ORDER_NONE);
+ var right = Blockly.propc.valueToCode(this, 'RIGHT', Blockly.propc.ORDER_NONE);
+ var bot = Blockly.propc.definitions_["include abdrive"];
+
+ var code = '';
+
+ if(bot === '#include "servodiffdrive.h"') {
+ code = 'drive_speeds(0, 0);\n';
+ } else {
+ if(Blockly.propc.setups_["abd_ramping"] === 'drive_setRampStep(64);\n') {
+ code = 'drive_speed(0, 0);\n';
+ } else {
+ code = 'drive_ramp(0, 0);\n';
+ }
+ }
+
+ if(bot === undefined) {
+ return '// Robot drive system is not initialized!\n';
+ } else {
+ return code;
+ }
+};
+
+Blockly.Blocks.activitybot_calibrate = {
+ helpUrl: Blockly.MSG_ROBOT_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_ACTIVITYBOT_CALIBRATE_TOOLTIP);
+ this.setColour(colorPalette.getColor('robot'));
+ this.appendDummyInput()
+ .appendField("ActivityBot calibrate");
+ }
+};
+
+Blockly.propc.activitybot_calibrate = function() {
+ Blockly.propc.definitions_["activitybot_calibrate"] = '#include "abcalibrate.h"';
+ Blockly.propc.setups_["activitybot_calibrate"] = 'cal_servoPins(12, 13);\n\tcal_encoderPins(14, 15);';
+
+ return 'high(26);\nhigh(27);\ncal_activityBot();\nlow(26);\nlow(27);\n';
+};
+
+Blockly.Blocks.activitybot_display_calibration = {
+ helpUrl: Blockly.MSG_ROBOT_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_ACTIVITYBOT_DISPLAY_CALIBRATION_TOOLTIP);
+ this.setColour(colorPalette.getColor('robot'));
+ this.appendDummyInput()
+ .appendField("ActivityBot display calibration");
+ }
+};
+
+Blockly.propc.activitybot_display_calibration = function() {
+ Blockly.propc.definitions_["include abdrive"] = '#include "abdrive.h"';
+
+ Blockly.propc.serial_terminal_ = true;
+
+ var code = '';
+ code += 'int abd_intTabSetup;\n';
+ code += 'volatile int abd_elCntL, abd_elCntR, abd_elCntL, abd_elCntR, abd_cntrLidx, abd_cntrRidx;\n';
+ code += 'int abd_spdrL[120], abd_spdmL[120], abd_spdrR[120], abd_spdmR[120];\n';
+
+ Blockly.propc.global_vars_["activitybot_display_calibration"] = code;
+
+ code = '';
+ code += 'if(!abd_intTabSetup) interpolation_table_setup();\n';
+ code += 'print("=== LEFT SERVO ===\\n");\n';
+ code += 'print("Table Entries = %d, Zero Speed Index = %d\\n\\n", abd_elCntL, abd_cntrLidx);\n';
+ code += 'print("Index, Servo Drive, Encoder Ticks/Second\\n");\n';
+ code += 'for(int __rIdx = 0; __rIdx < abd_elCntL; __rIdx++) print("%d, %d, %d\\n", __rIdx, abd_spdrL[__rIdx], abd_spdmL[__rIdx]);\n';
+ code += 'print("\\n\\n=== RIGHT SERVO ===\\n");\n';
+ code += 'print("Table Entries = %d, Zero Speed Index = %d\\n\\n", abd_elCntR, abd_cntrRidx);\n';
+ code += 'print("Index, Servo Drive, Encoder Ticks/Second\\n");\n';
+ code += 'for(int __rIdx = 0; __rIdx < abd_elCntR; __rIdx++) print("%d, %d, %d\\n", __rIdx, abd_spdrR[__rIdx], abd_spdmR[__rIdx]);\n';
+
+ return code;
+};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/hackable_electronic_badge.js b/src/main/webapp/cdn/blockly/generators/propc/heb.js
similarity index 100%
rename from src/main/webapp/cdn/blockly/generators/propc/hackable_electronic_badge.js
rename to src/main/webapp/cdn/blockly/generators/propc/heb.js
diff --git a/src/main/webapp/cdn/blockly/generators/propc/i2c.js b/src/main/webapp/cdn/blockly/generators/propc/i2c.js
deleted file mode 100644
index d52c50b8..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/i2c.js
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- This file implements support for I2C functions.
-
- Author: Vale Tolpegin ( valetolpegin@gmail.com )
-
- *Copyright 2016 Vale Tolpegin.
- *
- *
- * 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.
-
- */
-
-'use strict';
-
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-Blockly.Blocks.i2c_new_bus = {
- init: function () {
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("I2C initialize SCL")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "SCL_PIN");
- this.appendDummyInput()
- .appendField("SDA")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "SDA_PIN");
-// this.appendDummyInput()
-// .appendField("SCL Drive mode")
-// .appendField(new Blockly.FieldDropdown(profile.default.digital), "SCL_DRIVE");
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.i2c_out = {
- init: function () {
- this.setColour(colorPalette.getColor('protocols'));
- this.appendValueInput("DATA")
- .setCheck(null)
- .appendField("I2C send")
- .appendField(new Blockly.FieldDropdown([["byte", "BYTE"], ["number", "NUMBER"], ["text", "TEXT"]]), "TYPE");
- this.appendValueInput("DEVICE")
- .setCheck("Number")
- .appendField("to addresses: device");
- this.appendValueInput("ADDRESS")
- .setCheck("Number")
- .appendField("register");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.i2c_in = {
- init: function () {
- this.setColour(colorPalette.getColor('protocols'));
- this.appendValueInput("SIZE")
- .setCheck("Number")
- .appendField("I2C retrieve bytes (size)");
- this.appendValueInput("DEVICE")
- .setCheck("Number")
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("device address");
- this.appendValueInput("REGISTER")
- .setCheck("Number")
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("register address");
- this.appendValueInput("DATA")
- .setCheck(null)
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("store in");
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.propc.i2c_new_bus = function () {
- var scl_pin = this.getFieldValue('SCL_PIN');
- var sda_pin = this.getFieldValue('SDA_PIN');
- var scl_drive = '0';
-
- Blockly.propc.global_vars_["i2c_new_bus"] = 'i2c *i2cBusUD;';
- Blockly.propc.setups_["i2c_newbus"] = 'i2cBusUD = i2c_newbus(' + scl_pin + ', ' + sda_pin + ', ' + scl_drive + ');\n';
-
- return '';
-};
-
-Blockly.propc.i2c_in = function () {
- var device = Blockly.propc.valueToCode(this, 'DEVICE', Blockly.propc.ORDER_ATOMIC);
- var size = Blockly.propc.valueToCode(this, 'SIZE', Blockly.propc.ORDER_ATOMIC);
- var address = Blockly.propc.valueToCode(this, 'REGISTER', Blockly.propc.ORDER_ATOMIC);
- var data = Blockly.propc.valueToCode(this, 'DATA', Blockly.propc.ORDER_NONE) || '';
-
- if (Blockly.propc.setups_["i2c_newbus"] === undefined)
- {
- return '//Missing i2c new bus declaration\n';
- }
-
- Blockly.propc.global_vars_["i2c_new_bus"] = 'i2c *i2cBusUD;';
- Blockly.propc.global_vars_["i2c_address_size"] = 'int __addrSize = 4;';
-
- var code = '';
-
- if(data !== '') {
- code += '__addrSize = 4;\n';
- code += 'if(' + address + ' <= 0xFFFFFF) __addrSize = 3;\n';
- code += 'if(' + address + ' <= 0xFFFF) __addrSize = 2;\n';
- code += 'if(' + address + ' <= 0xFF) __addrSize = 1;\n';
- code += 'i2c_in(i2cBusUD, (' + device + ' & 127), ' + address + ', __addrSize, ' + data + ', ' + size + ');';
- }
-
- return code;
-};
-
-Blockly.propc.i2c_out = function () {
- var type = this.getFieldValue('TYPE');
- var device = Blockly.propc.valueToCode(this, 'DEVICE', Blockly.propc.ORDER_ATOMIC);
- var data = Blockly.propc.valueToCode(this, 'DATA', Blockly.propc.ORDER_ATOMIC);
- var address = Blockly.propc.valueToCode(this, 'ADDRESS', Blockly.propc.ORDER_ATOMIC);
-
- Blockly.propc.global_vars_["i2c_new_bus"] = 'i2c *i2cBusUD;';
- Blockly.propc.global_vars_["i2c_address_size"] = 'int __addrSize = 4;';
-
- var code = '__addrSize = 4;\n';
- code += 'if(' + address + ' <= 0xFFFFFF) __addrSize = 3;\n';
- code += 'if(' + address + ' <= 0xFFFF) __addrSize = 2;\n';
- code += 'if(' + address + ' <= 0xFF) __addrSize = 1;\n';
- code += 'i2c_out(i2cBusUD, (' + device + ' & 127), ' + address + ', __addrSize, ';
-
- if (type === 'BYTE') {
- code += '(' + data + ' & 0xFF),';
- } else {
- code += data + ',';
- }
-
- if (Blockly.propc.setups_["i2c_newbus"] === undefined)
- {
- return '//Missing i2c new bus declaration\n';
- }
-
- if (type === 'BYTE') {
- code += '1 );\n';
- } else {
- code += 'sizeof(' + data + ') );\n';
- }
-
- return code;
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/joystick.js b/src/main/webapp/cdn/blockly/generators/propc/joystick.js
deleted file mode 100644
index c061e5f1..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/joystick.js
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-
- This file supports joystick use in propc
-
- Author: Vale Tolpegin ( vale@tolpegin.net )
-
- *Copyright 2014 Vale Tolpegin.
- *
- *
- * 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.
-
- */
-'use strict';
-
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-Blockly.Blocks.joystick_input_yaxis = {
- helpUrl: Blockly.MSG_JOYSTICK_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_JOYSTICK_INPUT_YAXIS_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("Joystick y-axis A/D")
- .appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"]]), "PINY");
-
- this.setOutput(true, 'Number');
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- }
-};
-
-Blockly.Blocks.joystick_input_xaxis = {
- helpUrl: Blockly.MSG_JOYSTICK_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_JOYSTICK_INPUT_XAXIS_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("Joystick x-axis A/D")
- .appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"]]), "PINX");
-
- this.setOutput(true, 'Number');
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- }
-};
-
-Blockly.propc.joystick_input_yaxis = function() {
- var pin_number_yaxis = this.getFieldValue('PINY');
-
- Blockly.propc.definitions_["include abvolts"] = '#include "abvolts.h"';
-
- var code = 'ad_in(' + pin_number_yaxis + ') * 100 / 4096';
- return [code, Blockly.propc.ORDER_ATOMIC];
-};
-
-Blockly.propc.joystick_input_xaxis = function() {
- var pin_number_xaxis = this.getFieldValue('PINX');
-
- Blockly.propc.definitions_["include abvolts"] = '#include "abvolts.h"';
-
- var code = 'ad_in(' + pin_number_xaxis + ') * 100 / 4096';
- return [code, Blockly.propc.ORDER_ATOMIC];
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/logic.js b/src/main/webapp/cdn/blockly/generators/propc/logic.js
deleted file mode 100644
index 2dee56de..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/logic.js
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2012 Google Inc.
- * http://blockly.googlecode.com/
- *
- * 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.
- */
-
-/**
- * @fileoverview Generating Prop-C for control blocks.
- * @author michel@creatingfuture.eu (Michel Lampo)
- */
-'use strict';
-
-Blockly.propc.logic_compare = function() {
- // Comparison operator.
- var mode = this.getFieldValue('OP');
- var operator = Blockly.propc.logic_compare.OPERATORS[mode];
- var order = (operator === '==' || operator === '!=') ?
- Blockly.propc.ORDER_EQUALITY : Blockly.propc.ORDER_RELATIONAL;
- var argument0 = Blockly.propc.valueToCode(this, 'A', order) || '0';
- var argument1 = Blockly.propc.valueToCode(this, 'B', order) || '0';
- var code = argument0 + ' ' + operator + ' ' + argument1;
- return [code, order];
-};
-
-Blockly.propc.logic_compare.OPERATORS = {
- EQ: '==',
- NEQ: '!=',
- LT: '<',
- LTE: '<=',
- GT: '>',
- GTE: '>='
-};
-
-Blockly.propc.logic_operation = function() {
- // Operations 'and', 'or'.
- var operator = '';
- var order = Blockly.propc.ORDER_LOGICAL_AND;
- switch (this.getFieldValue('OP')) {
- case 'AND':
- operator = '&& ';
- break;
- case 'OR':
- operator = '|| ';
- order = Blockly.propc.ORDER_LOGICAL_OR;
- break;
- case 'AND_NOT':
- operator = '&& !';
- break;
- case 'OR_NOT':
- operator = '|| !';
- order = Blockly.propc.ORDER_LOGICAL_OR;
- break;
- }
- var argument0 = Blockly.propc.valueToCode(this, 'A', order) || '0';
- var argument1 = Blockly.propc.valueToCode(this, 'B', order) || '0';
- var code = argument0 + ' ' + operator + argument1;
- return [code, order];
-};
-
-Blockly.propc.logic_negate = function() {
- // Negation.
- var order = Blockly.propc.ORDER_UNARY_PREFIX;
- var argument0 = Blockly.propc.valueToCode(this, 'BOOL', order) || '0';
- var code = '!' + argument0;
- return [code, order];
-};
-
-Blockly.propc.logic_boolean = function() {
- // Boolean values true and false.
- var code = (this.getFieldValue('BOOL') === 'TRUE') ? '1' : '0';
- return [code, Blockly.propc.ORDER_ATOMIC];
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/math.js b/src/main/webapp/cdn/blockly/generators/propc/math.js
deleted file mode 100644
index 88fd4f8a..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/math.js
+++ /dev/null
@@ -1,202 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2014 Michel Lampo.
- * https://github.com/gasolin/BlocklyDuino
- *
- * 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.
- */
-
-/**
- * @fileoverview Generating Prop-c for control blocks.
- * @author michel@creatingfuture.eu (Michel Lampo)
- */
-'use strict';
-
-//To support syntax defined in http://arduino.cc/en/Reference/HomePage
-//define blocks
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-Blockly.propc['math_number'] = function() {
- // Numeric value.
- var code = window.parseInt(this.getFieldValue('NUM'));
- // -4.abs() returns -4 in Dart due to strange order of operation choices.
- // -4 is actually an operator and a number. Reflect this in the order.
- var order = code < 0 ?
- Blockly.propc.ORDER_UNARY_PREFIX : Blockly.propc.ORDER_ATOMIC;
- return [code, order];
-};
-
-
-Blockly.propc.math_arithmetic = function() {
- // Basic arithmetic operators, and power.
- var mode = this.getFieldValue('OP');
- var tuple = Blockly.propc.math_arithmetic.OPERATORS[mode];
- var operator = tuple[0];
- var order = tuple[1];
- var argument0 = Blockly.propc.valueToCode(this, 'A', order) || '0';
- var argument1 = Blockly.propc.valueToCode(this, 'B', order) || '0';
- var code;
-
- code = argument0 + operator + argument1;
- return [code, order];
-};
-
-Blockly.propc.math_arithmetic.OPERATORS = {
- ADD: [' + ', Blockly.propc.ORDER_ADDITIVE],
- MINUS: [' - ', Blockly.propc.ORDER_ADDITIVE],
- MULTIPLY: [' * ', Blockly.propc.ORDER_MULTIPLICATIVE],
- DIVIDE: [' / ', Blockly.propc.ORDER_MULTIPLICATIVE],
- MODULUS: [' % ', Blockly.propc.ORDER_MULTIPLICATIVE]
-};
-
-// Limit
-Blockly.Blocks.math_limit = {
- // Basic arithmetic operator.
- helpUrl: Blockly.MSG_NUMBERS_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_MATH_LIMIT_TOOLTIP);
- this.setColour(colorPalette.getColor('math'));
- this.appendValueInput('A')
- .setCheck('Number')
- .appendField(new Blockly.FieldDropdown(this.OPERATORS), 'OP');
- this.appendValueInput('B')
- .setCheck('Number')
- .appendField("and");
-
- this.setInputsInline(true);
- this.setOutput(true, 'Number');
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- }
-};
-
-Blockly.Blocks.math_limit.OPERATORS = [
- ["highest of", 'LIMIT_MIN'],
- ["lowest of", 'LIMIT_MAX']
-];
-
-Blockly.propc.math_limit = function() {
- // Basic arithmetic operators, and power.
- var mode = this.getFieldValue('OP');
- var tuple = Blockly.propc.math_limit.OPERATORS[mode];
- var operator = tuple[0];
- var order = tuple[1];
- var argument0 = Blockly.propc.valueToCode(this, 'A', order) || '0';
- var argument1 = Blockly.propc.valueToCode(this, 'B', order) || '0';
- var code;
-
- code = argument0 + operator + argument1;
- return [code, order];
-};
-
-Blockly.propc.math_limit.OPERATORS = {
- LIMIT_MIN: [' #> ', Blockly.propc.ORDER_ASSIGNMENT],
- LIMIT_MAX: [' <# ', Blockly.propc.ORDER_ASSIGNMENT]
-};
-
-// Increment/decrement
-Blockly.Blocks.math_crement = {
- helpUrl: Blockly.MSG_NUMBERS_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_MATH_CREMENT_TOOLTIP);
- this.setColour(colorPalette.getColor('math'));
- this.appendValueInput('VAR')
- .setCheck('Number')
- .appendField(new Blockly.FieldDropdown(this.OPERATORS), 'OP');
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- }
-};
-
-Blockly.Blocks.math_crement.OPERATORS = [
- ["decrement", 'DEC'],
- ["increment", 'INC']
-];
-
-Blockly.propc.math_crement = function() {
- // Basic arithmetic operators, and power.
- var mode = this.getFieldValue('OP');
- var tuple = Blockly.propc.math_crement.OPERATORS[mode];
- var operator = tuple[0];
- var order = tuple[1];
- var variable = Blockly.propc.valueToCode(this, 'VAR', order) || '0';
-
- var code = variable + operator + ';\n';
- return code;
-};
-
-Blockly.propc.math_crement.OPERATORS = {
- DEC: ['--', Blockly.propc.ORDER_UNARY_PREFIX],
- INC: ['++', Blockly.propc.ORDER_UNARY_PREFIX]
-};
-
-Blockly.Blocks.math_random = {
- // Rounding functions.
- helpUrl: Blockly.MSG_NUMBERS_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_MATH_RANDOM_TOOLTIP);
- this.setColour(colorPalette.getColor('math'));
- this.appendValueInput("A")
- .setCheck("Number")
- .appendField("random number from");
- this.appendValueInput("B")
- .setCheck("Number")
- .appendField("to");
- this.setInputsInline(true);
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- this.setOutput(true, 'Number');
- }
-};
-
-Blockly.propc.math_random = function() {
- Blockly.propc.setups_["random_seed"] = "srand(INA + CNT);\n";
- var arg1 = Blockly.propc.valueToCode(this, 'A', Blockly.propc.ORDER_ATOMIC) || '0';
- var arg2 = Blockly.propc.valueToCode(this, 'B', Blockly.propc.ORDER_ATOMIC) || '99';
-
- var code = '(' + arg1 + ' + rand() % (' + arg2 + ' - ' + arg1 + ' + 1))';
- return [code, Blockly.propc.ORDER_NONE];
-};
-
-Blockly.Blocks.math_bitwise = {
- helpUrl: Blockly.MSG_NUMBERS_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_MATH_BITWISE_TOOLTIP);
- this.setColour(colorPalette.getColor('math'));
- this.appendValueInput('VAL1');
- this.appendDummyInput()
- .appendField(new Blockly.FieldDropdown([
- ["& (bitwise AND)", "&"],
- ["| (bitwise OR)", "|"],
- ["^ (bitwise XOR)", "^"],
- [">> (bitwise right shift)", ">>"],
- ["<< (bitwise left shift)", "<<"]]), "OPERATION");
- this.appendValueInput('VAL2');
-
- this.setOutput(true, 'Number');
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- }
-};
-
-Blockly.propc.math_bitwise = function() {
- var value1 = Blockly.propc.valueToCode(this, 'VAL1', Blockly.propc.ORDER_NONE);
- var value2 = Blockly.propc.valueToCode(this, 'VAL2', Blockly.propc.ORDER_NONE);
- var operation = this.getFieldValue('OPERATION');
-
- var code = value1 + ' ' + operation + ' ' + value2;
- return [code, Blockly.propc.ORDER_NONE];
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/oled.js b/src/main/webapp/cdn/blockly/generators/propc/oled.js
deleted file mode 100644
index d6f9ff55..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/oled.js
+++ /dev/null
@@ -1,634 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2016 Vale Tolpegin
- *
- *
- * 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.
- */
-
-/**
- * @fileoverview Generating Prop-C & UI for OLED blocks.
- * @author valetolpegin@gmail.com (Vale Tolpegin)
- */
-'use strict';
-
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-Blockly.Blocks.oled_initialize = {
- helpUrl: Blockly.MSG_OLED_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_OLED_INITIALIZE_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- // Field order DIN, CLK, CS, D/C, RES
- this.appendDummyInput()
- .appendField("OLED initialize")
- .appendField("DIN")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "DIN")
- .appendField("CLK")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "CLK")
- .appendField("CS")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "CS")
- .appendField("D/C")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "DC")
- .appendField("RES")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "RES");
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.oled_font_loader = {
- helpUrl: Blockly.MSG_OLED_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_OLED_FONT_LOADER_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("OLED font loader (EEPROM only)");
- }
-};
-
-Blockly.Blocks.oled_clear_screen = {
- helpUrl: Blockly.MSG_OLED_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_OLED_CLEAR_SCREEN_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("OLED clear screen");
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.oled_draw_circle = {
- helpUrl: Blockly.MSG_OLED_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_OLED_DRAW_CIRCLE_TOOLTIP);
- // First x/y coordinates
- this.appendValueInput("POINT_X")
- .setCheck("Number")
- .appendField("OLED draw circle at (x)");
- this.appendValueInput("POINT_Y")
- .setCheck(null)
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("(y)");
- this.appendValueInput("RADIUS")
- .setCheck("Number")
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("radius");
- // Color picker control
- this.appendValueInput('COLOR')
- .setAlign(Blockly.ALIGN_RIGHT)
- .setCheck('Number')
- .appendField("color");
- this.appendDummyInput()
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("fill")
- .appendField(new Blockly.FieldCheckbox("TRUE"), "ck_fill");
-
- // Other details
- this.setInputsInline(false);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(colorPalette.getColor('protocols'));
- }
-};
-
-Blockly.Blocks.oled_draw_line = {
- helpUrl: Blockly.MSG_OLED_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_OLED_DRAW_LINE_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendValueInput("X_ONE")
- .setCheck('Number')
- .appendField("OLED draw line from 1 (x)");
- this.appendValueInput("Y_ONE")
- .setCheck('Number')
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("(y)");
- this.appendValueInput("X_TWO")
- .setCheck('Number')
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("to 2 (x)");
- this.appendValueInput("Y_TWO")
- .setCheck('Number')
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("(y)");
- this.appendValueInput('COLOR')
- .setAlign(Blockly.ALIGN_RIGHT)
- .setCheck('Number')
- .appendField("color");
-
- this.setInputsInline(false);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.oled_draw_pixel = {
- helpUrl: Blockly.MSG_OLED_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_OLED_DRAW_PIXEL_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendValueInput("X_AXIS")
- .setCheck('Number')
- .appendField("OLED draw pixel at");
- this.appendValueInput("Y_AXIS")
- .setCheck('Number')
- .appendField(",");
- this.appendValueInput('COLOR')
- .setCheck('Number')
- .appendField("color");
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.oled_draw_triangle = {
- helpUrl: Blockly.MSG_OLED_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_OLED_DRAW_TRIANGLE_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- // First x/y coordinates
- this.appendValueInput("POINT_X0")
- .setCheck(null)
- .appendField("OLED draw triangle at 1 (x)");
- this.appendValueInput("POINT_Y0")
- .setCheck(null)
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("(y)");
- // Second x/y coordinates
- this.appendValueInput("POINT_X1")
- .setCheck(null)
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("2 (x)");
- this.appendValueInput("POINT_Y1")
- .setCheck(null)
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("(y)");
- // Third x/y coordinates
- this.appendValueInput("POINT_X2")
- .setCheck(null)
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("3 (x)");
- this.appendValueInput("POINT_Y2")
- .setCheck(null)
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("(y)");
- // Color picker control
- this.appendValueInput('COLOR')
- .setCheck('Number')
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("color");
- this.appendDummyInput()
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("fill")
- .appendField(new Blockly.FieldCheckbox("TRUE"), "ck_fill");
-
- // Other details
- this.setInputsInline(false);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.oled_draw_rectangle = {
- helpUrl: Blockly.MSG_OLED_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_OLED_DRAW_RECTANGLE_TOOLTIP);
- this.appendValueInput("POINT_X")
- .setCheck("Number")
- // .appendField("draw")
- // .appendField(new Blockly.FieldDropdown([
- // ["rectangle", "REG_RECTANGLE"],
- // ["round rectangle", "ROUND_RECTANGLE"]
- // ]), "rect_round")
- // .appendField("at (x)");
- .appendField("OLED draw rectangle at (x)")
- this.appendValueInput("POINT_Y")
- .setCheck("Number")
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("(y)");
- this.appendValueInput("RECT_WIDTH")
- .setCheck(null)
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("width");
- this.appendValueInput("RECT_HEIGHT")
- .setCheck(null)
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("height");
- this.appendValueInput("RECT_ROUND")
- .setCheck(null)
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("roundness");
- // Color picker control
- this.appendValueInput('COLOR')
- .setAlign(Blockly.ALIGN_RIGHT)
- .setCheck('Number')
- .appendField("color");
- this.appendDummyInput()
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField("fill")
- .appendField(new Blockly.FieldCheckbox("TRUE"), "ck_fill");
-
- // Other details
- this.setInputsInline(false);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(colorPalette.getColor('protocols'));
- }
-};
-
-Blockly.Blocks.oled_text_size = {
- helpUrl: Blockly.MSG_OLED_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_OLED_TEXT_SIZE_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("OLED text size")
- .appendField(new Blockly.FieldDropdown([
- ["small", "SMALL"],
- ["medium", "MEDIUM"],
- ["large", "LARGE"]]), "size_select")
- .appendField("font")
- .appendField(new Blockly.FieldDropdown([
- ["sans", "FONT_SANS"],
- ["serif", "FONT_SERIF"],
- ["script", "FONT_SCRIPT"],
- ["bubble", "FONT_BUBBLE"]]), "font_select");
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.oled_text_color = {
- helpUrl: Blockly.MSG_OLED_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_OLED_TEXT_COLOR_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendValueInput('FONT_COLOR')
- .setCheck('Number')
- .appendField("OLED font color");
- this.appendValueInput('BACKGROUND_COLOR')
- .setCheck('Number')
- .appendField("font background color");
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.oled_get_max_height = {
- helpUrl: Blockly.MSG_OLED_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_OLED_GET_MAX_HEIGHT_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("OLED max height");
-
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- this.setOutput(true, "Number");
- }
-};
-
-Blockly.Blocks.oled_get_max_width = {
- helpUrl: Blockly.MSG_OLED_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_OLED_GET_MAX_WIDTH_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("OLED max width");
-
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- this.setOutput(true, "Number");
- }
-};
-
-Blockly.Blocks.oled_set_cursor = {
- helpUrl: Blockly.MSG_OLED_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_OLED_SET_CURSOR_TOOLTIP);
- this.appendValueInput('X_POS')
- .setCheck('Number')
- .appendField("OLED set cursor at (x)");
- this.appendValueInput('Y_POS')
- .setCheck('Number')
- .appendField("(y)");
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(colorPalette.getColor('protocols'));
- }
-};
-
-Blockly.Blocks.oled_print_text = {
- helpUrl: Blockly.MSG_OLED_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_OLED_PRINT_TEXT_TOOLTIP);
- this.appendValueInput('MESSAGE')
- .setCheck('String')
- .appendField("OLED print text ");
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(colorPalette.getColor('protocols'));
- }
-};
-
-Blockly.Blocks.oled_print_number = {
- helpUrl: Blockly.MSG_OLED_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_OLED_PRINT_NUMBER_TOOLTIP);
- this.appendValueInput('NUMIN')
- .setCheck('Number')
- .appendField("OLED print number ");
- this.appendDummyInput()
- .appendField(new Blockly.FieldDropdown([
- ["Decimal", "DEC"],
- ["Hexadecimal", "HEX"],
- ["Binary", "BIN"]
- //["OCT", "OCT"],
- ]), "type");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(colorPalette.getColor('protocols'));
- }
-};
-
-
-Blockly.propc.oled_initialize = function () {
- var cs_pin = this.getFieldValue("CS");
- var dc_pin = this.getFieldValue("DC");
- var din_pin = this.getFieldValue("DIN");
- var clk_pin = this.getFieldValue("CLK");
- var res_pin = this.getFieldValue("RES");
-
- Blockly.propc.definitions_["oledtools"] = '#include "oledc.h"';
- Blockly.propc.setups_["oled"] = 'oledc_init(' + din_pin + ', ' + clk_pin + ', ' + cs_pin + ', ' + dc_pin + ', ' + res_pin + ', 2);';
-
- return '';
-};
-
-
-Blockly.propc.oled_font_loader = function () {
- Blockly.propc.serial_terminal_ = true;
- Blockly.propc.definitions_["oledfonts"] = '#include "oledc_fontLoader.h"';
-
- var code = 'oledc_fontLoader();';
- return code;
-};
-
-
-Blockly.propc.oled_clear_screen = function() {
- // Ensure header file is included
- Blockly.propc.definitions_["oledtools"] = '#include "oledc.h"';
-
- // Emit code to clear the screen
- var code = 'oledc_clear(0, 0, oledc_getWidth(), oledc_getHeight() );';
- return code;
-};
-
-Blockly.propc.oled_draw_circle = function() {
- // Ensure header file is included
- Blockly.propc.definitions_["oledtools"] = '#include "oledc.h"';
- Blockly.propc.definitions_["colormath"] = '#include "colormath.h"';
-
- var point_x0 = Blockly.propc.valueToCode(this, 'POINT_X', Blockly.propc.ORDER_NONE);
- var point_y0 = Blockly.propc.valueToCode(this, 'POINT_Y', Blockly.propc.ORDER_NONE);
- var radius = Blockly.propc.valueToCode(this, 'RADIUS', Blockly.propc.ORDER_NONE);
- var color = Blockly.propc.valueToCode(this, 'COLOR', Blockly.propc.ORDER_NONE);
-
- var checkbox = this.getFieldValue('ck_fill');
- var code;
-
- if (checkbox === 'TRUE') {
- code = 'oledc_fillCircle(';
- } else {
- code = 'oledc_drawCircle(';
- }
-
- code += point_x0 + ', ' + point_y0 + ', ';
- code += radius + ', ';
- code += 'oledc_color565(get8bitColor(' + color + ', "RED"), get8bitColor(' + color + ', "GREEN"), get8bitColor(' + color + ', "BLUE")) ';
- code += ');';
-
- return code;
-};
-
-Blockly.propc.oled_draw_line = function () {
- // Ensure header file is included
- Blockly.propc.definitions_["oledtools"] = '#include "oledc.h"';
- Blockly.propc.definitions_["colormath"] = '#include "colormath.h"';
-
- var x_one = Blockly.propc.valueToCode(this, "X_ONE", Blockly.propc.ORDER_NONE);
- var y_one = Blockly.propc.valueToCode(this, "Y_ONE", Blockly.propc.ORDER_NONE);
- var x_two = Blockly.propc.valueToCode(this, "X_TWO", Blockly.propc.ORDER_NONE);
- var y_two = Blockly.propc.valueToCode(this, "Y_TWO", Blockly.propc.ORDER_NONE);
- var color = Blockly.propc.valueToCode(this, 'COLOR', Blockly.propc.ORDER_NONE);
-
- var code = 'oledc_drawLine(' + x_one + ', ' + y_one + ', ' + x_two + ', ' + y_two + ', ';
- code += 'oledc_color565(get8bitColor(' + color + ', "RED"), get8bitColor(' + color + ', "GREEN"), get8bitColor(' + color + ', "BLUE")));';
-
- return code;
-};
-
-Blockly.propc.oled_draw_pixel = function() {
- // Ensure header file is included
- Blockly.propc.definitions_["oledtools"] = '#include "oledc.h"';
- Blockly.propc.definitions_["colormath"] = '#include "colormath.h"';
-
- var point_x = Blockly.propc.valueToCode(this, 'X_AXIS', Blockly.propc.ORDER_ATOMIC);
- var point_y = Blockly.propc.valueToCode(this, 'Y_AXIS', Blockly.propc.ORDER_ATOMIC);
- var color = Blockly.propc.valueToCode(this, 'COLOR', Blockly.propc.ORDER_NONE);
-
- var code = 'oledc_drawPixel(' + point_x + ', ' + point_y + ', ';
- code += 'oledc_color565(get8bitColor(' + color + ', "RED"), get8bitColor(' + color + ', "GREEN"), get8bitColor(' + color + ', "BLUE")));';
-
- return code;
-};
-
-Blockly.propc.oled_draw_triangle = function() {
- // Ensure header file is included
- Blockly.propc.definitions_["oledtools"] = '#include "oledc.h"';
- Blockly.propc.definitions_["colormath"] = '#include "colormath.h"';
-
- var point_x0 = Blockly.propc.valueToCode(this, 'POINT_X0', Blockly.propc.ORDER_NONE);
- var point_y0 = Blockly.propc.valueToCode(this, 'POINT_Y0', Blockly.propc.ORDER_NONE);
- var point_x1 = Blockly.propc.valueToCode(this, 'POINT_X1', Blockly.propc.ORDER_NONE);
- var point_y1 = Blockly.propc.valueToCode(this, 'POINT_Y1', Blockly.propc.ORDER_NONE);
- var point_x2 = Blockly.propc.valueToCode(this, 'POINT_X2', Blockly.propc.ORDER_NONE);
- var point_y2 = Blockly.propc.valueToCode(this, 'POINT_Y2', Blockly.propc.ORDER_NONE);
- var color = Blockly.propc.valueToCode(this, 'COLOR', Blockly.propc.ORDER_NONE);
-
- var checkbox = this.getFieldValue('ck_fill');
- var code;
-
- if (checkbox === 'TRUE') {
- code = 'oledc_fillTriangle(';
- } else {
- code = 'oledc_drawTriangle(';
- }
-
- code += point_x0 + ', ' + point_y0 + ', ';
- code += point_x1 + ', ' + point_y1 + ', ';
- code += point_x2 + ', ' + point_y2 + ', ';
- code += 'oledc_color565(get8bitColor(' + color + ', "RED"), get8bitColor(' + color + ', "GREEN"), get8bitColor(' + color + ', "BLUE")));';
-
- return code;
-};
-
-Blockly.propc.oled_draw_rectangle = function() {
- // Ensure header file is included
- Blockly.propc.definitions_["oledtools"] = '#include "oledc.h"';
- Blockly.propc.definitions_["colormath"] = '#include "colormath.h"';
-
-// var corners = this.getFieldValue('rect_round');
- var point_x = Blockly.propc.valueToCode(this, 'POINT_X', Blockly.propc.ORDER_NONE);
- var point_y = Blockly.propc.valueToCode(this, 'POINT_Y', Blockly.propc.ORDER_NONE);
- var width = Blockly.propc.valueToCode(this, 'RECT_WIDTH', Blockly.propc.ORDER_NONE);
- var height = Blockly.propc.valueToCode(this, 'RECT_HEIGHT', Blockly.propc.ORDER_NONE);
- var corners = Blockly.propc.valueToCode(this, 'RECT_ROUND', Blockly.propc.ORDER_NONE);
- var color = Blockly.propc.valueToCode(this, 'COLOR', Blockly.propc.ORDER_NONE);
-
- var checkbox = this.getFieldValue('ck_fill');
- var code;
-
-// if (corners === 'REG_RECTANGLE') {
- if (corners === '0') {
- if (checkbox === 'TRUE') {
- code = 'oledc_fillRect(';
- } else {
- code = 'oledc_drawRect(';
- }
-
- code += point_x + ', ' + point_y + ', ';
- code += width + ', ' + height + ', ';
- code += 'oledc_color565(get8bitColor(' + color + ', "RED"), get8bitColor(' + color + ', "GREEN"), get8bitColor(' + color + ', "BLUE"))';
- } else { // Rounded rectangle
- if (checkbox === 'TRUE') {
- code = 'oledc_fillRoundRect(';
- }
- else {
- code = 'oledc_drawRoundRect(';
- }
-
- code += point_x + ', ' + point_y + ', ';
- code += width + ', ' + height + ', ';
-// code += '((' + width + ') + (' + height + ') / 20),';
- code += corners + ', ';
- code += 'oledc_color565(get8bitColor(' + color + ', "RED"), get8bitColor(' + color + ', "GREEN"), get8bitColor(' + color + ', "BLUE"))';
- }
-
- code += ');';
-
- return code;
-};
-
-Blockly.propc.oled_text_size = function() {
- // Ensure header file is included
- Blockly.propc.definitions_["oledtools"] = '#include "oledc.h"';
-
- var size = this.getFieldValue('size_select');
- var font = this.getFieldValue('font_select');
-
- // TODO: Update constants when new oledc library is published
- var code = 'oledc_setTextSize(' + size + ');\n';
- code += 'oledc_setTextFont(' + font + ');\n';
- return code;
-};
-
-
-Blockly.propc.oled_text_color = function() {
- Blockly.propc.definitions_["oledtools"] = '#include "oledc.h"';
- Blockly.propc.definitions_["colormath"] = '#include "colormath.h"';
-
- var font_color = Blockly.propc.valueToCode(this, 'FONT_COLOR', Blockly.propc.ORDER_NONE);
- var background_color = Blockly.propc.valueToCode(this, 'BACKGROUND_COLOR', Blockly.propc.ORDER_NONE);
-
- var code = 'oledc_setTextColor(';
- code += 'oledc_color565(get8bitColor(' + font_color + ', "RED"), get8bitColor(' + font_color + ', "GREEN"), get8bitColor(' + font_color + ', "BLUE")), ';
- code += 'oledc_color565(get8bitColor(' + background_color + ', "RED"), get8bitColor(' + background_color + ', "GREEN"), get8bitColor(' + background_color + ', "BLUE")));';
-
- return code;
-};
-
-Blockly.propc.oled_get_max_height = function() {
- // Ensure header file is included
- Blockly.propc.definitions_["oledtools"] = '#include "oledc.h"';
-
- // Emit code to clear the screen
- var code = 'oledc_getHeight()';
-
- // Return function call with surrounding parens:
- // oledc_drawPixel(..., (oledc_getWidth()), ...);
- return [code, Blockly.propc.ORDER_NONE];
-};
-
-
-Blockly.propc.oled_get_max_width = function() {
- // Ensure header file is included
- Blockly.propc.definitions_["oledtools"] = '#include "oledc.h"';
-
- // Emit code to clear the screen
- var code = 'oledc_getWidth()';
- return [code, Blockly.propc.ORDER_NONE];
-};
-
-Blockly.propc.oled_set_cursor = function() {
- // Ensure header file is included
- Blockly.propc.definitions_["oledtools"] = '#include "oledc.h"';
-
- // Get user input
- var x = Blockly.propc.valueToCode(this, 'X_POS', Blockly.propc.ORDER_NONE);
- var y = Blockly.propc.valueToCode(this, 'Y_POS', Blockly.propc.ORDER_NONE);
-
- // Do range checks
- if (x < 0) { x = 0; }
- if (x > 95) { x = 95; }
- if (y < 0) { y = 0; }
- if (y > 63) { y = 63; }
-
- var code = 'oledc_setCursor(' + x + ', ' + y + ',0);';
- return code;
-// return [code, Blockly.propc.ORDER_NONE];
-};
-
-Blockly.propc.oled_print_text = function() {
- // Ensure header file is included
- Blockly.propc.definitions_["oledtools"] = '#include "oledc.h"';
-
- var msg = Blockly.propc.valueToCode(this, 'MESSAGE', Blockly.propc.ORDER_NONE);
- var code = 'oledc_drawText(' + msg + ');';
- return code;
-};
-
-Blockly.propc.oled_print_number = function() {
- // Ensure header file is included
- Blockly.propc.definitions_["oledtools"] = '#include "oledc.h"';
-
- var num = Blockly.propc.valueToCode(this, 'NUMIN', Blockly.propc.ORDER_NONE);
- var type = this.getFieldValue('type');
- var code = 'oledc_drawNumber(' + num + ', ' + type + ');';
- return code;
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/pointers.js b/src/main/webapp/cdn/blockly/generators/propc/pointers.js
deleted file mode 100644
index 97c00c0a..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/pointers.js
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2012 Google Inc.
- * http://blockly.googlecode.com/
- *
- * 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.
- */
-
-/**
- * @fileoverview Generating Prop-C for control blocks.
- * @author michel@creatingfuture.eu (Michel Lampo)
- */
-'use strict';
-
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-Blockly.Blocks.pointers_get = {
- // Variable getter.
- init: function() {
- this.setColour(330);
- this.appendDummyInput("")
- .appendField(Blockly.LANG_VARIABLES_GET_TITLE)
- .appendField(new Blockly.FieldPointer(
- Blockly.LANG_VARIABLES_GET_ITEM), 'VAR');
- this.setOutput(true, null);
- // this.setTooltip(Blockly.LANG_VARIABLES_GET_TOOLTIP_1);
- },
- getPointers: function() {
- return [this.getFieldValue('VAR')];
- },
- renameVar: function(oldName, newName) {
- if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
- this.setTitleValue(newName, 'VAR');
- }
- }
-};
-
-Blockly.Blocks.pointers_declare = {
- // Variable setter.
- init: function() {
- this.setColour(330);
- this.appendValueInput('VALUE', null)
- .appendField('Declare')
- .appendField(new Blockly.FieldPointer(
- Blockly.LANG_VARIABLES_SET_ITEM), 'VAR')
- .appendField("as")
- .appendField(new Blockly.FieldDropdown([["file", "FILE*"]]), "TYPE")
- .appendField("value");
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- },
- getPointers: function() {
- return [this.getFieldValue('VAR')];
- },
- renameVar: function(oldName, newName) {
- if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
- this.setTitleValue(newName, 'VAR');
- }
- }
-};
-
-Blockly.Blocks.pointers_set = {
- // Variable setter.
- init: function() {
- this.setColour(330);
- this.appendValueInput('VALUE')
- .appendField(Blockly.LANG_VARIABLES_SET_TITLE)
- .appendField(new Blockly.FieldPointer(
- Blockly.LANG_VARIABLES_SET_ITEM), 'VAR').appendField('=');
- this.setPreviousStatement(true);
- this.setNextStatement(true);
- },
- getPointers: function() {
- return [this.getFieldValue('VAR')];
- },
- renameVar: function(oldName, newName) {
- if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
- this.setTitleValue(newName, 'VAR');
- }
- }
-};
-
-
-/**
- * @fileoverview Generating propc for control blocks.
- * @author michel@creatingfuture.eu (Michel Lampo)
- */
-
-Blockly.propc.pointers_get = function() {
- // Variable getter.
- var code = Blockly.propc.pointerDB_.getName(this.getFieldValue('VAR'),
- Blockly.Pointers.NAME_TYPE);
- return [code, Blockly.propc.ORDER_ATOMIC];
-};
-
-Blockly.propc.pointers_declare = function() {
- // Variable setter.
- var dropdown_type = this.getFieldValue('TYPE');
- //TODO: settype to variable
- var argument0 = Blockly.propc.valueToCode(this, 'VALUE',
- Blockly.propc.ORDER_ASSIGNMENT) || '0';
- var varName = Blockly.propc.pointerDB_.getName(this.getFieldValue('VAR'),
- Blockly.Pointers.NAME_TYPE);
- Blockly.propc.setups_['setup_var' + varName] = varName + ' = ' + argument0 + ';\n';
- Blockly.propc.pointerType_[varName] = dropdown_type;
- return '';
-};
-
-Blockly.propc.pointers_set = function() {
- // Variable setter.
- var argument0 = Blockly.propc.valueToCode(this, 'VALUE',
- Blockly.propc.ORDER_ASSIGNMENT) || '0';
- var varName = Blockly.propc.pointerDB_.getName(this.getFieldValue('VAR'),
- Blockly.Pointers.NAME_TYPE);
- if (Blockly.propc.pointerType_[varName] === undefined) {
- Blockly.propc.pointerType_[varName] = 'int';
- }
- return varName + ' = ' + argument0 + ';\n';
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/pressure.js b/src/main/webapp/cdn/blockly/generators/propc/pressure.js
deleted file mode 100644
index d9664b0d..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/pressure.js
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- This file contains support for pressure sensors
-
- Author: Vale Tolpegin ( valetolpegin@gmail.com )
-
- *Copyright 2014 Vale Tolpegin.
- *
- *
- * 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.
-
- */
-'use strict';
-
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-//Creating GUI blocks for eTape liquid sensor
-Blockly.Blocks.etape_rc_time = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("ETape sensor rc_time input")
- .appendField("pin")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
- this.appendDummyInput()
- .appendField("put input value in")
- .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VAR');
-
- this.setNextStatement(true, null);
- this.setPreviousStatement(true, null);
- },
- getVars: function () {
- return [this.getFieldValue('VAR')];
- },
- renameVar: function (oldName, newName) {
- if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
- this.setTitleValue(newName, 'VAR');
- }
- }
-};
-
-Blockly.Blocks.etape_voltage_input = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("ETape sensor voltage input")
- .appendField("pin")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
-
- this.setNextStatement(false, null);
- this.setPreviousStatement(false, null);
- this.setOutput(true, 'Number');
- }
-};
-
-Blockly.propc.etape_rc_time = function() {
- var pin = this.getFieldValue('PIN');
- var inputStorage = Blockly.propc.variableDB_.getName(this.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE);
-
- var code = 'high(' + pin + ');\npause(1);\n' + inputStorage + ' = ' + 'rc_time(' + pin + ', 1);\n';
- return [code, Blockly.propc.ORDER_ATOMIC];
-};
-
-Blockly.propc.etape_voltage_input = function() {
- var pin = this.getFieldValue('PIN');
-
- Blockly.propc.setups_["include abvolt"] = 'ad_init(21, 20, 19, 18);\n';
-
- var code = 'ad_volts(' + pin + ')';
- return [code, Blockly.propc.ORDER_ATOMIC];
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/procedures.js b/src/main/webapp/cdn/blockly/generators/propc/procedures.js
index a10dd24b..b3f8e36e 100644
--- a/src/main/webapp/cdn/blockly/generators/propc/procedures.js
+++ b/src/main/webapp/cdn/blockly/generators/propc/procedures.js
@@ -23,6 +23,644 @@
*/
'use strict';
+Blockly.Blocks['procedures_defnoreturn'] = {
+ /**
+ * Block for defining a procedure with no return value.
+ * @this Blockly.Block
+ */
+ init: function() {
+ if(profile.default.description === "Scribbler Robot") {
+ this.setHelpUrl(Blockly.MSG_S3_FUNCTIONS_HELPURL);
+ } else {
+ this.setHelpUrl(Blockly.MSG_FUNCTIONS_HELPURL);
+ }
+ this.setTooltip(Blockly.MSG_PROCEDURES_DEFNORETURN_TOOLTIP);
+ var nameField = new Blockly.FieldTextInput(
+ Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE,
+ Blockly.Procedures.rename);
+ nameField.setSpellcheck(false);
+ this.appendDummyInput()
+ .appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_TITLE)
+ .appendField(nameField, 'NAME')
+ .appendField('', 'PARAMS');
+ this.setColour(colorPalette.getColor('functions'));
+ //this.setTooltip(Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP);
+ //this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL);
+ this.arguments_ = [];
+ this.setStatements_(true);
+ this.statementConnection_ = null;
+ },
+ /**
+ * Initialization of the block has completed, clean up anything that may be
+ * inconsistent as a result of the XML loading.
+ * @this Blockly.Block
+ */
+ validate: function () {
+ var name = Blockly.Procedures.findLegalName(
+ this.getFieldValue('NAME'), this);
+ this.setFieldValue(name, 'NAME');
+ },
+ /**
+ * Add or remove the statement block from this function definition.
+ * @param {boolean} hasStatements True if a statement block is needed.
+ * @this Blockly.Block
+ */
+ setStatements_: function (hasStatements) {
+ if (this.hasStatements_ === hasStatements) {
+ return;
+ }
+ if (hasStatements) {
+ this.appendStatementInput('STACK')
+ .appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_DO);
+ if (this.getInput('RETURN')) {
+ this.moveInputBefore('STACK', 'RETURN');
+ }
+ } else {
+ this.removeInput('STACK', true);
+ }
+ this.hasStatements_ = hasStatements;
+ },
+ /**
+ * Update the display of parameters for this procedure definition block.
+ * Display a warning if there are duplicately named parameters.
+ * @private
+ * @this Blockly.Block
+ */
+ updateParams_: function () {
+ // Check for duplicated arguments.
+ var badArg = false;
+ var hash = {};
+ for (var i = 0; i < this.arguments_.length; i++) {
+ if (hash['arg_' + this.arguments_[i].toLowerCase()]) {
+ badArg = true;
+ break;
+ }
+ hash['arg_' + this.arguments_[i].toLowerCase()] = true;
+ }
+ if (badArg) {
+ this.setWarningText(Blockly.Msg.PROCEDURES_DEF_DUPLICATE_WARNING);
+ } else {
+ this.setWarningText(null);
+ }
+ // Merge the arguments into a human-readable list.
+ var paramString = '';
+ if (this.arguments_.length) {
+ paramString = Blockly.Msg.PROCEDURES_BEFORE_PARAMS +
+ ' ' + this.arguments_.join(', ');
+ }
+ // The params field is deterministic based on the mutation,
+ // no need to fire a change event.
+ Blockly.Events.disable();
+ this.setFieldValue(paramString, 'PARAMS');
+ Blockly.Events.enable();
+ },
+ /**
+ * Create XML to represent the argument inputs.
+ * @param {=boolean} opt_paramIds If true include the IDs of the parameter
+ * quarks. Used by Blockly.Procedures.mutateCallers for reconnection.
+ * @return {!Element} XML storage element.
+ * @this Blockly.Block
+ */
+ mutationToDom: function (opt_paramIds) {
+ var container = document.createElement('mutation');
+ if (opt_paramIds) {
+ container.setAttribute('name', this.getFieldValue('NAME'));
+ }
+ for (var i = 0; i < this.arguments_.length; i++) {
+ var parameter = document.createElement('arg');
+ parameter.setAttribute('name', this.arguments_[i]);
+ if (opt_paramIds && this.paramIds_) {
+ parameter.setAttribute('paramId', this.paramIds_[i]);
+ }
+ container.appendChild(parameter);
+ }
+
+ // Save whether the statement input is visible.
+ if (!this.hasStatements_) {
+ container.setAttribute('statements', 'false');
+ }
+ return container;
+ },
+ /**
+ * Parse XML to restore the argument inputs.
+ * @param {!Element} xmlElement XML storage element.
+ * @this Blockly.Block
+ */
+ domToMutation: function (xmlElement) {
+ this.arguments_ = [];
+ for (var i = 0, childNode; childNode = xmlElement.childNodes[i]; i++) {
+ if (childNode.nodeName.toLowerCase() === 'arg') {
+ this.arguments_.push(childNode.getAttribute('name'));
+ }
+ }
+ this.updateParams_();
+ Blockly.Procedures.mutateCallers(this);
+
+ // Show or hide the statement input.
+ this.setStatements_(xmlElement.getAttribute('statements') !== 'false');
+ },
+ /**
+ * Populate the mutator's dialog with this block's components.
+ * @param {!Blockly.Workspace} workspace Mutator's workspace.
+ * @return {!Blockly.Block} Root block in mutator.
+ * @this Blockly.Block
+ */
+ decompose: function (workspace) {
+ var containerBlock = workspace.newBlock('procedures_mutatorcontainer');
+ containerBlock.initSvg();
+
+ // Check/uncheck the allow statement box.
+ if (this.getInput('RETURN')) {
+ containerBlock.setFieldValue(this.hasStatements_ ? 'TRUE' : 'FALSE',
+ 'STATEMENTS');
+ } else {
+ containerBlock.getInput('STATEMENT_INPUT').setVisible(false);
+ }
+
+ // Parameter list.
+ var connection = containerBlock.getInput('STACK').connection;
+ for (var i = 0; i < this.arguments_.length; i++) {
+ var paramBlock = workspace.newBlock('procedures_mutatorarg');
+ paramBlock.initSvg();
+ paramBlock.setFieldValue(this.arguments_[i], 'NAME');
+ // Store the old location.
+ paramBlock.oldLocation = i;
+ connection.connect(paramBlock.previousConnection);
+ connection = paramBlock.nextConnection;
+ }
+ // Initialize procedure's callers with blank IDs.
+ Blockly.Procedures.mutateCallers(this);
+ return containerBlock;
+ },
+ /**
+ * Reconfigure this block based on the mutator dialog's components.
+ * @param {!Blockly.Block} containerBlock Root block in mutator.
+ * @this Blockly.Block
+ */
+ compose: function (containerBlock) {
+ // Parameter list.
+ this.arguments_ = [];
+ this.paramIds_ = [];
+ var paramBlock = containerBlock.getInputTargetBlock('STACK');
+ while (paramBlock) {
+ this.arguments_.push(paramBlock.getFieldValue('NAME'));
+ this.paramIds_.push(paramBlock.id);
+ paramBlock = paramBlock.nextConnection &&
+ paramBlock.nextConnection.targetBlock();
+ }
+ this.updateParams_();
+ Blockly.Procedures.mutateCallers(this);
+
+ // Show/hide the statement input.
+ var hasStatements = containerBlock.getFieldValue('STATEMENTS');
+ if (hasStatements !== null) {
+ hasStatements = hasStatements === 'TRUE';
+ if (this.hasStatements_ !== hasStatements) {
+ if (hasStatements) {
+ this.setStatements_(true);
+ // Restore the stack, if one was saved.
+ Blockly.Mutator.reconnect(this.statementConnection_, this, 'STACK');
+ this.statementConnection_ = null;
+ } else {
+ // Save the stack, then disconnect it.
+ var stackConnection = this.getInput('STACK').connection;
+ this.statementConnection_ = stackConnection.targetConnection;
+ if (this.statementConnection_) {
+ var stackBlock = stackConnection.targetBlock();
+ stackBlock.unplug();
+ stackBlock.bumpNeighbours_();
+ }
+ this.setStatements_(false);
+ }
+ }
+ }
+ },
+ /**
+ * Dispose of any callers.
+ * @this Blockly.Block
+ */
+ dispose: function () {
+ var name = this.getFieldValue('NAME');
+ Blockly.Procedures.disposeCallers(name, this.workspace);
+ // Call parent's destructor.
+ this.constructor.prototype.dispose.apply(this, arguments);
+ },
+ /**
+ * Return the signature of this procedure definition.
+ * @return {!Array} Tuple containing three elements:
+ * - the name of the defined procedure,
+ * - a list of all its arguments,
+ * - that it DOES NOT have a return value.
+ * @this Blockly.Block
+ */
+ getProcedureDef: function () {
+ return [this.getFieldValue('NAME'), this.arguments_, false];
+ },
+ /**
+ * Return all variables referenced by this block.
+ * @return {!Array.
} List of variable names.
+ * @this Blockly.Block
+ */
+ getVars: function () {
+ return this.arguments_;
+ },
+ /**
+ * Notification that a variable is renaming.
+ * If the name matches one of this block's variables, rename it.
+ * @param {string} oldName Previous name of variable.
+ * @param {string} newName Renamed variable.
+ * @this Blockly.Block
+ */
+ renameVar: function (oldName, newName) {
+ var change = false;
+ for (var i = 0; i < this.arguments_.length; i++) {
+ if (Blockly.Names.equals(oldName, this.arguments_[i])) {
+ this.arguments_[i] = newName;
+ change = true;
+ }
+ }
+ if (change) {
+ this.updateParams_();
+ // Update the mutator's variables if the mutator is open.
+ if (this.mutator.isVisible()) {
+ var blocks = this.mutator.workspace_.getAllBlocks();
+ for (var i = 0, block; block = blocks[i]; i++) {
+ if (block.type == 'procedures_mutatorarg' &&
+ Blockly.Names.equals(oldName, block.getFieldValue('NAME'))) {
+ block.setFieldValue(newName, 'NAME');
+ }
+ }
+ }
+ }
+ },
+ /**
+ * Add custom menu options to this block's context menu.
+ * @param {!Array} options List of menu options to add to.
+ * @this Blockly.Block
+ */
+ customContextMenu: function (options) {
+ // Add option to create caller.
+ var option = {enabled: true};
+ var name = this.getFieldValue('NAME');
+ option.text = Blockly.Msg.PROCEDURES_CREATE_DO.replace('%1', name);
+ var xmlMutation = goog.dom.createDom('mutation');
+ xmlMutation.setAttribute('name', name);
+ for (var i = 0; i < this.arguments_.length; i++) {
+ var xmlArg = goog.dom.createDom('arg');
+ xmlArg.setAttribute('name', this.arguments_[i]);
+ xmlMutation.appendChild(xmlArg);
+ }
+ var xmlBlock = goog.dom.createDom('block', null, xmlMutation);
+ xmlBlock.setAttribute('type', this.callType_);
+ option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);
+ options.push(option);
+
+ // Add options to create getters for each parameter.
+ if (!this.isCollapsed()) {
+ for (var i = 0; i < this.arguments_.length; i++) {
+ var option = {enabled: true};
+ var name = this.arguments_[i];
+ option.text = Blockly.Msg.VARIABLES_SET_CREATE_GET.replace('%1', name);
+ var xmlField = goog.dom.createDom('field', null, name);
+ xmlField.setAttribute('name', 'VAR');
+ var xmlBlock = goog.dom.createDom('block', null, xmlField);
+ xmlBlock.setAttribute('type', 'variables_get');
+ option.callback = Blockly.ContextMenu.callbackFactory(this, xmlBlock);
+ options.push(option);
+ }
+ }
+ },
+ callType_: 'procedures_callnoreturn'
+};
+
+
+Blockly.Blocks['procedures_mutatorcontainer'] = {
+ /**
+ * Mutator block for procedure container.
+ * @this Blockly.Block
+ */
+ init: function () {
+ this.appendDummyInput()
+ .appendField(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE);
+ this.appendStatementInput('STACK');
+ this.appendDummyInput('STATEMENT_INPUT')
+ .appendField(Blockly.Msg.PROCEDURES_ALLOW_STATEMENTS)
+ .appendField(new Blockly.FieldCheckbox('TRUE'), 'STATEMENTS');
+ this.setColour(colorPalette.getColor('functions'));
+ this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP);
+ this.contextMenu = false;
+ }
+};
+
+Blockly.Blocks['procedures_mutatorarg'] = {
+ /**
+ * Mutator block for procedure argument.
+ * @this Blockly.Block
+ */
+ init: function () {
+ this.appendDummyInput()
+ .appendField(Blockly.Msg.PROCEDURES_MUTATORARG_TITLE)
+ .appendField(new Blockly.FieldTextInput('x', this.validator_), 'NAME');
+ this.setPreviousStatement(true);
+ this.setNextStatement(true);
+ this.setColour(colorPalette.getColor('functions'));
+ this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP);
+ this.contextMenu = false;
+ },
+ /**
+ * Obtain a valid name for the procedure.
+ * Merge runs of whitespace. Strip leading and trailing whitespace.
+ * Beyond this, all names are legal.
+ * @param {string} newVar User-supplied name.
+ * @return {?string} Valid name, or null if a name was not specified.
+ * @private
+ * @this Blockly.Block
+ */
+ validator_: function (newVar) {
+ newVar = newVar.replace(/[\s\xa0]+/g, ' ').replace(/^ | $/g, '');
+ return newVar || null;
+ }
+};
+
+Blockly.Blocks['procedures_callnoreturn'] = {
+ /**
+ * Block for calling a procedure with no return value.
+ * @this Blockly.Block
+ */
+ init: function() {
+ if(profile.default.description === "Scribbler Robot") {
+ this.setHelpUrl(Blockly.MSG_S3_FUNCTIONS_HELPURL);
+ } else {
+ this.setHelpUrl(Blockly.MSG_FUNCTIONS_HELPURL);
+ }
+ this.setTooltip(Blockly.MSG_PROCEDURES_CALLNORETURN_TOOLTIP);
+ this.appendDummyInput('TOPROW')
+ .appendField("run function ")
+ .appendField(quotes.newQuote_(this.RTL))
+ .appendField(this.id, 'NAME')
+ .appendField(quotes.newQuote_(this.LTR));
+ this.setPreviousStatement(true);
+ this.setNextStatement(true);
+ this.setColour(colorPalette.getColor('functions'));
+ // Tooltip is set in renameProcedure.
+ //this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL);
+ this.arguments_ = [];
+ this.quarkConnections_ = {};
+ this.quarkIds_ = null;
+ },
+ /**
+ * Returns the name of the procedure this block calls.
+ * @return {string} Procedure name.
+ * @this Blockly.Block
+ */
+ getProcedureCall: function () {
+ // The NAME field is guaranteed to exist, null will never be returned.
+ return /** @type {string} */ (this.getFieldValue('NAME'));
+ },
+ /**
+ * Notification that a procedure is renaming.
+ * If the name matches this block's procedure, rename it.
+ * @param {string} oldName Previous name of procedure.
+ * @param {string} newName Renamed procedure.
+ * @this Blockly.Block
+ */
+ renameProcedure: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getProcedureCall())) {
+ this.setFieldValue(newName, 'NAME');
+ //this.setTooltip(
+ // (this.outputConnection ? Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP :
+ // Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP)
+ // .replace('%1', newName));
+ }
+ },
+ /**
+ * Notification that the procedure's parameters have changed.
+ * @param {!Array.} paramNames New param names, e.g. ['x', 'y', 'z'].
+ * @param {!Array.} paramIds IDs of params (consistent for each
+ * parameter through the life of a mutator, regardless of param renaming),
+ * e.g. ['piua', 'f8b_', 'oi.o'].
+ * @private
+ * @this Blockly.Block
+ */
+ setProcedureParameters_: function (paramNames, paramIds) {
+ // Data structures:
+ // this.arguments = ['x', 'y']
+ // Existing param names.
+ // this.quarkConnections_ {piua: null, f8b_: Blockly.Connection}
+ // Look-up of paramIds to connections plugged into the call block.
+ // this.quarkIds_ = ['piua', 'f8b_']
+ // Existing param IDs.
+ // Note that quarkConnections_ may include IDs that no longer exist, but
+ // which might reappear if a param is reattached in the mutator.
+ var defBlock = Blockly.Procedures.getDefinition(this.getProcedureCall(),
+ this.workspace);
+ var mutatorOpen = defBlock && defBlock.mutator &&
+ defBlock.mutator.isVisible();
+ if (!mutatorOpen) {
+ this.quarkConnections_ = {};
+ this.quarkIds_ = null;
+ }
+ if (!paramIds) {
+ // Reset the quarks (a mutator is about to open).
+ return;
+ }
+ if (goog.array.equals(this.arguments_, paramNames)) {
+ // No change.
+ this.quarkIds_ = paramIds;
+ return;
+ }
+ if (paramIds.length != paramNames.length) {
+ throw 'Error: paramNames and paramIds must be the same length.';
+ }
+ this.setCollapsed(false);
+ if (!this.quarkIds_) {
+ // Initialize tracking for this block.
+ this.quarkConnections_ = {};
+ if (paramNames.join('\n') == this.arguments_.join('\n')) {
+ // No change to the parameters, allow quarkConnections_ to be
+ // populated with the existing connections.
+ this.quarkIds_ = paramIds;
+ } else {
+ this.quarkIds_ = [];
+ }
+ }
+ // Switch off rendering while the block is rebuilt.
+ var savedRendered = this.rendered;
+ this.rendered = false;
+ // Update the quarkConnections_ with existing connections.
+ for (var i = 0; i < this.arguments_.length; i++) {
+ var input = this.getInput('ARG' + i);
+ if (input) {
+ var connection = input.connection.targetConnection;
+ this.quarkConnections_[this.quarkIds_[i]] = connection;
+ if (mutatorOpen && connection &&
+ paramIds.indexOf(this.quarkIds_[i]) === -1) {
+ // This connection should no longer be attached to this block.
+ connection.disconnect();
+ connection.getSourceBlock().bumpNeighbours_();
+ }
+ }
+ }
+ // Rebuild the block's arguments.
+ this.arguments_ = [].concat(paramNames);
+ this.updateShape_();
+ this.quarkIds_ = paramIds;
+ // Reconnect any child blocks.
+ if (this.quarkIds_) {
+ for (var i = 0; i < this.arguments_.length; i++) {
+ var quarkId = this.quarkIds_[i];
+ if (quarkId in this.quarkConnections_) {
+ var connection = this.quarkConnections_[quarkId];
+ if (!Blockly.Mutator.reconnect(connection, this, 'ARG' + i)) {
+ // Block no longer exists or has been attached elsewhere.
+ delete this.quarkConnections_[quarkId];
+ }
+ }
+ }
+ }
+ // Restore rendering and show the changes.
+ this.rendered = savedRendered;
+ if (this.rendered) {
+ this.render();
+ }
+ },
+ /**
+ * Modify this block to have the correct number of arguments.
+ * @private
+ * @this Blockly.Block
+ */
+ updateShape_: function () {
+ for (var i = 0; i < this.arguments_.length; i++) {
+ var field = this.getField('ARGNAME' + i);
+ if (field) {
+ // Ensure argument name is up to date.
+ // The argument name field is deterministic based on the mutation,
+ // no need to fire a change event.
+ Blockly.Events.disable();
+ field.setValue(this.arguments_[i]);
+ Blockly.Events.enable();
+ } else {
+ // Add new input.
+ field = new Blockly.FieldLabel(this.arguments_[i]);
+ var input = this.appendValueInput('ARG' + i)
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField(field, 'ARGNAME' + i);
+ input.init();
+ }
+ }
+ // Remove deleted inputs.
+ while (this.getInput('ARG' + i)) {
+ this.removeInput('ARG' + i);
+ i++;
+ }
+ // Add 'with:' if there are parameters, remove otherwise.
+ var topRow = this.getInput('TOPROW');
+ if (topRow) {
+ if (this.arguments_.length) {
+ if (!this.getField('WITH')) {
+ topRow.appendField(Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS, 'WITH');
+ topRow.init();
+ }
+ } else {
+ if (this.getField('WITH')) {
+ topRow.removeField('WITH');
+ }
+ }
+ }
+ },
+ /**
+ * Create XML to represent the (non-editable) name and arguments.
+ * @return {!Element} XML storage element.
+ * @this Blockly.Block
+ */
+ mutationToDom: function () {
+ var container = document.createElement('mutation');
+ container.setAttribute('name', this.getProcedureCall());
+ for (var i = 0; i < this.arguments_.length; i++) {
+ var parameter = document.createElement('arg');
+ parameter.setAttribute('name', this.arguments_[i]);
+ container.appendChild(parameter);
+ }
+ return container;
+ },
+ /**
+ * Parse XML to restore the (non-editable) name and parameters.
+ * @param {!Element} xmlElement XML storage element.
+ * @this Blockly.Block
+ */
+ domToMutation: function (xmlElement) {
+ var name = xmlElement.getAttribute('name');
+ this.renameProcedure(this.getProcedureCall(), name);
+ var args = [];
+ var paramIds = [];
+ for (var i = 0, childNode; childNode = xmlElement.childNodes[i]; i++) {
+ if (childNode.nodeName.toLowerCase() === 'arg') {
+ args.push(childNode.getAttribute('name'));
+ paramIds.push(childNode.getAttribute('paramId'));
+ }
+ }
+ this.setProcedureParameters_(args, paramIds);
+ },
+ /**
+ * Notification that a variable is renaming.
+ * If the name matches one of this block's variables, rename it.
+ * @param {string} oldName Previous name of variable.
+ * @param {string} newName Renamed variable.
+ * @this Blockly.Block
+ */
+ renameVar: function (oldName, newName) {
+ for (var i = 0; i < this.arguments_.length; i++) {
+ if (Blockly.Names.equals(oldName, this.arguments_[i])) {
+ this.arguments_[i] = newName;
+ this.getField('ARGNAME' + i).setValue(newName);
+ }
+ }
+ },
+ /**
+ * Add menu option to find the definition block for this call.
+ * @param {!Array} options List of menu options to add to.
+ * @this Blockly.Block
+ */
+ customContextMenu: function (options) {
+ var option = {enabled: true};
+ option.text = Blockly.Msg.PROCEDURES_HIGHLIGHT_DEF;
+ var name = this.getProcedureCall();
+ var workspace = this.workspace;
+ option.callback = function () {
+ var def = Blockly.Procedures.getDefinition(name, workspace);
+ def && def.select();
+ };
+ options.push(option);
+ }
+};
+
+Blockly.Blocks['procedures_callreturn'] = {
+ /**
+ * Block for calling a procedure with a return value.
+ * @this Blockly.Block
+ */
+ init: function () {
+ this.appendDummyInput('TOPROW')
+ .appendField('', 'NAME');
+ this.setOutput(true);
+ this.setColour(colorPalette.getColor('functions'));
+ // Tooltip is set in domToMutation.
+ this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL);
+ this.arguments_ = [];
+ this.quarkConnections_ = {};
+ this.quarkIds_ = null;
+ },
+ getProcedureCall: Blockly.Blocks['procedures_callnoreturn'].getProcedureCall,
+ renameProcedure: Blockly.Blocks['procedures_callnoreturn'].renameProcedure,
+ setProcedureParameters_:
+ Blockly.Blocks['procedures_callnoreturn'].setProcedureParameters_,
+ updateShape_: Blockly.Blocks['procedures_callnoreturn'].updateShape_,
+ mutationToDom: Blockly.Blocks['procedures_callnoreturn'].mutationToDom,
+ domToMutation: Blockly.Blocks['procedures_callnoreturn'].domToMutation,
+ renameVar: Blockly.Blocks['procedures_callnoreturn'].renameVar,
+ customContextMenu: Blockly.Blocks['procedures_callnoreturn'].customContextMenu
+};
+
Blockly.propc.procedures_defreturn = function() {
// Define a procedure with a return value.
var funcName = Blockly.propc.variableDB_.getName(this.getFieldValue('NAME'),
diff --git a/src/main/webapp/cdn/blockly/generators/propc/rfid.js b/src/main/webapp/cdn/blockly/generators/propc/rfid.js
deleted file mode 100644
index 68ac5cde..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/rfid.js
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
-
-This file contains support for the Tilt and Acceleration sensors
-
-Author: valetolpegin@gmail.com
-
- *Copyright 2014 Vale Tolpegin.
- *
- *
- * 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.
-
-*/
-'use strict';
-
-if ( !Blockly.Blocks )
- Blockly.Blocks = {};
-
-
-Blockly.Blocks.rfid_get = {
- helpUrl: Blockly.MSG_RFID_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_RFID_GET_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("RFID store reading in")
- .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'BUFFER');
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- },
- getVars: function () {
- return [this.getFieldValue('BUFFER')];
- },
- renameVar: function (oldName, newName) {
- if (Blockly.Names.equals(oldName, this.getFieldValue('BUFFER'))) {
- this.setTitleValue(newName, 'BUFFER');
- }
- }
-};
-
-Blockly.Blocks.rfid_disable = {
- helpUrl: Blockly.MSG_RFID_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_RFID_DISABLE_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("RFID")
- .appendField(new Blockly.FieldDropdown([
- ["disable", "DISABLE"],
- ["enable", "ENABLE"]
- ]), "ACTION");
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.rfid_enable = {
- helpUrl: Blockly.MSG_RFID_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_RFID_ENABLE_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("RFID initialize EN")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN_IN");
- this.appendDummyInput()
- .appendField("SOUT")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN_OUT");
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.rfid_close = {
- helpUrl: Blockly.MSG_RFID_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_RFID_CLOSE_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("RFID close");
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.propc.rfid_get = function() {
- var saveVariable = Blockly.propc.variableDB_.getName(this.getFieldValue('BUFFER'), Blockly.Variables.NAME_TYPE);
-
- Blockly.propc.global_vars_["rfid_buffer"] = "char *rfidBfr;";
- Blockly.propc.definitions_["rfidser"] = '#include "rfidser.h"';
-
- var code = 'rfidBfr = rfid_get(rfid, 500);\n\tsscan(&rfidBfr[2], "%x", &' + saveVariable + ');\n\tif(' + saveVariable + ' == 237) ' + saveVariable + ' = 0;';
- return code;
-};
-
-Blockly.propc.rfid_disable = function() {
- var data = this.getFieldValue('ACTION');
- Blockly.propc.definitions_["rfidser"] = '#include "rfidser.h"';
-
- if(data === "ENABLE") {
- return 'rfid_enable(rfid);\n';
- } else {
- return 'rfid_disable(rfid);\n';
- }
-};
-
-Blockly.propc.rfid_enable = function() {
- var pin_in = this.getFieldValue('PIN_IN');
- var pin_out = this.getFieldValue('PIN_OUT');
-
- Blockly.propc.definitions_["rfidser"] = '#include "rfidser.h"';
- Blockly.propc.global_vars_["rfidser"] = 'rfidser *rfid;';
- Blockly.propc.setups_["rfidser_setup"] = 'rfid = rfid_open(' + pin_out + ',' + pin_in + ');';
-
- return '';
-};
-
-Blockly.propc.rfid_close = function() {
- Blockly.propc.definitions_["rfidser"] = '#include "rfidser.h"';
-
- return 'rfidser_close(rfid);\n';
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/s3.js b/src/main/webapp/cdn/blockly/generators/propc/s3.js
new file mode 100644
index 00000000..bdedcdd6
--- /dev/null
+++ b/src/main/webapp/cdn/blockly/generators/propc/s3.js
@@ -0,0 +1,1215 @@
+/**
+ *
+ */
+
+/**
+ * @fileoverview
+ * @author
+ */
+'use strict';
+
+Blockly.Blocks.scribbler_loop = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("loop");
+ this.appendStatementInput("LOOP");
+
+ this.setPreviousStatement(true);
+ this.setNextStatement(true);
+ this.setInputsInline(true);
+ this.setColour(colorPalette.getColor('programming'));
+ this.setHelpUrl(Blockly.MSG_S3_SIMPLE_CONTROL_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_LOOP_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_loop = function() {
+ var branch = Blockly.propc.statementToCode(this, 'LOOP');
+ if (Blockly.propc.INFINITE_LOOP_TRAP) {
+ branch = Blockly.propc.INFINITE_LOOP_TRAP.replace(/%1/g,
+ '\'' + this.id + '\'') + branch;
+ }
+ return 'while(1) {\n' + branch + '}\n';
+};
+
+Blockly.Blocks.scribbler_limited_loop = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("loop")
+ .appendField(new Blockly.FieldTextInput('10', Blockly.FieldTextInput.numberValidator), 'LOOP_COUNT')
+ .appendField("times");
+ this.appendStatementInput("LOOP");
+
+ this.setPreviousStatement(true);
+ this.setNextStatement(true);
+ this.setInputsInline(true);
+ this.setColour(colorPalette.getColor('programming'));
+ this.setHelpUrl(Blockly.MSG_S3_SIMPLE_CONTROL_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_LIMITED_LOOP_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_limited_loop = function() {
+ var branch = Blockly.propc.statementToCode(this, 'LOOP');
+ if (Blockly.propc.INFINITE_LOOP_TRAP) {
+ branch = Blockly.propc.INFINITE_LOOP_TRAP.replace(/%1/g,
+ '\'' + this.id + '\'') + branch;
+ }
+ var repeats = this.getFieldValue('LOOP_COUNT') || '0';
+ return 'for (int __n = 0; __n < ' + repeats + '; __n++) {\n' + branch + '}\n';
+};
+
+Blockly.Blocks.scribbler_exit_loop = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("exit loop");
+ this.setPreviousStatement(true, null);
+ this.setColour(colorPalette.getColor('programming'));
+ this.setHelpUrl(Blockly.MSG_S3_SIMPLE_CONTROL_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_EXIT_LOOP_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_exit_loop = function() {
+ return 'break;\n';
+};
+
+Blockly.Blocks.scribbler_simple_wait = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("wait")
+ .appendField(new Blockly.FieldTextInput('5', Blockly.FieldTextInput.numberValidator), 'WAITTIME')
+ .appendField(new Blockly.FieldDropdown([['second(s) (1 to 53)', '1000'], ['tenth(s) of a second (1 to 535)', '100'], ['millisecond(s) (1 to 53,500)', '1']]), 'TIMESCALE');
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('programming'));
+ this.setHelpUrl(Blockly.MSG_S3_SIMPLE_CONTROL_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_SIMPLE_WAIT_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_simple_wait = function() {
+ var wait_time = this.getFieldValue('WAITTIME') || '1';
+ var time_scale = this.getFieldValue('TIMESCALE');
+ return 'pause(' + wait_time + ' * ' + time_scale + ');\n';
+};
+
+Blockly.Blocks.scribbler_wait = {
+ init: function () {
+ this.appendValueInput("WAITTIME", 'Number')
+ .appendField("wait")
+ .setCheck('Number');
+ this.appendDummyInput()
+ .appendField(new Blockly.FieldDropdown([['second(s) (1 to 53)', '1000'], ['tenth(s) of a second (1 to 535)', '100'], ['millisecond(s) (1 to 53,500)', '1']]), 'TIMESCALE');
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('programming'));
+ this.setHelpUrl(Blockly.MSG_S3_CONTROL_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_WAIT_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_wait = function() {
+ var wait_time = Blockly.propc.valueToCode(this, 'WAITTIME', Blockly.propc.ORDER_NONE) || '1';
+ var time_scale = this.getFieldValue('TIMESCALE');
+ return 'pause(' + wait_time + ' * ' + time_scale + ');\n';
+};
+
+Blockly.Blocks.scribbler_if_line = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("if the Scribbler robot")
+ .appendField(new Blockly.FieldDropdown([['is', 'IS'], ['is not', 'IS_NOT'], ['was', 'WAS'], ['was not', 'WAS_NOT']]), 'LINE_CONDITION')
+ .appendField("over")
+ .appendField(new Blockly.FieldDropdown([['the center', 'CENTER'], ['the left edge', 'LEFT'], ['the right edge', 'RIGHT'], ['any part', 'DETECTED']]), 'LINE_POSITION')
+ .appendField("of a")
+ .appendField(new Blockly.FieldDropdown([['black', 'BLACK'], ['white', 'WHITE']]), 'LINE_COLOR')
+ .appendField("line");
+ this.appendStatementInput("IF_LINE")
+ .appendField();
+ this.setPreviousStatement(true);
+ this.setNextStatement(true);
+ this.setInputsInline(true);
+ this.setColour(colorPalette.getColor('input'));
+ this.setHelpUrl(Blockly.MSG_S3_SIMPLE_SENSORS_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_IF_LINE_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_if_line = function () {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var line_condition = this.getFieldValue('LINE_CONDITION');
+ var line_position = this.getFieldValue('LINE_POSITION');
+ var line_color = this.getFieldValue('LINE_COLOR');
+ var code = 'if(s3_simpleLine(S3_' + line_condition + ', S3_' + line_position + ', S3_' + line_color + ')) {\n';
+ return code + Blockly.propc.statementToCode(this, 'IF_LINE') + '\n}';
+};
+
+Blockly.Blocks.scribbler_if_obstacle = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("if an obstacle")
+ .appendField(new Blockly.FieldDropdown([['is', 'IS'], ['is not', 'IS_NOT'], ['was', 'WAS'], ['was not', 'WAS_NOT']]), 'OBSTACLE_CONDITION')
+ .appendField(new Blockly.FieldDropdown([['in front of', 'CENTER'], ['to the left of', 'LEFT'], ['to the right of', 'RIGHT'], ['detected by', 'DETECTED']]), 'OBSTACLE_POSITION')
+ .appendField("the Scribbler robot");
+ this.appendStatementInput("IF_OBSTACLE")
+ .appendField();
+ this.setPreviousStatement(true);
+ this.setNextStatement(true);
+ this.setInputsInline(true);
+ this.setColour(colorPalette.getColor('input'));
+ this.setHelpUrl(Blockly.MSG_S3_SIMPLE_SENSORS_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_IF_OBSTACLE_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_if_obstacle = function () {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var obstacle_condition = this.getFieldValue('OBSTACLE_CONDITION');
+ var obstacle_position = this.getFieldValue('OBSTACLE_POSITION');
+ var code = 'if(s3_simpleObstacle(S3_' + obstacle_condition + ', S3_' + obstacle_position + ')) {\n';
+ return code + Blockly.propc.statementToCode(this, 'IF_OBSTACLE') + '\n}';
+};
+
+Blockly.Blocks.scribbler_if_light = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("if the most light")
+ .appendField(new Blockly.FieldDropdown([['is', 'IS'], ['is not', 'IS_NOT'], ['was', 'WAS'], ['was not', 'WAS_NOT']]), 'LIGHT_CONDITION')
+ .appendField(new Blockly.FieldDropdown([['in front', 'CENTER'], ['to the left', 'LEFT'], ['to the right', 'RIGHT'], ['on all sides', 'DETECTED']]), 'LIGHT_POSITION')
+ .appendField("of the Scribbler robot");
+ this.appendStatementInput("IF_LIGHT")
+ .appendField();
+ this.setPreviousStatement(true);
+ this.setNextStatement(true);
+ this.setInputsInline(true);
+ this.setColour(colorPalette.getColor('input'));
+ this.setHelpUrl(Blockly.MSG_S3_SIMPLE_SENSORS_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_IF_LIGHT_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_if_light = function () {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var light_condition = this.getFieldValue('LIGHT_CONDITION');
+ var light_position = this.getFieldValue('LIGHT_POSITION');
+ var code = 'if(s3_simpleLight(S3_' + light_condition + ', S3_' + light_position + ')) {\n';
+ return code + Blockly.propc.statementToCode(this, 'IF_LIGHT') + '\n}';
+};
+
+Blockly.Blocks.scribbler_if_stalled = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("if the Scribbler robot")
+ .appendField(new Blockly.FieldDropdown([['is', 'IS'], ['is not', 'IS_NOT'], ['was', 'WAS'], ['was not', 'WAS_NOT']]), 'STALLED_CONDITION')
+ .appendField("stuck");
+ this.appendStatementInput("IF_STALLED")
+ .appendField();
+ this.setPreviousStatement(true);
+ this.setNextStatement(true);
+ this.setInputsInline(true);
+ this.setColour(colorPalette.getColor('input'));
+ this.setHelpUrl(Blockly.MSG_S3_SIMPLE_SENSORS_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_IF_STALLED_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_if_stalled = function () {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var code = 'if(s3_simpleStalled(S3_' + this.getFieldValue('STALLED_CONDITION') + ')) {\n';
+ return code + Blockly.propc.statementToCode(this, 'IF_STALLED') + '\n}';
+};
+
+Blockly.Blocks.scribbler_if_button = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("if the red button")
+ .appendField(new Blockly.FieldDropdown([['is', 'IS'], ['is not', 'IS_NOT'], ['was', 'WAS'], ['was not', 'WAS_NOT']]), 'BUTTON_CONDITION')
+ .appendField("pressed");
+ this.appendStatementInput("IF_BUTTON");
+ this.setPreviousStatement(true);
+ this.setNextStatement(true);
+ this.setInputsInline(true);
+ this.setColour(colorPalette.getColor('input'));
+ }
+};
+
+Blockly.propc.scribbler_if_button = function () {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var code = 'if(s3_simpleButton(S3_' + this.getFieldValue('BUTTON_CONDITION') + ')) {\n';
+ return code + Blockly.propc.statementToCode(this, 'IF_BUTTON') + '\n}';
+};
+
+Blockly.Blocks.scribbler_if_random = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("if a virtual coin flip")
+ .appendField(new Blockly.FieldDropdown([['is', 'IS'], ['was', 'WAS']]), 'RANDOM_CONDITION')
+ .appendField(new Blockly.FieldDropdown([['heads', ''], ['tails', '_NOT']]), 'RANDOM_INVERT');
+ this.appendStatementInput("IF_RANDOM");
+ this.setPreviousStatement(true);
+ this.setNextStatement(true);
+ this.setInputsInline(true);
+ this.setColour(colorPalette.getColor('input'));
+ this.setHelpUrl(Blockly.MSG_S3_SIMPLE_SENSORS_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_IF_RANDOM_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_if_random = function () {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var code = 'if(s3_simpleRandom(S3_' + this.getFieldValue('RANDOM_CONDITION') + this.getFieldValue('RANDOM_INVERT') + ')) {\n';
+ return code + Blockly.propc.statementToCode(this, 'IF_RANDOM') + '\n}';
+};
+
+Blockly.Blocks.scribbler_drive = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("drive")
+ .appendField(new Blockly.FieldDropdown([['forward', ''], ['backward', '-']]), 'DRIVE_DIRECTION')
+ .appendField("and")
+ .appendField(new Blockly.FieldDropdown([['sharply to the left', 'SHARP_LEFT'], ['gently to the left', 'GENTLE_LEFT'], ['slightly to the left', 'SLIGHT_LEFT'], ['straight', 'STRAIGHT'], ['slightly to the right', 'SLIGHT_RIGHT'], ['gently to the right', 'GENTLE_RIGHT'], ['sharply to the right', 'SHARP_RIGHT']]), 'DRIVE_ANGLE')
+ .appendField("at")
+ .appendField(new Blockly.FieldDropdown([['full', '255'], ['a quick', '191'], ['a gentle', '127'], ['a slow', '63']]), 'DRIVE_SPEED')
+ .appendField("speed");
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('io'));
+ this.setHelpUrl(Blockly.MSG_S3_SIMPLE_ACTIONS_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_DRIVE_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_drive = function () {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var drive_direction = this.getFieldValue('DRIVE_DIRECTION');
+ var drive_angle = this.getFieldValue('DRIVE_ANGLE');
+ var drive_speed = this.getFieldValue('DRIVE_SPEED');
+ return 's3_simpleDrive(S3_' + drive_angle + ', ' + drive_direction + drive_speed + ');\n';
+};
+
+Blockly.Blocks.scribbler_spin = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("rotate")
+ .appendField(new Blockly.FieldDropdown([['\u21BB', ''], ['\u21BA', '-']]), 'SPIN_DIRECTION')
+ .appendField("for")
+ .appendField(new Blockly.FieldAngle(90), "SPIN_ANGLE")
+ .appendField("at")
+ .appendField(new Blockly.FieldDropdown([['full', '15'], ['a quick', '7'], ['a gentle', '3'], ['a slow', '1']]), 'SPIN_SPEED')
+ .appendField("speed");
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('io'));
+ this.setHelpUrl(Blockly.MSG_S3_SIMPLE_ACTIONS_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_SPIN_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_spin = function () {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var spin_direction = this.getFieldValue('SPIN_DIRECTION');
+ var spin_angle = this.getFieldValue('SPIN_ANGLE');
+ var spin_speed = this.getFieldValue('SPIN_SPEED');
+ return 's3_simpleSpin(' + spin_direction + spin_angle + ', ' + spin_speed + ', 0);\n';
+};
+
+Blockly.Blocks.scribbler_stop = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("stop driving");
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('io'));
+ this.setHelpUrl(Blockly.MSG_S3_SIMPLE_ACTIONS_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_STOP_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_stop = function () {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ return 's3_simpleStop();\n';
+};
+
+Blockly.Blocks.scribbler_LED = {
+ init: function () {
+ this.appendDummyInput()
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("change these LEDs: ")
+ .appendField(new Blockly.FieldCheckbox("TRUE"), "LEFT_LED")
+ .appendField(" ")
+ .appendField(new Blockly.FieldCheckbox("TRUE"), "CENTER_LED")
+ .appendField(" ")
+ .appendField(new Blockly.FieldCheckbox("TRUE"), "RIGHT_LED")
+ .appendField(" ");
+ var left_led_colors = new Blockly.FieldColour("#000000");
+ var center_led_colors = new Blockly.FieldColour("#000000");
+ var right_led_colors = new Blockly.FieldColour("#000000");
+ left_led_colors.setColours(['#FF0000','#00FF00','#FF7F00','#000000']).setColumns(2);
+ center_led_colors.setColours(['#FF0000','#00FF00','#FF7F00','#000000']).setColumns(2);
+ right_led_colors.setColours(['#FF0000','#00FF00','#FF7F00','#000000']).setColumns(2);
+ this.appendDummyInput()
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("to these colors: ")
+ .appendField(left_led_colors, "LEFT_COLOR")
+ .appendField(center_led_colors, "CENTER_COLOR")
+ .appendField(right_led_colors, "RIGHT_COLOR")
+ .appendField(" ");
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('io'));
+ this.setHelpUrl(Blockly.MSG_S3_LEDS_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_LED_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_LED = function () {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var left_color = this.getFieldValue('LEFT_COLOR');
+ var center_color = this.getFieldValue('CENTER_COLOR');
+ var right_color = this.getFieldValue('RIGHT_COLOR');
+ var code = '';
+
+ if (this.getFieldValue('LEFT_LED') === 'TRUE') {
+ code += 's3_setLED(S3_LEFT, S3_COLOR_' + left_color.substr(1,6).toUpperCase() + ');\n';
+ }
+ if (this.getFieldValue('CENTER_LED') === 'TRUE') {
+ code += 's3_setLED(S3_CENTER, S3_COLOR_' + center_color.substr(1,6).toUpperCase() + ');\n';
+ }
+ if (this.getFieldValue('RIGHT_LED') === 'TRUE') {
+ code += 's3_setLED(S3_RIGHT, S3_COLOR_' + right_color.substr(1,6).toUpperCase() + ');\n';
+ }
+
+ return code;
+};
+
+Blockly.Blocks.scribbler_play = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("play a")
+ .appendField(new Blockly.FieldDropdown([['double high', '2'], ['soprano', '4'], ['tenor', '8'], ['middle', '16'], ['low', '32'], ['deep', '64'], ['pedal', '128']]), 'NOTE_OCTAVE')
+ //.appendField(new Blockly.FieldDropdown([['double high', '1'], ['soprano', '2'], ['tenor', '3'], ['middle', '4'], ['low', '5'], ['deep', '6'], ['pedal', '7']]), 'NOTE_OCTAVE')
+ .appendField(new Blockly.FieldDropdown([['A\u266D', '3322'], ['A', '3520'], ['A\u266F/B\u266D', '3729'], ['B', '3951'], ['C', '4186'], ['C\u266F/D\u266D', '4435'], ['D', '4699'], ['D\u266F/E\u266D', '4978'], ['E', '5274'], ['F', '5588'], ['F\u266F/G\u266D', '5920'], ['G', '6272'], ['G\u266F', '6645']]), 'NOTE_FREQUENCY')
+ .appendField("for a")
+ .appendField(new Blockly.FieldDropdown([['sixteenth', '63'], ['dotted sixteenth', '94'], ['eighth', '125'], ['dotted eighth', '188'], ['quarter', '250'], ['dotted quarter', '375'], ['half', '500'], ['dotted half', '750'], ['whole', '1000'], ['dotted whole', '1500']]), 'NOTE_DURATION')
+ .appendField("note at a")
+ .appendField(new Blockly.FieldDropdown([['loud', '50'], ['medium', '30'], ['quiet', '15']]), 'NOTE_VOLUME')
+ .appendField("volume");
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('io'));
+ this.setHelpUrl(Blockly.MSG_S3_SOUND_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_PLAY_TOOLTIP);
+ }
+};
+
+
+Blockly.propc.scribbler_play = function () {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var note_octave = this.getFieldValue('NOTE_OCTAVE');
+ var note_frequency = this.getFieldValue('NOTE_FREQUENCY');
+ var note_duration = this.getFieldValue('NOTE_DURATION');
+ var note_volume = this.getFieldValue('NOTE_VOLUME');
+
+ return 's3_simplePlay((' + note_frequency + ' / ' + note_octave + '), ' + note_duration + ', ' + note_volume + ');\n';
+};
+
+// Move the motors for 0 to ? ms, or indefinately
+Blockly.Blocks.move_motors = {
+ init: function () {
+ this.appendValueInput("LEFT_MOTOR_SPEED")
+ .setCheck("Number")
+ .appendField("set left motor speed to (-100 to 100)%");
+ this.appendValueInput("RIGHT_MOTOR_SPEED")
+ .setCheck("Number")
+ .appendField("set right motor speed to (-100 to 100)%");
+ this.appendValueInput("MOTOR_DURATION")
+ .setCheck("Number")
+ .appendField("for a duration of (1 to 65,535) ms");
+ // TODO: Find duration
+ this.appendDummyInput()
+ .appendField("use 0 ms for continuous operation");
+
+ this.setInputsInline(false);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('io'));
+ this.setTooltip('Speeds are a range of -100 (full reverse) to 100 (full forward) with a duration of 1 to 15,000 milliseconds, or a duration of 0 for continuous operation');
+ this.setHelpUrl(Blockly.MSG_S3_MOTORS_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_MOVE_MOTORS_TOOLTIP);
+ }
+};
+
+Blockly.propc.move_motors = function () {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var left_speed = Blockly.propc.valueToCode(this, 'LEFT_MOTOR_SPEED', Blockly.propc.ORDER_ATOMIC) || '0';
+ var right_speed = Blockly.propc.valueToCode(this, 'RIGHT_MOTOR_SPEED', Blockly.propc.ORDER_ATOMIC) || '0';
+ var movement_time = Blockly.propc.valueToCode(this, 'MOTOR_DURATION', Blockly.propc.ORDER_ATOMIC) || '0';
+ return 's3_motorSet(' + left_speed + ', ' + right_speed + ', ' + movement_time + ');\n';
+};
+
+// Move the motors...
+Blockly.Blocks.move_motors_distance = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("in ")
+ .appendField(new Blockly.FieldDropdown([['inches (-633 to 633)', ' * 100000 / 1933'], ['tenths of an inch (-6,333 to 6,333)', ' * 10000 / 1933'], ['centimeters (-1,608 to 1,608)', ' * 10000 / 491'], ['millimeters (-16,088 to 16,088)', ' * 1000 / 491'], ['encoder counts (-32,767 to 32,767)', '']]), 'MULTIPLIER');
+ this.appendValueInput("LEFT_MOTOR_DISTANCE")
+ .setCheck("Number")
+ .appendField("move the left motor");
+ this.appendValueInput("RIGHT_MOTOR_DISTANCE")
+ .setCheck("Number")
+ .appendField("move the right motor");
+ this.appendValueInput("MOTOR_SPEED")
+ .setCheck("Number")
+ .appendField("at a top speed of (1 to 100)%");
+
+ this.setInputsInline(false);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('io'));
+ this.setTooltip('Maximum millimeters: +/- 15,937, Maximum centimeters: +/- 1,593, Maximum inches: +/- 643\n Maximum tenths of an inch: +/- 6,431, Maximum encoder counts: +/- 32,767');
+ this.setHelpUrl(Blockly.MSG_S3_MOTORS_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_MOVE_MOTORS_DISTANCE_TOOLTIP);
+ }
+};
+
+Blockly.propc.move_motors_distance = function () {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var distance_multiplier = this.getFieldValue('MULTIPLIER');
+ var left_distance = Blockly.propc.valueToCode(this, 'LEFT_MOTOR_DISTANCE', Blockly.propc.ORDER_ATOMIC) || '0';
+ var right_distance = Blockly.propc.valueToCode(this, 'RIGHT_MOTOR_DISTANCE', Blockly.propc.ORDER_ATOMIC) || '0';
+ var top_speed = Blockly.propc.valueToCode(this, 'MOTOR_SPEED', Blockly.propc.ORDER_ATOMIC) || '0';
+ return 's3_motorSetDistance(' + left_distance + distance_multiplier + ', ' + right_distance + distance_multiplier + ', ' + top_speed + ');\n';
+};
+
+Blockly.Blocks.move_motors_xy = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("in ")
+ .appendField(new Blockly.FieldDropdown([['inches (-20,755,429 to 20,755,429)', ' * 100000 / 1933'], ['tenths of an inch (-207,554,294 to 207,554,294)', ' * 10000 / 1933'], ['centimeters (-52,720,723 to 52,720,723)', ' * 10000 / 491'], ['millimeters (-527,207,235 to 527,207,235)', ' * 1000 / 491'], ['encoder counts (-1,073,741,823 to 1,073,741,823)', '']]), 'MULTIPLIER');
+ this.appendDummyInput()
+ .appendField("move the Scribbler robot to the");
+ this.appendValueInput("X_DISTANCE")
+ .setCheck("Number")
+ .appendField("left(-)/right(+) by");
+ this.appendValueInput("Y_DISTANCE")
+ .setCheck("Number")
+ .appendField("back(-)/forward(+) by");
+ this.appendValueInput("MOTOR_SPEED")
+ .setCheck("Number")
+ .appendField("at a top speed of (1 to 100)%");
+
+ this.setInputsInline(false);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('io'));
+ }
+};
+
+//TODO - This function appears to be missing.
+Blockly.propc.move_motors_xy = function () {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var distance_multiplier = this.getFieldValue('MULTIPLIER');
+ var x_distance = Blockly.propc.valueToCode(this, 'X_DISTANCE', Blockly.propc.ORDER_ATOMIC) || '0';
+ var y_distance = Blockly.propc.valueToCode(this, 'Y_DISTANCE', Blockly.propc.ORDER_ATOMIC) || '0';
+ var top_speed = Blockly.propc.valueToCode(this, 'MOTOR_SPEED', Blockly.propc.ORDER_ATOMIC) || '0';
+ return 'scribbler_set_speed(' + top_speed + ' * 3 / 20);\nscribbler_move_to(' + x_distance + distance_multiplier + ', ' + y_distance + distance_multiplier + ');\n';
+};
+
+// Move the motors...
+Blockly.Blocks.move_motors_angle = {
+ init: function () {
+ this.appendValueInput("ROTATE_ANGLE")
+ .setCheck("Number")
+ .appendField("rotate the Scribbler robot (-1,080 to 1,080)\u00B0");
+ this.appendValueInput("ROTATE_RADIUS")
+ .setCheck("Number")
+ .appendField("around a radius to the left(-)/right(+) in")
+ .appendField(new Blockly.FieldDropdown([['inches (-85 to 85) of', ' * 100000 / 1933'], ['tenths of an inch (-850 to 850) of', ' * 10000 / 1933'], ['centimeters (-216 to 216) of', ' * 10000 / 491'], ['millimeters (-2,160 to 2,160) of', ' * 1000 / 491'], ['encoder counts (-4,400 to 4,400) of', '']]), 'RADIUS_MULTIPLIER');
+ this.appendValueInput("ROTATE_SPEED")
+ .setCheck("Number")
+ .appendField("at a top speed of (1 to 100)%");
+
+ this.setInputsInline(false);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('io'));
+ this.setHelpUrl(Blockly.MSG_S3_MOTORS_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_MOVE_MOTORS_ANGLE_TOOLTIP);
+ }
+};
+
+Blockly.propc.move_motors_angle = function () {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var radius_multiplier = this.getFieldValue('RADIUS_MULTIPLIER');
+ var angle = Blockly.propc.valueToCode(this, 'ROTATE_ANGLE', Blockly.propc.ORDER_ATOMIC);
+ var radius = Blockly.propc.valueToCode(this, 'ROTATE_RADIUS', Blockly.propc.ORDER_ATOMIC);
+ var rotate_speed = Blockly.propc.valueToCode(this, 'ROTATE_SPEED', Blockly.propc.ORDER_ATOMIC);
+ return 's3_motorSetRotate(' + angle + ', ' + radius + radius_multiplier + ', ' + rotate_speed + ');\n';
+};
+
+Blockly.Blocks.play_polyphony = {
+ init: function () {
+ this.appendValueInput("FREQUENCY_1")
+ .setCheck("Number")
+ .appendField("play a tone of (1 to 10,000) Hz");
+ this.appendValueInput("FREQUENCY_2")
+ .setCheck("Number")
+ .appendField("and a tone of (1 to 10,000) Hz");
+ this.appendValueInput("POLYPHONY_DURATION")
+ .setCheck("Number")
+ .appendField("for a duration of (1 to 8,000) ms");
+ this.appendValueInput("POLYPHONY_VOLUME")
+ .setCheck("Number")
+ .appendField("at a volume of (0 to 100)%");
+
+ this.setInputsInline(false);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('io'));
+ this.setHelpUrl(Blockly.MSG_S3_SOUND_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_PLAY_POLYPHONY_TOOLTIP);
+ }
+};
+
+Blockly.propc.play_polyphony = function() {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var fq1 = Blockly.propc.valueToCode(this, 'FREQUENCY_1', Blockly.propc.ORDER_ATOMIC) || 1000;
+ var fq2 = Blockly.propc.valueToCode(this, 'FREQUENCY_2', Blockly.propc.ORDER_ATOMIC) || 2000;
+ var dur = Blockly.propc.valueToCode(this, 'POLYPHONY_DURATION', Blockly.propc.ORDER_ATOMIC) || 250;
+ var vol = Blockly.propc.valueToCode(this, 'POLYPHONY_VOLUME', Blockly.propc.ORDER_ATOMIC) || 50;
+
+ return 's3_setVolume((' + vol + ' / 2));\ns3_playNote(' + fq1 + ', ' + fq2 + ', ' + dur + ');\n';
+};
+
+Blockly.Blocks.line_sensor = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField(new Blockly.FieldDropdown([["left", "LEFT"], ["right", "RIGHT"]]), "LINE_SENSOR_CHOICE")
+ .appendField("line sensor reflectivity (0% to 100%)");
+
+ this.setInputsInline(false);
+ this.setOutput(true, "Number");
+ this.setColour(colorPalette.getColor('input'));
+ this.setHelpUrl(Blockly.MSG_S3_LINE_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_LINE_SENSOR_TOOLTIP);
+ }
+};
+
+Blockly.propc.line_sensor = function() {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var dir = this.getFieldValue("LINE_SENSOR_CHOICE");
+ return ['s3_lineSensor(S3_' + dir + ')', Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.obstacle_sensor = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField("an obstacle is present to the")
+ .appendField(new Blockly.FieldDropdown([["left", "LEFT"], ["right", "RIGHT"]]), "OBSTACLE_SENSOR_CHOICE")
+ .appendField("(true or false)");
+
+ this.setOutput(true, "Number");
+ this.setColour(colorPalette.getColor('input'));
+ this.setHelpUrl(Blockly.MSG_S3_OBSTACLE_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_OBSTACLE_SENSOR_TOOLTIP);
+ }
+};
+
+Blockly.propc.obstacle_sensor = function() {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var dir = this.getFieldValue("OBSTACLE_SENSOR_CHOICE");
+ return ['s3_readObstacle(S3_' + dir + ')', Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.stall_sensor = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField("tail wheel is currently stalled (true or false)");
+
+ this.setOutput(true, "Number");
+ this.setColour(colorPalette.getColor('input'));
+ this.setHelpUrl(Blockly.MSG_S3_STALL_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_STALL_SENSOR_TOOLTIP);
+ }
+};
+
+Blockly.propc.stall_sensor = function() {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ return ['s3_stalled()', Blockly.propc.ORDER_NONE];
+};
+
+
+Blockly.Blocks.button_pressed = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField("the red botton is currently pressed");
+ this.appendDummyInput("")
+ .appendField("(true or false)");
+
+ this.setOutput(true, "Number");
+ this.setColour(colorPalette.getColor('input'));
+ }
+};
+
+Blockly.Blocks.spinning_sensor = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField("drive wheels are currently stalled (true or false)");
+ this.setOutput(true, "Number");
+ this.setColour(colorPalette.getColor('input'));
+ this.setHelpUrl(Blockly.MSG_S3_STALL_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SPINNING_SENSOR_TOOLTIP);
+ }
+};
+
+Blockly.propc.spinning_sensor = function() {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var dir = this.getFieldValue("LGHT_SENSOR_CHOICE");
+ return ['!s3_motorsMoving()', Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.light_sensor = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField(new Blockly.FieldDropdown([["left", "LEFT"], ["center", "CENTER"], ["right", "RIGHT"]]), "LGHT_SENSOR_CHOICE")
+ .appendField("light sensor reading (0% to 100%)");
+
+ this.setOutput(true, "Number");
+ this.setColour(colorPalette.getColor('input'));
+ this.setHelpUrl(Blockly.MSG_S3_SENSORS_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_LIGHT_SENSOR_TOOLTIP);
+ }
+};
+
+Blockly.propc.light_sensor = function() {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ var dir = this.getFieldValue("LGHT_SENSOR_CHOICE");
+ return ['s3_lightSensor(S3_' + dir + ')', Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.reset_button_presses = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField("reset button presses during last reset (0 to 8)");
+ this.setOutput(true, "Number");
+ this.setColour(colorPalette.getColor('input'));
+ this.setHelpUrl(Blockly.MSG_S3_RESET_BUTTON_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_RESET_BUTTON_PRESSES_TOOLTIP);
+ }
+};
+
+Blockly.propc.reset_button_presses = function() {
+ Blockly.propc.definitions_[ "include_scribbler" ] = '#include "s3.h"';
+ Blockly.propc.setups_[ 'setup_scribbler' ] = 's3_setup();';
+
+ return ['s3_resetButtonCount()', Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.button_presses = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField("the number of red button presses, since the");
+ this.appendDummyInput("")
+ .appendField("last reading \u2013 in a range of 0 to 255");
+
+ this.setOutput(true, "Number");
+ this.setColour(colorPalette.getColor('input'));
+ }
+};
+
+Blockly.Blocks.scribbler_servo = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField("rotate servo on")
+ .appendField(new Blockly.FieldDropdown([['P0', '0'], ['P1', '1'], ['P2', '2'], ['P3', '3'], ['P4', '4'], ['P5', '5']]), "SERVO_PIN");
+ this.appendValueInput("SERVO_ANGLE")
+ .setCheck("Number")
+ .appendField("to an angle of (0 to 180)\u00B0");
+ this.setInputsInline(false);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('io'));
+ this.setHelpUrl(Blockly.MSG_S3_MOTORS_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_SERVO_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_servo = function () {
+ var dropdown_pin = this.getFieldValue('SERVO_PIN');
+ var degrees = Blockly.propc.valueToCode(this, 'SERVO_ANGLE', Blockly.propc.ORDER_NONE);
+
+ Blockly.propc.definitions_["include servo"] = '#include "servo.h"';
+ if (degrees < 0) {
+ degrees = 0;
+ }
+ if (degrees > 180) {
+ degrees = 180;
+ }
+ var code = 'servo_angle(' + dropdown_pin + ', ' + degrees + ' * 10);\n';
+ return code;
+};
+
+Blockly.Blocks.scribbler_stop_servo = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField("disable servo on")
+ .appendField(new Blockly.FieldDropdown([['P0', '0'], ['P1', '1'], ['P2', '2'], ['P3', '3'], ['P4', '4'], ['P5', '5']]), "SERVO_PIN");
+ this.setInputsInline(false);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('io'));
+ this.setHelpUrl(Blockly.MSG_S3_MOTORS_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_STOP_SERVO_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_stop_servo = function () {
+ Blockly.propc.definitions_["include servo"] = '#include "servo.h"';
+ return 'servo_disable(' + this.getFieldValue('SERVO_PIN') + ');\n';
+};
+
+Blockly.Blocks.scribbler_ping = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField("distance in")
+ .appendField(new Blockly.FieldDropdown([['inches (1 to 124)', '_inches'], ['centimeters (4 to 315)', '_cm']]), "SCALE")
+ .appendField("from Ping))) sensor on")
+ .appendField(new Blockly.FieldDropdown([['P0', '0'], ['P1', '1'], ['P2', '2'], ['P3', '3'], ['P4', '4'], ['P5', '5']]), "PIN");
+
+ this.setOutput(true, "Number");
+ this.setColour(colorPalette.getColor('input'));
+ this.setHelpUrl(Blockly.MSG_S3_PING_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_PING_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_ping = function() {
+ var dropdown_pin = this.getFieldValue('PIN');
+ var unit = this.getFieldValue('SCALE');
+
+ Blockly.propc.definitions_["include ping"] = '#include "ping.h"';
+
+ var code = 'ping' + unit + '(' + dropdown_pin + ')';
+ return [code, Blockly.propc.ORDER_ATOMIC];
+};
+
+Blockly.Blocks.digital_input = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField("Digital reading on")
+ .appendField(new Blockly.FieldDropdown([['P0', '0'], ['P1', '1'], ['P2', '2'], ['P3', '3'], ['P4', '4'], ['P5', '5']]), "PIN");
+ this.setOutput(true, "Number");
+ this.setColour(colorPalette.getColor('input'));
+ this.setHelpUrl(Blockly.MSG_S3_IO_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_DIGITAL_INPUT_TOOLTIP);
+ }
+};
+
+Blockly.propc.digital_input = function() {
+ var pin = this.getFieldValue('PIN');
+ return ['input(' + pin + ')', Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.digital_output = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField("set")
+ .appendField(new Blockly.FieldDropdown([['P0', '0'], ['P1', '1'], ['P2', '2'], ['P3', '3'], ['P4', '4'], ['P5', '5']]), "PIN");
+ this.appendDummyInput("")
+ .appendField("to")
+ .appendField(new Blockly.FieldDropdown([['high', "HIGH"], ['low', "LOW"], ['input', "INPUT"], ['toggle state', "TOGGLE"], ['toggle direction', "REVERSE"]]), "ACTION");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('io'));
+ this.setHelpUrl(Blockly.MSG_S3_IO_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_DIGITAL_OUTPUT_TOOLTIP);
+ }
+};
+
+Blockly.propc.digital_output = function() {
+ var dropdown_pin = this.getFieldValue('PIN');
+ var dropdown_action = this.getFieldValue('ACTION');
+ switch (dropdown_action) {
+ case "HIGH":
+ return 'high(' + dropdown_pin + ');\n';
+ case "LOW":
+ return 'low(' + dropdown_pin + ');\n';
+ case "TOGGLE":
+ return 'toggle(' + dropdown_pin + ');\n\tset_direction(' + dropdown_pin + ', 1);\n';
+ case "INPUT":
+ return 'set_direction(' + dropdown_pin + ', 0);\n';
+ case "REVERSE":
+ return 'reverse(' + dropdown_pin + ');\n';
+ }
+};
+
+Blockly.Blocks.analog_input = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField("Analog reading on")
+ .appendField(new Blockly.FieldDropdown([['A0', '0'], ['A1', '1']]), "ANALOG_PIN");
+ this.setOutput(true, "Number");
+ this.setColour(colorPalette.getColor('input'));
+ this.setHelpUrl(Blockly.MSG_S3_IO_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_ANALOG_INPUT_TOOLTIP);
+ }
+};
+
+// TODO: create this function in s3 library.
+Blockly.propc.analog_input = function() {
+ var pin = this.getFieldValue('PIN');
+ return ['s3_readADC(S3_ADC_A' + pin + ')', Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.spin_integer = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField(new Blockly.FieldTextInput('10', Blockly.FieldTextInput.numberValidator), 'INT_VALUE');
+
+ this.setOutput(true, 'Number');
+ this.setColour(colorPalette.getColor('math'));
+ this.setHelpUrl(Blockly.MSG_S3_MATH_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SPIN_INTEGER_TOOLTIP);
+ }
+};
+
+Blockly.propc.spin_integer = function() {
+ var code = window.parseInt(this.getFieldValue('INT_VALUE'));
+ var order = code < 0 ? Blockly.propc.ORDER_UNARY_PREFIX : Blockly.propc.ORDER_ATOMIC;
+ return [code, order];
+};
+
+Blockly.Blocks.math_int_angle = {
+ init: function () {
+ this.setHelpUrl(Blockly.MSG_S3_MATH_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_MATH_INT_ANGLE_TOOLTIP);
+ this.appendDummyInput()
+ .appendField(new Blockly.FieldAngle('90', Blockly.FieldTextInput.numberValidator), 'ANGLE_VALUE');
+
+ this.setOutput(true, 'Number');
+ this.setColour(colorPalette.getColor('math'));
+ }
+};
+
+Blockly.propc.math_int_angle = function () {
+ var code = window.parseInt(this.getFieldValue('ANGLE_VALUE'));
+ var order = code < 0 ?
+ Blockly.propc.ORDER_UNARY_PREFIX : Blockly.propc.ORDER_ATOMIC;
+ return [code, order];
+};
+
+Blockly.Blocks.scribbler_boolean = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField(new Blockly.FieldDropdown([['true', '1'], ['false', '0']]), 'BOOL');
+ this.setOutput(true, "Number");
+ this.setColour(colorPalette.getColor('math'));
+ this.setHelpUrl(Blockly.MSG_S3_MATH_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_BOOLEAN_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_boolean = function() {
+ return [this.getFieldValue('BOOL'), Blockly.propc.ORDER_ATOMIC];
+};
+
+Blockly.Blocks.scribbler_random_boolean = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField("random true/false");
+ this.setOutput(true, "Number");
+ this.setColour(colorPalette.getColor('math'));
+ this.setHelpUrl(Blockly.MSG_S3_MATH_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_RANDOM_BOOLEAN_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_random_boolean = function() {
+ Blockly.propc.setups_["random_seed"] = "srand(INA + CNT);\n";
+ return ['(rand() % 2)', Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.scribbler_random_number = {
+ init: function () {
+ this.appendValueInput("A")
+ .setCheck("Number")
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("random number from");
+ this.appendValueInput("B")
+ .setCheck("Number")
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("to");
+ this.setInputsInline(true);
+ this.setOutput(true, "Number");
+ this.setColour(colorPalette.getColor('math'));
+ this.setHelpUrl(Blockly.MSG_S3_MATH_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_RANDOM_NUMBER_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_random_number = function() {
+ Blockly.propc.setups_["random_seed"] = "srand(INA + CNT);\n";
+ var arg1 = Blockly.propc.valueToCode(this, 'A', Blockly.propc.ORDER_ATOMIC) || '0';
+ var arg2 = Blockly.propc.valueToCode(this, 'B', Blockly.propc.ORDER_ATOMIC) || '99';
+
+ var code = '(' + arg1 + ' + rand() % (' + arg2 + ' - ' + arg1 + ' + 1))';
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.spin_comment = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField("note:")
+ .appendField(new Blockly.FieldTextInput(""), "COMMENT");
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('programming'));
+ this.setHelpUrl(Blockly.MSG_S3_CONTROL_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SPIN_COMMENT_TOOLTIP);
+ }
+};
+
+Blockly.propc.spin_comment = function() {
+ var text = this.getFieldValue("COMMENT");
+
+ return '// ' + text + '\n';
+};
+
+Blockly.Blocks.factory_reset = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("restore_s3_demo");
+ this.setColour(colorPalette.getColor('programming'));
+ this.setHelpUrl(Blockly.MSG_S3_FACTORY_RESET_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_FACTORY_RESET_TOOLTIP);
+ }
+};
+
+Blockly.Blocks.scribbler_serial_send_text = {
+ init: function () {
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput("")
+ .appendField("Terminal / XBee / WX send text")
+ .appendField(quotes.newQuote_(this.RTL))
+ .appendField(new Blockly.FieldTextInput(""), "MESSAGE_TEXT")
+ .appendField(quotes.newQuote_(this.LTR));
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setHelpUrl(Blockly.MSG_S3_COMMUNICATE_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SERIAL_SEND_TEXT_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_serial_send_text = function () {
+ Blockly.propc.serial_terminal_ = true;
+ Blockly.propc.setups_["s3_serial_baud"] = "simpleterm_reopen(31,30,0,9600);";
+
+ var message = this.getFieldValue('MESSAGE_TEXT');
+
+ return 'print("' + message + '");\n';
+};
+
+Blockly.Blocks.scribbler_serial_send_char = {
+ init: function () {
+ this.appendValueInput("CHAR_VALUE")
+ .setCheck("Number")
+ .appendField("Terminal / XBee / WX send character (0 to 255)");
+ this.setInputsInline(false);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.setHelpUrl(Blockly.MSG_S3_COMMUNICATE_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SERIAL_SEND_CHAR_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_serial_send_char = function () {
+ Blockly.propc.serial_terminal_ = true;
+ Blockly.propc.setups_["s3_serial_baud"] = "simpleterm_reopen(31,30,0,9600);";
+
+ var message = Blockly.propc.valueToCode(this, 'CHAR_VALUE', Blockly.propc.ORDER_ATOMIC);
+
+ return 'print("%c", ' + message + ');\n';
+};
+
+Blockly.Blocks.scribbler_serial_send_decimal = {
+ init: function () {
+ this.appendValueInput("DECIMAL_VALUE")
+ .setCheck("Number")
+ .appendField("Terminal / XBee / WX send number (32-bit signed)");
+ this.setInputsInline(false);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.setHelpUrl(Blockly.MSG_S3_COMMUNICATE_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SERIAL_SEND_DECIMAL_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_serial_send_decimal = function () {
+ Blockly.propc.serial_terminal_ = true;
+ Blockly.propc.setups_["s3_serial_baud"] = "simpleterm_reopen(31,30,0,9600);";
+
+ var message = Blockly.propc.valueToCode(this, 'DECIMAL_VALUE', Blockly.propc.ORDER_ATOMIC) || 0;
+
+ return 'print("%d", ' + message + ');\n';
+};
+
+Blockly.Blocks.scribbler_serial_send_ctrl = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("Terminal / XBee / WX command")
+ .appendField(new Blockly.FieldDropdown([["carriage return", "13"], ["new line", "10"], ["backspace", "127"], ["clear screen", "256"]]), "SERIAL_CHAR");
+ this.setInputsInline(false);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('protocols'));
+ this.setHelpUrl(Blockly.MSG_S3_COMMUNICATE_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SERIAL_SEND_CTRL_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_serial_send_ctrl = function () {
+ Blockly.propc.serial_terminal_ = true;
+ Blockly.propc.setups_["s3_serial_baud"] = "simpleterm_reopen(31,30,0,9600);";
+
+ var message = this.getFieldValue('SERIAL_CHAR');
+ if(message === '256') {
+ return 'term_cmd(CLS);\n';
+ } else {
+ return 'print("%c", ' + message + ');\n';
+ }
+};
+
+Blockly.Blocks.scribbler_serial_rx_byte = {
+ init: function () {
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendDummyInput("")
+ .appendField("Terminal / XBee / WX receive character (0 to 255)");
+ this.setOutput(true, 'Number');
+ this.setHelpUrl(Blockly.MSG_S3_COMMUNICATE_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SERIAL_RX_BYTE_TOOLTIP);
+ }
+};
+
+
+Blockly.propc.scribbler_serial_rx_byte = function () {
+ Blockly.propc.setups_["s3_serial_baud"] = "simpleterm_reopen(31,30,0,9600);";
+
+ return ['getChar()', Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.scribbler_serial_cursor_xy = {
+ init: function () {
+ this.setColour(colorPalette.getColor('protocols'));
+ this.appendValueInput("Y")
+ .setCheck("Number")
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("Terminal set cursor position to row");
+ this.appendValueInput("X")
+ .setCheck("Number")
+ .setAlign(Blockly.ALIGN_RIGHT)
+ .appendField("column");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setHelpUrl(Blockly.MSG_S3_COMMUNICATE_HELPURL);
+ this.setTooltip(Blockly.MSG_S3_SERIAL_CURSOR_XY_TOOLTIP);
+ }
+};
+
+Blockly.propc.scribbler_serial_cursor_xy = function () {
+ Blockly.propc.serial_terminal_ = true;
+ Blockly.propc.setups_["s3_serial_baud"] = "simpleterm_reopen(31,30,0,9600);";
+
+ var row = Blockly.propc.valueToCode(this, 'Y', Blockly.propc.ORDER_NONE);
+ var column = Blockly.propc.valueToCode(this, 'X', Blockly.propc.ORDER_NONE);
+
+ if (Number(row) < 0) {
+ row = 0;
+ } else if (Number(row) > 255) {
+ row = 255;
+ }
+
+ if (Number(column) < 0) {
+ column = 0;
+ } else if (Number(column) > 255) {
+ column = 255;
+ }
+
+ return 'term_cmd(CRSRXY, ' + column + ', ' + row + ');\n';
+};
+
+Blockly.Blocks.sirc_s3_get = {
+ helpUrl: Blockly.MSG_S3_SIRC_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_S3_SCRIBBLER_SIRC_TOOLTIP);
+ var addPin = [["Onboard IR sensor", "SCRIBBLER_OBS_RX"]];
+ var thePins = addPin.concat(profile.default.digital);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("Sony Remote value received from")
+ .appendField(new Blockly.FieldDropdown(thePins), "PIN");
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ this.setOutput(true, 'Number');
+ }
+};
+
+Blockly.propc.sirc_s3_get = function() {
+ var pin = this.getFieldValue('PIN');
+
+ Blockly.propc.definitions_["sirc"] = '#include "sirc.h"';
+ Blockly.propc.setups_["sirc"] = "sirc_setTimeout(70);\n";
+
+ var code = 'sirc_button(' + pin + ')';
+ return [code, Blockly.propc.ORDER_NONE];
+};
\ No newline at end of file
diff --git a/src/main/webapp/cdn/blockly/generators/propc/sd_card.js b/src/main/webapp/cdn/blockly/generators/propc/sd_card.js
deleted file mode 100644
index e9d93791..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/sd_card.js
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
-
- This file contains support for the sd_card functions built into C
-
- Author: Vale Tolpegin (valetolpegin@gmail.com)
-
- *Copyright 2016 Vale Tolpegin.
- *
- *
- * 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.
-
- */
-'use strict';
-
-if ( !Blockly.Blocks )
- Blockly.Blocks = {};
-
-
-Blockly.Blocks.sd_card_mount = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("mount a SD Card")
- .appendField("do pin")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), 'DO_PIN');
- this.appendDummyInput()
- .appendField("clk pin")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), 'CLK_PIN');
- this.appendDummyInput()
- .appendField("di pin")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), 'DI_PIN');
- this.appendDummyInput()
- .appendField("cs pin")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), 'CS_PIN');
-
- this.setInputsInline(true);
- this.setNextStatement(true, null);
- this.setPreviousStatement(true, null);
- }
-};
-
-Blockly.Blocks.sd_card_int_to = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("save an int to the SD Card")
- .appendField("filename")
- .appendField(quotes.newQuote_(true))
- .appendField(new Blockly.FieldTextInput(''), 'TEXT')
- .appendField(quotes.newQuote_(false));
- this.appendValueInput('VALUE')
- .appendField("value");
- this.appendValueInput('STARTING_POINT_VALUE')
- .appendField("starting read location");
- this.appendValueInput('ENDING_POINT_VALUE')
- .appendField("ending read location");
-
- this.setInputsInline(true);
- this.setNextStatement(true, null);
- this.setPreviousStatement(true, null);
- }
-};
-
-Blockly.Blocks.sd_card_int_from = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("store an int from the SD Card")
- .appendField("filename")
- .appendField(quotes.newQuote_(true))
- .appendField(new Blockly.FieldTextInput(''), 'TEXT')
- .appendField(quotes.newQuote_(false));
- this.appendValueInput('STARTING_POINT_VALUE')
- .appendField("starting read location");
- this.appendValueInput('ENDING_POINT_VALUE')
- .appendField("ending read location");
-
- this.setInputsInline(true);
- this.setNextStatement(true, null);
- this.setPreviousStatement(true, null);
- }
-};
-
-Blockly.Blocks.sd_card_read_int = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendValueInput('INDEX')
- .appendField("get index #");
- this.appendDummyInput()
- .appendField("of the stored integers");
-
- this.setNextStatement(false, null);
- this.setPreviousStatement(false, null);
- this.setOutput(true, 'Number');
- }
-};
-
-Blockly.Blocks.sd_card_float_to = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("save a float to the SD Card")
- .appendField("filename")
- .appendField(quotes.newQuote_(true))
- .appendField(new Blockly.FieldTextInput(''), 'TEXT')
- .appendField(quotes.newQuote_(false));
- this.appendValueInput('VALUE')
- .appendField("value");
- this.appendValueInput('STARTING_POINT_VALUE')
- .appendField("starting read location");
- this.appendValueInput('ENDING_POINT_VALUE')
- .appendField("ending read location");
-
- this.setInputsInline(true);
- this.setNextStatement(true, null);
- this.setPreviousStatement(true, null);
- }
-};
-
-Blockly.Blocks.sd_card_float_from = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("store a float from the SD Card")
- .appendField("filename")
- .appendField(quotes.newQuote_(true))
- .appendField(new Blockly.FieldTextInput(''), 'TEXT')
- .appendField(quotes.newQuote_(false));
- this.appendValueInput('STARTING_POINT_VALUE')
- .appendField("starting read location");
- this.appendValueInput('ENDING_POINT_VALUE')
- .appendField("ending read location");
-
- this.setInputsInline(true);
- this.setNextStatement(true, null);
- this.setPreviousStatement(true, null);
- }
-};
-
-Blockly.Blocks.sd_card_read_float = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendValueInput('INDEX')
- .appendField("get index #");
- this.appendDummyInput()
- .appendField("of the stored floats");
-
- this.setNextStatement(false, null);
- this.setPreviousStatement(false, null);
- this.setOutput(true, 'Number');
- }
-};
-
-Blockly.Blocks.sd_card_text_to = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("save text to the SD Card")
- .appendField("filename")
- .appendField(quotes.newQuote_(true))
- .appendField(new Blockly.FieldTextInput(''), 'TEXT_FILENAME')
- .appendField(quotes.newQuote_(false));
- this.appendDummyInput()
- .appendField("text")
- .appendField(quotes.newQuote_(true))
- .appendField(new Blockly.FieldTextInput(''), 'TEXT_INPUT')
- .appendField(quotes.newQuote_(false));
- this.appendValueInput('VALUE')
- .appendField("value");
- this.appendValueInput('STARTING_POINT_VALUE')
- .appendField("starting read location");
- this.appendValueInput('ENDING_POINT_VALUE')
- .appendField("ending read location");
-
- this.setInputsInline(true);
- this.setNextStatement(true, null);
- this.setPreviousStatement(true, null);
- }
-};
-
-Blockly.Blocks.sd_card_text_from = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("store text from the SD Card")
- .appendField("filename")
- .appendField(quotes.newQuote_(true))
- .appendField(new Blockly.FieldTextInput(''), 'TEXT')
- .appendField(quotes.newQuote_(false));
- this.appendValueInput('STARTING_POINT_VALUE')
- .appendField("starting read location");
- this.appendValueInput('ENDING_POINT_VALUE')
- .appendField("ending read location");
-
- this.setInputsInline(true);
- this.setNextStatement(true, null);
- this.setPreviousStatement(true, null);
- }
-};
-
-Blockly.Blocks.sd_card_read_text = {
- init: function() {
- this.setColour(colorPalette.getColor('input'));
- this.appendValueInput('INDEX')
- .appendField("get index #");
- this.appendDummyInput()
- .appendField("of the stored text");
-
- this.setNextStatement(false, null);
- this.setPreviousStatement(false, null);
- this.setOutput(true, 'Number');
- }
-};
-
-Blockly.propc.sd_card_mount = function() {
- var do_pin = this.getFieldValue('DO_PIN');
- var clk_pin = this.getFieldValue('CLK_PIN');
- var di_pin = this.getFieldValue('DI_PIN');
- var cs_pin = this.getFieldValue('CS_PIN');
-
- if (Blockly.propc.setups_["sd_card"] === undefined)
- {
- Blockly.propc.setups_["sd_card"] = 'sd_mount(' + do_pin + ', ' + clk_pin + ', ' + di_pin + ', ' + cs_pin + ');';
- }
-
- return '';
-};
-
-Blockly.propc.sd_card_int_to = function() {
- var filename = this.getFieldValue('TEXT');
- var value = Blockly.propc.valueToCode(this, 'VALUE', Blockly.propc.ORDER_ATOMIC) || '1';
- var starting_value = Blockly.propc.valueToCode(this, 'STARTING_POINT_VALUE', Blockly.propc.ORDER_ATOMIC) || '0';
- var ending_value = Blockly.propc.valueToCode(this, 'ENDING_POINT_VALUE', Blockly.propc.ORDER_ATOMIC) || '1';
-
- return 'fwrite("' + value + '", ' + starting_value + ', ' + ending_value + ', fp_' + filename + ');\n';
-};
-
-Blockly.propc.sd_card_int_from = function() {
- var filename = this.getFieldValue('TEXT');
- var starting_value = Blockly.propc.valueToCode(this, 'STARTING_POINT_VALUE', Blockly.propc.ORDER_ATOMIC) || '0';
- var ending_value = Blockly.propc.valueToCode(this, 'ENDING_POINT_VALUE', Blockly.propc.ORDER_ATOMIC) || '1';
-
- Blockly.propc.global_vars_["int_array_reading"] = 'int file_reading_array_int[128];';
- Blockly.propc.setups_["int_array_reading"] = 'file_reading_array_int = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};\n';
-
- return 'fread(file_reading_array_int, ' + starting_value + ', ' + ending_value + ', fp_' + filename + ');\n';
-};
-
-Blockly.propc.sd_card_read_int = function() {
- var index = Blockly.propc.valueToCode(this, 'INDEX', Blockly.propc.ORDER_ATOMIC) || '0';
-
- var code = 'file_reading_array_int[' + index + ']';
- return [code, Blockly.propc.ORDER_NONE];
-};
-
-Blockly.propc.sd_card_float_to = function() {
- var filename = this.getFieldValue('TEXT');
- var value = Blockly.propc.valueToCode(this, 'VALUE', Blockly.propc.ORDER_ATOMIC) || '1';
- var starting_value = Blockly.propc.valueToCode(this, 'STARTING_POINT_VALUE', Blockly.propc.ORDER_ATOMIC) || '0';
- var ending_value = Blockly.propc.valueToCode(this, 'ENDING_POINT_VALUE', Blockly.propc.ORDER_ATOMIC) || '1';
-
- return 'fwrite("' + value + '", ' + starting_value + ', ' + ending_value + ', fp_' + filename + ');\n';
-};
-
-Blockly.propc.sd_card_float_from = function() {
- var filename = this.getFieldValue('TEXT');
- var starting_value = Blockly.propc.valueToCode(this, 'STARTING_POINT_VALUE', Blockly.propc.ORDER_ATOMIC) || '0';
- var ending_value = Blockly.propc.valueToCode(this, 'ENDING_POINT_VALUE', Blockly.propc.ORDER_ATOMIC) || '1';
-
- Blockly.propc.global_vars_["float_array_reading"] = 'float file_reading_array_float[128];\n';
- Blockly.propc.setups_["float_array_reading"] = 'file_reading_array_float = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};\n';
-
- return 'fread(file_reading_array_float, ' + starting_value + ', ' + ending_value + ', fp_' + filename + ');\n';
-};
-
-Blockly.propc.sd_card_read_float = function() {
- var index = Blockly.propc.valueToCode(this, 'INDEX', Blockly.propc.ORDER_ATOMIC) || '0';
-
- var code = 'file_reading_array_float[' + index + ']';
- return [code, Blockly.propc.ORDER_NONE];
-};
-
-Blockly.propc.sd_card_text_to = function() {
- var filename = this.getFieldValue('TEXT');
- var value = this.getFieldValue('TEXT_INPUT');
- var starting_value = Blockly.propc.valueToCode(this, 'STARTING_POINT_VALUE', Blockly.propc.ORDER_ATOMIC) || '0';
- var ending_value = Blockly.propc.valueToCode(this, 'ENDING_POINT_VALUE', Blockly.propc.ORDER_ATOMIC) || '1';
-
- return 'fwrite("' + value + '", ' + starting_value + ', ' + ending_value + ', fp_' + filename + ');\n';
-};
-
-Blockly.propc.sd_card_text_from = function() {
- var filename = this.getFieldValue('TEXT');
- var starting_value = Blockly.propc.valueToCode(this, 'STARTING_POINT_VALUE', Blockly.propc.ORDER_ATOMIC) || '0';
- var ending_value = Blockly.propc.valueToCode(this, 'ENDING_POINT_VALUE', Blockly.propc.ORDER_ATOMIC) || '1';
-
- Blockly.propc.global_vars_["text_array_reading"] = 'char file_reading_array_int[128];\n';
- Blockly.propc.setups_["text_array_reading"] = 'file_reading_array_text = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};\n';
-
-
- var code = 'fread(file_reading_array_text, ' + starting_value + ', ' + ending_value + ', fp_' + filename + ');\n';
- return code;
-};
-
-Blockly.propc.sd_card_read_text = function() {
- var index = Blockly.propc.valueToCode(this, 'INDEX', Blockly.propc.ORDER_ATOMIC) || '0';
-
- var code = 'file_reading_array_text[' + index + ']';
- return [code, Blockly.propc.ORDER_NONE];
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/sensors.js b/src/main/webapp/cdn/blockly/generators/propc/sensors.js
index ce56273e..11b06422 100644
--- a/src/main/webapp/cdn/blockly/generators/propc/sensors.js
+++ b/src/main/webapp/cdn/blockly/generators/propc/sensors.js
@@ -1,7 +1,7 @@
/**
* Visual Blocks Language
*
- * Copyright 2014 Michel Lampo
+ * Copyright 2014 Michel Lampo, Vale Tolpegin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,11 @@
/**
* @fileoverview Generating C for sensor blocks
* @author michel@creatingfuture.eu (Michel Lampo)
+ * valetolpegin@gmail.com (Vale Tolpegin)
+ * jewald@parallax.com (Jim Ewald)
+ * mmatz@parallax.com (Matthew Matz)
+ * kgracey@parallax.com (Ken Gracey)
+ * carsongracey@gmail.com (Carson Gracey)
*/
'use strict';
@@ -26,7 +31,56 @@
if (!Blockly.Blocks)
Blockly.Blocks = {};
+// ---------------- 2-axis Joystick Blocks -------------------------------------
+Blockly.Blocks.joystick_input_yaxis = {
+ helpUrl: Blockly.MSG_JOYSTICK_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_JOYSTICK_INPUT_YAXIS_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("Joystick y-axis A/D")
+ .appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"]]), "PINY");
+
+ this.setOutput(true, 'Number');
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ }
+};
+
+Blockly.propc.joystick_input_yaxis = function() {
+ var pin_number_yaxis = this.getFieldValue('PINY');
+
+ Blockly.propc.definitions_["include abvolts"] = '#include "abvolts.h"';
+
+ var code = 'ad_in(' + pin_number_yaxis + ') * 100 / 4096';
+ return [code, Blockly.propc.ORDER_ATOMIC];
+};
+Blockly.Blocks.joystick_input_xaxis = {
+ helpUrl: Blockly.MSG_JOYSTICK_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_JOYSTICK_INPUT_XAXIS_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("Joystick x-axis A/D")
+ .appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"]]), "PINX");
+
+ this.setOutput(true, 'Number');
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ }
+};
+
+Blockly.propc.joystick_input_xaxis = function() {
+ var pin_number_xaxis = this.getFieldValue('PINX');
+
+ Blockly.propc.definitions_["include abvolts"] = '#include "abvolts.h"';
+
+ var code = 'ad_in(' + pin_number_xaxis + ') * 100 / 4096';
+ return [code, Blockly.propc.ORDER_ATOMIC];
+};
+
+// ---------------- Ping))) Sensor Blocks --------------------------------------
Blockly.Blocks.sensor_ping = {
helpUrl: Blockly.MSG_PING_HELPURL,
init: function() {
@@ -34,7 +88,7 @@ Blockly.Blocks.sensor_ping = {
this.setColour(colorPalette.getColor('input'));
this.appendDummyInput()
.appendField("Ping))) distance in")
- .appendField(new Blockly.FieldDropdown([["inches", "INCHES"], ["cm", "CM"]]), "UNIT")
+ .appendField(new Blockly.FieldDropdown([["inches", "_inches"], ["cm", "_cm"]]), "UNIT")
.appendField("PIN")
.appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
@@ -44,24 +98,17 @@ Blockly.Blocks.sensor_ping = {
}
};
-
Blockly.propc.sensor_ping = function() {
var dropdown_pin = this.getFieldValue('PIN');
var unit = this.getFieldValue('UNIT');
- var methodForUnit = Blockly.propc.sensor_ping.UNITS[unit];
Blockly.propc.definitions_["include ping"] = '#include "ping.h"';
- var code = 'ping' + methodForUnit + '(' + dropdown_pin + ')';
+ var code = 'ping' + unit + '(' + dropdown_pin + ')';
return [code, Blockly.propc.ORDER_ATOMIC];
};
-Blockly.propc.sensor_ping.UNITS = {
- INCHES: '_inches',
- CM: '_cm',
- TICKS: ''
-};
-
+// ---------------- PIR Sensor Blocks ------------------------------------------
Blockly.Blocks.PIR_Sensor = {
helpUrl: Blockly.MSG_PIR_HELPURL,
init: function() {
@@ -84,6 +131,8 @@ Blockly.propc.PIR_Sensor = function () {
return [code, Blockly.propc.ORDER_ATOMIC];
};
+// ---------------- SF02 Laser Rangefinder Blocks ------------------------------
+/*
Blockly.Blocks.SF02_Laser_Rangefinder = {
init: function () {
this.setColour(colorPalette.getColor('input'));
@@ -106,7 +155,9 @@ Blockly.propc.SF02_Laser_Rangefinder = function() {
var code = 'ad_volts(' + pin + ')';
return [code, Blockly.propc.ORDER_ATOMIC];
};
+*/
+// ---------------- Sound Impact Sensor Blocks ---------------------------------
Blockly.Blocks.sound_impact_run = {
helpUrl: Blockly.MSG_SOUND_IMPACT_HELPURL,
init: function() {
@@ -122,6 +173,15 @@ Blockly.Blocks.sound_impact_run = {
}
};
+Blockly.propc.sound_impact_run = function() {
+ var pin = this.getTitleValue('PIN');
+
+ Blockly.propc.definitions_["sound_impact"] = '#include "soundimpact.h"';
+ Blockly.propc.setups_["sound_impact"] = 'int *__soundimpactcog = soundImpact_run(' + pin + ');\n';
+
+ return '';
+};
+
Blockly.Blocks.sound_impact_get = {
helpUrl: Blockly.MSG_SOUND_IMPACT_HELPURL,
init: function() {
@@ -136,6 +196,18 @@ Blockly.Blocks.sound_impact_get = {
}
};
+Blockly.propc.sound_impact_get = function() {
+ Blockly.propc.definitions_["sound_impact"] = '#include "soundimpact.h"';
+
+ if (Blockly.propc.setups_["sound_impact"] === undefined)
+ {
+ return '// Missing sound impact sensor declaration statement';
+ }
+
+ var code = 'soundImpact_getCount()';
+ return [code, Blockly.propc.ORDER_ATOMIC];
+};
+
Blockly.Blocks.sound_impact_end = {
helpUrl: Blockly.MSG_SOUND_IMPACT_HELPURL,
init: function() {
@@ -149,27 +221,6 @@ Blockly.Blocks.sound_impact_end = {
}
};
-Blockly.propc.sound_impact_run = function() {
- var pin = this.getTitleValue('PIN');
-
- Blockly.propc.definitions_["sound_impact"] = '#include "soundimpact.h"';
- Blockly.propc.setups_["sound_impact"] = 'int *__soundimpactcog = soundImpact_run(' + pin + ');\n';
-
- return '';
-};
-
-Blockly.propc.sound_impact_get = function() {
- Blockly.propc.definitions_["sound_impact"] = '#include "soundimpact.h"';
-
- if (Blockly.propc.setups_["sound_impact"] === undefined)
- {
- return '// Missing sound impact sensor declaration statement';
- }
-
- var code = 'soundImpact_getCount()';
- return [code, Blockly.propc.ORDER_ATOMIC];
-};
-
Blockly.propc.sound_impact_end = function() {
Blockly.propc.definitions_["sound_impact"] = '#include "soundimpact.h"';
if (Blockly.propc.setups_["sound_impact"] === undefined)
@@ -180,6 +231,7 @@ Blockly.propc.sound_impact_end = function() {
return 'soundImpact_end(__soundimpactcog);\n';
};
+// ---------------- ColorPal Color Sensor Blocks -------------------------------
Blockly.Blocks.colorpal_enable = {
helpUrl: Blockly.MSG_COLORPAL_HELPURL,
init: function() {
@@ -193,6 +245,17 @@ Blockly.Blocks.colorpal_enable = {
}
};
+Blockly.propc.colorpal_enable = function () {
+ Blockly.propc.global_vars_["colorpal"] = 'colorPal *cpal;';
+ Blockly.propc.definitions_["colorpal"] = '#include "colorpal.h"';
+
+ var pin = this.getFieldValue('IO_PIN');
+
+ Blockly.propc.setups_["colorpal"] = 'cpal = colorPal_open(' + pin + ');';
+
+ return '';
+};
+
Blockly.Blocks.colorpal_get_colors_raw = {
helpUrl: Blockly.MSG_COLORPAL_HELPURL,
init: function() {
@@ -226,6 +289,14 @@ Blockly.Blocks.colorpal_get_colors_raw = {
}
};
+Blockly.propc.colorpal_get_colors_raw = function () {
+ var r = Blockly.propc.variableDB_.getName(this.getFieldValue('R_STORAGE'), Blockly.Variables.NAME_TYPE);
+ var g = Blockly.propc.variableDB_.getName(this.getFieldValue('G_STORAGE'), Blockly.Variables.NAME_TYPE);
+ var b = Blockly.propc.variableDB_.getName(this.getFieldValue('B_STORAGE'), Blockly.Variables.NAME_TYPE);
+
+ return 'colorPal_getRGB(cpal, &' + r + ', &' + g + ', &' + b + ');';
+};
+
Blockly.Blocks.colorpal_get_colors = {
helpUrl: Blockly.MSG_COLORPAL_HELPURL,
init: function() {
@@ -249,33 +320,730 @@ Blockly.Blocks.colorpal_get_colors = {
}
};
-Blockly.propc.colorpal_enable = function () {
- Blockly.propc.global_vars_["colorpal"] = 'colorPal *cpal;';
- Blockly.propc.definitions_["colorpal"] = '#include "colorpal.h"';
+Blockly.propc.colorpal_get_colors = function () {
+ var color_var = Blockly.propc.variableDB_.getName(this.getFieldValue('COLOR'), Blockly.Variables.NAME_TYPE);
- var pin = this.getFieldValue('IO_PIN');
+ Blockly.propc.global_vars_["colorpal_rr"] = 'int cpRR = 0;';
+ Blockly.propc.global_vars_["colorpal_gg"] = 'int cpGG = 0;';
+ Blockly.propc.global_vars_["colorpal_bb"] = 'int cpBB = 0;';
+
+ var code = 'colorPal_getRGB(cpal, &cpRR, &cpGG, &cpBB);\n\t' + color_var + ' = colorPalRRGGBB(cpRR, cpGG, cpBB);';
+ return code;
+};
+
+// -------------Memsic Tilt/Accel (MX2125 Module) ------------------------------
+Blockly.Blocks.MX2125_acceleration_xaxis = {
+ helpUrl: Blockly.MSG_MEMSIC_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_MX2125_ACCELERATION_XAXIS_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("Memsic acceleration x-axis PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINX");
+
+ this.setNextStatement(false, null);
+ this.setPreviousStatement(false, null);
+ this.setOutput(true, 'Number');
+ }
+};
+
+Blockly.propc.MX2125_acceleration_xaxis = function () {
+ var pin = this.getFieldValue('PINX');
+
+ Blockly.propc.definitions_["include_mx2125"] = '#include "mx2125.h"';
+
+ var code = 'mx_accel(' + pin + ')';
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.MX2125_acceleration_yaxis = {
+ helpUrl: Blockly.MSG_MEMSIC_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_MX2125_ACCELERATION_YAXIS_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("Memsic acceleration y-axis PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINY");
+
+ this.setNextStatement(false, null);
+ this.setPreviousStatement(false, null);
+ this.setOutput(true, 'Number');
+ }
+};
+
+Blockly.propc.MX2125_acceleration_yaxis = function () {
+ Blockly.propc.definitions_["include_mx2125"] = '#include "mx2125.h"';
+
+ var pin = this.getFieldValue('PINY');
+ var code = 'mx_accel(' + pin + ')';
+
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.MX2125_rotation = {
+ helpUrl: Blockly.MSG_MEMSIC_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_MX2125_ROTATION_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("Memsic rotation x-axis PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINX")
+ .appendField("y-axis PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINY");
+
+ this.setInputsInline(true);
+ this.setNextStatement(false, null);
+ this.setPreviousStatement(false, null);
+ this.setOutput(true, 'Number');
+ }
+};
+
+Blockly.propc.MX2125_rotation = function () {
+ var pinx = this.getFieldValue('PINX');
+ var piny = this.getFieldValue('PINY');
+
+ Blockly.propc.definitions_["include_mx2125"] = '#include "mx2125.h"';
+
+ var code = 'mx_rotate(' + pinx + ', ' + piny + ')';
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.MX2125_tilt_xaxis = {
+ helpUrl: Blockly.MSG_MEMSIC_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_MX2125_TILT_XAXIS_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("Memsic tilt x-axis PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINX");
+
+ this.setNextStatement(false, null);
+ this.setPreviousStatement(false, null);
+ this.setOutput(true, 'Number');
+ }
+};
+
+Blockly.propc.MX2125_tilt_xaxis = function () {
+ var pin = this.getFieldValue('PINX');
+
+ Blockly.propc.definitions_["include_mx2125"] = '#include "mx2125.h"';
+
+ var code = 'mx_tilt(' + pin + ')';
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+Blockly.Blocks.MX2125_tilt_yaxis = {
+ helpUrl: Blockly.MSG_MEMSIC_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_MX2125_TILT_YAXIS_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("Memsic tilt y-axis PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINY");
+
+ this.setNextStatement(false, null);
+ this.setPreviousStatement(false, null);
+ this.setOutput(true, 'Number');
+ }
+};
+
+Blockly.propc.MX2125_tilt_yaxis = function () {
+ var pin = this.getFieldValue('PINY');
+
+ Blockly.propc.definitions_["include_mx2125"] = '#include "mx2125.h"';
+
+ var code = 'mx_tilt(' + pin + ')';
+ return [code, Blockly.propc.ORDER_NONE];
+};
+
+// --------------Accelerometer (MMA7455 Module) Blocks--------------------------
+Blockly.Blocks.MMA7455_init = {
+ helpUrl: Blockly.MSG_ACCELEROMETER_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_MMA7455_INIT_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("Accelerometer initialize CS")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINZ")
+ .appendField("DATA")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINX")
+ .appendField("CLK")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PINY");
+
+ this.setInputsInline(false);
+ this.setNextStatement(true, null);
+ this.setPreviousStatement(true, null);
+ }
+};
+
+Blockly.propc.MMA7455_init = function () {
+ var pinx = this.getFieldValue('PINX');
+ var piny = this.getFieldValue('PINY');
+ var pinz = this.getFieldValue('PINZ');
+
+ Blockly.propc.definitions_["include_mma7455"] = '#include "mma7455.h"';
+ Blockly.propc.setups_["mma_7455"] = 'MMA7455_init(' + pinx + ', ' + piny + ', ' + pinz + ');\n';
+
+ return '';
+};
+
+Blockly.Blocks.MMA7455_acceleration = {
+ helpUrl: Blockly.MSG_ACCELEROMETER_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_MMA7455_ACCELERATION_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("Accelerometer store x-axis in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'X_VAR')
+ .appendField(" y-axis in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'Y_VAR')
+ .appendField(" z-axis in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'Z_VAR');
+
+ this.setInputsInline(false);
+ this.setNextStatement(true, null);
+ this.setPreviousStatement(true, null);
+ },
+ getVars: function () {
+ return [this.getFieldValue('X_VAR'), this.getFieldValue('Y_VAR'), this.getFieldValue('Z_VAR')];
+ },
+ renameVar: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getFieldValue('X_VAR'))) {
+ this.setTitleValue(newName, 'X_VAR');
+ } else if (Blockly.Names.equals(oldName, this.getFieldValue('Y_VAR'))) {
+ this.setTitleValue(newName, 'Y_VAR');
+ } else if (Blockly.Names.equals(oldName, this.getFieldValue('Z_VAR'))) {
+ this.setTitleValue(newName, 'Z_VAR');
+ }
+ }
+};
+
+Blockly.propc.MMA7455_acceleration = function () {
+
+ var xstorage = Blockly.propc.variableDB_.getName(this.getFieldValue('X_VAR'), Blockly.Variables.NAME_TYPE);
+ var ystorage = Blockly.propc.variableDB_.getName(this.getFieldValue('Y_VAR'), Blockly.Variables.NAME_TYPE);
+ var zstorage = Blockly.propc.variableDB_.getName(this.getFieldValue('Z_VAR'), Blockly.Variables.NAME_TYPE);
+
+ return 'MMA7455_getxyz10(&' + xstorage + ', &' + ystorage + ', &' + zstorage + ');\n';
+};
+
+//-----------------------Compass (HMC5883L Module) Blocks ----------------------
+Blockly.Blocks.HMC5883L_init = {
+ helpUrl: Blockly.MSG_COMPASS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_HMC5883L_INIT_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("Compass initialize SCL")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "SCL");
+ this.appendDummyInput()
+ .appendField("SDA")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "SDA");
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.HMC5883L_init = function () {
+ var scl = this.getFieldValue("SCL");
+ var sda = this.getFieldValue("SDA");
+
+ Blockly.propc.definitions_["HMC5883L"] = '#include "compass3d.h"';
+ Blockly.propc.setups_["HMC5883L"] = 'i2c *compass_bus = i2c_newbus(' + scl + ', ' + sda + ', 0);\n\tcompass_init(compass_bus);';
+
+ return '';
+};
+
+Blockly.Blocks.HMC5883L_read = {
+ helpUrl: Blockly.MSG_COMPASS_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_HMC5883L_READ_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("Compass heading store in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'HEADING');
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ },
+ getVars: function () {
+ return [this.getFieldValue('HEADING')];
+ },
+ renameVar: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getFieldValue('HEADING'))) {
+ this.setTitleValue(newName, 'HEADING');
+ }
+ }
+};
+
+Blockly.propc.HMC5883L_read = function () {
+ var storage = Blockly.propc.variableDB_.getName(this.getFieldValue('HEADING'), Blockly.Variables.NAME_TYPE);
+ Blockly.propc.global_vars_["compass_vars"] = 'int __compX, __compY, __compZ;\nfloat __compH;\n';
- //Blockly.propc.global_vars_["colorpal_pin"] = 'int cpSIO = ' + pin + ';';
- Blockly.propc.setups_["colorpal"] = 'cpal = colorPal_open(' + pin + ');';
+ var code = '';
+ code += 'compass_read(bus, &__compX, &__compY, &__compZ);\n';
+ code += '\t__compH = atan2(((float) __compY), (((float) __compX)) * 180.0/PI;\n';
+ code += '\tif(__compH < 0.0) __compH = (360.0 + __compH);\n';
+ code += '\t' + storage + ' = (int) __compH;\n';
+
+ return code;
+};
+
+// ------------------ IMU (LSM9DS1 module) Blocks ------------------------------
+Blockly.Blocks.lsm9ds1_init = {
+ helpUrl: Blockly.MSG_IMU_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_LSM9DS1_INIT_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("IMU initialize SCL")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN_SCL")
+ .appendField("SDIO")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN_SDIO")
+ .appendField("CS_AG")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN_CSAG")
+ .appendField("CS_M")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN_CSM");
+
+ this.setInputsInline(false);
+ this.setNextStatement(true, null);
+ this.setPreviousStatement(true, null);
+ }
+};
+
+Blockly.propc.lsm9ds1_init = function () {
+ var pin_scl = this.getFieldValue('PIN_SCL');
+ var pin_sio = this.getFieldValue('PIN_SDIO');
+ var pin_csa = this.getFieldValue('PIN_CSAG');
+ var pin_csm = this.getFieldValue('PIN_CSM');
+
+ Blockly.propc.definitions_["include_lsm9ds1"] = '#include "lsm9ds1.h"';
+ Blockly.propc.setups_["lsm9ds1_init"] = 'imu_init(' + pin_scl + ', ' + pin_sio + ', ' + pin_csa + ', ' + pin_csm + ');\n';
+ Blockly.propc.global_vars_["lsm9ds1_vars"] = 'float __imuX, __imuY, __imuZ, __compI;\n';
return '';
};
-Blockly.propc.colorpal_get_colors_raw = function () {
- var r = Blockly.propc.variableDB_.getName(this.getFieldValue('R_STORAGE'), Blockly.Variables.NAME_TYPE);
- var g = Blockly.propc.variableDB_.getName(this.getFieldValue('G_STORAGE'), Blockly.Variables.NAME_TYPE);
- var b = Blockly.propc.variableDB_.getName(this.getFieldValue('B_STORAGE'), Blockly.Variables.NAME_TYPE);
+Blockly.Blocks.lsm9ds1_read = {
+ helpUrl: Blockly.MSG_IMU_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_LSM9DS1_READ_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("IMU read")
+ .appendField(new Blockly.FieldDropdown([["accelerometer (g-100ths)", "Accel"], ["gyroscope (DPS-100ths)", "Gyro"], ["magnetometer (gauss-100ths)", "Mag"]]), "SENSOR")
+ .appendField("store X-axis in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'X_VAR')
+ .appendField(" y-axis in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'Y_VAR')
+ .appendField(" z-axis in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'Z_VAR');
+ this.setInputsInline(false);
+ this.setNextStatement(true, null);
+ this.setPreviousStatement(true, null);
+ },
+ getVars: function () {
+ return [this.getFieldValue('X_VAR'), this.getFieldValue('Y_VAR'), this.getFieldValue('Z_VAR')];
+ },
+ renameVar: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getFieldValue('X_VAR'))) {
+ this.setTitleValue(newName, 'X_VAR');
+ } else if (Blockly.Names.equals(oldName, this.getFieldValue('Y_VAR'))) {
+ this.setTitleValue(newName, 'Y_VAR');
+ } else if (Blockly.Names.equals(oldName, this.getFieldValue('Z_VAR'))) {
+ this.setTitleValue(newName, 'Z_VAR');
+ }
+ }
+};
- return 'colorPal_getRGB(cpal, &' + r + ', &' + g + ', &' + b + ');';
+Blockly.propc.lsm9ds1_read = function () {
+ var sensor = this.getFieldValue('SENSOR');
+ var xstorage = Blockly.propc.variableDB_.getName(this.getFieldValue('X_VAR'), Blockly.Variables.NAME_TYPE);
+ var ystorage = Blockly.propc.variableDB_.getName(this.getFieldValue('Y_VAR'), Blockly.Variables.NAME_TYPE);
+ var zstorage = Blockly.propc.variableDB_.getName(this.getFieldValue('Z_VAR'), Blockly.Variables.NAME_TYPE);
+
+ var code = '';
+ if(Blockly.propc.definitions_["include_lsm9ds1"] === '#include "lsm9ds1.h"') {
+ code += 'imu_read' + sensor + 'Calculated(&__imuX, &__imuY, &__imuZ);\n';
+ code += xstorage + ' = (int) (100.0 * __imuX);\n';
+ code += ystorage + ' = (int) (100.0 * __imuY);\n';
+ code += zstorage + ' = (int) (100.0 * __imuZ);\n';
+ } else {
+ code += "// LSM9DS1 IMU is not initialized!\n";
+ }
+
+ return code;
};
-Blockly.propc.colorpal_get_colors = function () {
- var color_var = Blockly.propc.variableDB_.getName(this.getFieldValue('COLOR'), Blockly.Variables.NAME_TYPE);
+Blockly.Blocks.lsm9ds1_tilt = {
+ helpUrl: Blockly.MSG_IMU_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_LSM9DS1_TILT_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("IMU tilt along ")
+ .appendField(new Blockly.FieldDropdown([["x-axis", "__imuX"], ["y-axis", "__imuY"], ["z-axis", "__imuZ"]]), "T_AXIS")
+ .appendField("gravity pulls along ")
+ .appendField(new Blockly.FieldDropdown([["z-axis", "__imuZ"], ["x-axis", "__imuX"], ["y-axis", "__imuY"]]), "G_AXIS")
+ .appendField("store in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VAR');
+ this.setInputsInline(false);
+ this.setNextStatement(true, null);
+ this.setPreviousStatement(true, null);
+ },
+ getVars: function () {
+ return [this.getFieldValue('VAR')];
+ },
+ renameVar: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
+ this.setTitleValue(newName, 'VAR');
+ }
+ }
+};
- Blockly.propc.global_vars_["colorpal_rr"] = 'int cpRR = 0;';
- Blockly.propc.global_vars_["colorpal_gg"] = 'int cpGG = 0;';
- Blockly.propc.global_vars_["colorpal_bb"] = 'int cpBB = 0;';
+Blockly.propc.lsm9ds1_tilt = function () {
+ var t_axis = this.getFieldValue('T_AXIS');
+ var g_axis = this.getFieldValue('G_AXIS');
+ var storage = Blockly.propc.variableDB_.getName(this.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE);
- var code = 'colorPal_getRGB(cpal, &cpRR, &cpGG, &cpBB);\n\t' + color_var + ' = colorPalRRGGBB(cpRR, cpGG, cpBB);';
+ var code = '';
+ if(Blockly.propc.definitions_["include_lsm9ds1"] === '#include "lsm9ds1.h"') {
+ code += 'imu_readAccelCalculated(&__imuX, &__imuY, &__imuZ);\n';
+ code += storage + ' = (int) (atan2(' + t_axis + ', ' + g_axis + ') * 180.0/PI);\n';
+ } else {
+ code += "// LSM9DS1 IMU is not initialized!\n";
+ }
+
+ return code;
+};
+
+Blockly.Blocks.lsm9ds1_heading = {
+ helpUrl: Blockly.MSG_IMU_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_LSM9DS1_HEADING_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("IMU heading")
+ .appendField(new Blockly.FieldDropdown([["Z-axis points forward", "__imuZ"], ["Z-axis points backward", "(-1.0*__imuZ)"], ["Y-axis points forward", "__imuY"], ["Y axis points backward", "(-1.0*__imuY)"], ["X-axis points forward", "(-1.0*__imuX)"], ["X-axis points backward", "__imuX"]]), "FB_AXIS")
+ .appendField(new Blockly.FieldDropdown([["Y-axis points left", "__imuY"], ["Y-axis points right", "(-1.0*__imuY)"], ["X-axis points left", "(-1.0*__imuX)"], ["X-axis points right", "__imuX"], ["Z-axis points left", "__imuZ"], ["Z-axis points right", "(-1.0*__imuZ)"]]), "LR_AXIS")
+ .appendField("store in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VAR');
+ this.setInputsInline(false);
+ this.setNextStatement(true, null);
+ this.setPreviousStatement(true, null);
+ },
+ getVars: function () {
+ return [this.getFieldValue('VAR')];
+ },
+ renameVar: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
+ this.setTitleValue(newName, 'VAR');
+ }
+ }
+};
+
+Blockly.propc.lsm9ds1_heading = function () {
+ var fb_axis = this.getFieldValue('FB_AXIS');
+ var lr_axis = this.getFieldValue('LR_AXIS');
+ var storage = Blockly.propc.variableDB_.getName(this.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE);
+
+ var code = '';
+ if(Blockly.propc.definitions_["include_lsm9ds1"] === '#include "lsm9ds1.h"') {
+ code += 'imu_readMagCalculated(&__imuX, &__imuY, &__imuZ);\n';
+ code += '__compI = atan2(' + lr_axis + ', ' + fb_axis + ') * 180.0/PI;\n';
+ code += 'if(__compI < 0.0) __compI = (360.0 + __compI);\n';
+ code += storage + ' = (int) __compI;\n';
+ } else {
+ code += "// LSM9DS1 IMU is not initialized!\n";
+ }
+
+ return code;
+};
+
+// ------------------ GPS (PAM7Q module) Blocks --------------------------------
+Blockly.Blocks.PAM_7Q_Init = {
+ init: function () {
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("PAM7Q GPS Module");
+ this.appendDummyInput()
+ .appendField("RX pin#")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "RXPIN");
+ this.appendDummyInput()
+ .appendField("TX pin#")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "TXPIN");
+ this.appendDummyInput()
+ .appendField("baud")
+ .appendField(new Blockly.FieldDropdown([["2400", "2400"], ["9600", "9600"], ["19200", "19200"]]), "BAUD");
+
+ this.setNextStatement(true, null);
+ this.setPreviousStatement(true, null);
+ }
+};
+
+Blockly.propc.PAM_7Q_Init = function() {
+ var rx_pin = this.getFieldValue('RXPIN');
+ var tx_pin = this.getFieldValue('TXPIN');
+ var baud = this.getFieldValue('BAUD');
+
+ Blockly.propc.definitions_["include PAM7Q"] = '#include "gps.h"';
+
+ var code = 'gps_open(' + rx_pin + ', ' + tx_pin + ', ' + baud + ');\npause(100)';
+ return code;
+};
+
+Blockly.Blocks.PAM_7Q_Latitude = {
+ init: function () {
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("get latitude");
+
+ this.setOutput(true, 'Number');
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ }
+};
+
+Blockly.propc.PAM_7Q_Latitude = function() {
+ Blockly.propc.definitions_["include PAM7Q"] = '#include "gps.h"';
+
+ var code = 'gps_latitude()';
return code;
};
+
+Blockly.Blocks.PAM_7Q_Longitude = {
+ init: function () {
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("get longitude");
+
+ this.setOutput(true, 'Number');
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ }
+};
+
+Blockly.propc.PAM_7Q_Longitude = function() {
+ Blockly.propc.definitions_["include PAM7Q"] = '#include "gps.h"';
+
+ var code = 'gps_longitude()';
+ return code;
+};
+
+Blockly.Blocks.PAM_7Q_Heading = {
+ init: function () {
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("get heading");
+
+ this.setOutput(true, 'Number');
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ }
+};
+
+Blockly.propc.PAM_7Q_Heading = function() {
+ Blockly.propc.definitions_["include PAM7Q"] = '#include "gps.h"';
+
+ var code = '(int)gps_heading()';
+ return code;
+};
+
+Blockly.Blocks.PAM_7Q_Altitude = {
+ init: function () {
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("get altitude");
+
+ this.setOutput(true, 'Number');
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ }
+};
+
+Blockly.propc.PAM_7Q_Altitude = function() {
+ Blockly.propc.definitions_["include PAM7Q"] = '#include "gps.h"';
+
+ var code = 'gps_altitude()';
+ return code;
+};
+
+Blockly.Blocks.PAM_7Q_SatsTracked = {
+ init: function () {
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("get # of satellites tracked");
+
+ this.setOutput(true, 'Number');
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ }
+};
+
+Blockly.propc.PAM_7Q_SatsTracked = function() {
+ Blockly.propc.definitions_["include PAM7Q"] = '#include "gps.h"';
+
+ var code = 'gps_satsTracked()';
+ return code;
+};
+
+Blockly.Blocks.PAM_7Q_Velocity = {
+ init: function () {
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("get velocity in units")
+ .appendField(new Blockly.FieldDropdown([["mph", "MPH"], ["knots", "KNOTS"]]), "VELOCITYUNITS");
+
+ this.setOutput(true, 'Number');
+ this.setNextStatement(false, null);
+ this.setPreviousStatement(false, null);
+ }
+};
+
+Blockly.propc.PAM_7Q_Velocity = function() {
+ var velocity_units = this.getFieldValue('VELOCITYUNITS');
+
+ Blockly.propc.definitions_["include PAM7Q"] = '#include "gps.h"';
+
+ var code = 'gps_velocity(' + velocity_units + ')';
+ return code;
+};
+
+// ------------------ RFID Reader Blocks ---------------------------------------
+Blockly.Blocks.rfid_get = {
+ helpUrl: Blockly.MSG_RFID_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_RFID_GET_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("RFID store reading in")
+ .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'BUFFER');
+
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ },
+ getVars: function () {
+ return [this.getFieldValue('BUFFER')];
+ },
+ renameVar: function (oldName, newName) {
+ if (Blockly.Names.equals(oldName, this.getFieldValue('BUFFER'))) {
+ this.setTitleValue(newName, 'BUFFER');
+ }
+ }
+};
+
+Blockly.propc.rfid_get = function() {
+ var saveVariable = Blockly.propc.variableDB_.getName(this.getFieldValue('BUFFER'), Blockly.Variables.NAME_TYPE);
+
+ Blockly.propc.global_vars_["rfid_buffer"] = "char *rfidBfr;";
+ Blockly.propc.definitions_["rfidser"] = '#include "rfidser.h"';
+
+ var code = 'rfidBfr = rfid_get(rfid, 500);\n\tsscan(&rfidBfr[2], "%x", &' + saveVariable + ');\n\tif(' + saveVariable + ' == 237) ' + saveVariable + ' = 0;';
+ return code;
+};
+
+Blockly.Blocks.rfid_disable = {
+ helpUrl: Blockly.MSG_RFID_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_RFID_DISABLE_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("RFID")
+ .appendField(new Blockly.FieldDropdown([
+ ["disable", "DISABLE"],
+ ["enable", "ENABLE"]
+ ]), "ACTION");
+
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.rfid_disable = function() {
+ var data = this.getFieldValue('ACTION');
+ Blockly.propc.definitions_["rfidser"] = '#include "rfidser.h"';
+
+ if(data === "ENABLE") {
+ return 'rfid_enable(rfid);';
+ } else {
+ return 'rfid_disable(rfid);';
+ }
+};
+
+Blockly.Blocks.rfid_enable = {
+ helpUrl: Blockly.MSG_RFID_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_RFID_ENABLE_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("RFID initialize EN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN_IN");
+ this.appendDummyInput()
+ .appendField("SOUT")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN_OUT");
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.rfid_enable = function() {
+ var pin_in = this.getFieldValue('PIN_IN');
+ var pin_out = this.getFieldValue('PIN_OUT');
+
+ Blockly.propc.definitions_["rfidser"] = '#include "rfidser.h"';
+ Blockly.propc.global_vars_["rfidser"] = 'rfidser *rfid;';
+ Blockly.propc.setups_["rfidser_setup"] = 'rfid = rfid_open(' + pin_out + ',' + pin_in + ');';
+
+ return '';
+};
+
+Blockly.Blocks.rfid_close = {
+ helpUrl: Blockly.MSG_RFID_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_RFID_CLOSE_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("RFID close");
+
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ }
+};
+
+Blockly.propc.rfid_close = function() {
+ Blockly.propc.definitions_["rfidser"] = '#include "rfidser.h"';
+
+ return 'rfidser_close(rfid);\n';
+};
+
+// ------------------ Sony TV Remote (Using 40 kHz IR sensor) Blocks -----------
+Blockly.Blocks.sirc_get = {
+ helpUrl: Blockly.MSG_SONY_REMOTE_HELPURL,
+ init: function() {
+ this.setTooltip(Blockly.MSG_SIRC_GET_TOOLTIP);
+ this.setColour(colorPalette.getColor('input'));
+ this.appendDummyInput()
+ .appendField("Sony Remote value received from PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
+
+ this.setInputsInline(true);
+ this.setPreviousStatement(false, null);
+ this.setNextStatement(false, null);
+ this.setOutput(true, 'Number');
+ }
+};
+
+Blockly.propc.sirc_get = function() {
+ var pin = this.getFieldValue('PIN');
+
+ Blockly.propc.definitions_["sirc"] = '#include "sirc.h"';
+ Blockly.propc.setups_["sirc"] = "sirc_setTimeout(70);\n";
+
+ var code = 'sirc_button(' + pin + ')';
+ return [code, Blockly.propc.ORDER_NONE];
+};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/serial.js b/src/main/webapp/cdn/blockly/generators/propc/serial.js
deleted file mode 100644
index 405926ac..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/serial.js
+++ /dev/null
@@ -1,227 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2014 Michel Lampo.
- *
- *
- * 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.
- */
-
-/**
- * @fileoverview Generating Prop-C for basic blocks.
- * @author michel@creatingfuture.eu (Michel Lampo)
- */
-'use strict';
-
-//define blocks
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-Blockly.Blocks.serial_open = {
- helpUrl: Blockly.MSG_PROTOCOLS_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_SERIAL_OPEN_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("Serial initialize RX")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "RXPIN")
- .appendField("TX")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "TXPIN");
- this.appendDummyInput()
- .appendField("baud")
- .appendField(new Blockly.FieldDropdown([["2400", "2400"], ["4800", "4800"], ["9600", "9600"], ["19200", "19200"], ["57600", "57600"], ["115200", "115200"]]), "BAUD");
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.serial_tx = {
- helpUrl: Blockly.MSG_PROTOCOLS_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_SERIAL_TX_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("Serial transmit")
- .appendField(new Blockly.FieldDropdown([
- ["number (32-bit integer)", "INT"],
- ["byte (ASCII character)", "BYTE"]
- ]), "TYPE");
- this.appendValueInput('VALUE', Number)
- .setCheck(null);
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.serial_send_text = {
- helpUrl: Blockly.MSG_PROTOCOLS_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_SERIAL_SEND_TEXT_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendValueInput('VALUE')
- .appendField("Serial transmit text")
- .setCheck('String');
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.serial_rx = {
- helpUrl: Blockly.MSG_PROTOCOLS_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_SERIAL_RX_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("Serial receive")
- .appendField(new Blockly.FieldDropdown([
- ["number (32-bit integer)", "INT"],
- ["byte (ASCII character)", "BYTE"]
- ]), "TYPE")
- .appendField("store in")
- .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VALUE');
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- },
- getVars: function () {
- return [this.getFieldValue('VALUE')];
- },
- renameVar: function (oldName, newName) {
- if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
- this.setTitleValue(newName, 'VALUE');
- }
- }
-};
-
-Blockly.Blocks.serial_receive_text = {
- helpUrl: Blockly.MSG_PROTOCOLS_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_SERIAL_RECEIVE_TEXT_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("Serial receive text store in")
- .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VALUE');
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- },
- getVars: function () {
- return [this.getFieldValue('VALUE')];
- },
- renameVar: function (oldName, newName) {
- if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
- this.setTitleValue(newName, 'VALUE');
- }
- }
-};
-
-Blockly.propc.serial_open = function () {
- var dropdown_rx_pin = this.getFieldValue('RXPIN');
- var dropdown_tx_pin = this.getFieldValue('TXPIN');
- var baud = this.getFieldValue('BAUD');
-
- Blockly.propc.definitions_["include fdserial"] = '#include "fdserial.h"';
- Blockly.propc.definitions_["var fdserial"] = 'fdserial *fdser;';
- Blockly.propc.setups_['setup_fdserial'] = 'fdser = fdserial_open(' + dropdown_rx_pin + ', ' + dropdown_tx_pin + ', 0, ' + baud + ');';
-
- return '';
-};
-
-Blockly.propc.serial_tx = function () {
- var type = this.getFieldValue('TYPE');
- var data = Blockly.propc.valueToCode(this, 'VALUE', Blockly.propc.ORDER_ATOMIC) || '0';
-
- if (Blockly.propc.setups_["setup_fdserial"] === undefined)
- {
- return '//Missing new serial port declaration\n';
- }
-
- if(type === "BYTE") {
- return 'fdserial_txChar(fdser, (' + data + ' & 0xFF) );\n';
- } else {
- var code = 'fdserial_txChar(fdser, (' + data + ' >> 24) & 255);\n';
- code += 'fdserial_txChar(fdser, (' + data + ' >> 16) & 255);\n';
- code += 'fdserial_txChar(fdser, (' + data + ' >> 8 ) & 255);\n';
- code += 'fdserial_txChar(fdser, ' + data + ' & 255);\n';
-
- return code;
- }
-};
-
-Blockly.propc.serial_send_text = function () {
- var text = Blockly.propc.valueToCode(this, 'VALUE', Blockly.propc.ORDER_NONE);
-
- if (Blockly.propc.setups_['setup_fdserial'] === undefined) {
- return '//Missing new serial port declaration\n';
- }
-
- var code = 'dprint(fdser, "%s", ' + text + ');\n';
- //code += 'fdserial_txChar(fdser, 0 );\n';
- code += 'while(!fdserial_txEmpty(fdser));\n';
- code += 'pause(5);\n';
-
- return code;
-};
-
-Blockly.propc.serial_rx = function () {
- var type = this.getFieldValue('TYPE');
- var data = Blockly.propc.variableDB_.getName(this.getFieldValue('VALUE'), Blockly.Variables.NAME_TYPE);
-
- if (Blockly.propc.setups_["setup_fdserial"] === undefined)
- {
- return '//Missing new serial port declaration\n';
- }
-
- if(data !== '') {
- if(type === "BYTE") {
- return data + ' = fdserial_rxChar(fdser);\n';
- } else {
- return data + ' = (fdserial_rxChar(fdser) << 24) | (fdserial_rxChar(fdser) << 16) | (fdserial_rxChar(fdser) << 8) | fdserial_rxChar(fdser);\n';
- }
- } else {
- return '';
- }
-};
-
-Blockly.propc.serial_receive_text = function () {
- var data = Blockly.propc.variableDB_.getName(this.getFieldValue('VALUE'), Blockly.Variables.NAME_TYPE);
- Blockly.propc.global_vars_["ser_rx"] = "int __idx;";
-
- //var varName = Blockly.propc.variableDB_.getName(this.getFieldValue('VALUE'),
- // Blockly.Variables.NAME_TYPE);
-
- Blockly.propc.vartype_[data] = 'char *';
-
- if (Blockly.propc.setups_["setup_fdserial"] === undefined)
- {
- return '//Missing new serial port declaration\n';
- }
-
- if(data !== '') {
- var code = '__idx = 0;\n';
- code += 'do {\n';
- code += ' ' + data + '[__idx] = fdserial_rxChar(fdser);\n';
- code += ' __idx++;\n';
- code += '} while(fdserial_rxPeek(fdser) != 0);\n';
- code += data + '[__idx] = 0;\nfdserial_rxFlush(fdser);\n';
-
- return code;
- } else {
- return '';
- }
-};
\ No newline at end of file
diff --git a/src/main/webapp/cdn/blockly/generators/propc/servo.js b/src/main/webapp/cdn/blockly/generators/propc/servo.js
deleted file mode 100644
index 43444640..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/servo.js
+++ /dev/null
@@ -1,308 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2014 Michel Lampo
- * https://github.com/gasolin/BlocklyDuino
- *
- * 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.
- */
-
-/**
- * @fileoverview Generating C for servo blocks.
- * @author michel@creatingfuture.eu (Michel Lampo)
- * @author valetolpegin@gmail.com (Vale Tolpegin)
- */
-'use strict';
-
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-Blockly.Blocks.servo_move = {
- helpUrl: Blockly.MSG_SERVO_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_SERVO_MOVE_TOOLTIP);
- this.setColour(colorPalette.getColor('output'));
- this.appendDummyInput()
- .appendField("Servo PIN")
- .setAlign(Blockly.ALIGN_RIGHT)
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
- this.appendValueInput("ANGLE")
- .appendField("set angle (0-180\u00B0)")
- .setCheck("Number");
-// this.appendDummyInput()
-// .appendField(new Blockly.FieldAngle(90), 'ANGLE')
-// .setCheck("Number");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- //},
- //onchange: function(event) {
- // if (event.type === Blockly.Events.CHANGE && event.element === 'field') {
- // if ((event.newValue < 0) || (event.newValue > 180)) {
- // alert("WARNING: The value for the angle must be between 0 and 180 degrees.");
- // }
- // }
- }
-};
-
-Blockly.Blocks.servo_speed = {
- helpUrl: Blockly.MSG_SERVO_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_SERVO_SPEED_TOOLTIP);
- this.setColour(colorPalette.getColor('output'));
- this.appendDummyInput()
- .appendField("CR Servo PIN")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), 'PIN');
- this.appendValueInput("SPEED")
- .appendField("speed")
-// .appendField(new Blockly.FieldDropdown([["-1", "-1"], ["-2", "-2"], ["-3", "-3"], ["-4", "-4"], ["-5", "-5"], ["-6", "-6"], ["-7", "-7"], ["-8", "-8"], ["-9", "-9"], ["-10", "-10"], ["-11", "-11"], ["-12", "-12"], ["-13", "-13"], ["-14", "-14"], ["-15", "-15"], ["-16", "-16"], ["-17", "-17"], ["-18", "-18"], ["-19", "-19"], ["-20", "-20"], ["-21", "-21"], ["-22", "-22"], ["-23", "-23"], ["-24", "-24"], ["-25", "-25"], ["-26", "-26"], ["-27", "-27"], ["-28", "-28"], ["-29", "-29"], ["-30", "-30"], ["-31", "-31"], ["-32", "-32"], ["-33", "-33"], ["-34", "-34"], ["-35", "-35"], ["-36", "-36"], ["-37", "-37"], ["-38", "-38"], ["-39", "-39"], ["-40", "-40"], ["-41", "-41"], ["-42", "-42"], ["-43", "-43"], ["-44", "-44"], ["-45", "-45"], ["-46", "-46"], ["-47", "-47"], ["-48", "-48"], ["-49", "-49"], ["-50", "-50"], ["-51", "-51"], ["-52", "-52"], ["-53", "-53"], ["-54", "-54"], ["-55", "-55"], ["-56", "-56"], ["-57", "-57"], ["-58", "-58"], ["-59", "-59"], ["-60", "-60"], ["-61", "-61"], ["-62", "-62"], ["-63", "-63"], ["-64", "-64"], ["-65", "-65"], ["-66", "-66"], ["-67", "-67"], ["-68", "-68"], ["-69", "-69"], ["-70", "-70"], ["-71", "-71"], ["-72", "-72"], ["-73", "-73"], ["-74", "-74"], ["-75", "-75"], ["-76", "-76"], ["-77", "-77"], ["-78", "-78"], ["-79", "-79"], ["-80", "-80"], ["-81", "-81"], ["-82", "-82"], ["-83", "-83"], ["-84", "-84"], ["-85", "-85"], ["-86", "-86"], ["-87", "-87"], ["-88", "-88"], ["-89", "-89"], ["-90", "-90"], ["-91", "-91"], ["-92", "-92"], ["-93", "-93"], ["-94", "-94"], ["-95", "-95"], ["-96", "-96"], ["-97", "-97"], ["-98", "-98"], ["-99", "-99"], ["-100", "-100"], ["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"], ["32", "32"], ["33", "33"], ["34", "34"], ["35", "35"], ["36", "36"], ["37", "37"], ["38", "38"], ["39", "39"], ["40", "40"], ["41", "41"], ["42", "42"], ["43", "43"], ["44", "44"], ["45", "45"], ["46", "46"], ["47", "47"], ["48", "48"], ["49", "49"], ["50", "50"], ["51", "51"], ["52", "52"], ["53", "53"], ["54", "54"], ["55", "55"], ["56", "56"], ["57", "57"], ["58", "58"], ["59", "59"], ["60", "60"], ["61", "61"], ["62", "62"], ["63", "63"], ["64", "64"], ["65", "65"], ["66", "66"], ["67", "67"], ["68", "68"], ["69", "69"], ["70", "70"], ["71", "71"], ["72", "72"], ["73", "73"], ["74", "74"], ["75", "75"], ["76", "76"], ["77", "77"], ["78", "78"], ["79", "79"], ["80", "80"], ["81", "81"], ["82", "82"], ["83", "83"], ["84", "84"], ["85", "85"], ["86", "86"], ["87", "87"], ["88", "88"], ["89", "89"], ["90", "90"], ["91", "91"], ["92", "92"], ["93", "93"], ["94", "94"], ["95", "95"], ["96", "96"], ["97", "97"], ["98", "98"], ["99", "99"], ["100", "100"]]), 'SPEED');
- .setCheck("Number");
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.servo_set_ramp = {
- helpUrl: Blockly.MSG_SERVO_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_SERVO_SET_RAMP_TOOLTIP);
- this.setColour(colorPalette.getColor('output'));
- this.appendDummyInput()
- .appendField("CR Servo set ramp PIN")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), 'PIN');
- this.appendValueInput('RAMPSTEP')
- .appendField("rampstep (0 - 100)")
- .setCheck('Number');
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.servodiffdrive_library_drive_pins = {
- init: function () {
- this.setColour(colorPalette.getColor('output'));
- this.appendDummyInput()
- .appendField("Drive setup")
- .appendField("left PIN")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), 'LEFT_PIN');
- this.appendDummyInput()
- .appendField("right PIN")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), 'RIGHT_PIN');
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.servodiffdrive_library_drive_speed = {
- init: function () {
- this.setColour(colorPalette.getColor('output'));
- this.appendDummyInput()
- .appendField("Drive set")
- .appendField("left speed")
- .appendField(new Blockly.FieldDropdown([["-1", "-1"], ["-2", "-2"], ["-3", "-3"], ["-4", "-4"], ["-5", "-5"], ["-6", "-6"], ["-7", "-7"], ["-8", "-8"], ["-9", "-9"], ["-10", "-10"], ["-11", "-11"], ["-12", "-12"], ["-13", "-13"], ["-14", "-14"], ["-15", "-15"], ["-16", "-16"], ["-17", "-17"], ["-18", "-18"], ["-19", "-19"], ["-20", "-20"], ["-21", "-21"], ["-22", "-22"], ["-23", "-23"], ["-24", "-24"], ["-25", "-25"], ["-26", "-26"], ["-27", "-27"], ["-28", "-28"], ["-29", "-29"], ["-30", "-30"], ["-31", "-31"], ["-32", "-32"], ["-33", "-33"], ["-34", "-34"], ["-35", "-35"], ["-36", "-36"], ["-37", "-37"], ["-38", "-38"], ["-39", "-39"], ["-40", "-40"], ["-41", "-41"], ["-42", "-42"], ["-43", "-43"], ["-44", "-44"], ["-45", "-45"], ["-46", "-46"], ["-47", "-47"], ["-48", "-48"], ["-49", "-49"], ["-50", "-50"], ["-51", "-51"], ["-52", "-52"], ["-53", "-53"], ["-54", "-54"], ["-55", "-55"], ["-56", "-56"], ["-57", "-57"], ["-58", "-58"], ["-59", "-59"], ["-60", "-60"], ["-61", "-61"], ["-62", "-62"], ["-63", "-63"], ["-64", "-64"], ["-65", "-65"], ["-66", "-66"], ["-67", "-67"], ["-68", "-68"], ["-69", "-69"], ["-70", "-70"], ["-71", "-71"], ["-72", "-72"], ["-73", "-73"], ["-74", "-74"], ["-75", "-75"], ["-76", "-76"], ["-77", "-77"], ["-78", "-78"], ["-79", "-79"], ["-80", "-80"], ["-81", "-81"], ["-82", "-82"], ["-83", "-83"], ["-84", "-84"], ["-85", "-85"], ["-86", "-86"], ["-87", "-87"], ["-88", "-88"], ["-89", "-89"], ["-90", "-90"], ["-91", "-91"], ["-92", "-92"], ["-93", "-93"], ["-94", "-94"], ["-95", "-95"], ["-96", "-96"], ["-97", "-97"], ["-98", "-98"], ["-99", "-99"], ["-100", "-100"], ["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"], ["32", "32"], ["33", "33"], ["34", "34"], ["35", "35"], ["36", "36"], ["37", "37"], ["38", "38"], ["39", "39"], ["40", "40"], ["41", "41"], ["42", "42"], ["43", "43"], ["44", "44"], ["45", "45"], ["46", "46"], ["47", "47"], ["48", "48"], ["49", "49"], ["50", "50"], ["51", "51"], ["52", "52"], ["53", "53"], ["54", "54"], ["55", "55"], ["56", "56"], ["57", "57"], ["58", "58"], ["59", "59"], ["60", "60"], ["61", "61"], ["62", "62"], ["63", "63"], ["64", "64"], ["65", "65"], ["66", "66"], ["67", "67"], ["68", "68"], ["69", "69"], ["70", "70"], ["71", "71"], ["72", "72"], ["73", "73"], ["74", "74"], ["75", "75"], ["76", "76"], ["77", "77"], ["78", "78"], ["79", "79"], ["80", "80"], ["81", "81"], ["82", "82"], ["83", "83"], ["84", "84"], ["85", "85"], ["86", "86"], ["87", "87"], ["88", "88"], ["89", "89"], ["90", "90"], ["91", "91"], ["92", "92"], ["93", "93"], ["94", "94"], ["95", "95"], ["96", "96"], ["97", "97"], ["98", "98"], ["99", "99"], ["100", "100"]]), 'LEFT_SPEED');
- this.appendDummyInput()
- .appendField("right speed")
- .appendField(new Blockly.FieldDropdown([["-1", "-1"], ["-2", "-2"], ["-3", "-3"], ["-4", "-4"], ["-5", "-5"], ["-6", "-6"], ["-7", "-7"], ["-8", "-8"], ["-9", "-9"], ["-10", "-10"], ["-11", "-11"], ["-12", "-12"], ["-13", "-13"], ["-14", "-14"], ["-15", "-15"], ["-16", "-16"], ["-17", "-17"], ["-18", "-18"], ["-19", "-19"], ["-20", "-20"], ["-21", "-21"], ["-22", "-22"], ["-23", "-23"], ["-24", "-24"], ["-25", "-25"], ["-26", "-26"], ["-27", "-27"], ["-28", "-28"], ["-29", "-29"], ["-30", "-30"], ["-31", "-31"], ["-32", "-32"], ["-33", "-33"], ["-34", "-34"], ["-35", "-35"], ["-36", "-36"], ["-37", "-37"], ["-38", "-38"], ["-39", "-39"], ["-40", "-40"], ["-41", "-41"], ["-42", "-42"], ["-43", "-43"], ["-44", "-44"], ["-45", "-45"], ["-46", "-46"], ["-47", "-47"], ["-48", "-48"], ["-49", "-49"], ["-50", "-50"], ["-51", "-51"], ["-52", "-52"], ["-53", "-53"], ["-54", "-54"], ["-55", "-55"], ["-56", "-56"], ["-57", "-57"], ["-58", "-58"], ["-59", "-59"], ["-60", "-60"], ["-61", "-61"], ["-62", "-62"], ["-63", "-63"], ["-64", "-64"], ["-65", "-65"], ["-66", "-66"], ["-67", "-67"], ["-68", "-68"], ["-69", "-69"], ["-70", "-70"], ["-71", "-71"], ["-72", "-72"], ["-73", "-73"], ["-74", "-74"], ["-75", "-75"], ["-76", "-76"], ["-77", "-77"], ["-78", "-78"], ["-79", "-79"], ["-80", "-80"], ["-81", "-81"], ["-82", "-82"], ["-83", "-83"], ["-84", "-84"], ["-85", "-85"], ["-86", "-86"], ["-87", "-87"], ["-88", "-88"], ["-89", "-89"], ["-90", "-90"], ["-91", "-91"], ["-92", "-92"], ["-93", "-93"], ["-94", "-94"], ["-95", "-95"], ["-96", "-96"], ["-97", "-97"], ["-98", "-98"], ["-99", "-99"], ["-100", "-100"], ["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"], ["11", "11"], ["12", "12"], ["13", "13"], ["14", "14"], ["15", "15"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"], ["24", "24"], ["25", "25"], ["26", "26"], ["27", "27"], ["28", "28"], ["29", "29"], ["30", "30"], ["31", "31"], ["32", "32"], ["33", "33"], ["34", "34"], ["35", "35"], ["36", "36"], ["37", "37"], ["38", "38"], ["39", "39"], ["40", "40"], ["41", "41"], ["42", "42"], ["43", "43"], ["44", "44"], ["45", "45"], ["46", "46"], ["47", "47"], ["48", "48"], ["49", "49"], ["50", "50"], ["51", "51"], ["52", "52"], ["53", "53"], ["54", "54"], ["55", "55"], ["56", "56"], ["57", "57"], ["58", "58"], ["59", "59"], ["60", "60"], ["61", "61"], ["62", "62"], ["63", "63"], ["64", "64"], ["65", "65"], ["66", "66"], ["67", "67"], ["68", "68"], ["69", "69"], ["70", "70"], ["71", "71"], ["72", "72"], ["73", "73"], ["74", "74"], ["75", "75"], ["76", "76"], ["77", "77"], ["78", "78"], ["79", "79"], ["80", "80"], ["81", "81"], ["82", "82"], ["83", "83"], ["84", "84"], ["85", "85"], ["86", "86"], ["87", "87"], ["88", "88"], ["89", "89"], ["90", "90"], ["91", "91"], ["92", "92"], ["93", "93"], ["94", "94"], ["95", "95"], ["96", "96"], ["97", "97"], ["98", "98"], ["99", "99"], ["100", "100"]]), 'RIGHT_SPEED');
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.servodiffdrive_library_drive_setRamp = {
- init: function () {
- this.setColour(colorPalette.getColor('output'));
- this.appendDummyInput()
- .appendField("Drive ramping")
- .appendField("left ramp")
- .appendField(new Blockly.FieldDropdown([["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"]]), 'LEFT_RAMP');
- this.appendDummyInput()
- .appendField("right ramp")
- .appendField(new Blockly.FieldDropdown([["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["8", "8"], ["9", "9"], ["10", "10"]]), 'RIGHT_RAMP');
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.servodiffdrive_library_drive_sleep = {
- init: function () {
- this.setColour(colorPalette.getColor('output'));
- this.appendDummyInput()
- .appendField("Drive sleep");
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.servodiffdrive_library_drive_stop = {
- init: function () {
- this.setColour(colorPalette.getColor('output'));
- this.appendDummyInput()
- .appendField("Drive stop");
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.pwm_start = {
- helpUrl: Blockly.MSG_ANALOG_PWM_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_PWM_START_TOOLTIP);
- this.setColour(colorPalette.getColor('io'));
- this.appendDummyInput()
- .appendField("PWM initialize");
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.pwm_set = {
- helpUrl: Blockly.MSG_ANALOG_PWM_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_PWM_SET_TOOLTIP);
- this.setColour(colorPalette.getColor('io'));
- this.appendDummyInput()
- .appendField("PWM set PIN")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
- this.appendDummyInput()
- .appendField("channel")
- .appendField(new Blockly.FieldDropdown([["A", "0"], ["B", "1"]]), "CHANNEL");
- this.appendValueInput("DUTY_CYCLE", Number)
- .setCheck('Number')
- .appendField("duty cycle (0 - 100)");
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.pwm_stop = {
- helpUrl: Blockly.MSG_ANALOG_PWM_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_PWM_STOP_TOOLTIP);
- this.setColour(colorPalette.getColor('io'));
- this.appendDummyInput()
- .appendField("PWM stop");
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.propc.servo_move = function () {
- var dropdown_pin = this.getFieldValue('PIN');
-// var degrees = Blockly.propc.valueToCode(this, 'DEGREES', Blockly.propc.ORDER_NONE);
- var degrees = Blockly.propc.valueToCode(this, 'ANGLE', Blockly.propc.ORDER_NONE);
-
- Blockly.propc.definitions_["include servo"] = '#include "servo.h"';
- if (degrees < 0) {
- degrees = 0;
- }
- if (degrees > 180) {
- degrees = 180;
- }
- var code = 'servo_angle(' + dropdown_pin + ', ' + degrees + ' * 10);\n';
- return code;
-};
-
-
-Blockly.propc.servo_speed = function () {
- var pin = this.getFieldValue('PIN');
- var speed = Blockly.propc.valueToCode(this, 'SPEED', Blockly.propc.ORDER_NONE);
-
- Blockly.propc.definitions_["include servo"] = '#include "servo.h"';
-
- return 'servo_speed(' + pin + ', ' + speed + ');\n';
-};
-
-Blockly.propc.servo_set_ramp = function () {
- var pin = this.getFieldValue('PIN');
- var ramp_step = Blockly.propc.valueToCode(this, 'RAMPSTEP', Blockly.propc.ORDER_NONE);
-
- if (Number(ramp_step) < 0) {
- ramp_step = "0"
- } else if (Number(ramp_step) > 100) {
- ramp_step = "100"
- }
-
- Blockly.propc.definitions_["include servo"] = '#include "servo.h"';
-
- return 'servo_setramp(' + pin + ', ' + ramp_step + ');\n';
-};
-
-Blockly.propc.servodiffdrive_library_drive_pins = function () {
- var left_pin = this.getFieldValue('LEFT_PIN');
- var right_pin = this.getFieldValue('RIGHT_PIN');
-
- return 'drive_pins(' + left_pin + ', ' + right_pin + ');\n';
-};
-
-Blockly.propc.servodiffdrive_library_drive_speed = function () {
- var left_speed = this.getFieldValue('LEFT_SPEED');
- var right_speed = this.getFieldValue('RIGHT_SPEED');
-
- return 'drive_speeds(' + left_speed + ', ' + right_speed + ');\n';
-};
-
-Blockly.propc.servodiffdrive_library_drive_setRamp = function () {
- var left_ramp = this.getFieldValue('LEFT_RAMP');
- var right_ramp = this.getFieldValue('RIGHT_RAMP');
-
- return 'drive_setramp(' + left_ramp + ', ' + right_ramp + ');\n';
-};
-
-Blockly.propc.servodiffdrive_library_drive_sleep = function () {
- return 'drive_sleep();\n';
-};
-
-Blockly.propc.servodiffdrive_library_drive_stop = function () {
- return 'drive_stop();\n';
-};
-
-Blockly.propc.pwm_start = function () {
- var code = 'pwm_start(100);\n';
- return code;
-};
-
-Blockly.propc.pwm_set = function () {
- var pin = this.getFieldValue("PIN");
- var channel = this.getFieldValue("CHANNEL");
- var duty_cycle = Blockly.propc.valueToCode(this, "DUTY_CYCLE", Blockly.propc.ORDER_NONE);
-
- if (Number(duty_cycle) < 0) {
- duty_cycle = '0';
- } else if (Number(duty_cycle) > 100) {
- duty_cycle = '100';
- }
-
- var code = 'pwm_start(' + pin + ', ' + channel + ', ' + duty_cycle + ');\n';
- return code;
-};
-
-Blockly.propc.pwm_stop = function () {
- var code = 'pwm_stop();\n';
- return code;
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/tv_remote.js b/src/main/webapp/cdn/blockly/generators/propc/tv_remote.js
deleted file mode 100644
index 601a4c2e..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/tv_remote.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-
-This file contains support for the Tilt and Acceleration sensors
-
-Author: valetolpegin@gmail.com
-
- *Copyright 2016 Vale Tolpegin.
- *
- *
- * 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.
-
-*/
-'use strict';
-
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-Blockly.Blocks.sirc_get = {
- helpUrl: Blockly.MSG_SONY_REMOTE_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_SIRC_GET_TOOLTIP);
- this.setColour(colorPalette.getColor('input'));
- this.appendDummyInput()
- .appendField("Sony Remote value received from PIN")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
-
- this.setInputsInline(true);
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- this.setOutput(true, 'Number');
- }
-};
-
-Blockly.propc.sirc_get = function() {
- var pin = this.getFieldValue('PIN');
-
- Blockly.propc.definitions_["sirc"] = '#include "sirc.h"';
- Blockly.propc.setups_["sirc"] = "sirc_setTimeout(70);\n";
-
- var code = 'sirc_button(' + pin + ')';
- return [code, Blockly.propc.ORDER_NONE];
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/variables.js b/src/main/webapp/cdn/blockly/generators/propc/variables.js
index 0d5f0e23..4ca5df03 100644
--- a/src/main/webapp/cdn/blockly/generators/propc/variables.js
+++ b/src/main/webapp/cdn/blockly/generators/propc/variables.js
@@ -1,8 +1,7 @@
/**
* Visual Blocks Language
*
- * Copyright 2012 Google Inc.
- * http://blockly.googlecode.com/
+ * Copyright 2014 Michel Lampo, Vale Tolpegin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,8 +17,13 @@
*/
/**
- * @fileoverview Generating Prop-C for control blocks.
+ * @fileoverview Generating C for variable blocks
* @author michel@creatingfuture.eu (Michel Lampo)
+ * valetolpegin@gmail.com (Vale Tolpegin)
+ * jewald@parallax.com (Jim Ewald)
+ * mmatz@parallax.com (Matthew Matz)
+ * kgracey@parallax.com (Ken Gracey)
+ * carsongracey@gmail.com (Carson Gracey)
*/
'use strict';
diff --git a/src/main/webapp/cdn/blockly/generators/propc/wav.js b/src/main/webapp/cdn/blockly/generators/propc/wav.js
deleted file mode 100644
index ed849679..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/wav.js
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
-
-This file contains support for the Tilt and Acceleration sensors
-
-Author: valetolpegin@gmail.com
-
- *Copyright 2016 Vale Tolpegin.
- *
- *
- * 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.
-
-*/
-'use strict';
-
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-Blockly.Blocks.wav_play = {
- helpUrl: Blockly.MSG_AUDIO_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_WAV_PLAY_TOOLTIP);
- this.setColour(colorPalette.getColor('io'));
- this.appendDummyInput()
- .appendField("WAV play file")
- .appendField(new Blockly.FieldTextInput('File_name'), 'FILENAME');
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.wav_status = {
- helpUrl: Blockly.MSG_AUDIO_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_WAV_STATUS_TOOLTIP);
- this.setColour(colorPalette.getColor('io'));
- this.appendDummyInput()
- .appendField("WAV status");
-
- this.setPreviousStatement(false, null);
- this.setNextStatement(false, null);
- this.setOutput(true, 'Number');
- }
-};
-
-Blockly.Blocks.wav_volume = {
- helpUrl: Blockly.MSG_AUDIO_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_WAV_VOLUME_TOOLTIP);
- this.setColour(colorPalette.getColor('io'));
- this.appendValueInput('VOLUME')
- .appendField("WAV volume (0 - 10)");
-// this.appendValueInput('LENGTH')
-// .appendField("length of file (ms)");
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.wav_stop = {
- helpUrl: Blockly.MSG_AUDIO_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_WAV_STOP_TOOLTIP);
- this.setColour(colorPalette.getColor('io'));
- this.appendDummyInput()
- .appendField("WAV stop");
-
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.propc.wav_play = function() {
- var filename = this.getFieldValue('FILENAME');
-
- Blockly.propc.definitions_["include wavplayer"] = '#include "wavplayer.h"';
- Blockly.propc.setups_["sd_card"] = 'int DO = 22, CLK = 23, DI = 24, CS = 25;\n\tsd_mount(DO, CLK, DI, CS);\n';
-
- var code = 'wav_play("' + filename + '.wav");\n';
- return code;
-};
-
-Blockly.propc.wav_status = function() {
- Blockly.propc.definitions_["include wavplayer"] = '#include "wavplayer.h"';
-
- var code = 'wav_playing()';
- return [code, Blockly.propc.ORDER_NONE];
-};
-
-Blockly.propc.wav_volume = function() {
- var volume = Blockly.propc.valueToCode(this, 'VOLUME', Blockly.propc.ORDER_NONE) || '0';
-// var length = Blockly.propc.valueToCode(this, 'LENGTH', Blockly.propc.ORDER_NONE) || '0';
-
- Blockly.propc.definitions_["include wavplayer"] = '#include "wavplayer.h"';
-
- if (Number(volume) < 0) {
- volume = '0';
- } else if (Number(volume) > 10) {
- volume = '10';
- }
-
- var code = 'wav_volume(' + volume + ');\n';
-// var code += 'pause(' + length + ');\n';
- return code;
-};
-
-Blockly.propc.wav_stop = function() {
- var code = 'wav_stop();\n';
- return code;
-};
diff --git a/src/main/webapp/cdn/blockly/generators/propc/xbee.js b/src/main/webapp/cdn/blockly/generators/propc/xbee.js
deleted file mode 100644
index e354d43a..00000000
--- a/src/main/webapp/cdn/blockly/generators/propc/xbee.js
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2016 Vale Tolpegin.
- *
- *
- * 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.
- */
-
-/**
- * @fileoverview XBee blocks.
- * @author valetolpegin@gmail.com (Vale Tolpegin)
- */
-'use strict';
-
-//define blocks
-if (!Blockly.Blocks)
- Blockly.Blocks = {};
-
-
-Blockly.Blocks.xbee_setup = {
- helpUrl: Blockly.MSG_XBEE_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_XBEE_SETUP_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("XBee initialize DI")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), 'DO_PIN')
- .appendField("DO")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), 'DI_PIN')
- .appendField("baud")
- .appendField(new Blockly.FieldDropdown([["9600", "9600"], ["2400", "2400"], ["4800", "4800"], ["19200", "19200"], ["57600", "57600"], ["115200", "115200"]]), "BAUD");
-
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.xbee_transmit = {
- helpUrl: Blockly.MSG_XBEE_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_XBEE_TRANSMIT_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("XBee transmit")
- .appendField(new Blockly.FieldDropdown([
- ["text", "TEXT"],
- ["number (32-bit integer)", "INT"],
- ["byte (ASCII character)", "BYTE"]
- ]), "TYPE");
- this.appendValueInput('VALUE', Number)
- .setCheck(null);
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- }
-};
-
-Blockly.Blocks.xbee_receive = {
- helpUrl: Blockly.MSG_XBEE_HELPURL,
- init: function() {
- this.setTooltip(Blockly.MSG_XBEE_RECEIVE_TOOLTIP);
- this.setColour(colorPalette.getColor('protocols'));
- this.appendDummyInput()
- .appendField("XBee receive")
- .appendField(new Blockly.FieldDropdown([
- ["text", "TEXT"],
- ["number (32-bit integer)", "INT"],
- ["byte (ASCII character)", "BYTE"]
- ]), "TYPE")
- .appendField("store in")
- .appendField(new Blockly.FieldVariable(Blockly.LANG_VARIABLES_GET_ITEM), 'VALUE');
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- },
- getVars: function () {
- return [this.getFieldValue('VALUE')];
- },
- renameVar: function (oldName, newName) {
- if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
- this.setTitleValue(newName, 'VALUE');
- }
- }
-};
-
-Blockly.propc.xbee_setup = function () {
- var do_pin = this.getFieldValue('DO_PIN');
- var di_pin = this.getFieldValue('DI_PIN');
- var baud = this.getFieldValue('BAUD');
-
- Blockly.propc.definitions_["include fdserial"] = '#include "fdserial.h"';
-
- Blockly.propc.global_vars_["xbee"] = "fdserial *xbee;";
- Blockly.propc.setups_["xbee"] = 'xbee = fdserial_open(' + di_pin + ', ' + do_pin + ', 0, ' + baud + ');\n';
-
- return '';
-};
-
-Blockly.propc.xbee_transmit = function () {
- var type = this.getFieldValue('TYPE');
- var data = Blockly.propc.valueToCode(this, 'VALUE', Blockly.propc.ORDER_ATOMIC) || '0';
-
- if (Blockly.propc.setups_["xbee"] === undefined)
- {
- return '//Missing xbee initialization\n';
- }
-
- if(type === "BYTE") {
- return 'fdserial_txChar(xbee, (' + data + ' & 0xFF) );\n';
- } else if(type === "INT") {
- return 'dprint(xbee, "%d\\r", ' + data + ');\n';
- } else {
- var code = 'dprint(xbee, "%s\\r", ' + data + ');\n';
- //code += 'fdserial_txChar(xbee, 0 );\n';
- code += 'while(!fdserial_txEmpty(xbee));\n';
- code += 'pause(5);\n';
-
- return code;
- }
-};
-
-Blockly.propc.xbee_receive = function () {
- var data = Blockly.propc.variableDB_.getName(this.getFieldValue('VALUE'), Blockly.Variables.NAME_TYPE);
- var type = this.getFieldValue('TYPE');
-
- if (Blockly.propc.setups_["xbee"] === undefined)
- {
- return '//Missing xbee initialization\n';
- }
-
- if(type === "BYTE") {
- return data + ' = fdserial_rxChar(xbee);\n';
- } else if(type === "INT") {
- return 'dscan(xbee, "%d", &' + data + ');\n';
- } else {
- Blockly.propc.global_vars_["xbee_rx"] = "int __XBidx;";
- Blockly.propc.vartype_[data] = 'char *';
-
- var code = '__XBidx = 0;\n';
- code += 'while(1) {\n';
- code += ' ' + data + '[__XBidx] = fdserial_rxChar(xbee);\n';
- code += ' if(' + data + '[__XBidx] == 13 || ' + data + '[__XBidx] == 10) break;\n';
- code += ' __XBidx++;\n';
- code += '}\n';
- code += data + '[__XBidx] = 0;\nfdserial_rxFlush(xbee);\n';
- return code;
- }
-};
diff --git a/src/main/webapp/cdn/blockly/generators/scribbler.js b/src/main/webapp/cdn/blockly/generators/scribbler.js
deleted file mode 100644
index c33be6a7..00000000
--- a/src/main/webapp/cdn/blockly/generators/scribbler.js
+++ /dev/null
@@ -1,240 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2012 Google Inc.
- * http://code.google.com/p/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.
- */
-
-/**
- * @fileoverview Helper functions for generating Spin for blocks.
- * @author gasolin@gmail.com (Fred Lin)
- */
-'use strict';
-
-Blockly.Spin = Blockly.Generator.get('Spin');
-
-/**
- * List of illegal variable names.
- * This is not intended to be a security feature. Blockly is 100% client-side,
- * so bypassing this list is trivial. This is intended to prevent users from
- * accidentally clobbering a built-in object or function.
- * @private
- */
-if (!Blockly.Spin.RESERVED_WORDS_) {
- Blockly.Spin.RESERVED_WORDS_ = '';
-}
-
-Blockly.Spin.RESERVED_WORDS_ +=
- // http://arduino.cc/en/Reference/HomePage
- 'cogid,if,else,elseif,repeat,switch,case,while,do,break,continue,return,goto,define,include,HIGH,LOW,INPUT,OUTPUT,INPUT_PULLUP,true,false,interger, constants,floating,point,void,bookean,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'
- ;
-
-/**
- * Order of operation ENUMs.
- *
- */
-Blockly.Spin.ORDER_ATOMIC = 0; // 0 "" ...
-Blockly.Spin.ORDER_UNARY_POSTFIX = 1; // expr++ expr-- () [] .
-Blockly.Spin.ORDER_UNARY_PREFIX = 2; // -expr !expr ~expr ++expr --expr
-Blockly.Spin.ORDER_MULTIPLICATIVE = 3; // * / % ~/
-Blockly.Spin.ORDER_ADDITIVE = 4; // + -
-Blockly.Spin.ORDER_SHIFT = 5; // << >>
-Blockly.Spin.ORDER_RELATIONAL = 7; // is is! >= > <= <
-Blockly.Spin.ORDER_EQUALITY = 8; // == != === !==
-Blockly.Spin.ORDER_BITWISE_AND = 9; // &
-Blockly.Spin.ORDER_BITWISE_XOR = 10; // ^
-Blockly.Spin.ORDER_BITWISE_OR = 11; // |
-Blockly.Spin.ORDER_LOGICAL_AND = 12; // &&
-Blockly.Spin.ORDER_LOGICAL_OR = 13; // ||
-Blockly.Spin.ORDER_CONDITIONAL = 14; // expr ? expr : expr
-Blockly.Spin.ORDER_ASSIGNMENT = 15; // := *= /= ~/= %= += -= <<= >>= &= ^= |=
-Blockly.Spin.ORDER_NONE = 99; // (...)
-
-/*
- * Spin Board profiles
- *
- */
-var profile = {
- demoboard: {
- description: "Parallax propeller Demo board",
- digital: [["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"], ["4", "4"], ["5", "5"], ["6", "6"], ["7", "7"], ["16", "16"], ["17", "17"], ["18", "18"], ["19", "19"], ["20", "20"], ["21", "21"], ["22", "22"], ["23", "23"]],
- analog: [["A0", "A0"], ["A1", "A1"], ["A2", "A2"], ["A3", "A3"], ["A4", "A4"], ["A5", "A5"]],
- serial: 9600,
- },
-}
-//set default profile to Parallax propeller demo board
-profile["default"] = profile["demoboard"];
-//alert(profile.default.digital[0]);
-
-/**
- * Initialise the database of variable names.
- */
-Blockly.Spin.init = function() {
- // Create a dictionary of definitions to be printed before setups.
- Blockly.Spin.definitions_ = {};
- // Create a dictionary of setups to be printed before the code.
- Blockly.Spin.setups_ = {};
-
- // Create a list of stacks
- Blockly.Spin.stacks_ = [];
-
- Blockly.Spin.vartype_ = {};
-
- if (Blockly.Variables) {
- if (!Blockly.Spin.variableDB_) {
- Blockly.Spin.variableDB_ =
- new Blockly.Names(Blockly.Spin.RESERVED_WORDS_);
- } else {
- Blockly.Spin.variableDB_.reset();
- }
-
- var defvars = [];
- var variables = Blockly.Variables.allVariables();
- for (var x = 0; x < variables.length; x++) {
- var varName = Blockly.Spin.variableDB_.getDistinctName(variables[x],
- Blockly.Variables.NAME_TYPE);
- defvars[x] = ' ' + '{{$var_type_' + variables[x].name + '}} ' +
- varName + '\n';
- }
- Blockly.Spin.definitions_['variables'] = defvars.join('\n');
- }
-};
-
-/**
- * Prepend the generated code with the variable definitions.
- * @param {string} code Generated code.
- * @return {string} Completed code.
- */
-Blockly.Spin.finish = function(code) {
- // Indent every line.
- code = ' ' + code.replace(/\n/g, '\n ');
- code = code.replace(/\n\s+$/, '\n');
- code = 'PUB Start\n\n' + code;
-
- // Convert the definitions dictionary into a list.
- var imports = [];
- var methods = [];
- var objects = [];
- var definitions = [];
- for (var name in Blockly.Spin.definitions_) {
- var def = Blockly.Spin.definitions_[name];
- if (def.match(/^#include/)) {
- imports.push(def);
- } else if (def.match(/^PUB/)) {
- methods.push(def);
- } else if (def.match(/^OBJ/)) {
- objects.push(' ' + def.substring(3));
- } else {
- definitions.push(def);
- }
- }
-
- for (var def in definitions) {
- for (var variable in Blockly.Spin.vartype_) {
- if (definitions[def].indexOf("{{$var_type_" + variable + "}}") > -1) {
- if (Blockly.Spin.vartype_[variable] !== 'LOCAL') {
- definitions[def] = definitions[def].replace("{{$var_type_" + variable + "}}", Blockly.Spin.vartype_[variable]);
- } else {
- definitions[def] = definitions[def].replace("{{$var_type_" + variable + "}} " + variable, "");
- }
- }
- definitions[def] = definitions[def].replace("\n\n", "\n");
- }
- }
-
- for (var stack in Blockly.Spin.stacks_) {
- definitions.push(' ' + Blockly.Spin.stacks_[stack]);
- }
-
- // Convert the setups dictionary into a list.
- var setups = [];
- for (var name in Blockly.Spin.setups_) {
- setups.push(Blockly.Spin.setups_[name]);
- }
- setups.push('Start');
-
- var OBJ = (objects.length > 0) ? '\n\nOBJ\n' + objects.join('\n') + '\n' : '';
-
- var allDefs = imports.join('\n') + '\n\nVAR\n' + definitions.join('\n') + OBJ + '\n\nPUB Setup\n ' + setups.join('\n ') + '\n\n';
- var setup = 'CON\n _clkmode = xtal1 + pll16x\n _xinfreq = 5_000_000\n\n';
- return setup + allDefs.replace(/\n\n+/g, '\n\n').replace(/\n*$/, '\n\n\n') + code + '\n\n' + methods.join('\n');
-};
-
-/**
- * Naked values are top-level blocks with outputs that aren't plugged into
- * anything. A trailing semicolon is needed to make this legal.
- * @param {string} line Line of generated code.
- * @return {string} Legal line of code.
- */
-Blockly.Spin.scrubNakedValue = function(line) {
- return line + ';\n';
-};
-
-/**
- * Encode a string as a properly escaped Spin string, complete with quotes.
- * @param {string} string Text to encode.
- * @return {string} Spin string.
- * @private
- */
-Blockly.Spin.quote_ = function(string) {
- // TODO: This is a quick hack. Replace with goog.string.quote
- string = string.replace(/\\/g, '\\\\')
- .replace(/\n/g, '\\\n')
- .replace(/\$/g, '\\$')
- .replace(/'/g, '\\\'');
- return '\"' + string + '\"';
-};
-
-/**
- * Common tasks for generating Spin from blocks.
- * Handles comments for the specified block and any connected value blocks.
- * Calls any statements following this block.
- * @param {!Blockly.Block} block The current block.
- * @param {string} code The Spin code created for this block.
- * @return {string} Spin code with comments and subsequent blocks added.
- * @this {Blockly.CodeGenerator}
- * @private
- */
-Blockly.Spin.scrub_ = function(block, code) {
- if (code === null) {
- // Block has handled code generation itself.
- return '';
- }
- var commentCode = '';
- // Only collect comments for blocks that aren't inline.
- if (!block.outputConnection || !block.outputConnection.targetConnection) {
- // Collect comment for this block.
- var comment = block.getCommentText();
- if (comment) {
- commentCode += Blockly.Generator.prefixLines(comment, '// ') + '\n';
- }
- // Collect comments for all value arguments.
- // Don't collect comments for nested statements.
- for (var x = 0; x < block.inputList.length; x++) {
- if (block.inputList[x].type == Blockly.INPUT_VALUE) {
- var childBlock = block.inputList[x].connection.targetBlock();
- if (childBlock) {
- var comment = Blockly.Generator.allNestedComments(childBlock);
- if (comment) {
- commentCode += Blockly.Generator.prefixLines(comment, '// ');
- }
- }
- }
- }
- }
- var nextBlock = block.nextConnection && block.nextConnection.targetBlock();
- var nextCode = this.blockToCode(nextBlock);
- return commentCode + code + nextCode;
-};
diff --git a/src/main/webapp/cdn/blockly/generators/scribbler/scribbler.js b/src/main/webapp/cdn/blockly/generators/scribbler/scribbler.js
deleted file mode 100644
index 3e125214..00000000
--- a/src/main/webapp/cdn/blockly/generators/scribbler/scribbler.js
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Visual Blocks Language
- *
- * Copyright 2014 Creating Future.
- * http://www.creatingfuture.eu/
- *
- * 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.
- */
-
-/**
- * @fileoverview Generating Spin for Scribbler blocks.
- * @author michel@creatingfuture.eu (Michel Lampo)
- */
-'use strict';
-
-Blockly.Spin = Blockly.Generator.get('Spin');
-
-Blockly.Spin.move = function() {
- var code = 'MOTORS.move()';
- return code + '\n';
-};
-
-Blockly.Spin.line_sensor = function() {
- var code = 'LINESENSOR.read()';
- return code + '\n';
-};
\ No newline at end of file
diff --git a/src/main/webapp/cdn/blockly/generators/spin/control.js b/src/main/webapp/cdn/blockly/generators/spin/control.js
index 0a609b5d..371d3cc5 100644
--- a/src/main/webapp/cdn/blockly/generators/spin/control.js
+++ b/src/main/webapp/cdn/blockly/generators/spin/control.js
@@ -56,7 +56,7 @@ Blockly.Spin.controls_repeat = function () {
return code;
};
-Blockly.Spin.controls_if = function () {
+Blockly.Spin.controls_boolean_if = function () {
// If/elseif/else condition.
var n = 0;
var argument = Blockly.Spin.valueToCode(this, 'IF' + n,
diff --git a/src/main/webapp/cdn/blockly/generators/spin/logic.js b/src/main/webapp/cdn/blockly/generators/spin/logic.js
index fc936355..59946056 100644
--- a/src/main/webapp/cdn/blockly/generators/spin/logic.js
+++ b/src/main/webapp/cdn/blockly/generators/spin/logic.js
@@ -23,10 +23,10 @@
*/
'use strict';
-Blockly.Spin.logic_compare = function () {
+Blockly.Spin.logic_boolean_compare = function () {
// Comparison operator.
var mode = this.getFieldValue('OP');
- var operator = Blockly.Spin.logic_compare.OPERATORS[mode];
+ var operator = Blockly.Spin.logic_boolean_compare.OPERATORS[mode];
var order = (operator == '==' || operator == '!=') ?
Blockly.Spin.ORDER_EQUALITY : Blockly.Spin.ORDER_RELATIONAL;
var argument0 = Blockly.Spin.valueToCode(this, 'A', order) || '0';
@@ -35,7 +35,7 @@ Blockly.Spin.logic_compare = function () {
return [code, order];
};
-Blockly.Spin.logic_compare.OPERATORS = {
+Blockly.Spin.logic_boolean_compare.OPERATORS = {
EQ: '==',
NEQ: '<>',
LT: '<',
@@ -44,7 +44,7 @@ Blockly.Spin.logic_compare.OPERATORS = {
GTE: '=>'
};
-Blockly.Spin.logic_operation = function () {
+Blockly.Spin.logic_boolean_operation = function () {
// Operations 'and', 'or'.
var operator = ''; //(this.getFieldValue('OP') == 'AND') ? '&&' : '||';
var order = Blockly.Spin.ORDER_LOGICAL_AND;
@@ -70,7 +70,7 @@ Blockly.Spin.logic_operation = function () {
return [code, order];
};
-Blockly.Spin.logic_negate = function () {
+Blockly.Spin.logic_boolean_negate = function () {
// Negation.
var order = Blockly.Spin.ORDER_UNARY_PREFIX;
var argument0 = Blockly.Spin.valueToCode(this, 'BOOL', order) || 'FALSE';
diff --git a/src/main/webapp/cdn/blockly/generators/spin/scribbler.js b/src/main/webapp/cdn/blockly/generators/spin/scribbler.js
index 75999dd3..bf148649 100644
--- a/src/main/webapp/cdn/blockly/generators/spin/scribbler.js
+++ b/src/main/webapp/cdn/blockly/generators/spin/scribbler.js
@@ -275,7 +275,7 @@ Blockly.Blocks.scribbler_play = {
.appendField("for a")
.appendField(new Blockly.FieldDropdown([['sixteenth', '63'], ['dotted sixteenth', '94'], ['eighth', '125'], ['dotted eighth', '188'], ['quarter', '250'], ['dotted quarter', '375'], ['half', '500'], ['dotted half', '750'], ['whole', '1000'], ['dotted whole', '1500']]), 'NOTE_DURATION')
.appendField("note at a")
- .appendField(new Blockly.FieldDropdown([['loud', '100'], ['medium', '50'], ['quiet', '25']]), 'NOTE_VOLUME')
+ .appendField(new Blockly.FieldDropdown([['loud', '50'], ['medium', '30'], ['quiet', '15']]), 'NOTE_VOLUME')
.appendField("volume");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
@@ -338,6 +338,30 @@ Blockly.Blocks.move_motors_distance = {
}
};
+Blockly.Blocks.move_motors_xy = {
+ init: function () {
+ this.appendDummyInput()
+ .appendField("in ")
+ .appendField(new Blockly.FieldDropdown([['inches (-20,755,429 to 20,755,429)', ' * 100_000 / 1933'], ['tenths of an inch (-207,554,294 to 207,554,294)', ' * 10_000 / 1933'], ['centimeters (-52,720,723 to 52,720,723)', ' * 10_000 / 491'], ['millimeters (-527,207,235 to 527,207,235)', ' * 1_000 / 491'], ['encoder counts (-1,073,741,823 to 1,073,741,823)', '']]), 'MULTIPLIER');
+ this.appendDummyInput()
+ .appendField("move the Scribbler robot to the");
+ this.appendValueInput("X_DISTANCE")
+ .setCheck("Number")
+ .appendField("left(-)/right(+) by");
+ this.appendValueInput("Y_DISTANCE")
+ .setCheck("Number")
+ .appendField("back(-)/forward(+) by");
+ this.appendValueInput("MOTOR_SPEED")
+ .setCheck("Number")
+ .appendField("at a top speed of (1 to 100)%");
+
+ this.setInputsInline(false);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('io'));
+ }
+};
+
// Move the motors...
Blockly.Blocks.move_motors_angle = {
init: function () {
@@ -346,7 +370,7 @@ Blockly.Blocks.move_motors_angle = {
.appendField("rotate the Scribbler robot (-1,080 to 1,080)\u00B0");
this.appendValueInput("ROTATE_RADIUS")
.setCheck("Number")
- .appendField("around a radius in")
+ .appendField("around a radius to the left(-)/right(+) in")
.appendField(new Blockly.FieldDropdown([['inches (-85 to 85) of', ' * 100_000 / 1933'], ['tenths of an inch (-850 to 850) of', ' * 10_000 / 1933'], ['centimeters (-216 to 216) of', ' * 10_000 / 491'], ['millimeters (-2,160 to 2,160) of', ' * 1_000 / 491'], ['encoder counts (-4,400 to 4,400) of', '']]), 'RADIUS_MULTIPLIER');
this.appendValueInput("ROTATE_SPEED")
.setCheck("Number")
@@ -536,6 +560,41 @@ Blockly.Blocks.scribbler_ping = {
}
};
+Blockly.Blocks.digital_input = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField("Digital reading on")
+ .appendField(new Blockly.FieldDropdown([['P0', '0'], ['P1', '1'], ['P2', '2'], ['P3', '3'], ['P4', '4'], ['P5', '5']]), "DIGITAL_PIN");
+ this.setOutput(true, "Boolean");
+ this.setColour(colorPalette.getColor('input'));
+ }
+};
+
+Blockly.Blocks.digital_output = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField("set")
+ .appendField(new Blockly.FieldDropdown([['P0', '0'], ['P1', '1'], ['P2', '2'], ['P3', '3'], ['P4', '4'], ['P5', '5']]), "OUTPUT_PIN");
+ this.appendDummyInput("")
+ .appendField("to")
+ .appendField(new Blockly.FieldDropdown([['high', "HIGH"], ['low', "LOW"], ['input', "INPUT"], ['output', "OUTPUT"], ['toggle state', "TOGGLE_STATE"], ['toggle direction', "TOGGLE_DIRECTION"]]), "OUTPUT_ACTION");
+ this.setInputsInline(true);
+ this.setPreviousStatement(true, null);
+ this.setNextStatement(true, null);
+ this.setColour(colorPalette.getColor('io'));
+ }
+};
+
+Blockly.Blocks.analog_input = {
+ init: function () {
+ this.appendDummyInput("")
+ .appendField("Analog reading on")
+ .appendField(new Blockly.FieldDropdown([['A0', '0'], ['A1', '1']]), "ANALOG_PIN");
+ this.setOutput(true, "Number");
+ this.setColour(colorPalette.getColor('input'));
+ }
+};
+
Blockly.Blocks.spin_integer = {
init: function () {
this.appendDummyInput()
@@ -805,6 +864,19 @@ Blockly.Spin.move_motors_distance = function () {
return 'Scribbler.MotorSetDistance(' + left_distance + distance_multiplier + ', ' + right_distance + distance_multiplier + ', ' + top_speed + ')\n';
};
+Blockly.Spin.move_motors_xy = function () {
+ Blockly.Spin.definitions_[ "include_scribbler" ] = 'OBJscribbler : "Block_Wrapper"';
+ if (Blockly.Spin.setups_[ 'setup_scribbler' ] === undefined) {
+ Blockly.Spin.setups_[ 'setup_scribbler' ] = 'Scribbler.Start';
+ }
+
+ var distance_multiplier = this.getFieldValue('MULTIPLIER');
+ var x_distance = Blockly.Spin.valueToCode(this, 'X_DISTANCE', Blockly.Spin.ORDER_ATOMIC) || '0';
+ var y_distance = Blockly.Spin.valueToCode(this, 'Y_DISTANCE', Blockly.Spin.ORDER_ATOMIC) || '0';
+ var top_speed = Blockly.Spin.valueToCode(this, 'MOTOR_SPEED', Blockly.Spin.ORDER_ATOMIC) || '0';
+ return 'Scribbler.MoveXY(' + x_distance + distance_multiplier + ', ' + y_distance + distance_multiplier + ', ' + top_speed + ')\n';
+};
+
Blockly.Spin.move_motors_angle = function () {
Blockly.Spin.definitions_[ "include_scribbler" ] = 'OBJscribbler : "Block_Wrapper"';
if (Blockly.Spin.setups_[ 'setup_scribbler' ] === undefined) {
@@ -837,7 +909,7 @@ Blockly.Spin.play_tone = function () {
var Frequency = Blockly.Spin.valueToCode(this, 'FREQUENCY', Blockly.Spin.ORDER_ATOMIC) || '0';
var Note_Duration = Blockly.Spin.valueToCode(this, 'NOTE_DURATION', Blockly.Spin.ORDER_ATOMIC) || '0';
var Volume = Blockly.Spin.valueToCode(this, 'NOTE_VOLUME', Blockly.Spin.ORDER_ATOMIC) || '0';
- return 'Scribbler.SetVolume(' + Volume + ')\nScribbler.PlayNote(' + Frequency + ', 0, ' + Note_Duration + ')\n';
+ return 'Scribbler.SetVolume((' + Volume + ' / 2))\nScribbler.PlayNote(' + Frequency + ', 0, ' + Note_Duration + ')\n';
};
Blockly.Spin.play_polyphony = function () {
@@ -850,7 +922,7 @@ Blockly.Spin.play_polyphony = function () {
var Frequency2 = Blockly.Spin.valueToCode(this, 'FREQUENCY_2', Blockly.Spin.ORDER_ATOMIC) || '0';
var Polyphony_Duration = Blockly.Spin.valueToCode(this, 'POLYPHONY_DURATION', Blockly.Spin.ORDER_ATOMIC) || '0';
var Volume = Blockly.Spin.valueToCode(this, 'POLYPHONY_VOLUME', Blockly.Spin.ORDER_ATOMIC) || '0';
- return 'Scribbler.SetVolume(' + Volume + ')\nScribbler.PlayNote(' + Frequency1 + ', ' + Frequency2 + ', ' + Polyphony_Duration + ')\n';
+ return 'Scribbler.SetVolume((' + Volume + ' / 2))\nScribbler.PlayNote(' + Frequency1 + ', ' + Frequency2 + ', ' + Polyphony_Duration + ')\n';
};
Blockly.Spin.line_sensor = function () {
@@ -955,6 +1027,29 @@ Blockly.Spin.scribbler_ping = function () {
return [code, Blockly.Spin.ORDER_ATOMIC];
};
+Blockly.Spin.digital_input = function () {
+ var Pin = window.parseInt(this.getFieldValue('DIGITAL_PIN'));
+ var Code = 'Scribbler.DigitalInput(' + Pin + ')';
+ return [Code, Blockly.Spin.ORDER_ATOMIC];
+};
+
+Blockly.Spin.digital_output = function () {
+ var Pin = window.parseInt(this.getFieldValue('OUTPUT_PIN'));
+ var Action = this.getFieldValue('OUTPUT_ACTION');
+ return 'Scribbler.DigitalOutput(' + Pin + ', Scribbler#' + Action + ')\n';
+};
+
+Blockly.Spin.analog_input = function () {
+ Blockly.Spin.definitions_[ "include_scribbler" ] = 'OBJscribbler : "Block_Wrapper"';
+ if (Blockly.Spin.setups_[ 'setup_scribbler' ] === undefined) {
+ Blockly.Spin.setups_[ 'setup_scribbler' ] = 'Scribbler.Start';
+ }
+
+ var Pin = window.parseInt(this.getFieldValue('ANALOG_PIN'));
+ var Code = 'Scribbler.ADC(' + Pin + ')';
+ return [Code, Blockly.Spin.ORDER_ATOMIC];
+};
+
Blockly.Spin.scribbler_servo = function () {
Blockly.Spin.definitions_[ "include_scribbler" ] = 'OBJscribbler : "Block_Wrapper"';
if (Blockly.Spin.setups_[ 'setup_scribbler_servo' ] === undefined) {
@@ -1009,6 +1104,5 @@ Blockly.Spin.factory_reset = function () {
Blockly.Spin.setups_[ 'setup_scribbler_default' ] = 'Scribbler_Default.Start';
}
- return
-
+ return
};
diff --git a/src/main/webapp/cdn/blockly/generators/spin/serial.js b/src/main/webapp/cdn/blockly/generators/spin/serial.js
index 75d82762..c46cdb22 100644
--- a/src/main/webapp/cdn/blockly/generators/spin/serial.js
+++ b/src/main/webapp/cdn/blockly/generators/spin/serial.js
@@ -81,7 +81,7 @@ Blockly.Blocks.serial_send_char = {
init: function () {
this.appendValueInput("CHAR_VALUE")
.setCheck("Number")
- .appendField("send character (0 to 255)");
+ .appendField("Terminal / XBee / WX send character (0 to 255)");
this.setInputsInline(false);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
@@ -95,7 +95,7 @@ Blockly.Blocks.serial_send_decimal = {
init: function () {
this.appendValueInput("DECIMAL_VALUE")
.setCheck("Number")
- .appendField("send number (32-bit signed)");
+ .appendField("Terminal / XBee / WX send number (32-bit signed)");
this.setInputsInline(false);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
@@ -123,7 +123,7 @@ Blockly.Blocks.serial_rx_byte = {
init: function () {
this.setColour(colorPalette.getColor('protocols'));
this.appendDummyInput("")
- .appendField("receive character (0 to 255)");
+ .appendField("Terminal / XBee / WX receive character (0 to 255)");
this.setOutput(true, 'Number');
// this.setInputsInline(true);
this.setHelpUrl(Blockly.MSG_S3_COMMUNICATE_HELPURL);
@@ -150,7 +150,7 @@ Blockly.Blocks.serial_cursor_xy = {
this.appendValueInput("Y")
.setCheck("Number")
.setAlign(Blockly.ALIGN_RIGHT)
- .appendField("set cursor position to row");
+ .appendField("Terminal set cursor position to row");
this.appendValueInput("X")
.setCheck("Number")
.setAlign(Blockly.ALIGN_RIGHT)
diff --git a/src/main/webapp/cdn/blockly/language/common/base.js b/src/main/webapp/cdn/blockly/language/common/base.js
index faf05206..d6ed4445 100644
--- a/src/main/webapp/cdn/blockly/language/common/base.js
+++ b/src/main/webapp/cdn/blockly/language/common/base.js
@@ -64,14 +64,14 @@ Blockly.Blocks.base_freqout = {
this.setTooltip(Blockly.MSG_BASE_FREQOUT_TOOLTIP);
this.setColour(colorPalette.getColor('io'));
this.appendDummyInput("")
- .appendField("frequency PIN")
- .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
+ .appendField("frequency PIN")
+ .appendField(new Blockly.FieldDropdown(profile.default.digital), "PIN");
this.appendValueInput("DURATION", 'Number')
- .appendField("duration (ms)")
- .setCheck('Number');
+ .appendField("duration (ms)")
+ .setCheck('Number');
this.appendValueInput("FREQUENCY", 'Number')
- .appendField("frequecy (hz)")
- .setCheck('Number');
+ .appendField("frequecy (Hz)")
+ .setCheck('Number');
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
diff --git a/src/main/webapp/cdn/blockly/language/common/control.js b/src/main/webapp/cdn/blockly/language/common/control.js
index 935be2f8..8a4db490 100644
--- a/src/main/webapp/cdn/blockly/language/common/control.js
+++ b/src/main/webapp/cdn/blockly/language/common/control.js
@@ -26,16 +26,164 @@
Blockly.Blocks.controls_if = {
// If/elseif/else condition.
category: Blockly.LANG_CATEGORY_CONTROLS,
- init: function() {
- if(profile.default.description === "Scribbler Robot") {
- this.setHelpUrl(Blockly.MSG_S3_CONTROL_HELPURL);
- } else {
- this.setHelpUrl(Blockly.MSG_CONTROL_HELPURL);
+ helpUrl: Blockly.LANG_CONTROLS_IF_HELPURL,
+ init: function () {
+ this.setColour(colorPalette.getColor('programming'));
+ this.appendValueInput('IF0')
+ .setCheck('Boolean')
+ .appendField(Blockly.LANG_CONTROLS_IF_MSG_IF);
+ this.appendStatementInput('DO0')
+ .appendField(Blockly.LANG_CONTROLS_IF_MSG_THEN);
+ this.setPreviousStatement(true);
+ this.setNextStatement(true);
+ this.setMutator(new Blockly.Mutator(['controls_if_elseif',
+ 'controls_if_else']));
+ // Assign 'this' to a variable for use in the tooltip closure below.
+ var thisBlock = this;
+ this.setTooltip(function () {
+ if (!thisBlock.elseifCount_ && !thisBlock.elseCount_) {
+ return Blockly.LANG_CONTROLS_IF_TOOLTIP_1;
+ } else if (!thisBlock.elseifCount_ && thisBlock.elseCount_) {
+ return Blockly.LANG_CONTROLS_IF_TOOLTIP_2;
+ } else if (thisBlock.elseifCount_ && !thisBlock.elseCount_) {
+ return Blockly.LANG_CONTROLS_IF_TOOLTIP_3;
+ } else if (thisBlock.elseifCount_ && thisBlock.elseCount_) {
+ return Blockly.LANG_CONTROLS_IF_TOOLTIP_4;
+ }
+ return '';
+ });
+ this.elseifCount_ = 0;
+ this.elseCount_ = 0;
+ },
+ mutationToDom: function () {
+ if (!this.elseifCount_ && !this.elseCount_) {
+ return null;
+ }
+ var container = document.createElement('mutation');
+ if (this.elseifCount_) {
+ container.setAttribute('elseif', this.elseifCount_);
+ }
+ if (this.elseCount_) {
+ container.setAttribute('else', 1);
+ }
+ return container;
+ },
+ domToMutation: function (xmlElement) {
+ this.elseifCount_ = window.parseInt(xmlElement.getAttribute('elseif'), 10);
+ this.elseCount_ = window.parseInt(xmlElement.getAttribute('else'), 10);
+ for (var x = 1; x <= this.elseifCount_; x++) {
+ this.appendValueInput('IF' + x)
+ .setCheck('Boolean')
+ .appendField(Blockly.LANG_CONTROLS_IF_MSG_ELSEIF);
+ this.appendStatementInput('DO' + x)
+ .appendField(Blockly.LANG_CONTROLS_IF_MSG_THEN);
+ }
+ if (this.elseCount_) {
+ this.appendStatementInput('ELSE')
+ .appendField(Blockly.LANG_CONTROLS_IF_MSG_ELSE);
+ }
+ },
+ decompose: function (workspace) {
+ var containerBlock = Blockly.Block.obtain(workspace, 'controls_if_if');
+ containerBlock.initSvg();
+ var connection = containerBlock.getInput('STACK').connection;
+ for (var x = 1; x <= this.elseifCount_; x++) {
+ var elseifBlock = Blockly.Block.obtain(workspace, 'controls_if_elseif');
+ elseifBlock.initSvg();
+ connection.connect(elseifBlock.previousConnection);
+ connection = elseifBlock.nextConnection;
+ }
+ if (this.elseCount_) {
+ var elseBlock = Blockly.Block.obtain(workspace, 'controls_if_else');
+ elseBlock.initSvg();
+ connection.connect(elseBlock.previousConnection);
+ }
+ return containerBlock;
+ },
+ compose: function (containerBlock) {
+ // Disconnect the else input blocks and remove the inputs.
+ if (this.elseCount_) {
+ this.removeInput('ELSE');
+ }
+ this.elseCount_ = 0;
+ // Disconnect all the elseif input blocks and remove the inputs.
+ for (var x = this.elseifCount_; x > 0; x--) {
+ this.removeInput('IF' + x);
+ this.removeInput('DO' + x);
+ }
+ this.elseifCount_ = 0;
+ // Rebuild the block's optional inputs.
+ var clauseBlock = containerBlock.getInputTargetBlock('STACK');
+ while (clauseBlock) {
+ switch (clauseBlock.type) {
+ case 'controls_if_elseif':
+ this.elseifCount_++;
+ var ifInput = this.appendValueInput('IF' + this.elseifCount_)
+ .setCheck('Boolean')
+ .appendField(Blockly.LANG_CONTROLS_IF_MSG_ELSEIF);
+ var doInput = this.appendStatementInput('DO' + this.elseifCount_);
+ doInput.appendField(Blockly.LANG_CONTROLS_IF_MSG_THEN);
+ // Reconnect any child blocks.
+ if (clauseBlock.valueConnection_) {
+ ifInput.connection.connect(clauseBlock.valueConnection_);
+ }
+ if (clauseBlock.statementConnection_) {
+ doInput.connection.connect(clauseBlock.statementConnection_);
+ }
+ break;
+ case 'controls_if_else':
+ this.elseCount_++;
+ var elseInput = this.appendStatementInput('ELSE');
+ elseInput.appendField(Blockly.LANG_CONTROLS_IF_MSG_ELSE);
+ // Reconnect any child blocks.
+ if (clauseBlock.statementConnection_) {
+ elseInput.connection.connect(clauseBlock.statementConnection_);
+ }
+ break;
+ default:
+ throw 'Unknown block type.';
+ }
+ clauseBlock = clauseBlock.nextConnection &&
+ clauseBlock.nextConnection.targetBlock();
+ }
+ },
+ saveConnections: function (containerBlock) {
+ // Store a pointer to any connected child blocks.
+ var clauseBlock = containerBlock.getInputTargetBlock('STACK');
+ var x = 1;
+ while (clauseBlock) {
+ switch (clauseBlock.type) {
+ case 'controls_if_elseif':
+ var inputIf = this.getInput('IF' + x);
+ var inputDo = this.getInput('DO' + x);
+ clauseBlock.valueConnection_ =
+ inputIf && inputIf.connection.targetConnection;
+ clauseBlock.statementConnection_ =
+ inputDo && inputDo.connection.targetConnection;
+ x++;
+ break;
+ case 'controls_if_else':
+ var inputDo = this.getInput('ELSE');
+ clauseBlock.statementConnection_ =
+ inputDo && inputDo.connection.targetConnection;
+ break;
+ default:
+ throw 'Unknown block type.';
+ }
+ clauseBlock = clauseBlock.nextConnection &&
+ clauseBlock.nextConnection.targetBlock();
}
- this.setTooltip(Blockly.MSG_CONTROLS_IF_TOOLTIP);
+ }
+};
+
+Blockly.Blocks.controls_boolean_if = {
+ // If/elseif/else condition.
+ category: Blockly.LANG_CATEGORY_CONTROLS,
+ helpUrl: Blockly.LANG_CONTROLS_IF_HELPURL,
+ init: function () {
this.setColour(colorPalette.getColor('programming'));
this.appendValueInput('IF0')
- .setCheck('Number')
+ .setCheck('Boolean')
.appendField(Blockly.LANG_CONTROLS_IF_MSG_IF);
this.appendStatementInput('DO0')
.appendField(Blockly.LANG_CONTROLS_IF_MSG_THEN);
@@ -44,19 +192,19 @@ Blockly.Blocks.controls_if = {
this.setMutator(new Blockly.Mutator(['controls_if_elseif',
'controls_if_else']));
// Assign 'this' to a variable for use in the tooltip closure below.
- //var thisBlock = this;
- //this.setTooltip(function () {
- // if (!thisBlock.elseifCount_ && !thisBlock.elseCount_) {
- // return Blockly.LANG_CONTROLS_IF_TOOLTIP_1;
- // } else if (!thisBlock.elseifCount_ && thisBlock.elseCount_) {
- // return Blockly.LANG_CONTROLS_IF_TOOLTIP_2;
- // } else if (thisBlock.elseifCount_ && !thisBlock.elseCount_) {
- // return Blockly.LANG_CONTROLS_IF_TOOLTIP_3;
- // } else if (thisBlock.elseifCount_ && thisBlock.elseCount_) {
- // return Blockly.LANG_CONTROLS_IF_TOOLTIP_4;
- // }
- // return '';
- //});
+ var thisBlock = this;
+ this.setTooltip(function () {
+ if (!thisBlock.elseifCount_ && !thisBlock.elseCount_) {
+ return Blockly.LANG_CONTROLS_IF_TOOLTIP_1;
+ } else if (!thisBlock.elseifCount_ && thisBlock.elseCount_) {
+ return Blockly.LANG_CONTROLS_IF_TOOLTIP_2;
+ } else if (thisBlock.elseifCount_ && !thisBlock.elseCount_) {
+ return Blockly.LANG_CONTROLS_IF_TOOLTIP_3;
+ } else if (thisBlock.elseifCount_ && thisBlock.elseCount_) {
+ return Blockly.LANG_CONTROLS_IF_TOOLTIP_4;
+ }
+ return '';
+ });
this.elseifCount_ = 0;
this.elseCount_ = 0;
},
@@ -78,7 +226,7 @@ Blockly.Blocks.controls_if = {
this.elseCount_ = window.parseInt(xmlElement.getAttribute('else'), 10);
for (var x = 1; x <= this.elseifCount_; x++) {
this.appendValueInput('IF' + x)
- .setCheck('Number')
+ .setCheck('Boolean')
.appendField(Blockly.LANG_CONTROLS_IF_MSG_ELSEIF);
this.appendStatementInput('DO' + x)
.appendField(Blockly.LANG_CONTROLS_IF_MSG_THEN);
@@ -124,7 +272,7 @@ Blockly.Blocks.controls_if = {
case 'controls_if_elseif':
this.elseifCount_++;
var ifInput = this.appendValueInput('IF' + this.elseifCount_)
- .setCheck('Number')
+ .setCheck('Boolean')
.appendField(Blockly.LANG_CONTROLS_IF_MSG_ELSEIF);
var doInput = this.appendStatementInput('DO' + this.elseifCount_);
doInput.appendField(Blockly.LANG_CONTROLS_IF_MSG_THEN);
diff --git a/src/main/webapp/cdn/blockly/language/common/logic.js b/src/main/webapp/cdn/blockly/language/common/logic.js
index a72458bd..fd8d1f37 100644
--- a/src/main/webapp/cdn/blockly/language/common/logic.js
+++ b/src/main/webapp/cdn/blockly/language/common/logic.js
@@ -58,6 +58,41 @@ Blockly.Blocks.logic_compare.OPERATORS =
['>', 'GT'],
['\u2265', 'GTE']];
+Blockly.Blocks.logic_boolean_compare = {
+ // Comparison operator.
+ category: Blockly.LANG_CATEGORY_LOGIC,
+ init: function() {
+ if(profile.default.description === "Scribbler Robot") {
+ this.setHelpUrl(Blockly.MSG_S3_MATH_HELPURL);
+ } else {
+ this.setHelpUrl(Blockly.MSG_NUMBERS_HELPURL);
+ }
+ this.setTooltip(Blockly.MSG_LOGIC_COMPARE_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.setOutput(true, 'Boolean');
+ this.appendValueInput('A')
+ .setCheck("Number");
+ this.appendValueInput('B')
+ .setCheck("Number")
+ .appendField(new Blockly.FieldDropdown(this.OPERATORS), 'OP');
+ this.setInputsInline(true);
+ // Assign 'this' to a variable for use in the tooltip closure below.
+ //var thisBlock = this;
+ //this.setTooltip(function () {
+ // var op = thisBlock.getFieldValue('OP');
+ // return Blockly.Language.logic_compare.TOOLTIPS[op];
+ //});
+ }
+};
+
+Blockly.Blocks.logic_boolean_compare.OPERATORS =
+ [['=', 'EQ'],
+ ['\u2260', 'NEQ'],
+ ['<', 'LT'],
+ ['\u2264', 'LTE'],
+ ['>', 'GT'],
+ ['\u2265', 'GTE']];
+
//Blockly.Blocks.logic_compare.TOOLTIPS = {
// EQ: Blockly.LANG_LOGIC_COMPARE_TOOLTIP_EQ,
// NEQ: Blockly.LANG_LOGIC_COMPARE_TOOLTIP_NEQ,
@@ -105,6 +140,44 @@ Blockly.Blocks.logic_operation.TOOLTIPS = {
OR: Blockly.LANG_LOGIC_OPERATION_TOOLTIP_OR
};
+Blockly.Blocks.logic_boolean_operation = {
+ // Logical operations: 'and', 'or'.
+ category: Blockly.LANG_CATEGORY_LOGIC,
+ init: function() {
+ if(profile.default.description === "Scribbler Robot") {
+ this.setHelpUrl(Blockly.MSG_S3_MATH_HELPURL);
+ } else {
+ this.setHelpUrl(Blockly.MSG_NUMBERS_HELPURL);
+ }
+ this.setTooltip(Blockly.MSG_LOGIC_OPERATION_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.setOutput(true, 'Boolean');
+ this.appendValueInput('A')
+ .setCheck('Boolean');
+ this.appendValueInput('B')
+ .setCheck('Boolean')
+ .appendField(new Blockly.FieldDropdown(this.OPERATORS), 'OP');
+ this.setInputsInline(true);
+ // Assign 'this' to a variable for use in the tooltip closure below.
+// var thisBlock = this;
+// this.setTooltip(function() {
+// var op = thisBlock.getFieldValue('OP');
+// return Blockly.Language.logic_operation.TOOLTIPS[op];
+// });
+ }
+};
+
+Blockly.Blocks.logic_boolean_operation.OPERATORS =
+ [[Blockly.LANG_LOGIC_OPERATION_AND, 'AND'],
+ [Blockly.LANG_LOGIC_OPERATION_OR, 'OR'],
+ ['and not', 'AND_NOT'],
+ ['or not', 'OR_NOT']];
+
+Blockly.Blocks.logic_boolean_operation.TOOLTIPS = {
+ AND: Blockly.LANG_LOGIC_OPERATION_TOOLTIP_AND,
+ OR: Blockly.LANG_LOGIC_OPERATION_TOOLTIP_OR
+};
+
Blockly.Blocks.logic_negate = {
// Negation.
category: Blockly.LANG_CATEGORY_LOGIC,
@@ -124,6 +197,25 @@ Blockly.Blocks.logic_negate = {
}
};
+Blockly.Blocks.logic_boolean_negate = {
+ // Negation.
+ category: Blockly.LANG_CATEGORY_LOGIC,
+ init: function() {
+ if(profile.default.description === "Scribbler Robot") {
+ this.setHelpUrl(Blockly.MSG_S3_MATH_HELPURL);
+ } else {
+ this.setHelpUrl(Blockly.MSG_NUMBERS_HELPURL);
+ }
+ this.setTooltip(Blockly.MSG_LOGIC_NEGATE_TOOLTIP);
+ this.setColour(colorPalette.getColor('math'));
+ this.setOutput(true, 'Boolean');
+ this.appendValueInput('BOOL')
+ .setCheck('Boolean')
+ .appendField(Blockly.LANG_LOGIC_NEGATE_INPUT_NOT);
+ // this.setTooltip(Blockly.LANG_LOGIC_NEGATE_TOOLTIP);
+ }
+};
+
Blockly.Blocks.logic_boolean = {
// Boolean data type: true and false.
category: Blockly.LANG_CATEGORY_LOGIC,
@@ -390,4 +482,4 @@ Blockly.propc.string_compare = function () {
}
return [code, Blockly.propc.ORDER_NONE];
-};
\ No newline at end of file
+};
diff --git a/src/main/webapp/cdn/blockly/language/en/_messages.js b/src/main/webapp/cdn/blockly/language/en/_messages.js
index 3fb5eac7..d40d41f0 100644
--- a/src/main/webapp/cdn/blockly/language/en/_messages.js
+++ b/src/main/webapp/cdn/blockly/language/en/_messages.js
@@ -42,417 +42,76 @@ Blockly.MSG_DISABLE_BLOCK = 'Disable Block';
Blockly.MSG_ENABLE_BLOCK = 'Enable Block';
Blockly.MSG_HELP = 'Help';
+// Editor dialogs.
+Blockly.Msg.DIALOG_CLEAR_WORKSPACE = 'Clear Workspace';
+Blockly.Msg.DIALOG_CLEAR_WORKSPACE_WARNING = 'Are you sure you want to clear your workspace? This action cannot be undone!';
+Blockly.Msg.DIALOG_CHANGED_SINCE = 'The project has been changed since the last save.';
+Blockly.Msg.DIALOG_PROJECT_SAVED = 'Project saved';
+Blockly.Msg.DIALOG_PROJECT_SAVED_TEXT = 'The project has been saved';
+Blockly.Msg.DIALOG_SIDE_FILES = '';
+Blockly.Msg.DIALOG_SIDE_FILES_WARNING = '';
+Blockly.Msg.DIALOG_NO_CLIENT = ' BlocklyPropClient is not running';
+Blockly.Msg.DIALOG_CLIENT_SEARCHING = ' Looking for BlocklyPropClient';
+
// Variable renaming.
Blockly.MSG_CHANGE_VALUE_TITLE = 'Change value:';
Blockly.MSG_NEW_VARIABLE = 'New variable...';
Blockly.MSG_NEW_VARIABLE_TITLE = 'New variable name:';
Blockly.MSG_RENAME_VARIABLE = 'Rename variable...';
Blockly.MSG_RENAME_VARIABLE_TITLE = 'Rename all "%1" variables to:';
-
-// Pointer renaming.
-Blockly.MSG_NEW_POINTER = 'New pointer...';
-Blockly.MSG_NEW_POINTER_TITLE = 'New pointer name:';
-Blockly.MSG_RENAME_POINTER = 'Rename pointer...';
-Blockly.MSG_RENAME_POINTER_TITLE = 'Rename all "%1" pointers to:';
-
-// Toolbox.
-Blockly.MSG_VARIABLE_CATEGORY = 'Variables';
-Blockly.MSG_PROCEDURE_CATEGORY = 'Methods';
-Blockly.MSG_POINTER_CATEGORY = 'Pointers';
-
-// Colour Blocks.
-Blockly.LANG_CATEGORY_COLOUR = 'Colour';
-Blockly.LANG_COLOUR_PICKER_HELPURL = 'http://en.wikipedia.org/wiki/Color';
-Blockly.LANG_COLOUR_PICKER_TOOLTIP = 'Choose a colour form the palette.';
-
-Blockly.LANG_COLOUR_RGB_HELPURL = 'http://en.wikipedia.org/wiki/RGB_color_model';
-Blockly.LANG_COLOUR_RGB_TITLE = 'colour with';
-Blockly.LANG_COLOUR_RGB_RED = 'red';
-Blockly.LANG_COLOUR_RGB_GREEN = 'green';
-Blockly.LANG_COLOUR_RGB_BLUE = 'blue';
-Blockly.LANG_COLOUR_RGB_TOOLTIP = 'Create a colour with the specified amount of red, green,\n' +
- 'and blue. All values must be between 0.0 and 1.0.';
-
-Blockly.LANG_COLOUR_BLEND_TITLE = 'blend';
-Blockly.LANG_COLOUR_BLEND_COLOUR1 = 'colour 1';
-Blockly.LANG_COLOUR_BLEND_COLOUR2 = 'colour 2';
-Blockly.LANG_COLOUR_BLEND_RATIO = 'ratio';
-Blockly.LANG_COLOUR_BLEND_TOOLTIP = 'Blends two colours together with a given ratio (0.0 - 1.0).';
+Blockly.LANG_VARIABLES_SET_ITEM = 'item';
+Blockly.LANG_VARIABLES_GET_ITEM = 'item';
// Control Blocks.
Blockly.LANG_CATEGORY_CONTROLS = 'Control';
-//Blockly.LANG_CONTROLS_IF_HELPURL = 'http://code.google.com/p/blockly/wiki/If_Then';
-//Blockly.LANG_CONTROLS_IF_TOOLTIP_1 = 'If a value is true, then do some statements.';
-//Blockly.LANG_CONTROLS_IF_TOOLTIP_2 = 'If a value is true, then do the first block of statements.\n' +
-// 'Otherwise, do the second block of statements.';
-//Blockly.LANG_CONTROLS_IF_TOOLTIP_3 = 'If the first value is true, then do the first block of statements.\n' +
-// 'Otherwise, if the second value is true, do the second block of statements.';
-//Blockly.LANG_CONTROLS_IF_TOOLTIP_4 = 'If the first value is true, then do the first block of statements.\n' +
-// 'Otherwise, if the second value is true, do the second block of statements.\n' +
-// 'If none of the values are true, do the last block of statements.';
Blockly.LANG_CONTROLS_IF_MSG_IF = 'if';
Blockly.LANG_CONTROLS_IF_MSG_ELSEIF = 'else if';
Blockly.LANG_CONTROLS_IF_MSG_ELSE = 'else';
Blockly.LANG_CONTROLS_IF_MSG_THEN = 'do';
Blockly.LANG_CONTROLS_IF_IF_TITLE_IF = 'if';
-Blockly.LANG_CONTROLS_IF_IF_TOOLTIP = 'Add, remove, or reorder sections\n' +
- 'to reconfigure this if block.';
-
+Blockly.LANG_CONTROLS_IF_IF_TOOLTIP = 'Add, remove, or reorder sections\nto reconfigure this if block.';
Blockly.LANG_CONTROLS_IF_ELSEIF_TITLE_ELSEIF = 'else if';
Blockly.LANG_CONTROLS_IF_ELSEIF_TOOLTIP = 'Add a condition to the if block.';
Blockly.LANG_CONTROLS_IF_ELSE_TITLE_ELSE = 'else';
Blockly.LANG_CONTROLS_IF_ELSE_TOOLTIP = 'Add a final, catch-all condition to the if block.';
-//Blockly.LANG_CONTROLS_REPEAT_HELPURL = 'http://en.wikipedia.org/wiki/For_loop';
Blockly.LANG_CONTROLS_REPEAT_TITLE_REPEAT = 'repeat';
Blockly.LANG_CONTROLS_REPEAT_TITLE_TIMES = 'times';
Blockly.LANG_CONTROLS_REPEAT_INPUT_DO = 'do';
-//Blockly.LANG_CONTROLS_REPEAT_TOOLTIP = 'Do some statements several times.';
-
-Blockly.LANG_CONTROLS_WHILEUNTIL_HELPURL = 'http://code.google.com/p/blockly/wiki/Repeat';
-Blockly.LANG_CONTROLS_WHILEUNTIL_TITLE_REPEAT = 'repeat';
-Blockly.LANG_CONTROLS_WHILEUNTIL_INPUT_DO = 'do';
-Blockly.LANG_CONTROLS_WHILEUNTIL_OPERATOR_WHILE = 'while';
-Blockly.LANG_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL = 'until';
-Blockly.LANG_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE = 'While a value is true, then do some statements.';
-Blockly.LANG_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL = 'While a value is false, then do some statements.';
-
-Blockly.LANG_CONTROLS_FOR_HELPURL = 'http://en.wikipedia.org/wiki/For_loop';
-Blockly.LANG_CONTROLS_FOR_INPUT_WITH = 'count with';
-Blockly.LANG_CONTROLS_FOR_INPUT_VAR = 'x';
-Blockly.LANG_CONTROLS_FOR_INPUT_FROM = 'from';
-Blockly.LANG_CONTROLS_FOR_INPUT_TO = 'to';
-Blockly.LANG_CONTROLS_FOR_INPUT_DO = 'do';
-Blockly.LANG_CONTROLS_FOR_TOOLTIP = 'Count from a start number to an end number.\n' +
- 'For each count, set the current count number to\n' +
- 'variable "%1", and then do some statements.';
-
-Blockly.LANG_CONTROLS_FOREACH_HELPURL = 'http://en.wikipedia.org/wiki/For_loop';
-Blockly.LANG_CONTROLS_FOREACH_INPUT_ITEM = 'for each item';
-Blockly.LANG_CONTROLS_FOREACH_INPUT_VAR = 'x';
-Blockly.LANG_CONTROLS_FOREACH_INPUT_INLIST = 'in list';
-Blockly.LANG_CONTROLS_FOREACH_INPUT_DO = 'do';
-Blockly.LANG_CONTROLS_FOREACH_TOOLTIP = 'For each item in a list, set the item to\n' +
- 'variable "%1", and then do some statements.';
-
-Blockly.LANG_CONTROLS_FLOW_STATEMENTS_HELPURL = 'http://en.wikipedia.org/wiki/Control_flow';
Blockly.LANG_CONTROLS_FLOW_STATEMENTS_INPUT_OFLOOP = 'of loop';
Blockly.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK = 'break out';
Blockly.LANG_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE = 'continue with next iteration';
-Blockly.LANG_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK = 'Break out of the containing loop.';
-Blockly.LANG_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE = 'Skip the rest of this loop, and\n' +
- 'continue with the next iteration.';
-Blockly.LANG_CONTROLS_FLOW_STATEMENTS_WARNING = 'Warning:\n' +
- 'This block may only\n' +
- 'be used within a loop.';
+Blockly.LANG_CONTROLS_FLOW_STATEMENTS_WARNING = 'Warning:\nThis block may only\nbe used within a loop.';
// Logic Blocks.
Blockly.LANG_CATEGORY_LOGIC = 'Logic';
-//Blockly.LANG_LOGIC_COMPARE_HELPURL = 'http://en.wikipedia.org/wiki/Inequality_(mathematics)';
-//Blockly.LANG_LOGIC_COMPARE_TOOLTIP_EQ = 'Return true if both inputs equal each other.';
-//Blockly.LANG_LOGIC_COMPARE_TOOLTIP_NEQ = 'Return true if both inputs are not equal to each other.';
-//Blockly.LANG_LOGIC_COMPARE_TOOLTIP_LT = 'Return true if the first input is smaller\n' +
-// 'than the second input.';
-//Blockly.LANG_LOGIC_COMPARE_TOOLTIP_LTE = 'Return true if the first input is smaller\n' +
-// 'than or equal to the second input.';
-//Blockly.LANG_LOGIC_COMPARE_TOOLTIP_GT = 'Return true if the first input is greater\n' +
-// 'than the second input.';
-//Blockly.LANG_LOGIC_COMPARE_TOOLTIP_GTE = 'Return true if the first input is greater\n' +
-// 'than or equal to the second input.';
-
-//Blockly.LANG_LOGIC_OPERATION_HELPURL = 'http://code.google.com/p/blockly/wiki/And_Or';
Blockly.LANG_LOGIC_OPERATION_AND = 'and';
Blockly.LANG_LOGIC_OPERATION_OR = 'or';
-//Blockly.LANG_LOGIC_OPERATION_TOOLTIP_AND = 'Return true if both inputs are true.';
-//Blockly.LANG_LOGIC_OPERATION_TOOLTIP_OR = 'Return true if either inputs are true.';
-
-//Blockly.LANG_LOGIC_NEGATE_HELPURL = 'http://code.google.com/p/blockly/wiki/Not';
Blockly.LANG_LOGIC_NEGATE_INPUT_NOT = 'not';
-//Blockly.LANG_LOGIC_NEGATE_TOOLTIP = 'Returns true if the input is false.\n' +
-// 'Returns false if the input is true.';
-
-//Blockly.LANG_LOGIC_BOOLEAN_HELPURL = 'http://code.google.com/p/blockly/wiki/True_False';
Blockly.LANG_LOGIC_BOOLEAN_TRUE = 'true';
Blockly.LANG_LOGIC_BOOLEAN_FALSE = 'false';
-//Blockly.LANG_LOGIC_BOOLEAN_TOOLTIP = 'Returns either true or false.';
-
-Blockly.LANG_LOGIC_NULL_HELPURL = 'http://en.wikipedia.org/wiki/Nullable_type';
Blockly.LANG_LOGIC_NULL = 'null';
-Blockly.LANG_LOGIC_NULL_TOOLTIP = 'Returns null.';
// Math Blocks.
Blockly.LANG_CATEGORY_MATH = 'Math';
-//Blockly.LANG_MATH_NUMBER_HELPURL = 'http://en.wikipedia.org/wiki/Number';
-//Blockly.LANG_MATH_NUMBER_TOOLTIP = 'A number.';
-
-//Blockly.LANG_MATH_ARITHMETIC_HELPURL = 'http://en.wikipedia.org/wiki/Arithmetic';
-//Blockly.LANG_MATH_ARITHMETIC_TOOLTIP_ADD = 'Return the sum of the two numbers.';
-//Blockly.LANG_MATH_ARITHMETIC_TOOLTIP_MINUS = 'Return the difference of the two numbers.';
-//Blockly.LANG_MATH_ARITHMETIC_TOOLTIP_MULTIPLY = 'Return the product of the two numbers.';
-//Blockly.LANG_MATH_ARITHMETIC_TOOLTIP_DIVIDE = 'Return the quotient of the two numbers.';
-//Blockly.LANG_MATH_ARITHMETIC_TOOLTIP_POWER = 'Return the first number raised to\n' +
-// 'the power of the second number.';
-
-Blockly.LANG_MATH_CHANGE_HELPURL = 'http://en.wikipedia.org/wiki/Negation';
-Blockly.LANG_MATH_CHANGE_TITLE_CHANGE = 'change';
-Blockly.LANG_MATH_CHANGE_TITLE_ITEM = 'item';
-Blockly.LANG_MATH_CHANGE_INPUT_BY = 'by';
-Blockly.LANG_MATH_CHANGE_TOOLTIP = 'Add a number to variable "%1".';
-
-Blockly.LANG_MATH_SINGLE_HELPURL = 'http://en.wikipedia.org/wiki/Square_root';
-Blockly.LANG_MATH_SINGLE_OP_ROOT = 'square root';
-Blockly.LANG_MATH_SINGLE_OP_ABSOLUTE = 'absolute';
-Blockly.LANG_MATH_SINGLE_TOOLTIP_ROOT = 'Return the square root of a number.';
-Blockly.LANG_MATH_SINGLE_TOOLTIP_ABS = 'Return the absolute value of a number.';
-Blockly.LANG_MATH_SINGLE_TOOLTIP_NEG = 'Return the negation of a number.';
-Blockly.LANG_MATH_SINGLE_TOOLTIP_LN = 'Return the natural logarithm of a number.';
-Blockly.LANG_MATH_SINGLE_TOOLTIP_LOG10 = 'Return the base 10 logarithm of a number.';
-Blockly.LANG_MATH_SINGLE_TOOLTIP_EXP = 'Return e to the power of a number.';
-Blockly.LANG_MATH_SINGLE_TOOLTIP_POW10 = 'Return 10 to the power of a number.';
-
-Blockly.LANG_MATH_ROUND_HELPURL = 'http://en.wikipedia.org/wiki/Rounding';
-Blockly.LANG_MATH_ROUND_TOOLTIP = 'Round a number up or down.';
-Blockly.LANG_MATH_ROUND_OPERATOR_ROUND = 'round';
-Blockly.LANG_MATH_ROUND_OPERATOR_ROUNDUP = 'round up';
-Blockly.LANG_MATH_ROUND_OPERATOR_ROUNDDOWN = 'round down';
-
-Blockly.LANG_MATH_TRIG_HELPURL = 'http://en.wikipedia.org/wiki/Trigonometric_functions';
-Blockly.LANG_MATH_TRIG_TOOLTIP_SIN = 'Return the sine of a degree.';
-Blockly.LANG_MATH_TRIG_TOOLTIP_COS = 'Return the cosine of a degree.';
-Blockly.LANG_MATH_TRIG_TOOLTIP_TAN = 'Return the tangent of a degree.';
-Blockly.LANG_MATH_TRIG_TOOLTIP_ASIN = 'Return the arcsine of a number.';
-Blockly.LANG_MATH_TRIG_TOOLTIP_ACOS = 'Return the arccosine of a number.';
-Blockly.LANG_MATH_TRIG_TOOLTIP_ATAN = 'Return the arctangent of a number.';
-
-Blockly.LANG_MATH_ONLIST_HELPURL = '';
-Blockly.LANG_MATH_ONLIST_INPUT_OFLIST = 'of list';
-Blockly.LANG_MATH_ONLIST_OPERATOR_SUM = 'sum';
-Blockly.LANG_MATH_ONLIST_OPERATOR_MIN = 'min';
-Blockly.LANG_MATH_ONLIST_OPERATOR_MAX = 'max';
-Blockly.LANG_MATH_ONLIST_OPERATOR_AVERAGE = 'average';
-Blockly.LANG_MATH_ONLIST_OPERATOR_MEDIAN = 'median';
-Blockly.LANG_MATH_ONLIST_OPERATOR_MODE = 'modes';
-Blockly.LANG_MATH_ONLIST_OPERATOR_STD_DEV = 'standard deviation';
-Blockly.LANG_MATH_ONLIST_OPERATOR_RANDOM = 'random item';
-Blockly.LANG_MATH_ONLIST_TOOLTIP_SUM = 'Return the sum of all the numbers in the list.';
-Blockly.LANG_MATH_ONLIST_TOOLTIP_MIN = 'Return the smallest number in the list.';
-Blockly.LANG_MATH_ONLIST_TOOLTIP_MAX = 'Return the largest number in the list.';
-Blockly.LANG_MATH_ONLIST_TOOLTIP_AVERAGE = 'Return the arithmetic mean of the list.';
-Blockly.LANG_MATH_ONLIST_TOOLTIP_MEDIAN = 'Return the median number in the list.';
-Blockly.LANG_MATH_ONLIST_TOOLTIP_MODE = 'Return a list of the most common item(s) in the list.';
-Blockly.LANG_MATH_ONLIST_TOOLTIP_STD_DEV = 'Return the standard deviation of the list.';
-Blockly.LANG_MATH_ONLIST_TOOLTIP_RANDOM = 'Return a random element from the list.';
-
-Blockly.LANG_MATH_CONSTRAIN_HELPURL = 'http://en.wikipedia.org/wiki/Clamping_%28graphics%29';
-Blockly.LANG_MATH_CONSTRAIN_INPUT_CONSTRAIN = 'constrain';
-Blockly.LANG_MATH_CONSTRAIN_INPUT_LOW = 'between (low)';
-Blockly.LANG_MATH_CONSTRAIN_INPUT_HIGH = 'and (high)';
-Blockly.LANG_MATH_CONSTRAIN_TOOLTIP = 'Constrain a number to be between the specified limits (inclusive).';
-
-Blockly.LANG_MATH_MODULO_HELPURL = 'http://en.wikipedia.org/wiki/Modulo_operation';
-Blockly.LANG_MATH_MODULO_INPUT_DIVIDEND = 'remainder of';
-Blockly.LANG_MATH_MODULO_TOOLTIP = 'Return the remainder of dividing both numbers.';
-
-Blockly.LANG_MATH_RANDOM_INT_HELPURL = 'http://en.wikipedia.org/wiki/Random_number_generation';
-Blockly.LANG_MATH_RANDOM_INT_INPUT_FROM = 'random integer from';
-Blockly.LANG_MATH_RANDOM_INT_INPUT_TO = 'to';
-Blockly.LANG_MATH_RANDOM_INT_TOOLTIP = 'Return a random integer between the two\n' +
- 'specified limits, inclusive.';
-
-Blockly.LANG_MATH_RANDOM_FLOAT_HELPURL = 'http://en.wikipedia.org/wiki/Random_number_generation';
-Blockly.LANG_MATH_RANDOM_FLOAT_TITLE_RANDOM = 'random fraction';
-Blockly.LANG_MATH_RANDOM_FLOAT_TOOLTIP = 'Return a random fraction between\n' +
- '0.0 (inclusive) and 1.0 (exclusive).';
-
-// Text Blocks.
-Blockly.LANG_CATEGORY_TEXT = 'Text';
-Blockly.LANG_TEXT_TEXT_HELPURL = 'http://en.wikipedia.org/wiki/String_(computer_science)';
-Blockly.LANG_TEXT_TEXT_TOOLTIP = 'A letter, word, or line of text.';
-
-Blockly.LANG_TEXT_JOIN_HELPURL = '';
-Blockly.LANG_TEXT_JOIN_TITLE_CREATEWITH = 'create text with';
-Blockly.LANG_TEXT_JOIN_TOOLTIP = 'Create a piece of text by joining\n' +
- 'together any number of items.';
-
-Blockly.LANG_TEXT_CREATE_JOIN_TITLE_JOIN = 'join';
-Blockly.LANG_TEXT_CREATE_JOIN_TOOLTIP = 'Add, remove, or reorder sections to reconfigure this text block.';
-
-Blockly.LANG_TEXT_CREATE_JOIN_ITEM_TITLE_ITEM = 'item';
-Blockly.LANG_TEXT_CREATE_JOIN_ITEM_TOOLTIP = 'Add an item to the text.';
-
-Blockly.LANG_TEXT_APPEND_HELPURL = 'http://www.liv.ac.uk/HPC/HTMLF90Course/HTMLF90CourseNotesnode91.html';
-Blockly.LANG_TEXT_APPEND_TO = 'to';
-Blockly.LANG_TEXT_APPEND_APPENDTEXT = 'append text';
-Blockly.LANG_TEXT_APPEND_VARIABLE = 'item';
-Blockly.LANG_TEXT_APPEND_TOOLTIP = 'Append some text to variable "%1".';
-
-Blockly.LANG_TEXT_LENGTH_HELPURL = 'http://www.liv.ac.uk/HPC/HTMLF90Course/HTMLF90CourseNotesnode91.html';
-Blockly.LANG_TEXT_LENGTH_INPUT_LENGTH = 'length';
-Blockly.LANG_TEXT_LENGTH_TOOLTIP = 'Returns number of letters (including spaces)\n' +
- 'in the provided text.';
-
-Blockly.LANG_TEXT_ISEMPTY_HELPURL = 'http://www.liv.ac.uk/HPC/HTMLF90Course/HTMLF90CourseNotesnode91.html';
-Blockly.LANG_TEXT_ISEMPTY_INPUT_ISEMPTY = 'is empty';
-Blockly.LANG_TEXT_ISEMPTY_TOOLTIP = 'Returns true if the provided text is empty.';
-
-Blockly.LANG_TEXT_ENDSTRING_HELPURL = 'http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Farsubex.htm';
-Blockly.LANG_TEXT_ENDSTRING_INPUT = 'letters in text';
-Blockly.LANG_TEXT_ENDSTRING_TOOLTIP = 'Returns specified number of letters at the beginning or end of the text.';
-Blockly.LANG_TEXT_ENDSTRING_OPERATOR_FIRST = 'first';
-Blockly.LANG_TEXT_ENDSTRING_OPERATOR_LAST = 'last';
-
-Blockly.LANG_TEXT_INDEXOF_HELPURL = 'http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Farsubex.htm';
-Blockly.LANG_TEXT_INDEXOF_TITLE_FIND = 'find';
-Blockly.LANG_TEXT_INDEXOF_INPUT_OCCURRENCE = 'occurrence of text';
-Blockly.LANG_TEXT_INDEXOF_INPUT_INTEXT = 'in text';
-Blockly.LANG_TEXT_INDEXOF_TOOLTIP = 'Returns the index of the first/last occurrence\n' +
- 'of first text in the second text.\n' +
- 'Returns 0 if text is not found.';
-Blockly.LANG_TEXT_INDEXOF_OPERATOR_FIRST = 'first';
-Blockly.LANG_TEXT_INDEXOF_OPERATOR_LAST = 'last';
-
-Blockly.LANG_TEXT_CHARAT_HELPURL = 'http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Farsubex.htm';
-Blockly.LANG_TEXT_CHARAT_INPUT_AT = 'letter at';
-Blockly.LANG_TEXT_CHARAT_INPUT_INTEXT = 'in text';
-Blockly.LANG_TEXT_CHARAT_TOOLTIP = 'Returns the letter at the specified position.';
-
-Blockly.LANG_TEXT_CHANGECASE_HELPURL = 'http://www.liv.ac.uk/HPC/HTMLF90Course/HTMLF90CourseNotesnode91.html';
-Blockly.LANG_TEXT_CHANGECASE_TITLE_TO = 'to';
-Blockly.LANG_TEXT_CHANGECASE_TOOLTIP = 'Return a copy of the text in a different case.';
-Blockly.LANG_TEXT_CHANGECASE_OPERATOR_UPPERCASE = 'UPPER CASE';
-Blockly.LANG_TEXT_CHANGECASE_OPERATOR_LOWERCASE = 'lower case';
-Blockly.LANG_TEXT_CHANGECASE_OPERATOR_TITLECASE = 'Title Case';
-
-Blockly.LANG_TEXT_TRIM_HELPURL = 'http://www.liv.ac.uk/HPC/HTMLF90Course/HTMLF90CourseNotesnode91.html';
-Blockly.LANG_TEXT_TRIM_TITLE_SPACE = 'trim spaces from';
-Blockly.LANG_TEXT_TRIM_TITLE_SIDES = 'sides';
-Blockly.LANG_TEXT_TRIM_TOOLTIP = 'Return a copy of the text with spaces\n' +
- 'removed from one or both ends.';
-Blockly.LANG_TEXT_TRIM_TITLE_SIDES = 'sides';
-Blockly.LANG_TEXT_TRIM_TITLE_SIDE = 'side';
-Blockly.LANG_TEXT_TRIM_OPERATOR_BOTH = 'both';
-Blockly.LANG_TEXT_TRIM_OPERATOR_LEFT = 'left';
-Blockly.LANG_TEXT_TRIM_OPERATOR_RIGHT = 'right';
-
-Blockly.LANG_TEXT_PRINT_HELPURL = 'http://www.liv.ac.uk/HPC/HTMLF90Course/HTMLF90CourseNotesnode91.html';
-Blockly.LANG_TEXT_PRINT_TITLE_PRINT = 'print';
-Blockly.LANG_TEXT_PRINT_TOOLTIP = 'Print the specified text, number or other value.';
-
-Blockly.LANG_TEXT_PROMPT_HELPURL = 'http://www.liv.ac.uk/HPC/HTMLF90Course/HTMLF90CourseNotesnode92.html';
-Blockly.LANG_TEXT_PROMPT_TITLE_PROMPT_FOR = 'prompt for';
-Blockly.LANG_TEXT_PROMPT_TITILE_WITH_MESSAGE = 'with message';
-Blockly.LANG_TEXT_PROMPT_TOOLTIP = 'Prompt for user input with the specified text.';
-Blockly.LANG_TEXT_PROMPT_TYPE_TEXT = 'text';
-Blockly.LANG_TEXT_PROMPT_TYPE_NUMBER = 'number';
-
-// Lists Blocks.
-Blockly.LANG_CATEGORY_LISTS = 'Lists';
-Blockly.LANG_LISTS_CREATE_EMPTY_HELPURL = 'http://en.wikipedia.org/wiki/Linked_list#Empty_lists';
-Blockly.LANG_LISTS_CREATE_EMPTY_TITLE = 'create empty list';
-Blockly.LANG_LISTS_CREATE_EMPTY_TOOLTIP = 'Returns a list, of length 0, containing no data records';
-
-Blockly.LANG_LISTS_CREATE_WITH_INPUT_WITH = 'create list with';
-Blockly.LANG_LISTS_CREATE_WITH_TOOLTIP = 'Create a list with any number of items.';
-
-Blockly.LANG_LISTS_CREATE_WITH_CONTAINER_TITLE_ADD = 'list';
-Blockly.LANG_LISTS_CREATE_WITH_CONTAINER_TOOLTIP = 'Add, remove, or reorder sections to reconfigure this list block.';
-
-Blockly.LANG_LISTS_CREATE_WITH_ITEM_TITLE = 'item';
-Blockly.LANG_LISTS_CREATE_WITH_ITEM_TOOLTIP = 'Add an item to the list.';
-
-Blockly.LANG_LISTS_REPEAT_HELPURL = 'http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Farsubex.htm';
-Blockly.LANG_LISTS_REPEAT_INPUT_WITH = 'create list with item';
-Blockly.LANG_LISTS_REPEAT_INPUT_REPEATED = 'repeated';
-Blockly.LANG_LISTS_REPEAT_INPUT_TIMES = 'times';
-Blockly.LANG_LISTS_REPEAT_TOOLTIP = 'Creates a list consisting of the given value\n' +
- 'repeated the specified number of times.';
-
-Blockly.LANG_LISTS_LENGTH_HELPURL = 'http://www.liv.ac.uk/HPC/HTMLF90Course/HTMLF90CourseNotesnode91.html';
-Blockly.LANG_LISTS_LENGTH_INPUT_LENGTH = 'length';
-Blockly.LANG_LISTS_LENGTH_TOOLTIP = 'Returns the length of a list.';
-
-Blockly.LANG_LISTS_IS_EMPTY_HELPURL = 'http://www.liv.ac.uk/HPC/HTMLF90Course/HTMLF90CourseNotesnode91.html';
-Blockly.LANG_LISTS_INPUT_IS_EMPTY = 'is empty';
-Blockly.LANG_LISTS_TOOLTIP = 'Returns true if the list is empty.';
-
-Blockly.LANG_LISTS_INDEX_OF_HELPURL = 'http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Farsubex.htm';
-Blockly.LANG_LISTS_INDEX_OF_TITLE_FIND = 'find';
-Blockly.LANG_LISTS_INDEX_OF_INPUT_OCCURRENCE = 'occurrence of item';
-Blockly.LANG_LISTS_INDEX_OF_INPUT_IN_LIST = 'in list';
-Blockly.LANG_LISTS_INDEX_OF_TOOLTIP = 'Returns the index of the first/last occurrence\n' +
- 'of the item in the list.\n' +
- 'Returns 0 if text is not found.';
-Blockly.LANG_LISTS_INDEX_OF_FIRST = 'first';
-Blockly.LANG_LISTS_INDEX_OF_LAST = 'last';
-
-Blockly.LANG_LISTS_GET_INDEX_HELPURL = 'http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Farsubex.htm';
-Blockly.LANG_LISTS_GET_INDEX_INPUT_AT = 'get item at';
-Blockly.LANG_LISTS_GET_INDEX_INPUT_IN_LIST = 'in list';
-Blockly.LANG_LISTS_GET_INDEX_TOOLTIP = 'Returns the value at the specified position in a list.';
-
-Blockly.LANG_LISTS_SET_INDEX_HELPURL = 'http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Farsubex.htm';
-Blockly.LANG_LISTS_SET_INDEX_INPUT_AT = 'set item at';
-Blockly.LANG_LISTS_SET_INDEX_INPUT_IN_LIST = 'in list';
-Blockly.LANG_LISTS_SET_INDEX_INPUT_TO = 'to';
-Blockly.LANG_LISTS_SET_INDEX_TOOLTIP = 'Sets the value at the specified position in a list.';
-
-// Variables Blocks.
-Blockly.LANG_VARIABLES_GET_HELPURL = 'http://en.wikipedia.org/wiki/Variable_(computer_science)';
-Blockly.LANG_VARIABLES_GET_TITLE = 'get';
-Blockly.LANG_VARIABLES_GET_ITEM = 'item';
-Blockly.LANG_VARIABLES_GET_TOOLTIP = 'Returns the value of this variable.';
-
-Blockly.LANG_VARIABLES_SET_HELPURL = 'http://en.wikipedia.org/wiki/Variable_(computer_science)';
-Blockly.LANG_VARIABLES_SET_TITLE = 'set';
-Blockly.LANG_VARIABLES_SET_ITEM = 'item';
-Blockly.LANG_VARIABLES_SET_TOOLTIP = 'Sets this variable to be equal to the input.';
// Procedures Blocks.
-Blockly.LANG_PROCEDURES_DEFNORETURN_HELPURL = 'http://en.wikipedia.org/wiki/Procedure_%28computer_science%29';
Blockly.LANG_PROCEDURES_DEFNORETURN_PROCEDURE = 'method';
Blockly.LANG_PROCEDURES_DEFNORETURN_DO = 'do';
-Blockly.LANG_PROCEDURES_DEFNORETURN_TOOLTIP = 'A method with no return value.';
-
-Blockly.LANG_PROCEDURES_DEFRETURN_HELPURL = 'http://en.wikipedia.org/wiki/Procedure_%28computer_science%29';
Blockly.LANG_PROCEDURES_DEFRETURN_PROCEDURE = Blockly.LANG_PROCEDURES_DEFNORETURN_PROCEDURE;
Blockly.LANG_PROCEDURES_DEFRETURN_DO = Blockly.LANG_PROCEDURES_DEFNORETURN_DO;
Blockly.LANG_PROCEDURES_DEFRETURN_RETURN = 'return';
-Blockly.LANG_PROCEDURES_DEFRETURN_TOOLTIP = 'A method with a return value.';
-
-Blockly.LANG_PROCEDURES_DEF_DUPLICATE_WARNING = 'Warning:\n' +
- 'This method has\n' +
- 'duplicate parameters.';
-
-Blockly.LANG_PROCEDURES_CALLNORETURN_HELPURL = 'http://en.wikipedia.org/wiki/Procedure_%28computer_science%29';
+Blockly.LANG_PROCEDURES_DEF_DUPLICATE_WARNING = 'Warning:\nThis method has\nduplicate parameters.';
Blockly.LANG_PROCEDURES_CALLNORETURN_CALL = 'do';
Blockly.LANG_PROCEDURES_CALLNORETURN_PROCEDURE = 'method';
-Blockly.LANG_PROCEDURES_CALLNORETURN_TOOLTIP = 'Call a method with no return value.';
-
-Blockly.LANG_PROCEDURES_CALLRETURN_HELPURL = 'http://en.wikipedia.org/wiki/Procedure_%28computer_science%29';
Blockly.LANG_PROCEDURES_CALLRETURN_CALL = Blockly.LANG_PROCEDURES_CALLNORETURN_CALL;
Blockly.LANG_PROCEDURES_CALLRETURN_PROCEDURE = Blockly.LANG_PROCEDURES_CALLNORETURN_PROCEDURE;
-Blockly.LANG_PROCEDURES_CALLRETURN_TOOLTIP = 'Call a method with a return value.';
-
Blockly.LANG_PROCEDURES_MUTATORCONTAINER_TITLE = 'parameters';
Blockly.LANG_PROCEDURES_MUTATORARG_TITLE = 'variable:';
-
Blockly.LANG_PROCEDURES_HIGHLIGHT_DEF = 'Highlight Procedure';
-
-Blockly.LANG_PROCEDURES_IFRETURN_TOOLTIP = 'If a value is true, then return a value.';
-Blockly.LANG_PROCEDURES_IFRETURN_WARNING = 'Warning:\n' +
- 'This block may only be\n' +
- 'used within a method.';
-
-
-// Bit Math Blocks.
-Blockly.LANG_CATEGORY_BIT_MATH = 'Bit math';
-
-Blockly.LANG_CATEGORY_COG = 'Cog';
-
-
-
+Blockly.LANG_PROCEDURES_IFRETURN_WARNING = 'Warning:\nThis block may only be\nused within a method.';
Blockly.Msg.ADD_COMMENT = "Add Comment";
Blockly.Msg.AUTH = "Please authorize this app to enable your work to be saved and to allow it to be shared by you.";
@@ -461,55 +120,7 @@ Blockly.Msg.CHAT = "Chat with your collaborator by typing in this box!";
Blockly.Msg.CLEAN_UP = "Clean up Blocks";
Blockly.Msg.COLLAPSE_ALL = "Collapse Blocks";
Blockly.Msg.COLLAPSE_BLOCK = "Collapse Block";
-Blockly.Msg.COLOUR_BLEND_COLOUR1 = "colour 1";
-Blockly.Msg.COLOUR_BLEND_COLOUR2 = "colour 2";
-Blockly.Msg.COLOUR_BLEND_HELPURL = "http://meyerweb.com/eric/tools/color-blend/";
-Blockly.Msg.COLOUR_BLEND_RATIO = "ratio";
-Blockly.Msg.COLOUR_BLEND_TITLE = "blend";
-Blockly.Msg.COLOUR_BLEND_TOOLTIP = "Blends two colours together with a given ratio (0.0 - 1.0).";
-Blockly.Msg.COLOUR_PICKER_HELPURL = "https://en.wikipedia.org/wiki/Color";
-Blockly.Msg.COLOUR_PICKER_TOOLTIP = "Choose a colour from the palette.";
-Blockly.Msg.COLOUR_RANDOM_HELPURL = "http://randomcolour.com";
-Blockly.Msg.COLOUR_RANDOM_TITLE = "random colour";
-Blockly.Msg.COLOUR_RANDOM_TOOLTIP = "Choose a colour at random.";
-Blockly.Msg.COLOUR_RGB_BLUE = "blue";
-Blockly.Msg.COLOUR_RGB_GREEN = "green";
-Blockly.Msg.COLOUR_RGB_HELPURL = "http://www.december.com/html/spec/colorper.html";
-Blockly.Msg.COLOUR_RGB_RED = "red";
-Blockly.Msg.COLOUR_RGB_TITLE = "colour with";
-Blockly.Msg.COLOUR_RGB_TOOLTIP = "Create a colour with the specified amount of red, green, and blue. All values must be between 0 and 100.";
-Blockly.Msg.CONTROLS_FLOW_STATEMENTS_HELPURL = "https://github.com/google/blockly/wiki/Loops#loop-termination-blocks";
-Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK = "break out of loop";
-Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE = "continue with next iteration of loop";
-Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK = "Break out of the containing loop.";
-Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE = "Skip the rest of this loop, and continue with the next iteration.";
-Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING = "Warning: This block may only be used within a loop.";
-Blockly.Msg.CONTROLS_FOREACH_HELPURL = "https://github.com/google/blockly/wiki/Loops#for-each";
-Blockly.Msg.CONTROLS_FOREACH_TITLE = "for each item %1 in list %2";
-Blockly.Msg.CONTROLS_FOREACH_TOOLTIP = "For each item in a list, set the variable '%1' to the item, and then do some statements.";
-Blockly.Msg.CONTROLS_FOR_HELPURL = "https://github.com/google/blockly/wiki/Loops#count-with";
-Blockly.Msg.CONTROLS_FOR_TITLE = "count with %1 from %2 to %3 by %4";
-Blockly.Msg.CONTROLS_FOR_TOOLTIP = "Have the variable '%1' take on the values from the start number to the end number, counting by the specified interval, and do the specified blocks.";
-Blockly.Msg.CONTROLS_IF_ELSEIF_TOOLTIP = "Add a condition to the if block.";
-Blockly.Msg.CONTROLS_IF_ELSE_TOOLTIP = "Add a final, catch-all condition to the if block.";
-Blockly.Msg.CONTROLS_IF_HELPURL = "https://github.com/google/blockly/wiki/IfElse";
-Blockly.Msg.CONTROLS_IF_IF_TOOLTIP = "Add, remove, or reorder sections to reconfigure this if block.";
-Blockly.Msg.CONTROLS_IF_MSG_ELSE = "else";
-Blockly.Msg.CONTROLS_IF_MSG_ELSEIF = "else if";
-Blockly.Msg.CONTROLS_IF_MSG_IF = "if";
-Blockly.Msg.CONTROLS_IF_TOOLTIP_1 = "If a value is true, then do some statements.";
-Blockly.Msg.CONTROLS_IF_TOOLTIP_2 = "If a value is true, then do the first block of statements. Otherwise, do the second block of statements.";
-Blockly.Msg.CONTROLS_IF_TOOLTIP_3 = "If the first value is true, then do the first block of statements. Otherwise, if the second value is true, do the second block of statements.";
-Blockly.Msg.CONTROLS_IF_TOOLTIP_4 = "If the first value is true, then do the first block of statements. Otherwise, if the second value is true, do the second block of statements. If none of the values are true, do the last block of statements.";
-Blockly.Msg.CONTROLS_REPEAT_HELPURL = "https://en.wikipedia.org/wiki/For_loop";
-Blockly.Msg.CONTROLS_REPEAT_INPUT_DO = "do";
-Blockly.Msg.CONTROLS_REPEAT_TITLE = "repeat %1 times";
-Blockly.Msg.CONTROLS_REPEAT_TOOLTIP = "Do some statements several times.";
-Blockly.Msg.CONTROLS_WHILEUNTIL_HELPURL = "https://github.com/google/blockly/wiki/Loops#repeat";
-Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_UNTIL = "repeat until";
-Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE = "repeat while";
-Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL = "While a value is false, then do some statements.";
-Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE = "While a value is true, then do some statements.";
+
Blockly.Msg.DELETE_ALL_BLOCKS = "Delete all %1 blocks?";
Blockly.Msg.DELETE_BLOCK = "Delete Block";
Blockly.Msg.DELETE_X_BLOCKS = "Delete %1 Blocks";
@@ -521,316 +132,66 @@ Blockly.Msg.EXPAND_BLOCK = "Expand Block";
Blockly.Msg.EXTERNAL_INPUTS = "External Inputs";
Blockly.Msg.HELP = "Help";
Blockly.Msg.INLINE_INPUTS = "Inline Inputs";
-Blockly.Msg.LISTS_CREATE_EMPTY_HELPURL = "https://github.com/google/blockly/wiki/Lists#create-empty-list";
-Blockly.Msg.LISTS_CREATE_EMPTY_TITLE = "create empty list";
-Blockly.Msg.LISTS_CREATE_EMPTY_TOOLTIP = "Returns a list, of length 0, containing no data records";
-Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD = "list";
-Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP = "Add, remove, or reorder sections to reconfigure this list block.";
-Blockly.Msg.LISTS_CREATE_WITH_HELPURL = "https://github.com/google/blockly/wiki/Lists#create-list-with";
-Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH = "create list with";
-Blockly.Msg.LISTS_CREATE_WITH_ITEM_TOOLTIP = "Add an item to the list.";
-Blockly.Msg.LISTS_CREATE_WITH_TOOLTIP = "Create a list with any number of items.";
-Blockly.Msg.LISTS_GET_INDEX_FIRST = "first";
-Blockly.Msg.LISTS_GET_INDEX_FROM_END = "# from end";
-Blockly.Msg.LISTS_GET_INDEX_FROM_START = "#";
-Blockly.Msg.LISTS_GET_INDEX_GET = "get";
-Blockly.Msg.LISTS_GET_INDEX_GET_REMOVE = "get and remove";
-Blockly.Msg.LISTS_GET_INDEX_LAST = "last";
-Blockly.Msg.LISTS_GET_INDEX_RANDOM = "random";
-Blockly.Msg.LISTS_GET_INDEX_REMOVE = "remove";
-Blockly.Msg.LISTS_GET_INDEX_TAIL = "";
-Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FIRST = "Returns the first item in a list.";
-Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM_END = "Returns the item at the specified position in a list. #1 is the last item.";
-Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM_START = "Returns the item at the specified position in a list. #1 is the first item.";
-Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_LAST = "Returns the last item in a list.";
-Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM = "Returns a random item in a list.";
-Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST = "Removes and returns the first item in a list.";
-Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM_END = "Removes and returns the item at the specified position in a list. #1 is the last item.";
-Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM_START = "Removes and returns the item at the specified position in a list. #1 is the first item.";
-Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST = "Removes and returns the last item in a list.";
-Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM = "Removes and returns a random item in a list.";
-Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST = "Removes the first item in a list.";
-Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM_END = "Removes the item at the specified position in a list. #1 is the last item.";
-Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM_START = "Removes the item at the specified position in a list. #1 is the first item.";
-Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST = "Removes the last item in a list.";
-Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM = "Removes a random item in a list.";
-Blockly.Msg.LISTS_GET_SUBLIST_END_FROM_END = "to # from end";
-Blockly.Msg.LISTS_GET_SUBLIST_END_FROM_START = "to #";
-Blockly.Msg.LISTS_GET_SUBLIST_END_LAST = "to last";
-Blockly.Msg.LISTS_GET_SUBLIST_HELPURL = "https://github.com/google/blockly/wiki/Lists#getting-a-sublist";
-Blockly.Msg.LISTS_GET_SUBLIST_START_FIRST = "get sub-list from first";
-Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_END = "get sub-list from # from end";
-Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_START = "get sub-list from #";
-Blockly.Msg.LISTS_GET_SUBLIST_TAIL = "";
-Blockly.Msg.LISTS_GET_SUBLIST_TOOLTIP = "Creates a copy of the specified portion of a list.";
-Blockly.Msg.LISTS_INDEX_OF_FIRST = "find first occurrence of item";
-Blockly.Msg.LISTS_INDEX_OF_HELPURL = "https://github.com/google/blockly/wiki/Lists#getting-items-from-a-list";
-Blockly.Msg.LISTS_INDEX_OF_LAST = "find last occurrence of item";
-Blockly.Msg.LISTS_INDEX_OF_TOOLTIP = "Returns the index of the first/last occurrence of the item in the list. Returns 0 if item is not found.";
-Blockly.Msg.LISTS_INLIST = "in list";
-Blockly.Msg.LISTS_ISEMPTY_HELPURL = "https://github.com/google/blockly/wiki/Lists#is-empty";
-Blockly.Msg.LISTS_ISEMPTY_TITLE = "%1 is empty";
-Blockly.Msg.LISTS_ISEMPTY_TOOLTIP = "Returns true if the list is empty.";
-Blockly.Msg.LISTS_LENGTH_HELPURL = "https://github.com/google/blockly/wiki/Lists#length-of";
-Blockly.Msg.LISTS_LENGTH_TITLE = "length of %1";
-Blockly.Msg.LISTS_LENGTH_TOOLTIP = "Returns the length of a list.";
-Blockly.Msg.LISTS_REPEAT_HELPURL = "https://github.com/google/blockly/wiki/Lists#create-list-with";
-Blockly.Msg.LISTS_REPEAT_TITLE = "create list with item %1 repeated %2 times";
-Blockly.Msg.LISTS_REPEAT_TOOLTIP = "Creates a list consisting of the given value repeated the specified number of times.";
-Blockly.Msg.LISTS_SET_INDEX_HELPURL = "https://github.com/google/blockly/wiki/Lists#in-list--set";
-Blockly.Msg.LISTS_SET_INDEX_INPUT_TO = "as";
-Blockly.Msg.LISTS_SET_INDEX_INSERT = "insert at";
-Blockly.Msg.LISTS_SET_INDEX_SET = "set";
-Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST = "Inserts the item at the start of a list.";
-Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM_END = "Inserts the item at the specified position in a list. #1 is the last item.";
-Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM_START = "Inserts the item at the specified position in a list. #1 is the first item.";
-Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_LAST = "Append the item to the end of a list.";
-Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM = "Inserts the item randomly in a list.";
-Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FIRST = "Sets the first item in a list.";
-Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM_END = "Sets the item at the specified position in a list. #1 is the last item.";
-Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM_START = "Sets the item at the specified position in a list. #1 is the first item.";
-Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST = "Sets the last item in a list.";
-Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM = "Sets a random item in a list.";
-Blockly.Msg.LISTS_SPLIT_HELPURL = "https://github.com/google/blockly/wiki/Lists#splitting-strings-and-joining-lists";
-Blockly.Msg.LISTS_SPLIT_LIST_FROM_TEXT = "make list from text";
-Blockly.Msg.LISTS_SPLIT_TEXT_FROM_LIST = "make text from list";
-Blockly.Msg.LISTS_SPLIT_TOOLTIP_JOIN = "Join a list of texts into one text, separated by a delimiter.";
-Blockly.Msg.LISTS_SPLIT_TOOLTIP_SPLIT = "Split text into a list of texts, breaking at each delimiter.";
-Blockly.Msg.LISTS_SPLIT_WITH_DELIMITER = "with delimiter";
-Blockly.Msg.LOGIC_BOOLEAN_FALSE = "false";
-Blockly.Msg.LOGIC_BOOLEAN_HELPURL = "https://github.com/google/blockly/wiki/Logic#values";
-Blockly.Msg.LOGIC_BOOLEAN_TOOLTIP = "Returns either true or false.";
-Blockly.Msg.LOGIC_BOOLEAN_TRUE = "true";
-Blockly.Msg.LOGIC_COMPARE_HELPURL = "https://en.wikipedia.org/wiki/Inequality_(mathematics)";
-Blockly.Msg.LOGIC_COMPARE_TOOLTIP_EQ = "Return true if both inputs equal each other.";
-Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GT = "Return true if the first input is greater than the second input.";
-Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GTE = "Return true if the first input is greater than or equal to the second input.";
-Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LT = "Return true if the first input is smaller than the second input.";
-Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LTE = "Return true if the first input is smaller than or equal to the second input.";
-Blockly.Msg.LOGIC_COMPARE_TOOLTIP_NEQ = "Return true if both inputs are not equal to each other.";
-Blockly.Msg.LOGIC_NEGATE_HELPURL = "https://github.com/google/blockly/wiki/Logic#not";
+
+Blockly.Msg.LOGIC_BOOLEAN_FALSE = Blockly.LANG_LOGIC_BOOLEAN_FALSE;
+Blockly.Msg.LOGIC_BOOLEAN_TRUE = Blockly.LANG_LOGIC_BOOLEAN_TRUE;
Blockly.Msg.LOGIC_NEGATE_TITLE = "not %1";
-Blockly.Msg.LOGIC_NEGATE_TOOLTIP = "Returns true if the input is false. Returns false if the input is true.";
-Blockly.Msg.LOGIC_NULL = "null";
-Blockly.Msg.LOGIC_NULL_HELPURL = "https://en.wikipedia.org/wiki/Nullable_type";
-Blockly.Msg.LOGIC_NULL_TOOLTIP = "Returns null.";
-Blockly.Msg.LOGIC_OPERATION_AND = "and";
-Blockly.Msg.LOGIC_OPERATION_HELPURL = "https://github.com/google/blockly/wiki/Logic#logical-operations";
-Blockly.Msg.LOGIC_OPERATION_OR = "or";
-Blockly.Msg.LOGIC_OPERATION_TOOLTIP_AND = "Return true if both inputs are true.";
-Blockly.Msg.LOGIC_OPERATION_TOOLTIP_OR = "Return true if at least one of the inputs is true.";
+Blockly.Msg.LOGIC_NULL = Blockly.LANG_LOGIC_NULL;
+Blockly.Msg.LOGIC_OPERATION_AND = Blockly.LANG_LOGIC_OPERATION_AND;
+Blockly.Msg.LOGIC_OPERATION_OR = Blockly.LANG_LOGIC_OPERATION_OR;
Blockly.Msg.LOGIC_TERNARY_CONDITION = "test";
-Blockly.Msg.LOGIC_TERNARY_HELPURL = "https://en.wikipedia.org/wiki/%3F:";
Blockly.Msg.LOGIC_TERNARY_IF_FALSE = "if false";
Blockly.Msg.LOGIC_TERNARY_IF_TRUE = "if true";
-Blockly.Msg.LOGIC_TERNARY_TOOLTIP = "Check the condition in 'test'. If the condition is true, returns the 'if true' value; otherwise returns the 'if false' value.";
-Blockly.Msg.MATH_ADDITION_SYMBOL = "+";
-Blockly.Msg.MATH_ARITHMETIC_HELPURL = "https://en.wikipedia.org/wiki/Arithmetic";
-Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_ADD = "Return the sum of the two numbers.";
-Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE = "Return the quotient of the two numbers.";
-Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MINUS = "Return the difference of the two numbers.";
-Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MULTIPLY = "Return the product of the two numbers.";
-Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_POWER = "Return the first number raised to the power of the second number.";
-Blockly.Msg.MATH_CHANGE_HELPURL = "https://en.wikipedia.org/wiki/Programming_idiom#Incrementing_a_counter";
Blockly.Msg.MATH_CHANGE_TITLE = "change %1 by %2";
-Blockly.Msg.MATH_CHANGE_TOOLTIP = "Add a number to variable '%1'.";
-Blockly.Msg.MATH_CONSTANT_HELPURL = "https://en.wikipedia.org/wiki/Mathematical_constant";
-Blockly.Msg.MATH_CONSTANT_TOOLTIP = "Return one of the common constants: π (3.141…), e (2.718…), φ (1.618…), sqrt(2) (1.414…), sqrt(½) (0.707…), or ∞ (infinity).";
-Blockly.Msg.MATH_CONSTRAIN_HELPURL = "https://en.wikipedia.org/wiki/Clamping_%28graphics%29";
Blockly.Msg.MATH_CONSTRAIN_TITLE = "constrain %1 low %2 high %3";
-Blockly.Msg.MATH_CONSTRAIN_TOOLTIP = "Constrain a number to be between the specified limits (inclusive).";
+Blockly.Msg.MATH_ADDITION_SYMBOL = "+";
Blockly.Msg.MATH_DIVISION_SYMBOL = "÷";
-Blockly.Msg.MATH_IS_DIVISIBLE_BY = "is divisible by";
-Blockly.Msg.MATH_IS_EVEN = "is even";
-Blockly.Msg.MATH_IS_NEGATIVE = "is negative";
-Blockly.Msg.MATH_IS_ODD = "is odd";
-Blockly.Msg.MATH_IS_POSITIVE = "is positive";
-Blockly.Msg.MATH_IS_PRIME = "is prime";
-Blockly.Msg.MATH_IS_TOOLTIP = "Check if a number is an even, odd, prime, whole, positive, negative, or if it is divisible by certain number. Returns true or false.";
-Blockly.Msg.MATH_IS_WHOLE = "is whole";
-Blockly.Msg.MATH_MODULO_HELPURL = "https://en.wikipedia.org/wiki/Modulo_operation";
-Blockly.Msg.MATH_MODULO_TITLE = "remainder of %1 ÷ %2";
-Blockly.Msg.MATH_MODULO_TOOLTIP = "Return the remainder from dividing the two numbers.";
Blockly.Msg.MATH_MULTIPLICATION_SYMBOL = "×";
-Blockly.Msg.MATH_NUMBER_HELPURL = "https://en.wikipedia.org/wiki/Number";
-Blockly.Msg.MATH_NUMBER_TOOLTIP = "A number.";
-Blockly.Msg.MATH_ONLIST_HELPURL = "";
-Blockly.Msg.MATH_ONLIST_OPERATOR_AVERAGE = "average of list";
-Blockly.Msg.MATH_ONLIST_OPERATOR_MAX = "max of list";
-Blockly.Msg.MATH_ONLIST_OPERATOR_MEDIAN = "median of list";
-Blockly.Msg.MATH_ONLIST_OPERATOR_MIN = "min of list";
-Blockly.Msg.MATH_ONLIST_OPERATOR_MODE = "modes of list";
-Blockly.Msg.MATH_ONLIST_OPERATOR_RANDOM = "random item of list";
-Blockly.Msg.MATH_ONLIST_OPERATOR_STD_DEV = "standard deviation of list";
-Blockly.Msg.MATH_ONLIST_OPERATOR_SUM = "sum of list";
-Blockly.Msg.MATH_ONLIST_TOOLTIP_AVERAGE = "Return the average (arithmetic mean) of the numeric values in the list.";
-Blockly.Msg.MATH_ONLIST_TOOLTIP_MAX = "Return the largest number in the list.";
-Blockly.Msg.MATH_ONLIST_TOOLTIP_MEDIAN = "Return the median number in the list.";
-Blockly.Msg.MATH_ONLIST_TOOLTIP_MIN = "Return the smallest number in the list.";
-Blockly.Msg.MATH_ONLIST_TOOLTIP_MODE = "Return a list of the most common item(s) in the list.";
-Blockly.Msg.MATH_ONLIST_TOOLTIP_RANDOM = "Return a random element from the list.";
-Blockly.Msg.MATH_ONLIST_TOOLTIP_STD_DEV = "Return the standard deviation of the list.";
-Blockly.Msg.MATH_ONLIST_TOOLTIP_SUM = "Return the sum of all the numbers in the list.";
-Blockly.Msg.MATH_POWER_SYMBOL = "^";
-Blockly.Msg.MATH_RANDOM_FLOAT_HELPURL = "https://en.wikipedia.org/wiki/Random_number_generation";
-Blockly.Msg.MATH_RANDOM_FLOAT_TITLE_RANDOM = "random fraction";
-Blockly.Msg.MATH_RANDOM_FLOAT_TOOLTIP = "Return a random fraction between 0.0 (inclusive) and 1.0 (exclusive).";
-Blockly.Msg.MATH_RANDOM_INT_HELPURL = "https://en.wikipedia.org/wiki/Random_number_generation";
-Blockly.Msg.MATH_RANDOM_INT_TITLE = "random integer from %1 to %2";
-Blockly.Msg.MATH_RANDOM_INT_TOOLTIP = "Return a random integer between the two specified limits, inclusive.";
-Blockly.Msg.MATH_ROUND_HELPURL = "https://en.wikipedia.org/wiki/Rounding";
-Blockly.Msg.MATH_ROUND_OPERATOR_ROUND = "round";
-Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDDOWN = "round down";
-Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDUP = "round up";
-Blockly.Msg.MATH_ROUND_TOOLTIP = "Round a number up or down.";
-Blockly.Msg.MATH_SINGLE_HELPURL = "https://en.wikipedia.org/wiki/Square_root";
-Blockly.Msg.MATH_SINGLE_OP_ABSOLUTE = "absolute";
-Blockly.Msg.MATH_SINGLE_OP_ROOT = "square root";
-Blockly.Msg.MATH_SINGLE_TOOLTIP_ABS = "Return the absolute value of a number.";
-Blockly.Msg.MATH_SINGLE_TOOLTIP_EXP = "Return e to the power of a number.";
-Blockly.Msg.MATH_SINGLE_TOOLTIP_LN = "Return the natural logarithm of a number.";
-Blockly.Msg.MATH_SINGLE_TOOLTIP_LOG10 = "Return the base 10 logarithm of a number.";
-Blockly.Msg.MATH_SINGLE_TOOLTIP_NEG = "Return the negation of a number.";
-Blockly.Msg.MATH_SINGLE_TOOLTIP_POW10 = "Return 10 to the power of a number.";
-Blockly.Msg.MATH_SINGLE_TOOLTIP_ROOT = "Return the square root of a number.";
Blockly.Msg.MATH_SUBTRACTION_SYMBOL = "-";
-Blockly.Msg.MATH_TRIG_ACOS = "acos";
-Blockly.Msg.MATH_TRIG_ASIN = "asin";
-Blockly.Msg.MATH_TRIG_ATAN = "atan";
-Blockly.Msg.MATH_TRIG_COS = "cos";
-Blockly.Msg.MATH_TRIG_HELPURL = "https://en.wikipedia.org/wiki/Trigonometric_functions";
-Blockly.Msg.MATH_TRIG_SIN = "sin";
-Blockly.Msg.MATH_TRIG_TAN = "tan";
-Blockly.Msg.MATH_TRIG_TOOLTIP_ACOS = "Return the arccosine of a number.";
-Blockly.Msg.MATH_TRIG_TOOLTIP_ASIN = "Return the arcsine of a number.";
-Blockly.Msg.MATH_TRIG_TOOLTIP_ATAN = "Return the arctangent of a number.";
-Blockly.Msg.MATH_TRIG_TOOLTIP_COS = "Return the cosine of a degree (not radian).";
-Blockly.Msg.MATH_TRIG_TOOLTIP_SIN = "Return the sine of a degree (not radian).";
-Blockly.Msg.MATH_TRIG_TOOLTIP_TAN = "Return the tangent of a degree (not radian).";
+
Blockly.Msg.ME = "Me";
Blockly.Msg.NEW_VARIABLE = "New variable...";
Blockly.Msg.NEW_VARIABLE_TITLE = "New variable name:";
Blockly.Msg.ORDINAL_NUMBER_SUFFIX = "";
Blockly.Msg.PROCEDURES_ALLOW_STATEMENTS = "allow statements";
Blockly.Msg.PROCEDURES_BEFORE_PARAMS = "with:";
-Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL = "https://en.wikipedia.org/wiki/Procedure_%28computer_science%29";
-Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP = "Run the user-defined function '%1'.";
-Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL = "https://en.wikipedia.org/wiki/Procedure_%28computer_science%29";
-Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP = "Run the user-defined function '%1' and use its output.";
Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS = "with:";
Blockly.Msg.PROCEDURES_CREATE_DO = "Create '%1'";
Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT = "Describe this function...";
Blockly.Msg.PROCEDURES_DEFNORETURN_DO = "";
-//Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL = "https://en.wikipedia.org/wiki/Procedure_%28computer_science%29";
Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE = "my function";
Blockly.Msg.PROCEDURES_DEFNORETURN_TITLE = "function";
-//Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP = "Creates a function with no output.";
-Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL = "https://en.wikipedia.org/wiki/Procedure_%28computer_science%29";
Blockly.Msg.PROCEDURES_DEFRETURN_RETURN = "return";
Blockly.Msg.PROCEDURES_DEFRETURN_TOOLTIP = "Creates a function with an output.";
Blockly.Msg.PROCEDURES_DEF_DUPLICATE_WARNING = "Warning: This function has duplicate parameters.";
Blockly.Msg.PROCEDURES_HIGHLIGHT_DEF = "Highlight function definition";
-Blockly.Msg.PROCEDURES_IFRETURN_HELPURL = "http://c2.com/cgi/wiki?GuardClause";
-Blockly.Msg.PROCEDURES_IFRETURN_TOOLTIP = "If a value is true, then return a second value.";
Blockly.Msg.PROCEDURES_IFRETURN_WARNING = "Warning: This block may be used only within a function definition.";
Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "input name:";
-Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Add an input to the function.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "inputs";
-Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Add, remove, or reorder inputs to this function.";
Blockly.Msg.REDO = "Redo";
Blockly.Msg.REMOVE_COMMENT = "Remove Comment";
Blockly.Msg.RENAME_VARIABLE = "Rename variable...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Rename all '%1' variables to:";
-Blockly.Msg.TEXT_APPEND_APPENDTEXT = "append text";
-Blockly.Msg.TEXT_APPEND_HELPURL = "https://github.com/google/blockly/wiki/Text#text-modification";
-Blockly.Msg.TEXT_APPEND_TO = "to";
-Blockly.Msg.TEXT_APPEND_TOOLTIP = "Append some text to variable '%1'.";
-Blockly.Msg.TEXT_CHANGECASE_HELPURL = "https://github.com/google/blockly/wiki/Text#adjusting-text-case";
-Blockly.Msg.TEXT_CHANGECASE_OPERATOR_LOWERCASE = "to lower case";
-Blockly.Msg.TEXT_CHANGECASE_OPERATOR_TITLECASE = "to Title Case";
-Blockly.Msg.TEXT_CHANGECASE_OPERATOR_UPPERCASE = "to UPPER CASE";
-Blockly.Msg.TEXT_CHANGECASE_TOOLTIP = "Return a copy of the text in a different case.";
-Blockly.Msg.TEXT_CHARAT_FIRST = "get first letter";
-Blockly.Msg.TEXT_CHARAT_FROM_END = "get letter # from end";
-Blockly.Msg.TEXT_CHARAT_FROM_START = "get letter #";
-Blockly.Msg.TEXT_CHARAT_HELPURL = "https://github.com/google/blockly/wiki/Text#extracting-text";
-Blockly.Msg.TEXT_CHARAT_INPUT_INTEXT = "in text";
-Blockly.Msg.TEXT_CHARAT_LAST = "get last letter";
-Blockly.Msg.TEXT_CHARAT_RANDOM = "get random letter";
-Blockly.Msg.TEXT_CHARAT_TAIL = "";
-Blockly.Msg.TEXT_CHARAT_TOOLTIP = "Returns the letter at the specified position.";
-Blockly.Msg.TEXT_CREATE_JOIN_ITEM_TOOLTIP = "Add an item to the text.";
-Blockly.Msg.TEXT_CREATE_JOIN_TITLE_JOIN = "join";
-Blockly.Msg.TEXT_CREATE_JOIN_TOOLTIP = "Add, remove, or reorder sections to reconfigure this text block.";
-Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_END = "to letter # from end";
-Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_START = "to letter #";
-Blockly.Msg.TEXT_GET_SUBSTRING_END_LAST = "to last letter";
-Blockly.Msg.TEXT_GET_SUBSTRING_HELPURL = "https://github.com/google/blockly/wiki/Text#extracting-a-region-of-text";
-Blockly.Msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT = "in text";
-Blockly.Msg.TEXT_GET_SUBSTRING_START_FIRST = "get substring from first letter";
-Blockly.Msg.TEXT_GET_SUBSTRING_START_FROM_END = "get substring from letter # from end";
-Blockly.Msg.TEXT_GET_SUBSTRING_START_FROM_START = "get substring from letter #";
-Blockly.Msg.TEXT_GET_SUBSTRING_TAIL = "";
-Blockly.Msg.TEXT_GET_SUBSTRING_TOOLTIP = "Returns a specified portion of the text.";
-Blockly.Msg.TEXT_INDEXOF_HELPURL = "https://github.com/google/blockly/wiki/Text#finding-text";
-Blockly.Msg.TEXT_INDEXOF_INPUT_INTEXT = "in text";
-Blockly.Msg.TEXT_INDEXOF_OPERATOR_FIRST = "find first occurrence of text";
-Blockly.Msg.TEXT_INDEXOF_OPERATOR_LAST = "find last occurrence of text";
-Blockly.Msg.TEXT_INDEXOF_TAIL = "";
-Blockly.Msg.TEXT_INDEXOF_TOOLTIP = "Returns the index of the first/last occurrence of the first text in the second text. Returns 0 if text is not found.";
-Blockly.Msg.TEXT_ISEMPTY_HELPURL = "https://github.com/google/blockly/wiki/Text#checking-for-empty-text";
-Blockly.Msg.TEXT_ISEMPTY_TITLE = "%1 is empty";
-Blockly.Msg.TEXT_ISEMPTY_TOOLTIP = "Returns true if the provided text is empty.";
-Blockly.Msg.TEXT_JOIN_HELPURL = "https://github.com/google/blockly/wiki/Text#text-creation";
-Blockly.Msg.TEXT_JOIN_TITLE_CREATEWITH = "create text with";
-Blockly.Msg.TEXT_JOIN_TOOLTIP = "Create a piece of text by joining together any number of items.";
-Blockly.Msg.TEXT_LENGTH_HELPURL = "https://github.com/google/blockly/wiki/Text#text-modification";
-Blockly.Msg.TEXT_LENGTH_TITLE = "length of %1";
-Blockly.Msg.TEXT_LENGTH_TOOLTIP = "Returns the number of letters (including spaces) in the provided text.";
-Blockly.Msg.TEXT_PRINT_HELPURL = "https://github.com/google/blockly/wiki/Text#printing-text";
-Blockly.Msg.TEXT_PRINT_TITLE = "print %1";
-Blockly.Msg.TEXT_PRINT_TOOLTIP = "Print the specified text, number or other value.";
-Blockly.Msg.TEXT_PROMPT_HELPURL = "https://github.com/google/blockly/wiki/Text#getting-input-from-the-user";
-Blockly.Msg.TEXT_PROMPT_TOOLTIP_NUMBER = "Prompt for user for a number.";
-Blockly.Msg.TEXT_PROMPT_TOOLTIP_TEXT = "Prompt for user for some text.";
-Blockly.Msg.TEXT_PROMPT_TYPE_NUMBER = "prompt for number with message";
-Blockly.Msg.TEXT_PROMPT_TYPE_TEXT = "prompt for text with message";
-Blockly.Msg.TEXT_TEXT_HELPURL = "https://en.wikipedia.org/wiki/String_(computer_science)";
-Blockly.Msg.TEXT_TEXT_TOOLTIP = "A letter, word, or line of text.";
-Blockly.Msg.TEXT_TRIM_HELPURL = "https://github.com/google/blockly/wiki/Text#trimming-removing-spaces";
-Blockly.Msg.TEXT_TRIM_OPERATOR_BOTH = "trim spaces from both sides of";
-Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "trim spaces from left side of";
-Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "trim spaces from right side of";
-Blockly.Msg.TEXT_TRIM_TOOLTIP = "Return a copy of the text with spaces removed from one or both ends.";
+
Blockly.Msg.TODAY = "Today";
Blockly.Msg.UNDO = "Undo";
Blockly.Msg.VARIABLES_DEFAULT_NAME = "item";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Create 'set %1'";
-Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get";
-Blockly.Msg.VARIABLES_GET_TOOLTIP = "Returns the value of this variable.";
Blockly.Msg.VARIABLES_SET = "set %1 to %2";
Blockly.Msg.VARIABLES_SET_CREATE_GET = "Create 'get %1'";
-Blockly.Msg.VARIABLES_SET_HELPURL = "https://github.com/google/blockly/wiki/Variables#set";
-Blockly.Msg.VARIABLES_SET_TOOLTIP = "Sets this variable to be equal to the input.";
Blockly.Msg.PROCEDURES_DEFRETURN_TITLE = Blockly.Msg.PROCEDURES_DEFNORETURN_TITLE;
Blockly.Msg.CONTROLS_IF_IF_TITLE_IF = Blockly.Msg.CONTROLS_IF_MSG_IF;
Blockly.Msg.CONTROLS_WHILEUNTIL_INPUT_DO = Blockly.Msg.CONTROLS_REPEAT_INPUT_DO;
Blockly.Msg.CONTROLS_IF_MSG_THEN = Blockly.Msg.CONTROLS_REPEAT_INPUT_DO;
Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE = Blockly.Msg.CONTROLS_IF_MSG_ELSE;
Blockly.Msg.PROCEDURES_DEFRETURN_PROCEDURE = Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE;
-Blockly.Msg.LISTS_GET_SUBLIST_INPUT_IN_LIST = Blockly.Msg.LISTS_INLIST;
-Blockly.Msg.LISTS_GET_INDEX_INPUT_IN_LIST = Blockly.Msg.LISTS_INLIST;
Blockly.Msg.MATH_CHANGE_TITLE_ITEM = Blockly.Msg.VARIABLES_DEFAULT_NAME;
Blockly.Msg.PROCEDURES_DEFRETURN_DO = Blockly.Msg.PROCEDURES_DEFNORETURN_DO;
Blockly.Msg.CONTROLS_IF_ELSEIF_TITLE_ELSEIF = Blockly.Msg.CONTROLS_IF_MSG_ELSEIF;
-Blockly.Msg.LISTS_GET_INDEX_HELPURL = Blockly.Msg.LISTS_INDEX_OF_HELPURL;
Blockly.Msg.CONTROLS_FOREACH_INPUT_DO = Blockly.Msg.CONTROLS_REPEAT_INPUT_DO;
-Blockly.Msg.LISTS_SET_INDEX_INPUT_IN_LIST = Blockly.Msg.LISTS_INLIST;
Blockly.Msg.CONTROLS_FOR_INPUT_DO = Blockly.Msg.CONTROLS_REPEAT_INPUT_DO;
-Blockly.Msg.LISTS_CREATE_WITH_ITEM_TITLE = Blockly.Msg.VARIABLES_DEFAULT_NAME;
Blockly.Msg.TEXT_APPEND_VARIABLE = Blockly.Msg.VARIABLES_DEFAULT_NAME;
Blockly.Msg.TEXT_CREATE_JOIN_ITEM_TITLE_ITEM = Blockly.Msg.VARIABLES_DEFAULT_NAME;
-Blockly.Msg.LISTS_INDEX_OF_INPUT_IN_LIST = Blockly.Msg.LISTS_INLIST;
Blockly.Msg.PROCEDURES_DEFRETURN_COMMENT = Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT;
@@ -864,6 +225,9 @@ Blockly.MSG_ANALOG_PULSE_IN_OUT_HELPURL = "http://learn.parallax.com/ab-blocks/p
Blockly.MSG_ANALOG_RC_TIME_HELPURL = "http://learn.parallax.com/ab-blocks/rc-time";
Blockly.MSG_AUDIO_HELPURL = "http://learn.parallax.com/ab-blocks/audio";
Blockly.MSG_SERVO_HELPURL = "http://learn.parallax.com/ab-blocks/servo";
+Blockly.MSG_ROBOT_HELPURL = "http://learn.parallax.com/ab-blocks/robot";
+Blockly.MSG_IMU_HELPURL = "http://learn.parallax.com/ab-blocks/lsm9ds1";
+Blockly.MSG_WS2812B_HELPURL = "http://learn.parallax.com/ab-blocks/ws2812b";
//----------Activity Board (Propeller C) block tooltips ----------------------------
@@ -881,7 +245,7 @@ Blockly.MSG_MATH_CREMENT_TOOLTIP = "de/increment: increase or decrease attached
Blockly.MSG_MATH_RANDOM_TOOLTIP = "random: Pick random number between the low “from” and high “to” values.";
Blockly.MSG_MATH_BITWISE_TOOLTIP = "bitwise:& AND, | OR, ^ XOR, >> right shift, << left shift.";
Blockly.MSG_LOGIC_OPERATION_TOOLTIP = "boolean comparison: and, or, and not, or not; return 1/true or 0/false.";
-Blockly.MSG_LOGIC_NEGATE_TOOLTIP = "not: Get boolean (1/true or 0/false) opposite of attached value.";
+Blockly.MSG_LOGIC_NEGATE_TOOLTIP = "not: Get boolean (1/true or 0/false) opposite,\nnegate: get the negative decimal value,\nabs: get the absolute value of.";
Blockly.MSG_LOGIC_COMPARE_TOOLTIP = "compare values: boolean comparison returns 1/true or 0/false.";
Blockly.MSG_STRING_COMPARE_TOOLTIP = "compare strings: returns 1/true or 0/false. Case sensitive.";
Blockly.MSG_STRING_LENGTH_TOOLTIP = "length of string: number of characters in string or string variable.";
@@ -903,7 +267,7 @@ Blockly.MSG_SYSTEM_COUNTER_TOOLTIP = "system counter: 0 to 4,294,967,295 before
Blockly.MSG_VARIABLES_SET_TOOLTIP = "set variable: name and attach initial value block.";
Blockly.MSG_VARIABLES_GET_TOOLTIP = "use variable: choose set variables from dropdown.";
Blockly.MSG_PROCEDURES_DEFNORETURN_TOOLTIP = "define function: group blocks to re-use ending with return; name group.";
-Blockly.MSG_PROCEDURES_CALLNORETURN_TOOLTIP = "return: Required at the end of code enclosed in a “define function” block.";
+Blockly.MSG_PROCEDURES_CALLNORETURN_TOOLTIP = "return: use in a “define function” block to go back to the main code.";
Blockly.MSG_MAKE_PIN_TOOLTIP = "make PIN (dropdown): Select I/O pin and setting with menus.";
Blockly.MSG_MAKE_PIN_INPUT_TOOLTIP = "make PIN (programmable): Select I/O pin with value and setting with menu.";
Blockly.MSG_CHECK_PIN_TOOLTIP = "check PIN (dropdown): Get the state of I/O pin; high = 1, low = 0.";
@@ -945,6 +309,9 @@ Blockly.MSG_SERIAL_RECEIVE_TEXT_TOOLTIP = "Serial receive text: receives and sto
Blockly.MSG_XBEE_SETUP_TOOLTIP = "XBee initialize: match to Propeller I/O pin connections and XBee Baud rate.";
Blockly.MSG_XBEE_TRANSMIT_TOOLTIP = "XBee transmit: sends information to an XBee. Strings and numbers are terminated with an ASCII 13";
Blockly.MSG_XBEE_RECEIVE_TOOLTIP = "XBee receive: receives information from an XBee. Expects strings and numbers to be terminated with an ASCII 13";
+Blockly.MSG_WS2812B_INIT_TOOLTIP = "RGB-LED init: match to Propeller I/O pin connections and number of LEDs.";
+Blockly.MSG_WS2812B_SET_TOOLTIP = "RGB-LED set: specify color for a specific LED.";
+Blockly.MSG_WS2812B_UPDATE_TOOLTIP = "RGB-LED update: update colors of all connected RGB-LEDs.";
Blockly.MSG_HMC5883L_INIT_TOOLTIP = "Compass initialize: match to Propeller I/O pin connections.";
Blockly.MSG_HMC5883L_READ_TOOLTIP = "Compass heading: get current heading in degrees.";
Blockly.MSG_JOYSTICK_INPUT_XAXIS_TOOLTIP = "Joystick x-axis: gets horizontal position of Joystick, match to A/D socket.";
@@ -956,6 +323,10 @@ Blockly.MSG_MX2125_TILT_XAXIS_TOOLTIP = "Memsic x tilt: gets x-\tilt in degrees
Blockly.MSG_MX2125_TILT_YAXIS_TOOLTIP = "Memsic y tilt: gets y-tilt in degrees from level with horizon, match to Propeller I/O pin.";
Blockly.MSG_MMA7455_INIT_TOOLTIP = "Accelerometer initialize: match to Propeller I/O pin connections.";
Blockly.MSG_MMA7455_ACCELERATION_TOOLTIP = "Accelerometer store values: stores measured x, y, & z acceleration in specified variables.";
+Blockly.MSG_LSM9DS1_INIT_TOOLTIP = "IMU initialize: match to Propeller I/O pin connections.";
+Blockly.MSG_LSM9DS1_READ_TOOLTIP = "IMU read: get measurements from specified sensor.";
+Blockly.MSG_LSM9DS1_TILT_TOOLTIP = "IMU tilt: gets tilt along specified axis.";
+Blockly.MSG_LSM9DS1_HEADING_TOOLTIP = "IMU heading: specify axes, get current heading in degrees.";
Blockly.MSG_SENSOR_PING_TOOLTIP = "Ping))) distance: gets distance measured in the specified units, match to Propeller I/O pin.";
Blockly.MSG_PIR_SENSOR_TOOLTIP = "PIR sensor: returns 1/true if motion is detected, match to Propeller I/O pin.";
Blockly.MSG_RFID_ENABLE_TOOLTIP = "RFID initialize: match to Propeller I/O pin connections.";
@@ -987,6 +358,20 @@ Blockly.MSG_BASE_FREQOUT_TOOLTIP = "frequency out: sends pulses to the I/O pin a
Blockly.MSG_SERVO_MOVE_TOOLTIP = "Standard servo: sets the position of a standard servo connected to the I/O pin.";
Blockly.MSG_SERVO_SPEED_TOOLTIP = "CR servo speed: sets the speed of a continuous rotation servo connected to the I/O pin.";
Blockly.MSG_SERVO_SET_RAMP_TOOLTIP = "CR servo set ramp: sets the amount a servo's speed can change each update cycle.";
+Blockly.MSG_ROBOT_DRIVE_INIT_TOOLTIP = "Robot drive init: set up the Robot's drive system on the Propeller";
+Blockly.MSG_ROBOT_DRIVE_DISTANCE_TOOLTIP = "Robot drive distance: drives each wheel a specified distance.";
+Blockly.MSG_ROBOT_DRIVE_SPEED_TOOLTIP = "Robot drive speed: drives each wheel at a specified speed.";
+Blockly.MSG_ROBOT_DRIVE_STOP_TOOLTIP = "Robot drive stop: stops the robot from driving.";
+Blockly.MSG_ROBOT_ACTIVITYBOT_CALIBRATE_TOOLTIP = "ActivityBot calibrate: runs the ActivityBot calibration routine.";
+Blockly.MSG_ROBOT_ACTIVITYBOT_DISPLAY_CALIBRATION_TOOLTIP = "ActivityBot display calibration: displays the calibration results on the terminal.";
+Blockly.MSG_STRING_TO_NUMBER_TOOLTIP = "string to number: convert a number (integer) value to a string.";
+Blockly.MSG_NUMBER_TO_STRING_TOOLTIP = "number to string: convert a string representing a number to an integer.";
+Blockly.MSG_NUMBER_BINARY_TOOLTIP = "binary value: use to enter a binary number.";
+Blockly.MSG_NUMBER_HEX_TOOLTIP = "hexadecimal value: use to enter a hexadecimal number.";
+Blockly.MSG_CONSTRAIN_VALUE_TOOLTIP = "constrain value: prevent a value from being too large or too small.";
+Blockly.MSG_MATH_ADVANCED_TOOLTIP = "advanced math: perform a trigonometric, exponential, or logrithmic function.\nAngles are in degrees.";
+Blockly.MSG_MATH_INV_TRIG_TOOLTIP = "inverse trig: perform an inverse trigonometric function.\nAngles are in degrees.";
+
//-------Scribbler 3 help URLs ---------------------------------------------
Blockly.MSG_S3_COMMUNICATE_HELPURL = "http://learn.parallax.com/s3-blocks/communicate";
@@ -1000,6 +385,7 @@ Blockly.MSG_S3_MATH_HELPURL = "http://learn.parallax.com/s3-blocks/math";
Blockly.MSG_S3_MOTORS_HELPURL = "http://learn.parallax.com/s3-blocks/motors";
Blockly.MSG_S3_OBSTACLE_HELPURL = "http://learn.parallax.com/s3-blocks/obstacle";
Blockly.MSG_S3_PING_HELPURL = "http://learn.parallax.com/s3-blocks/ping";
+Blockly.MSG_S3_SIRC_HELPURL = "http://learn.parallax.com/s3-blocks/sirc";
Blockly.MSG_S3_RESET_BUTTON_HELPURL = "http://learn.parallax.com/s3-blocks/reset-button";
Blockly.MSG_S3_SIMPLE_ACTIONS_HELPURL = "http://learn.parallax.com/s3-blocks/simple-actions";
Blockly.MSG_S3_SIMPLE_CONTROL_HELPURL = "http://learn.parallax.com/s3-blocks/simple-control";
@@ -1007,6 +393,7 @@ Blockly.MSG_S3_SIMPLE_SENSORS_HELPURL = "http://learn.parallax.com/s3-blocks/sim
Blockly.MSG_S3_SOUND_HELPURL = "http://learn.parallax.com/s3-blocks/sound";
Blockly.MSG_S3_STALL_HELPURL = "http://learn.parallax.com/s3-blocks/stall";
Blockly.MSG_S3_VARIABLES_HELPURL = "http://learn.parallax.com/s3-blocks/variables";
+Blockly.MSG_S3_IO_HELPURL = "http://learn.parallax.com/s3-blocks/io";
//-------Scribbler 3 block tooltips --------------------------
@@ -1029,7 +416,7 @@ Blockly.MSG_S3_CONTROLS_IF_TOOLTIP = "if...do: when condition attached is true.
Blockly.MSG_S3_SCRIBBLER_WAIT_TOOLTIP = "wait: waits a set amount of time before moving on the to the next block";
Blockly.MSG_S3_SPIN_COMMENT_TOOLTIP = "note: use to add a note to your program. Does not affect the program.";
Blockly.MSG_S3_PROCEDURES_DEFNORETURN_TOOLTIP = "define function: group blocks to re-use ending with return; name group.";
-Blockly.MSG_S3_PROCEDURES_CALLNORETURN_TOOLTIP = "return: Required at the end of code enclosed in a “define function” block.";
+Blockly.MSG_S3_PROCEDURES_CALLNORETURN_TOOLTIP = "return: use in a “define function” block to go back to the main code.";
Blockly.MSG_S3_VARIABLES_SET_TOOLTIP = "set variable: name and attach initial value block.";
Blockly.MSG_S3_VARIABLES_GET_TOOLTIP = "use variable: choose set variables from dropdown.";
Blockly.MSG_S3_SPIN_INTEGER_TOOLTIP = "number value: positive or negative; truncates to integers.";
@@ -1049,11 +436,15 @@ Blockly.MSG_S3_STALL_SENSOR_TOOLTIP = "tail wheel stall: returns true of tail wh
Blockly.MSG_S3_SPINNING_SENSOR_TOOLTIP = "drive wheel stall: returns true if drive wheels are not spinning but should be";
Blockly.MSG_S3_RESET_BUTTON_PRESSES_TOOLTIP = "button sensor: returns how many times the reset button was pressed";
Blockly.MSG_S3_SCRIBBLER_PING_TOOLTIP = "Ping))) distance: measures distances using a Ping))) sensor attached to the hacker port";
+Blockly.MSG_S3_SCRIBBLER_SIRC_TOOLTIP = "Sony Remote value: returns button pressed on remote, returns -1 if none.";
Blockly.MSG_S3_MOVE_MOTORS_TOOLTIP = "motor speed: use to move the Scribbler at specific speeds";
Blockly.MSG_S3_MOVE_MOTORS_DISTANCE_TOOLTIP = "move distance: use to move the Scribbler specific distances";
Blockly.MSG_S3_MOVE_MOTORS_ANGLE_TOOLTIP = "rotate by radius: rotates the scribbler by driving it";
Blockly.MSG_S3_SCRIBBLER_SERVO_TOOLTIP = "rotate Servo: turns a servo connected to the hacker port to a position";
Blockly.MSG_S3_SCRIBBLER_STOP_SERVO_TOOLTIP = "disable Servo: disables a servo connected to the hacker port";
+Blockly.MSG_S3_ANALOG_INPUT_TOOLTIP = "analog read pin: Get the voltage input on the specified pin.";
+Blockly.MSG_S3_DIGITAL_OUTPUT_TOOLTIP = "digital set pin: Select I/O pin and setting with menus.";
+Blockly.MSG_S3_DIGITAL_INPUT_TOOLTIP = "digital read pin: Get the state of I/O pin; high = 1, low = 0.";
Blockly.MSG_S3_PLAY_POLYPHONY_TOOLTIP = "play tone: mix two frequencies set in Hz.";
Blockly.MSG_S3_SERIAL_SEND_TEXT_TOOLTIP = "send message: send text out from the serial port";
Blockly.MSG_S3_SERIAL_SEND_DECIMAL_TOOLTIP = "send number: send a number out from the serial port";
@@ -1061,4 +452,4 @@ Blockly.MSG_S3_SERIAL_SEND_CHAR_TOOLTIP = "send character: send a character out
Blockly.MSG_S3_SERIAL_SEND_CTRL_TOOLTIP = "send control character: send a special character out from the serial port";
Blockly.MSG_S3_SERIAL_CURSOR_XY_TOOLTIP = "set cursor position: set the cursor position in the terminal";
Blockly.MSG_S3_SERIAL_RX_BYTE_TOOLTIP = "receive character: receieve a character from the serial port";
-Blockly.MSG_S3_FACTORY_RESET_TOOLTIP = "factory reset: use to reload the factory default demo program back onto the Scribbler";
\ No newline at end of file
+Blockly.MSG_S3_FACTORY_RESET_TOOLTIP = "factory reset: use to reload the factory default demo program back onto the Scribbler";
diff --git a/src/main/webapp/cdn/blocklyc.js b/src/main/webapp/cdn/blocklyc.js
index 6aeb8118..180d2878 100644
--- a/src/main/webapp/cdn/blocklyc.js
+++ b/src/main/webapp/cdn/blocklyc.js
@@ -43,15 +43,32 @@ function tabClick(id) {
// Deselect all tabs and hide all panes.
for (var x in TABS_) {
- if (document.getElementById('tab_' + TABS_[x])) {
- document.getElementById('tab_' + TABS_[x]).className = 'taboff';
- }
+ //if (document.getElementById('tab_' + TABS_[x])) {
+ // document.getElementById('tab_' + TABS_[x]).className = 'taboff';
+ //}
document.getElementById('content_' + TABS_[x]).style.display = 'none';
}
// Select the active tab.
selected = id.replace('tab_', '');
- document.getElementById(id).className = 'active';
+ //document.getElementById(id).className = 'active';
+
+ if (id === 'tab_blocks') {
+ document.getElementById('btn-view-blocks').style.display = 'none';
+ var btns = document.getElementsByClassName("btn-view-code");
+ for (var i = 0; i < btns.length; i++)
+ {
+ btns[i].style.display = 'inline';
+ }
+ } else {
+ document.getElementById('btn-view-blocks').style.display = 'inline';
+ var btns = document.getElementsByClassName("btn-view-code");
+ for (var i = 0; i < btns.length; i++)
+ {
+ btns[i].style.display = 'none';
+ }
+ }
+
// Show the selected pane.
var content = document.getElementById('content_' + selected);
content.style.display = 'block';
@@ -98,6 +115,7 @@ function init(blockly) {
window.Blockly = blockly;
// Make the 'Blocks' tab line up with the toolbox.
+ /*
if (Blockly.Toolbox) {
window.setTimeout(function () {
document.getElementById('tab_blocks').style.minWidth =
@@ -105,6 +123,7 @@ function init(blockly) {
// Account for the 19 pixel margin and on each side.
}, 1);
}
+ */
loadProject();
}
@@ -228,7 +247,7 @@ function serial_console() {
connection.onerror = function (error) {
console.log('WebSocket Error');
console.log(error);
- // term.destroy();
+ // term.destroy();
};
// Log messages from the server
connection.onmessage = function (e) {
@@ -316,3 +335,50 @@ $(document).ready(function () {
getComPort = function () {
return $('#comPort').find(":selected").text();
};
+
+function downloadPropC() {
+ var propcCode = Blockly.propc.workspaceToCode(Blockly.mainWorkspace);
+ var isEmptyProject = propcCode.indexOf("EMPTY_PROJECT") > -1;
+ if (isEmptyProject) {
+ alert("You can't download an empty project");
+ } else {
+ utils.confirm('Downloading a SimpleIDE project', 'To open your project in SimpleIDE, two files will be downloaded. They must both be saved in the same folder on your computer.', function (confirmed) {
+ if (confirmed) {
+ utils.prompt("Download SimpleIDE files", "Filename:", 'Project' + idProject, function (value) {
+ if (value) {
+
+ var sideFileContent = ".c\n>compiler=C\n>memtype=cmm main ram compact\n";
+ sideFileContent += ">optimize=-Os\n>-m32bit-doubles\n>-fno-exceptions\n>defs::-std=c99\n";
+ sideFileContent += ">-lm\n>BOARD::ACTIVITYBOARD";
+
+ var saveData = (function () {
+ var a = document.createElement("a");
+ document.body.appendChild(a);
+ a.style = "display: none";
+ return function (data, fileName) {
+ var blob = new Blob([data], {type: "octet/stream"});
+ var url = window.URL.createObjectURL(blob);
+ a.href = url;
+ a.download = fileName;
+ a.click();
+ window.URL.revokeObjectURL(url);
+ };
+ }());
+
+ // Check for any file extentions at the end of the submitted name, and truncate if any
+ if(value.indexOf(".") !== -1) value = value.substring(0,value.indexOf("."));
+ // Check to make sure the filename is not too long
+ if(value.length >= 30) value = value.substring(0, 29);
+ // Replace any illegal characters
+ value = value.replace(/[\\/:*?\"<>|]/g, '_');
+
+ saveData(propcCode, value + ".c");
+ saveData(value + sideFileContent, value + ".side");
+ }
+ });
+ }
+ });
+ }
+
+
+}
diff --git a/src/main/webapp/cdn/blocklypropclient.js b/src/main/webapp/cdn/blocklypropclient.js
index 7d7bee51..f27a0e32 100644
--- a/src/main/webapp/cdn/blocklypropclient.js
+++ b/src/main/webapp/cdn/blocklypropclient.js
@@ -41,6 +41,7 @@ check_client = function () {
client_available = true;
$("#client-available").removeClass("hidden");
+ $("#client-searching").addClass("hidden");
$("#client-unavailable").addClass("hidden");
// $("#client_status").text($("#client_status").data('available')).removeClass("not_available").addClass("available");
if (check_com_ports && typeof (check_com_ports) === "function") {
@@ -52,7 +53,7 @@ check_client = function () {
}).fail(function () {
clearInterval(check_com_ports_interval);
client_available = false;
- $("#client_status").text($("#client_status").data('not-available')).removeClass("available").addClass("not_available");
+ $("#client-searching").addClass("hidden");
$("#client-available").addClass("hidden");
$("#client-unavailable").removeClass("hidden");
setTimeout(check_client, 2000);
diff --git a/src/main/webapp/cdn/blocklyspin.js b/src/main/webapp/cdn/blocklyspin.js
index 95326e4f..b1378d7c 100644
--- a/src/main/webapp/cdn/blocklyspin.js
+++ b/src/main/webapp/cdn/blocklyspin.js
@@ -41,19 +41,35 @@ function tabClick(id) {
// Deselect all tabs and hide all panes.
for (var x in TABS_) {
- if (document.getElementById('tab_' + TABS_[x])) {
- document.getElementById('tab_' + TABS_[x]).className = 'taboff';
- }
+ //if (document.getElementById('tab_' + TABS_[x])) {
+ // document.getElementById('tab_' + TABS_[x]).className = 'taboff';
+ //}
if (document.getElementById('content_' + TABS_[x])) {
document.getElementById('content_' + TABS_[x]).style.display = 'none';
- } else {
+ //} else {
// document.getElementByName('content_' + TABS_[x])[0].style.display = 'none';
}
}
// Select the active tab.
selected = id.replace('tab_', '');
- document.getElementById(id).className = 'active';
+ //document.getElementById(id).className = 'active';
+ if (id === 'tab_blocks') {
+ document.getElementById('btn-view-blocks').style.display = 'none';
+ var btns = document.getElementsByClassName("btn-view-code");
+ for (var i = 0; i < btns.length; i++)
+ {
+ btns[i].style.display = 'inline';
+ }
+ } else {
+ document.getElementById('btn-view-blocks').style.display = 'inline';
+ var btns = document.getElementsByClassName("btn-view-code");
+ for (var i = 0; i < btns.length; i++)
+ {
+ btns[i].style.display = 'none';
+ }
+ }
+
// Show the selected pane.
var content = document.getElementById('content_' + selected);
content.style.display = 'block';
@@ -94,6 +110,7 @@ function init(blockly) {
window.Blockly = blockly;
// Make the 'Blocks' tab line up with the toolbox.
+ /*
if (Blockly.Toolbox) {
window.setTimeout(function () {
document.getElementById('tab_blocks').style.minWidth =
@@ -101,6 +118,8 @@ function init(blockly) {
// Account for the 19 pixel margin and on each side.
}, 1);
}
+ */
+
loadProject();
}
diff --git a/src/main/webapp/cdn/demoeditor.js b/src/main/webapp/cdn/demoeditor.js
index e0393c82..be222976 100644
--- a/src/main/webapp/cdn/demoeditor.js
+++ b/src/main/webapp/cdn/demoeditor.js
@@ -84,9 +84,9 @@ function getUrlParameters(parameter, staticURL, decode) {
for (var i = 0; i < parArr.length; i++) {
parr = parArr[i].split("=");
- if (parr[0] == parameter) {
- return (decode) ? decodeURIComponent(parr[1]) : parr[1];
+ if (parr[0] === parameter) {
returnBool = true;
+ return (decode) ? decodeURIComponent(parr[1]) : parr[1];
} else {
returnBool = false;
}
diff --git a/src/main/webapp/cdn/editor.js b/src/main/webapp/cdn/editor.js
index 07d00902..f91bec1c 100644
--- a/src/main/webapp/cdn/editor.js
+++ b/src/main/webapp/cdn/editor.js
@@ -1,10 +1,9 @@
-/*
+ /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
-
var baseUrl = $("meta[name=base]").attr("content");
var projectData = null;
@@ -13,6 +12,8 @@ var projectLoaded = false;
var idProject = 0;
+var uploadedXML = '';
+
$(document).ready(function () {
idProject = getUrlParameters('project', '', false);
if (!idProject) {
@@ -32,10 +33,36 @@ $(document).ready(function () {
$('#save-project').on('click', function () {
saveProject();
+
+ var elem = document.getElementById('save-project');
+ elem.style.paddingLeft = '10px';
+ elem.style.background = 'rgb(92, 184, 92)';
+ elem.style.borderColor = 'rgb(76, 174, 76)';
+
+ setTimeout(function() {
+ elem.innerHTML = 'Save ✓';
+ }, 600);
+
+ setTimeout(function() {
+ elem.innerHTML = 'Save ';
+ elem.style.paddingLeft = '15px';
+ elem.style.background = '#337ab7';
+ elem.style.borderColor = '#2e6da4';
+ }, 1750);
});
+
$('#save-project-as').on('click', function () {
saveProjectAs();
});
+ $('#download-project').on('click', function () {
+ downloadCode();
+ });
+ $('#upload-project').on('click', function () {
+ uploadCode();
+ });
+ $('#clear-workspace').on('click', function () {
+ clearWorkspace();
+ });
});
@@ -54,7 +81,7 @@ saveProject = function () {
var previousOwner = projectData['yours'];
projectData = data;
projectData['code'] = code; // Save code in projectdata to be able to verify if code has changed upon leave
- utils.showMessage("Project saved", "The project has been saved");
+ //utils.showMessage(Blockly.Msg.DIALOG_PROJECT_SAVED, Blockly.Msg.DIALOG_PROJECT_SAVED_TEXT);
if (!previousOwner) {
window.location.href = baseUrl + 'projecteditor?id=' + data['id'];
}
@@ -71,7 +98,7 @@ saveProjectAs = function () {
var previousOwner = projectData['yours'];
projectData = data;
projectData['code'] = code; // Save code in projectdata to be able to verify if code has changed upon leave
- utils.showMessage("Project saved", "The project has been saved");
+ utils.showMessage(Blockly.Msg.DIALOG_PROJECT_SAVED, Blockly.Msg.DIALOG_PROJECT_SAVED_TEXT);
// Reloading project with new id
window.location.href = baseUrl + 'projecteditor?id=' + data['id'];
});
@@ -96,7 +123,7 @@ loadProject = function () {
window.onbeforeunload = function () {
if (checkLeave()) {
- return "The project has been changed since the last save.";
+ return Blockly.Msg.DIALOG_CHANGED_SINCE;
}
};
@@ -137,9 +164,9 @@ function getUrlParameters(parameter, staticURL, decode) {
for (var i = 0; i < parArr.length; i++) {
parr = parArr[i].split("=");
- if (parr[0] == parameter) {
- return (decode) ? decodeURIComponent(parr[1]) : parr[1];
+ if (parr[0] === parameter) {
returnBool = true;
+ return (decode) ? decodeURIComponent(parr[1]) : parr[1];
} else {
returnBool = false;
}
@@ -151,4 +178,217 @@ function getUrlParameters(parameter, staticURL, decode) {
setInterval(function () {
$.get(baseUrl + 'ping');
-}, 60000);
\ No newline at end of file
+}, 60000);
+
+function hashCode(str) {
+ var hash = 0, i = 0, len = str.length;
+ while ( i < len ) {
+ hash = ((hash << 5) - hash + str.charCodeAt(i++)) << 0;
+ }
+ return (hash + 2147483647) + 1;
+};
+
+function downloadCode() {
+ var projXMLcode = window.frames["content_blocks"].getXml(); //projectData['code'];
+ projXMLcode = projXMLcode.substring(42,projXMLcode.length);
+ projXMLcode = projXMLcode.substring(0,(projXMLcode.length - 6));
+
+ utils.prompt("Download Project", "Filename:", 'Project' + idProject, function (value) {
+ if (value) {
+ // extract the SVG from the iFrame that contains it
+ var x = document.getElementsByName("content_blocks");
+ var y = (x[0].contentWindow || x[0].contentDocument);
+ if (y.document)y = y.document;
+
+ // get the paths of the blocks themselves and the size/position of the blocks
+ var projSVG = y.getElementsByClassName('blocklyBlockCanvas');
+ var projSVGcode = projSVG[0].outerHTML.replace(/ /g, ' ');
+ var projSize = projSVG[0].getBoundingClientRect();
+ var projH = (parseInt(projSize.height) + parseInt(projSize.top) + 100).toString();
+ var projW = (parseInt(projSize.width) + parseInt(projSize.left) + 236).toString();
+
+ // put all of the pieces together into a downloadable file
+ var saveData = (function () {
+ var a = document.createElement("a");
+ document.body.appendChild(a);
+ a.style = "display: none";
+ return function (data, fileName) {
+ var blob = new Blob([data], {type: "octet/stream"});
+ var url = window.URL.createObjectURL(blob);
+ a.href = url;
+ a.download = fileName;
+ a.click();
+ window.URL.revokeObjectURL(url);
+ };
+ }());
+
+ // a header with the necessary svg XML header and style information to make the blocks render correctly
+ var SVGheader = '';
+ SVGheader += '', value + '.svg');
+ }
+ });
+};
+
+function uploadCode() {
+ if (checkLeave()) {
+ utils.showMessage('Unsaved Project', 'You must save your project before you can upload a blocks file to it.');
+ } else {
+ $('#upload-dialog').modal('show');
+ }
+};
+
+function uploadHandler(files) {
+ var UploadReader = new FileReader();
+ UploadReader.onload = function() {
+ //var parsed = new DOMParser().parseFromString(this.result, "text/xml");
+ //var xmlString = (new XMLSerializer()).serializeToString(parsed);
+ var xmlString = this.result;
+ var xmlValid = false;
+ var uploadBoardType = '';
+
+ //validate file, screen for potentially malicious code.
+ if(files[0].type === 'image/svg+xml'
+ && xmlString.indexOf("