Package com.ardublock.translator.block

Examples of com.ardublock.translator.block.TranslatorBlock


  {
    translator.addHeaderFile("keenlon.h");   
    translator.addDefinitionCommand("Encoder " + "encoder" + ";");   
    translator.addSetupCommand("encoder.init();");
   
    TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
    String index = translatorBlock.toCode();
   
    String ret = "encoder.clear(" + index  + ");\n";
    return ret;               
  }
View Full Code Here


  //@Override
  public String toCode() throws SocketNullException, SubroutineNotDeclaredException
  {
   
    TranslatorBlock tb = this.getRequiredTranslatorBlockAtSocket(0);
    String I2C_addr = tb.toCode();
    String ret = "lcd_I2C_" + I2C_addr + ".setBacklight(HIGH);\n";
    return ret;
  }
View Full Code Here

      String Pin ;
      String Pixel_Nb;
      String Red;
      String Blue;
      String Green;
      TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
      Pin = translatorBlock.toCode();
      translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
      Pixel_Nb = translatorBlock.toCode();
      translatorBlock = this.getRequiredTranslatorBlockAtSocket(2);
      Red = translatorBlock.toCode();
      translatorBlock = this.getRequiredTranslatorBlockAtSocket(3);
      Green = translatorBlock.toCode();
      translatorBlock = this.getRequiredTranslatorBlockAtSocket(4);
      Blue = translatorBlock.toCode();
     
     
      String ret = "monRuban_pin"+Pin+".preparerPixel("+Pixel_Nb+","+Red+" ,"+Green+" ,"+Blue+" );\n";
     
      return codePrefix + ret + codeSuffix;
View Full Code Here

 
  public String translate(Long blockId) throws SocketNullException, SubroutineNotDeclaredException, BlockException
  {
    TranslatorBlockFactory translatorBlockFactory = new TranslatorBlockFactory();
    Block block = workspace.getEnv().getBlock(blockId);
    TranslatorBlock rootTranslatorBlock = translatorBlockFactory.buildTranslatorBlock(this, blockId, block.getGenusName(), "", "", block.getBlockLabel());
    return rootTranslatorBlock.toCode();
  }
View Full Code Here

      String Clk ;
      String X ;
      String Y;
      String Level;
     
      TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
      Din = translatorBlock.toCode();
      translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
      Cs = translatorBlock.toCode();
      translatorBlock = this.getRequiredTranslatorBlockAtSocket(2);
      Clk = translatorBlock.toCode();
      translatorBlock = this.getRequiredTranslatorBlockAtSocket(3);
      X = translatorBlock.toCode();
      translatorBlock = this.getRequiredTranslatorBlockAtSocket(4);
      Y = translatorBlock.toCode();
      translatorBlock = this.getRequiredTranslatorBlockAtSocket(5);
      Level = translatorBlock.toCode();
     
     
      translator.addHeaderFile("Sprite.h");
      translator.addDefinitionCommand("//libraries http://duinoedu.com/dl/lib/dupont/sprite/");
      translator.addHeaderFile("Matrix.h");
View Full Code Here

    if (context.getArduinoVersionString().equals(Context.ARDUINO_VERSION_UNKNOWN))
    {
      ret += "//Unable to detect your Arduino version, using 1.0 in default\n";
    }
   
    TranslatorBlock t1 = getRequiredTranslatorBlockAtSocket(0);
    String b1 = t1.toCode();
    TranslatorBlock t2 = getRequiredTranslatorBlockAtSocket(1);
    String b2 = t2.toCode();
    TranslatorBlock t3 = getRequiredTranslatorBlockAtSocket(2);
    String b3 = t3.toCode();
    //Switch was not used for compatibility with java 1.6

    if (b2.equals("Return")) {

      ret += "__ardublockWriteNumberSDln ( ";
View Full Code Here

   
    translator.addHeaderFile("keenlon.h");   
    translator.addDefinitionCommand("Encoder " + "encoder" + ";")
    translator.addSetupCommand("encoder.init();");
   
    TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
    String index = translatorBlock.toCode();
   
    String ret = "encoder.getEncoder(" + index  + ")";
    return codePrefix + ret + codePrefix;               
  }
View Full Code Here

    if (context.getArduinoVersionString().equals(Context.ARDUINO_VERSION_UNKNOWN))
    {
      ret += "//Unable to detect your Arduino version, using 1.0 in default\n";
    }
   
    TranslatorBlock t1 = getRequiredTranslatorBlockAtSocket(0);
    String b1 = t1.toCode();
    TranslatorBlock t2 = getRequiredTranslatorBlockAtSocket(1);
    String b2 = t2.toCode();
    TranslatorBlock t3 = getRequiredTranslatorBlockAtSocket(2);
    String b3 = t3.toCode();
    //Switch was not used for compatibility with java 1.6

    if (b2.equals("Return")) {

      ret += "__ardublockWriteNumberIntSDln ( ";
View Full Code Here

      String Pin3 ;
      String Pin4 ;
      String Speed;
      String Step;
     
      TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
      Pin1 = translatorBlock.toCode();
      translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
      Pin2 = translatorBlock.toCode();
      translatorBlock = this.getRequiredTranslatorBlockAtSocket(2);
      Pin3 = translatorBlock.toCode();
      translatorBlock = this.getRequiredTranslatorBlockAtSocket(3);
      Pin4 = translatorBlock.toCode();
      translatorBlock = this.getRequiredTranslatorBlockAtSocket(4);
      Speed = translatorBlock.toCode();
      translatorBlock = this.getRequiredTranslatorBlockAtSocket(5);
      Step = translatorBlock.toCode();
     
     
      String ret = "monMoteur"+Pin1+Pin2+Pin3+Pin4+".setSpeed("+Speed+");\n"+ "monMoteur"+Pin1+Pin2+Pin3+Pin4+".step("+Step+");";
     
      return codePrefix + ret + codeSuffix;
View Full Code Here

   
    translator.addHeaderFile("keenlon.h");   
    translator.addDefinitionCommand("Motor motor;");
    translator.addSetupCommand("motor.init();");
   
    TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
    String num = translatorBlock.toCode();
    translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
    String speed = translatorBlock.toCode();
   
    String ret ="motor.setMotor(" + num + " , " + speed + ");\n";
    return  ret ;           
  }
View Full Code Here

TOP

Related Classes of com.ardublock.translator.block.TranslatorBlock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.