@@ -35,11 +35,10 @@ import java.util.concurrent.TimeUnit;
3535import java.util.concurrent.TimeoutException ;
3636
3737// FLAG FOR DEBUG MODE
38- final boolean DEBUG = true ;
38+ final boolean DEBUG = false ;
3939
4040// CONSTANTS
4141final char OUTER_KEY = ' #' ;
42- final String INNER_KEY = " @" ;
4342final int MARGIN_SZ = 20 ; // between plots
4443final int BG_COL = 75 ; // background
4544final int PORT_INTERVAL = 5000 ; // time to sit on each port
@@ -94,10 +93,6 @@ void setup()
9493
9594void draw ()
9695{
97- // REMOVE ***
98- int start = millis ();
99- // *** REMOVE
100-
10196 // PLOT ALL
10297 try
10398 {
@@ -143,30 +138,10 @@ void draw()
143138 }
144139 catch ( Exception e )
145140 {}
146-
147- // REMOVE ***
148- totalGraphing += ( millis () - start );
149- // *** REMOVE
150141}
151142
152- // REMOVE **** timing vars
153- int countTo = 1000 ;
154- int count = 0 ;
155- int startTrial = 0 ;
156- int totalSerialEvent = 0 ;
157- int totalGraphing = 0 ;
158- // *** REMOVE
159-
160143void serialEvent( Serial ser )
161144{
162- // REMOVE**** timing logic: start
163- int start = millis ();
164- if ( count == 0 )
165- {
166- startTrial = start;
167- }
168- // ***** REMOVE
169-
170145 // Listen for serial data until #, the end of transmission key
171146 try
172147 {
@@ -198,9 +173,11 @@ void serialEvent( Serial ser )
198173 // If config code has changed, need to go through setup again
199174 if ( config && ! configCode. equals( tempCode ) )
200175 {
176+ lastPortSwitch = millis (); // (likely on the right port, just need to reconfigure graph layout)
177+
201178 // Check for size of full transmission against expected to flag bad transmission
202179 numGraphs = json. getInt( " ng" );
203-
180+
204181 JSONArray jsonGraphs = json. getJSONArray( " g" );
205182
206183 if ( jsonGraphs. size() != numGraphs )
@@ -297,20 +274,6 @@ void serialEvent( Serial ser )
297274 {
298275 logMessage( " Exception in serialEvent: " + e. toString(), true );
299276 }
300-
301- // REMOVE ***** timing logic: end
302- int end = millis ();
303- totalSerialEvent += ( end - start );
304- count++ ;
305- if ( count == countTo )
306- {
307- logMessage( " Time per " + count + " counts: overall: " + ( end - startTrial ) + " , in serialEvent: "
308- + totalSerialEvent + " , graphing: " + totalGraphing, false );
309- count = 0 ;
310- totalSerialEvent = 0 ;
311- totalGraphing = 0 ;
312- }
313- // ***** REMOVE
314277}
315278
316279// Helper method to calculate bounds of graphs
0 commit comments