Skip to content
Snippets Groups Projects
Commit 63ae5814 authored by Anian Bühler's avatar Anian Bühler
Browse files

optimized SerialPrintln Block

parent 3319a7a9
No related branches found
No related tags found
1 merge request!2Dev preferences
...@@ -33,20 +33,25 @@ public class SerialPrintBlock extends TranslatorBlock ...@@ -33,20 +33,25 @@ public class SerialPrintBlock extends TranslatorBlock
String stringInput = tB1.toCode(); String stringInput = tB1.toCode();
String[] stringParts = stringInput.split(VarMarker); String[] stringParts = stringInput.split(VarMarker);
String newLine = tB2.toCode().replaceAll("\\s*_.new\\b\\s*", "");
for(int i = 0; i < stringParts.length; i += 1){ for(int i = 0; i < stringParts.length; i += 1){
if(stringParts[i].endsWith("\"")){ if(stringParts[i].endsWith("\"")){
stringParts[i] = stringParts[i].substring(0,stringParts[i].length() - 1) + " \"";// SPACE added at the end of every part stringParts[i] = stringParts[i].substring(0,stringParts[i].length() - 1) + " \"";// SPACE added at the end of every part
} }
if(newLine.equals("true")||newLine.equals("HIGH")){
ret += "Serial.println(" + stringParts[i] + ");\n";
}else {
ret += "Serial.print(" + stringParts[i] + ");\n"; ret += "Serial.print(" + stringParts[i] + ");\n";
} }
String newLine = tB2.toCode().replaceAll("\\s*_.new\\b\\s*", "");
if(newLine.equals("true")||newLine.equals("HIGH")){
ret += "Serial.println();\n";
} }
return ret; return ret;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment