Skip to content

Commit

Permalink
Merge branch 'release-1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
gregcorbett committed Jul 26, 2016
2 parents a6729c0 + 0334698 commit 72a0d7d
Show file tree
Hide file tree
Showing 27 changed files with 730 additions and 41 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,5 @@ bin/
*~
src/main/resources/com/ardublock/block/ardublock.zip
deploy.sh
<<<<<<< HEAD
=======
test-output
src/main/resources/com/ardublock/block/littlebits/files
>>>>>>> upstream/master
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

19 changes: 19 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Changelog

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

Major Changes:
None

Minor Changes:
Add blocks to support FaireBot: https://www.youtube.com/watch?v=ru-OUyFdxc4
Re-add Tilt Switch block

Patches and Bug Fixes:
Fix of the'pin# bug' for Tilt Switch block
Re-add 'pin#' to LED block (instead of '#')
Rename 'Tests' to 'Logical Operators'

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

First Release (of this fork)
9 changes: 7 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
ArduBlock is a Block Programming Language for Arduino. The language and functions model closely to [Arduino Language Reference](http://arduino.cc/en/Reference/HomePage)

##Users
Ardublock is a free graphical programming environment to make programming physical computing with Arduino as easy as drag and drop. It is based on the popular ‘scratch’ programming language, which many will already be familiar with. Ardublock generates code in C, a text based language used by the Arduino IDE, which can then be studied and modified if desired. Ardublock is an extension to the Arduino IDE so that will need to be downloaded as well (found here https://www.arduino.cc/en/Main/Software). Code written in the Arduino IDE has the file extension .abp.
Ardublock is a free graphical programming environment to make programming physical computing with Arduino as easy as drag and drop. It is based on the popular ‘scratch’ programming language, which many will already be familiar with. Ardublock generates code in C, a text based language used by the Arduino IDE, which can then be studied and modified if desired.

Ardublock is an extension to the Arduino IDE so that will need to be downloaded as well (found here https://www.arduino.cc/en/Main/Software).
* Ardublock has been tested with version 1.0.5-r2, available here: http://arduino.googlecode.com/files/arduino-1.0.5-r2-windows.exe

Code written in Ardublock has the file extension .abp.

####Getting Started with ArduBlock
1. Install the Arduino IDE, from https://www.arduino.cc/en/Main/Software
Expand Down Expand Up @@ -52,7 +57,7 @@ The original code (https://github.com/taweili/ardublock) was developed at MIT an
* David Li [email protected]
* HE Qichen [email protected]

The author/maintainer of this branch can be contacted at [email protected].
The author/maintainer of this fork can be contacted at [email protected].

##License
Copyright (C) 2011 David Li and He Qichen
Expand Down
2 changes: 1 addition & 1 deletion install_openblocks
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /bin/sh
git clone https://github.com/taweili/openblocks.git && \
git clone https://github.com/gregcorbett/openblocks.git && \
cd openblocks && \
mvn install && \
cd .. && \
Expand Down
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>0.1.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<name>ArduBlock</name>
<description>A Block Programming Language for Arduino</description>
<properties>
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/ardublock/translator/Translator.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

public class Translator
{
private static final String variablePrefix = "_ABVAR_";
private static final String variablePrefix = "";

private Set<String> headerFileSet;
private Set<String> definitionSet;
Expand Down Expand Up @@ -284,8 +284,7 @@ public String buildVariableName()

public String buildVariableName(String reference)
{
variableCnt = variableCnt + 1;
String varName = variablePrefix + variableCnt + "_";
String varName = "";
int i;
for (i=0; i<reference.length(); ++i)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.ardublock.translator.block.FaireBot;

import com.ardublock.translator.Translator;
import com.ardublock.translator.block.NumberBlock;
import com.ardublock.translator.block.TranslatorBlock;
import com.ardublock.translator.block.exception.SocketNullException;
import com.ardublock.translator.block.exception.SubroutineNotDeclaredException;

public class FaireBotAddBackwardBlock extends TranslatorBlock
{
public FaireBotAddBackwardBlock(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label)
{
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
translator.addSetupCommand("pinMode( 10 , OUTPUT);");
translator.addDefinitionCommand("int FAIRE_backward = 5;");
return "memory[memoryPtr] = FAIRE_backward; memoryPtr++; while(digitalRead(FAIRE_backward) == 1) {digitalWrite(10, HIGH);} digitalWrite(10, LOW);";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.ardublock.translator.block.FaireBot;

import com.ardublock.translator.Translator;
import com.ardublock.translator.block.NumberBlock;
import com.ardublock.translator.block.TranslatorBlock;
import com.ardublock.translator.block.exception.SocketNullException;
import com.ardublock.translator.block.exception.SubroutineNotDeclaredException;

public class FaireBotAddForwardBlock extends TranslatorBlock
{
public FaireBotAddForwardBlock(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label)
{
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
translator.addSetupCommand("pinMode( 8 , OUTPUT);");
translator.addDefinitionCommand("int FAIRE_forward = 3;");
return "memory[memoryPtr] = FAIRE_forward ; memoryPtr++; while(digitalRead(FAIRE_forward) == 1) {digitalWrite(8, HIGH);} digitalWrite(8, LOW);";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.ardublock.translator.block.FaireBot;

import com.ardublock.translator.Translator;
import com.ardublock.translator.block.NumberBlock;
import com.ardublock.translator.block.TranslatorBlock;
import com.ardublock.translator.block.exception.SocketNullException;
import com.ardublock.translator.block.exception.SubroutineNotDeclaredException;

public class FaireBotAddLeftBlock extends TranslatorBlock
{
public FaireBotAddLeftBlock(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label)
{
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
translator.addSetupCommand("pinMode( 9 , OUTPUT);");
translator.addDefinitionCommand("int FAIRE_left = 2;");
return "memory[memoryPtr] = FAIRE_left; memoryPtr++; while(digitalRead(FAIRE_left) == 1) {digitalWrite(9, HIGH);} digitalWrite(9, LOW);";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.ardublock.translator.block.FaireBot;

import com.ardublock.translator.Translator;
import com.ardublock.translator.block.NumberBlock;
import com.ardublock.translator.block.TranslatorBlock;
import com.ardublock.translator.block.exception.SocketNullException;
import com.ardublock.translator.block.exception.SubroutineNotDeclaredException;

public class FaireBotAddRightBlock extends TranslatorBlock
{
public FaireBotAddRightBlock(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label)
{
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
translator.addSetupCommand("pinMode( 7 , OUTPUT);");
translator.addDefinitionCommand("int FAIRE_right = 6;");
return "memory[memoryPtr] = FAIRE_right; memoryPtr++; while(digitalRead(FAIRE_right) == 1) {digitalWrite(7, HIGH);} digitalWrite(7, LOW);";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.ardublock.translator.block.FaireBot;

import com.ardublock.translator.Translator;
import com.ardublock.translator.block.NumberBlock;
import com.ardublock.translator.block.TranslatorBlock;
import com.ardublock.translator.block.exception.SocketNullException;
import com.ardublock.translator.block.exception.SubroutineNotDeclaredException;
import com.ardublock.translator.block.exception.BlockException;

public class FaireBotBackwardBlock extends TranslatorBlock
{
public FaireBotBackwardBlock(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label)
{
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
if (!(translatorBlock instanceof NumberBlock))
{
throw new BlockException(this.blockId, "the rotation of FaireBotForward must a number");
}


NumberBlock rotationNumberBlock = (NumberBlock)translatorBlock;
String rotationNumber = rotationNumberBlock.toCode();
//String servoName = "servo_pin_" + pinNumber;

//translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);

String ret = "digitalWrite(10, HIGH);";
ret = ret + "for (int i = 0; i < " + rotationNumber + "; i++) {";
ret = ret + "leftServo.write(0); rightServo.write(180); delay(30);}";
ret = ret + "digitalWrite(10, LOW);";
ret = ret + "leftServo.write(90); rightServo.write(90); delay(30);";

//servoName + ".write( " + translatorBlock.toCode() + " );\n";
translator.addHeaderFile("Servo.h");
translator.addDefinitionCommand("Servo leftServo;");
translator.addDefinitionCommand("Servo rightServo;");
translator.addSetupCommand("pinMode( 10 , OUTPUT);");
translator.addSetupCommand("leftServo.attach(A1);");
translator.addSetupCommand("rightServo.attach(A2);");
translator.addSetupCommand("leftServo.write(90);");
translator.addSetupCommand("rightServo.write(90);");
return ret;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.ardublock.translator.block.FaireBot;

import com.ardublock.translator.Translator;
import com.ardublock.translator.block.NumberBlock;
import com.ardublock.translator.block.TranslatorBlock;
import com.ardublock.translator.block.exception.SocketNullException;
import com.ardublock.translator.block.exception.SubroutineNotDeclaredException;
import com.ardublock.translator.block.exception.BlockException;

public class FaireBotDistanceBlock extends TranslatorBlock
{
public FaireBotDistanceBlock(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label)
{
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
if (!(translatorBlock instanceof NumberBlock))
{
throw new BlockException(this.blockId, "the FaireBot distance must a number");
}


NumberBlock distanceNumberBlock = (NumberBlock)translatorBlock;
String distanceNumber = distanceNumberBlock.toCode();

translator.addDefinitionCommand("int FAIRE_movementDistance;");
return "FAIRE_movementDistance = " + distanceNumber + ";";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.ardublock.translator.block.FaireBot;

import com.ardublock.translator.Translator;
import com.ardublock.translator.block.NumberBlock;
import com.ardublock.translator.block.TranslatorBlock;
import com.ardublock.translator.block.exception.SocketNullException;
import com.ardublock.translator.block.exception.SubroutineNotDeclaredException;
import com.ardublock.translator.block.exception.BlockException;

public class FaireBotForwardBlock extends TranslatorBlock
{
public FaireBotForwardBlock(Long blockId, Translator translator, String codePrefix, String codeSuffix, String label)
{
super(blockId, translator, codePrefix, codeSuffix, label);
}

@Override
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
TranslatorBlock translatorBlock = this.getRequiredTranslatorBlockAtSocket(0);
if (!(translatorBlock instanceof NumberBlock))
{
throw new BlockException(this.blockId, "the rotation of FaireBotForward must a number");
}


NumberBlock rotationNumberBlock = (NumberBlock)translatorBlock;
String rotationNumber = rotationNumberBlock.toCode();
//String servoName = "servo_pin_" + pinNumber;

//translatorBlock = this.getRequiredTranslatorBlockAtSocket(1);

String ret = "digitalWrite(8, HIGH);";
ret = ret + "for (int i = 0; i < " + rotationNumber + "; i++) {";
ret = ret + "leftServo.write(180); rightServo.write(0); delay(30);}";
ret = ret + "digitalWrite(8, LOW);";
ret = ret + "leftServo.write(90); rightServo.write(90); delay(30);";

//servoName + ".write( " + translatorBlock.toCode() + " );\n";
translator.addHeaderFile("Servo.h");
translator.addDefinitionCommand("Servo leftServo;");
translator.addDefinitionCommand("Servo rightServo;");
translator.addSetupCommand("pinMode( 8 , OUTPUT);");
translator.addSetupCommand("leftServo.attach(A1);");
translator.addSetupCommand("rightServo.attach(A2);");
translator.addSetupCommand("leftServo.write(90);");
translator.addSetupCommand("rightServo.write(90);");
return ret;
}

}
Loading

0 comments on commit 72a0d7d

Please sign in to comment.