Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
gregcorbett committed Jul 27, 2016
2 parents 72a0d7d + bfe2701 commit c625bc0
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 28 deletions.
14 changes: 13 additions & 1 deletion ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
Changelog


========== Version 2.0.0 ==========

Major Changes:
Alter loop counters to be more pythonic (starting at 0)

Minor Changes:
Defines loop counters in the loop

Patches and Bug Fixes:
Tinker blocks in loops no longer generate functions

========== Version 1.1.0 ==========

Major Changes:
Expand All @@ -16,4 +28,4 @@ Rename 'Tests' to 'Logical Operators'

========== Version 1.0.0 ==========

First Release (of this fork)
First Release (of this fork)
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>org.ardublock</groupId>
<artifactId>ardublock</artifactId>
<packaging>jar</packaging>
<version>1.1.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<name>ArduBlock</name>
<description>A Block Programming Language for Arduino</description>
<properties>
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/ardublock/translator/block/RepeatBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@ public RepeatBlock(Long blockId, Translator translator, String codePrefix, Strin
@Override
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
String varName="";//this.getRequiredTranslatorBlockAtSocket(0);
TranslatorBlock teste = this.getRequiredTranslatorBlockAtSocket(0);
if (!(teste instanceof VariableNumberBlock || teste instanceof VariableNumberUnsignedLongBlock || teste instanceof VariableNumberDoubleBlock)) {
throw new BlockException(blockId, uiMessageBundle.getString("ardublock.error_msg.number_var_slot"));
}
varName=varName+teste.toCode();
//translator.addDefinitionCommand("int " + varName + "; //teste");
String ret = "for (" + varName + "= 1; " + varName + "<= ( ";
String varName=teste.toCode();
String ret = "for(int " + varName + "=0; " + varName + " < ";
TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
ret = ret + translatorBlock.toCode();
ret = ret + " ); " + varName + "++ )\n{\n";
ret = ret + "; " + varName + "++)\n{\n";


translatorBlock = getTranslatorBlockAtSocket(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,18 @@ public String toCode() throws SocketNullException, SubroutineNotDeclaredExceptio
tb = this.getRequiredTranslatorBlockAtSocket(3);
String incVal = tb.toCode();

String ret = "";
String ret = "for(int " + varName + " = " + startVal + "; ";

ret = ret + "for(" + varName + " = " + startVal + "; \n" +
startVal + "<=" + stopVal + "?" + varName + " <= " + stopVal + ":" + varName + " >= " + stopVal + "; \n" +
startVal + "<=" + stopVal + "?" + varName + " = " + varName + " + " + incVal + ":" + varName + " = " + varName + " - " + incVal + ")\n{";
if (Integer.parseInt(startVal) <= Integer.parseInt(stopVal)) {
ret = ret + varName + " < " + stopVal+"; ";
ret = ret + varName + " = " + varName + " + " + incVal+")\n";
}
else {
ret = ret + varName + " > " + stopVal+"; ";
ret = ret + varName + " = " + varName + " - " + incVal+")\n";
}

ret = ret +"{";

TranslatorBlock translatorBlock = getTranslatorBlockAtSocket(4);
while (translatorBlock != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ public RepeatTimesBlock(Long blockId, Translator translator, String codePrefix,
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
String varName = translator.buildVariableName();
translator.addDefinitionCommand("int " + varName + "a;");
String ret = "for (" + varName + "a=1; " + varName + "a<= ( ";
String ret = "for(int " + varName + "i=0; " + varName + "i < ";
TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
ret = ret + translatorBlock.toCode();
ret = ret + " ); ++" + varName + "a )\n{\n";
ret = ret + "; " + varName + "i++)\n{\n";


translatorBlock = getTranslatorBlockAtSocket(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,16 @@ public String toCode() throws SocketNullException, SubroutineNotDeclaredExceptio
TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
String ret = "";

if (translatorBlock instanceof NumberBlock || translatorBlock instanceof TinkerOutputPortBlock)
String number = translatorBlock.toCode();

if (translatorBlock instanceof NumberBlock)
{
String number = translatorBlock.toCode();
String setupCode = "pinMode( " + number + " , OUTPUT);";
translator.addSetupCommand(setupCode);

ret = "digitalWrite( ";
ret = ret + number;
}
else
{
translator.addDefinitionCommand(DigitalOutputBlock.ARDUBLOCK_DIGITAL_WRITE_DEFINE);
ret = "__ardublockDigitalWrite(";

ret = ret + translatorBlock.toCode();
}

ret = "digitalWrite( ";
ret = ret + number;

ret = ret + " , ";
translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/com/ardublock/block/ardublock.properties
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ ardublock.ui.create_refer=create reference
ardublock.ui.website=Go to Web Site
ardublock.ui.serialMonitor=Serial Monitor
ardublock.ui.saveImage=Save as image...
ardublock.ui.version=1.1.0
ardublock.ui.version=2.0.0

ardublock.error_msg.digital_var_slot=Digital variable slot must take a 'digital variable' name.\nHint: Look at the 'variable' socket on the highlighted block
ardublock.error_msg.number_var_slot=Standard variable slot must take a standard 'numeric' variable name.\nHint: Look at the 'variable' socket on the highlighted block
Expand Down Expand Up @@ -1505,4 +1505,4 @@ bg.FaireBot_AddRight.description=Save "right" in memory

bg.FaireBot_Go.description=Run saved commands
bg.FaireBot_Distance.description=Set the forward/back distance of the FaireBot
bg.FaireBot_Turn.description=Set the turn of the FaireBot
bg.FaireBot_Turn.description=Set the turn of the FaireBot

0 comments on commit c625bc0

Please sign in to comment.