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,19 +33,24 @@ public class SerialPrintBlock extends TranslatorBlock ...@@ -33,19 +33,24 @@ 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
} }
ret += "Serial.print(" + stringParts[i] + ");\n";
if(newLine.equals("true")||newLine.equals("HIGH")){
ret += "Serial.println(" + stringParts[i] + ");\n";
}else {
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.
Finish editing this message first!
Please register or to comment