Skip to content

Commit dd7e1c8

Browse files
committed
Verify correct title/labels before finishing config
1 parent 8360667 commit dd7e1c8

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

listener/listener.pde

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ int h;
5353
int w;
5454
int numGraphs;
5555
String configCode = "This will not be matched!";
56+
String lastLabels = "Also will not be matched";
5657
boolean configured = false;
5758
int lastConfig;
5859
int lastPortSwitch;
@@ -142,8 +143,8 @@ void serialEvent( Serial ser )
142143
throw new Exception();
143144
}
144145
configured = false;
145-
//print("New config");
146-
146+
String concatLabels = "";
147+
147148
// Setup new layout
148149
float[][] posGraphs = setupGraphPosition( numGraphs );
149150

@@ -153,13 +154,15 @@ void serialEvent( Serial ser )
153154
for ( int i = 0; i < numGraphs; i++ )
154155
{
155156
arraySub = arrayMain[i+1].split( INNER_KEY );
156-
String title = arraySub[0];
157+
String title = arraySub[0];
157158
boolean xvyTemp = Integer.parseInt( arraySub[1] ) == 1;
158159
int maxPoints = Integer.parseInt( arraySub[2] );
159160
int numVars = Integer.parseInt( arraySub[3] );
160161
String[] labelsTemp = new String[numVars];
161162
int[] colorsTemp = new int[numVars];
162-
163+
164+
concatLabels += title;
165+
163166
for ( int j = 0; j < numVars; j++ )
164167
{
165168
labelsTemp[j] = arraySub[4 + 3*j];
@@ -168,6 +171,7 @@ void serialEvent( Serial ser )
168171
{
169172
colorsTemp[j] = COLORMAP.get( "green" );
170173
}
174+
concatLabels += labelsTemp[j];
171175
}
172176

173177
if ( xvyTemp )
@@ -181,11 +185,14 @@ void serialEvent( Serial ser )
181185
graphs.add( temp );
182186
}
183187
println("Added ", graphs.size() );
184-
188+
185189
// Set new config code
186-
configCode = arrayMain[0];
187-
//println(config_code);
188-
lastConfig = millis();
190+
if ( concatLabels.equals( lastLabels ) ) // Only when we're sure on labels
191+
{
192+
configCode = arrayMain[0];
193+
lastConfig = millis();
194+
}
195+
lastLabels = concatLabels;
189196
}
190197
else
191198
{

0 commit comments

Comments
 (0)