Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Simulator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
letsgoING
ArduBlock Source
Simulator
Commits
48b65520
Commit
48b65520
authored
3 years ago
by
Anian Bühler
Browse files
Options
Downloads
Patches
Plain Diff
Added EscapeCodes to Serial.print
parent
490a3816
No related branches found
No related tags found
1 merge request
!1
Dev sim type float
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/tec/letsgoing/ardublock/simulator/simcode/comm/CodeSerialPrint.java
+19
-1
19 additions, 1 deletion
...ing/ardublock/simulator/simcode/comm/CodeSerialPrint.java
with
19 additions
and
1 deletion
src/tec/letsgoing/ardublock/simulator/simcode/comm/CodeSerialPrint.java
+
19
−
1
View file @
48b65520
...
...
@@ -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"
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment