Package com.ardublock.translator.block

Examples of com.ardublock.translator.block.TranslatorBlock


  @Override
  public String toCode() throws SocketNullException, SubroutineNotDeclaredException
  {
    String ret;
    TranslatorBlock childBlock; 

    ret = "{PALETTE_PIN_VIRTUAL_TIME, FUNCTION_SENSOR_VIRTUALTIME },";


    childBlock = getTranslatorBlockAtSocket(0);
    if (childBlock != null)
    {
      ret += childBlock.toCode() + ",";
    }
    else
    {
      ret += "0,";
    }
View Full Code Here


    func +=  "if (value < 10) value = 10;\n";
      func += "return ((67870.0 / (value - 3.0)) - 40.0);\n";
      func += "}\n\n";
    translator.addDefinitionCommand(func);

    TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
    String ret = "ComputeSharpGP2Y0A21(analogRead(";
    ret = ret + translatorBlock.toCode();
    ret = ret + "))";
   
    return ret;
  }
View Full Code Here

  //@Override
  public String toCode() throws SocketNullException, SubroutineNotDeclaredException
  {
   
    TranslatorBlock tb = this.getRequiredTranslatorBlockAtSocket(1);
    String lineNo = tb.toCode();
    tb = this.getRequiredTranslatorBlockAtSocket(2);
    String charNo = tb.toCode();
    tb = this.getRequiredTranslatorBlockAtSocket(3);
    String I2C_addr = tb.toCode();
   
    String ret = "";
    if ( !(charNo.equals("0") && lineNo.equals("0")) ){
      ret = "lcd_I2C_" + I2C_addr + ".setCursor( (" + charNo + ") - 1, (" + lineNo + ") - 1 );";
    }
   
    tb = this.getRequiredTranslatorBlockAtSocket(0, "lcd_I2C_"+ I2C_addr + ".print( ", " );\n");
    ret += tb.toCode();
    //Deal with line and character positioning
    translator.addHeaderFile("Wire.h");
    translator.addHeaderFile("LCD.h");
    translator.addHeaderFile("LiquidCrystal_I2C.h");
    translator.addDefinitionCommand(             "// For these LCD controls to work you MUST replace the standard LCD library with 'New LCD' from...");
View Full Code Here

  //@Override
  public String toCode() throws SocketNullException, SubroutineNotDeclaredException
  {
   
    TranslatorBlock tb = this.getRequiredTranslatorBlockAtSocket(1);
    String lineNo = tb.toCode();
    tb = this.getRequiredTranslatorBlockAtSocket(2);
    String charNo = tb.toCode();
    tb = this.getRequiredTranslatorBlockAtSocket(3);
    String I2C_addr = tb.toCode();
   
    String ret = "";
    if ( !(charNo.equals("0") && lineNo.equals("0")) ){
      ret = "lcd_I2C_" + I2C_addr + ".setCursor( (" + charNo + ") - 1, (" + lineNo + ") - 1 );";
    }
   
    tb = this.getRequiredTranslatorBlockAtSocket(0, "lcd_I2C_" + I2C_addr + ".print( ", " );\n");
    ret += tb.toCode();
    //Deal with line and character positioning
    translator.addHeaderFile("Wire.h");
    translator.addHeaderFile("LCD.h");
    translator.addHeaderFile("LiquidCrystal_I2C.h");
    translator.addDefinitionCommand(             "// For these LCD controls to work you MUST replace the standard LCD library with 'New LCD' from...");
View Full Code Here

      return null;
    }
    else
    {
      block = translator.getBlock(blockId);
      TranslatorBlock translatorBlock = translatorBlockFactory.buildTranslatorBlock(translator, blockId, block.getGenusName(), codePrefix, codeSuffix, block.getBlockLabel());
      return translatorBlock;
    }
  }
View Full Code Here

    }
    else
    {
      block = translator.getBlock(blockId);
//      System.out.println("name: " + block.getGenusName() + "      | label: " + block.getBlockLabel());
      TranslatorBlock translatorBlock = translatorBlockFactory.buildTranslatorBlock(translator, blockId, block.getGenusName(), codePrefix, codeSuffix, block.getBlockLabel());
      return translatorBlock;
    }
   
  }
View Full Code Here

  @Override
  public String toCode() throws SocketNullException, SubroutineNotDeclaredException {
    translator.addHeaderFile("Makeblock.h");
    translator.addHeaderFile("SoftwareSerial.h");
    translator.addHeaderFile("Wire.h");
    TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
    String ret = "MeLimitSwitch switch"+translatorBlock.toCode()+"(PORT_"+translatorBlock.toCode()+");";
    translator.addDefinitionCommand(ret);
    return "switch"+translatorBlock.toCode()+".touched()";
  }
View Full Code Here

 
  //@Override
    public String toCode() throws SocketNullException, SubroutineNotDeclaredException
    {
      String way;
      TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
      way = translatorBlock.toCode();
     
     
      translator.addHeaderFile("Wire.h");
      translator.addHeaderFile("MotorI2C.h");
      translator.addDefinitionCommand("//libraries at http://www.duinoedu.com/\nMotorI2C mesMoteurs;");
View Full Code Here

  @Override
  public String toCode() throws SocketNullException, SubroutineNotDeclaredException {
    translator.addHeaderFile("Makeblock.h");
    translator.addHeaderFile("SoftwareSerial.h");
    translator.addHeaderFile("Wire.h");
    TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
    String ret = "MeInfraredReceiver infraredReceiver"+translatorBlock.toCode()+"(PORT_"+translatorBlock.toCode()+");";
    translator.addDefinitionCommand(ret);
    translator.addSetupCommand("infraredReceiver"+translatorBlock.toCode()+".begin();");
   

    TranslatorBlock dataBlock = this.getRequiredTranslatorBlockAtSocket(1);
    TranslatorBlock keyDownBlock = getTranslatorBlockAtSocket(2);
    TranslatorBlock keyUpBlock = getTranslatorBlockAtSocket(3);
    ret = "\nif(infraredReceiver"+translatorBlock.toCode()+".buttonState()==1){\n"+dataBlock.toCode()+"=infraredReceiver"+translatorBlock.toCode()+".read();\n";
    String exec = "";
    while (keyDownBlock != null)
    {
      exec += "\t"+ keyDownBlock.toCode()+"\n";
      keyDownBlock = keyDownBlock.nextTranslatorBlock();
    }
    ret += "\n"+exec+"\n}else{\n";
    exec = "";
    while (keyUpBlock != null)
    {
      exec += "\t"+ keyUpBlock.toCode()+"\n";
      keyUpBlock = keyUpBlock.nextTranslatorBlock();
    }
    ret += "\n"+exec+"\n};\n";
    return ret;
  }
View Full Code Here

  @Override
  public String toCode() throws SocketNullException, SubroutineNotDeclaredException {
    translator.addHeaderFile("Makeblock.h");
    translator.addHeaderFile("SoftwareSerial.h");
    translator.addHeaderFile("Wire.h");
    TranslatorBlock block = this.getRequiredTranslatorBlockAtSocket(0);
    String ret = "MeBluetooth bluetooth"+block.toCode()+"(PORT_"+block.toCode()+");";
    translator.addDefinitionCommand(ret);
    translator.addSetupCommand("bluetooth"+block.toCode()+".begin(9600);");
    TranslatorBlock execBlock = getTranslatorBlockAtSocket(1);
    ret = "";  
    ret += "if(bluetooth"+block.toCode()+".paramAvailable()){\n";
    String exec = "";
    while (execBlock != null)
    {
      exec += "\t"+ execBlock.toCode()+"\n";
      execBlock = execBlock.nextTranslatorBlock();
    }
    ret += "\n"+exec+"\n};\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.