From 24314e1ed274711d56c77980c2730bf78318a6e0 Mon Sep 17 00:00:00 2001 From: Basil Stotz Date: Wed, 21 Dec 2016 09:55:54 +0100 Subject: [PATCH 1/2] added libs+playground --- blocks/thymio-math-blocks.js | 693 +++++++++++++++++++++++++++++++ blocks/thymio-sdcard-blocks.js | 196 +++++++++ generators/aesl.js | 3 +- generators/aesl/thymio-math.js | 230 ++++++++++ generators/aesl/thymio-sdcard.js | 73 ++++ tests/playground.de.html | 446 +++++++++++++++++++- 6 files changed, 1639 insertions(+), 2 deletions(-) create mode 100644 blocks/thymio-math-blocks.js create mode 100644 blocks/thymio-sdcard-blocks.js create mode 100644 generators/aesl/thymio-math.js create mode 100644 generators/aesl/thymio-sdcard.js diff --git a/blocks/thymio-math-blocks.js b/blocks/thymio-math-blocks.js new file mode 100644 index 00000000000..f4c74d1c627 --- /dev/null +++ b/blocks/thymio-math-blocks.js @@ -0,0 +1,693 @@ +Blockly.Blocks['math_copy'] = { + init: function(){ + + this.appendDummyInput() + .appendField("math.copy ("); + + this.appendValueInput("A") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(""); + this.appendValueInput("B") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + + this.appendDummyInput() + .appendField(")"); + + this.setInputsInline(true); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour(65); + this.setTooltip('math.copy(A,B) : Ai=Bi'); + this.setHelpUrl('https://www.thymio.org/de:asebastdnative/'); + } +}; + + +Blockly.Blocks['math_fill'] = { + init: function() { + + this.appendDummyInput() + .appendField("math.fill ("); + this.appendValueInput("A") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(""); + this.appendValueInput("s") + .setCheck("Number") + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + this.appendDummyInput() + .appendField(")"); + + this.setInputsInline(true); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour(65); + this.setTooltip('math.fill(A,s) : Ai=s'); + this.setHelpUrl('https://www.thymio.org/de:asebastdnative/'); + } +}; + +Blockly.Blocks['math_addscalar'] = { + init: function(){ + + this.appendDummyInput() + .appendField("math.addscalar ("); + this.appendValueInput("A") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(""); + this.appendValueInput("B") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + this.appendValueInput("c") + .setCheck("Number") + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + this.appendDummyInput() + .appendField(")"); + + + this.setInputsInline(true); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour(65); + this.setTooltip('math.addscalar(A,B,c) : Ai=Bi+c'); + this.setHelpUrl('https://www.thymio.org/de:asebastdnative/'); + } +}; + +Blockly.Blocks['math_add'] = { + init: function(){ + + this.appendDummyInput() + .appendField("math.add ("); + this.appendValueInput("A") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(""); + this.appendValueInput("B") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + this.appendValueInput("C") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + this.appendDummyInput() + .appendField(" )"); + + + this.setInputsInline(true); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour(65); + this.setTooltip('math.add(A,B,C) : Ai=Bi+Ci'); + this.setHelpUrl('https://www.thymio.org/de:asebastdnative/'); + } +}; + + + +Blockly.Blocks['math_sub'] = { + init: function(){ + + this.appendDummyInput() + .appendField("math.sub ("); + + this.appendValueInput("A") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(""); + this.appendValueInput("B") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + this.appendValueInput("C") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + + this.appendDummyInput() + .appendField(" )"); + + + this.setInputsInline(true); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour(65); + this.setTooltip('math.sub(A,B,C) : Ai=Bi-Ci'); + this.setHelpUrl('https://www.thymio.org/de:asebastdnative/'); + } +}; + +Blockly.Blocks['math_mul'] = { + init: function(){ + + this.appendDummyInput() + .appendField("math.mul ("); + + this.appendValueInput("A") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(""); + this.appendValueInput("B") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + this.appendValueInput("C") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + + this.appendDummyInput() + .appendField(" )"); + + this.setInputsInline(true); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour(65); + this.setTooltip('math.mul(A,B,C) : Ai=Bi*Ci'); + this.setHelpUrl('https://www.thymio.org/de:asebastdnative/'); + } +}; + +Blockly.Blocks['math_div'] = { + init: function(){ + + + this.appendDummyInput() + .appendField("math.div ("); + + this.appendValueInput("A") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(""); + this.appendValueInput("B") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + this.appendValueInput("C") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + + this.appendDummyInput() + .appendField(" )"); + + + this.setInputsInline(true); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour(65); + this.setTooltip('math.div(A,B,C) : Ai=Bi/Ci'); + this.setHelpUrl('https://www.thymio.org/de:asebastdnative/'); + } +}; + +Blockly.Blocks['math_min'] = { + init: function(){ + + + this.appendDummyInput() + .appendField("math.min ("); + + this.appendValueInput("A") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(""); + this.appendValueInput("B") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + this.appendValueInput("C") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + + this.appendDummyInput() + .appendField(" )"); + + + this.setInputsInline(true); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour(65); + this.setTooltip('math.min(A,B,C) : Ai=min(Bi,Ci)'); + this.setHelpUrl('https://www.thymio.org/de:asebastdnative/'); + } +}; + +Blockly.Blocks['math_max'] = { + init: function(){ + + + this.appendDummyInput() + .appendField("math.max ("); + + this.appendValueInput("A") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(""); + this.appendValueInput("B") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + this.appendValueInput("C") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + + this.appendDummyInput() + .appendField(" )"); + + + this.setInputsInline(true); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour(65); + this.setTooltip('math.max(A,B,C) : Ai=max(Bi,Ci)'); + this.setHelpUrl('https://www.thymio.org/de:asebastdnative/'); + } +}; + +Blockly.Blocks['math_clamp'] = { + init: function(){ + + + this.appendDummyInput() + .appendField("math.clamp ("); + + this.appendValueInput("A") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(""); + this.appendValueInput("B") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + this.appendValueInput("C") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + this.appendValueInput("D") + .setCheck(["Array", "Number"]) + .setAlign(Blockly.ALIGN_RIGHT) + .appendField(","); + this.appendDummyInput() + .appendField(" )"); + + + this.setInputsInline(true); + this.setPreviousStatement(true, null); + this.setNextStatement(true, null); + this.setColour(65); + this.setTooltip('math.clamp(A,B,C,D) : Ai=Bi mit Ci + + + + @@ -23,6 +27,10 @@ + + + + + + + + +