Hello,
Pleased to see that you found a solution for your project.
I added a ‘\n’ to a string and tested your function and split().
trim() removes the ‘\n’.
Your function works the same as split() with this example:
Summary
void setup()
{
size(640, 360);
String inString = "$GPGGA,182533.00,4355.94412,N,07859.68771,W,1,08,1.20,138.8,M,-35.9,M,,*6A\n";
println(split(inString.trim(), ',')); //Gives a warning put still prints to console
mySplit(inString.trim(), true);
printArray(split(inString.trim(), ','));
mySplit(inString.trim(), false);
printArray(split(inString, ','));
mySplit(inString, false);
print("");
}
void draw()
{
background(0);
}
void mySplit (String str, boolean row) {
int N = str.length();
int i;
String str2 = "";
char c;
for (i = 0; i < N; i++){
c = str.charAt(i);
if (c == ',') {
if (row)
print(str2 + " ");
else
println(str2);
str2 = "";
}
else {
str2 += c;
}
}
println(str2);
}
I always like to see code examples to replace existing functions; all too often the workings of a function are hidden away from us and I like to write my own and\or see the source to help me better understand the underlying code and sometimes improve on it.
I did find some Android apps on Google Play to generate GPS data and send serial
data over Bluetooth and I wrote code to receive with Processing.
I was able to plot my movement in my room!
:)