Skip to content

Commit

Permalink
Merge pull request #169 from vedes/irRemote-with-String-object-result
Browse files Browse the repository at this point in the history
It is better to make the object String thet then to apply an equals m…
  • Loading branch information
TonyCallear authored Nov 12, 2017
2 parents a5efea5 + f268f73 commit 70492d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
17 changes: 4 additions & 13 deletions src/main/java/com/ardublock/translator/block/IrGetCodeBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,18 @@ public class IrGetCodeBlock extends TranslatorBlock
" __ab_irrecv.enableIRIn();\n" +
" __ab_irrecv.resume();\n" +
"}\n" +
"void charsToUpper(char *str)\n" +
"{\n" +
" int p=0;\n" +
" while(str[p] != 0)\n" +
" {\n" +
" str[p] = toupper(str[p]);\n" +
" ++p;\n" +
" }\n" +
"}\n" +
"void __ab_getIrCommand(char *receivedCommand)\n" +
"void __ab_getIrCommand(String &receivedCommand)\n" +
"{\n" +
" decode_results result;\n" +
" if (__ab_irrecv.decode(&result))\n" +
" {\n" +
" ltoa(result.value, receivedCommand, 16);\n" +
" charsToUpper(receivedCommand);\n" +
" receivedCommand = String(result.value, HEX);\n" +
" receivedCommand.toUpperCase();\n" +
" __ab_irrecv.resume();\n" +
" }\n" +
" else\n" +
" {\n" +
" receivedCommand[0] = '\\0';\n" +
" receivedCommand = \"\";\n" +
" }\n" +
"}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public StringEmptyBlock(Long blockId, Translator translator, String codePrefix,
public String toCode() throws SocketNullException, SubroutineNotDeclaredException
{
StringBuilder ret = new StringBuilder();
ret.append("strlen(");
ret.append("");
TranslatorBlock tb = this.getRequiredTranslatorBlockAtSocket(0);
ret.append(tb.toCode());
ret.append(") == 0");
ret.append(".length() == 0");
return codePrefix + ret + codeSuffix;
}
}

0 comments on commit 70492d9

Please sign in to comment.