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

Added EscapeCodes to Serial.print

parent 490a3816
No related branches found
No related tags found
1 merge request!1Dev sim type float
......@@ -11,13 +11,28 @@ import tec.letsgoing.ardublock.simulator.simcode.datatypes.SimTypeString;
/**
* Sende Nachricht via Serial
*
* @author Lucas
* @author Lucas, Anian
*
*
*/
public class CodeSerialPrint extends SimCode {
private SimTypeString stringBlock;
private SimTypeBool boolBlock;
private String replaceEscapeCodes(String str) {
int indexNL = str.indexOf("\\n");
int indexTab = str.indexOf("\\t");
while(indexNL > -1) {
str = str.substring(0, indexNL) + "\n" + str.substring(indexNL+2);
indexNL = str.indexOf("\\n");
}
while(indexTab > -1) {
str = str.substring(0, indexTab) + "\t" + str.substring(indexTab+2);
indexTab = str.indexOf("\\t");
}
return str;
}
public CodeSerialPrint(SimTypeString _stringBlock, SimTypeBool _boolBlock) {
stringBlock = _stringBlock;
......@@ -26,7 +41,10 @@ public class CodeSerialPrint extends SimCode {
public SimCode run(Arduino _arduino, SimCode functionHead) {
String content;
content = stringBlock.run(_arduino, functionHead).toString();
content = replaceEscapeCodes(content);
if (boolBlock.run(_arduino, functionHead).getValue()) {
content += "\n";
}
......
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