The hit and times are correct for every hit registered now. The hits that never happened still get fill with junk.
DirtyD:
void FormatData()
{
// routine to format lines of data to be sent to LCD
// presently assume 4 lines of 20 characters
// switch formatting done based on display state
switch (DisplayState)
{
case 1:{
//this is for single A shooter mode
// display number of hits so far
String tmp = "A: # hits = ";
Line1 = tmp + A_count;
// now display the time of last hit in secs out to hundreths of secs
String tmp2 = TimeConvert(A_Times[A_count-1]); // convert hit time to XX.xx format
Line2 = “Hit time= " + tmp2 + " secs”;
Line3 = " ";
Line4 = " ";
break;}
case 2:{
// this is A review mode hits 1-8
String tmp = TimeConvert(A_Times[0]); // convert hit time to XX.xx format
String tmp2 = TimeConvert(A_Times[4]); // convert hit time to XX.xx format
Line1 = “A 1:” + tmp + “s 5:” + tmp2 + “s”;
tmp = TimeConvert(A_Times[1]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[5]); // convert hit time to XX.xx format
Line2 = “A 2:” + tmp + “s 6:” + tmp2 + “s”;
tmp = TimeConvert(A_Times[2]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[6]); // convert hit time to XX.xx format
Line3 = “A 3:” + tmp + “s 7:” + tmp2 + “s”;
tmp = TimeConvert(A_Times[3]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[7]); // convert hit time to XX.xx format
Line4 = “A 4:” + tmp + “s 8:” + tmp2 + “s”;
break;}
case 3:{
// this is A review mode hits 9-16
String tmp = TimeConvert(A_Times[8]); // convert hit time to XX.xx format
String tmp2 = TimeConvert(A_Times[12]); // convert hit time to XX.xx format
Line1 = “A 9:” + tmp + “s 13:” + tmp2 + “s”;
tmp = TimeConvert(A_Times[9]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[13]); // convert hit time to XX.xx format
Line2 = “A 10:” + tmp + “s14:” + tmp2 + “s”;
tmp = TimeConvert(A_Times[10]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[14]); // convert hit time to XX.xx format
Line3 = “A 11:” + tmp + “s15:” + tmp2 + “s”;
tmp = TimeConvert(A_Times[11]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[15]); // convert hit time to XX.xx format
Line4 = “A 12:” + tmp + “s16:” + tmp2 + “s”;
break;}
case 4:{
// this is A review mode hits 17-20
String tmp = TimeConvert(A_Times[16]); // convert hit time to XX.xx format
String tmp2 = TimeConvert(A_Times[18]); // convert hit time to XX.xx format
Line1 = “A 17:” + tmp + “s19:” + tmp2 + “s”;
tmp = TimeConvert(A_Times[17]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[19]); // convert hit time to XX.xx format
Line2 = “A 18:” + tmp + “s20:” + tmp2 + “s”;
Line3 = " ";
Line4 = " ";
break;}
default:
// do the default = 0
// 4 string objects
Line1 = " Shot Timer v1 ";
Line2 = " is running ";
Line3 = " Countdown to start ";
Line4 = " in progress ";
}
}
This should fix hit 15 from displaying wrong. Looks like there were a few variable declarations that weren't used (Both in case = 3 and 4). Scratch that they were used to hold the return value from the TimerConvert function but didn't get used when concatenating the strings for the display. :D
I see that the tmp3 and tmp4 are gone (and shouldn’t be missed !) but I’m not seeing what you did you prevent display of hits that didn’t happen. My thinking was, as far as it went, than rather than put a lot of if() tests, send the whole 4 lines to the LCD and then compute and overwrite with blanks those spaces and lines that hold no (good) info. I’d appreciate any thoughts re this … or a pointer to what you did (as it appears I’m going blind as well as deaf). :mrgreen:
And I expected that at this time. So now we can clean up the display as I mentioned above ... or see what DirtyD can suggest. Give the version above a try and see what happens. It's only software. :doh:sspbass:
The hit and times are correct for every hit registered now. The hits that never happened still get fill with junk.
Two things : Now that you have a display of the rounded times, can you compare them to the whole msec times sent to the PC and see if the rounding is being done correctly ? Also I wonder why the non-hit times are “goofy” instead of zeros. The code zero’s out the whole array of hit times upon a restart so I’d have guessed the conversion would convert 00000 msec into 00.00 sec and that would be displayed or the leading zeros blanked and .00 displayed.
Lastly I think the displays should be properly justified so the numbers all line up neatly (another ugliness I know would happen) but that might wait a bit until we get the next step working.
I’m not sure were the junk is coming from. Assuming the A_Times array is cleared properly it should be returning zeros for the hits not made. I checked the TimeConvert function last night sending it zero and it returned “0.00”. Do you get junk in all the times after the correct ones?
Insert this at the end of case 4 (right before the break) and see if it returns the same thing as the display.
Serial.println("tmp2 = " + tmp2);
Serial.println("Time 20 = " + A_Times[19]);
Mee_n_Mac:
DirtyD:
This should fix hit 15 from displaying wrong. Looks like there were a few variable declarations that weren’t used (Both in case = 3 and 4). Scratch that they were used to hold the return value from the TimerConvert function but didn’t get used when concatenating the strings for the display.I see that the tmp3 and tmp4 are gone (and shouldn’t be missed !) but I’m not seeing what you did you prevent display of hits that didn’t happen. My thinking was, as far as it went, than rather than put a lot of if() tests, send the whole 4 lines to the LCD and then compute and overwrite with blanks those spaces and lines that hold no (good) info. I’d appreciate any thoughts re this … or a pointer to what you did (as it appears I’m going blind as well as deaf). :mrgreen:
I didn’t do anything to fix the issue with the bad data being displayed. The thought of a bunch of if() statements crossed my mind but it would get really congested. As I posted last I think it should work fine just returning 0.00 for any hits not registered.
DirtyD:
This should fix hit 15 from displaying wrong. Looks like there were a few variable declarations that weren’t used (Both in case = 3 and 4). Scratch that they were used to hold the return value from the TimerConvert function but didn’t get used when concatenating the strings for the display.
Nevermind my last question. I see where the hit 15 code was fixed to remove the tmp3. So case 3 and 4 now resemble case 2, just as they should. And just as hits 1-8 display properly, hits >8 should as well.
@sspbass - give that cleaned up FormatData() a try. It should work the same as you just saw … but it pays to test !
Here’s the code that clears the arrays.
void ClearData()
{
A_count = 0;
B_count = 0;
for (int i=0; i < MaxHits ; i++)
{
A_Times[i] = 0;
B_Times[i] = 0;
A_splits[i] = 0;
B_splits[i] = 0;
AB_splits[i] = 0;
}
A_Hit_Factor = 0;
B_Hit_Factor = 0;
}
Looks OK to me … but then again it should. :mrgreen:
DirtyD:
I’m not sure were the junk is coming from. Assuming the A_Times array is cleared properly it should be returning zeros for the hits not made. I checked the TimeConvert function last night sending it zero and it returned “0.00”. Do you get junk in all the times after the correct ones?Insert this at the end of case 4 (right before the break) and see if it returns the same thing as the display.
Serial.println("tmp2 = " + tmp2);
Serial.println("Time 20 = " + A_Times[19]);
Here is what i ran.
void FormatData()
{
// routine to format lines of data to be sent to LCD
// presently assume 4 lines of 20 characters
// switch formatting done based on display state
switch (DisplayState)
{
case 1:{
//this is for single A shooter mode
// display number of hits so far
String tmp = "A: # hits = ";
Line1 = tmp + A_count;
// now display the time of last hit in secs out to hundreths of secs
String tmp2 = TimeConvert(A_Times[A_count-1]); // convert hit time to XX.xx format
Line2 = "Hit time= " + tmp2 + " secs";
Line3 = " ";
Line4 = " ";
break;}
case 2:{
// this is A review mode hits 1-8
String tmp = TimeConvert(A_Times[0]); // convert hit time to XX.xx format
String tmp2 = TimeConvert(A_Times[4]); // convert hit time to XX.xx format
Line1 = "A 1:" + tmp + "s 5:" + tmp2 + "s";
tmp = TimeConvert(A_Times[1]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[5]); // convert hit time to XX.xx format
Line2 = "A 2:" + tmp + "s 6:" + tmp2 + "s";
tmp = TimeConvert(A_Times[2]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[6]); // convert hit time to XX.xx format
Line3 = "A 3:" + tmp + "s 7:" + tmp2 + "s";
tmp = TimeConvert(A_Times[3]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[7]); // convert hit time to XX.xx format
Line4 = "A 4:" + tmp + "s 8:" + tmp2 + "s";
break;}
case 3:{
// this is A review mode hits 9-16
String tmp = TimeConvert(A_Times[8]); // convert hit time to XX.xx format
String tmp2 = TimeConvert(A_Times[12]); // convert hit time to XX.xx format
Line1 = "A 9:" + tmp + "s 13:" + tmp2 + "s";
tmp = TimeConvert(A_Times[9]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[13]); // convert hit time to XX.xx format
Line2 = "A 10:" + tmp + "s14:" + tmp2 + "s";
tmp = TimeConvert(A_Times[10]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[14]); // convert hit time to XX.xx format
Line3 = "A 11:" + tmp + "s15:" + tmp2 + "s";
tmp = TimeConvert(A_Times[11]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[15]); // convert hit time to XX.xx format
Line4 = "A 12:" + tmp + "s16:" + tmp2 + "s";
break;}
case 4:{
// this is A review mode hits 17-20
String tmp = TimeConvert(A_Times[16]); // convert hit time to XX.xx format
String tmp2 = TimeConvert(A_Times[18]); // convert hit time to XX.xx format
Line1 = "A 17:" + tmp + "s19:" + tmp2 + "s";
tmp = TimeConvert(A_Times[17]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[19]); // convert hit time to XX.xx format
Line2 = "A 18:" + tmp + "s20:" + tmp2 + "s";
Line3 = " ";
Line4 = " ";
//debug code
Serial.println("tmp2 = " + tmp2);
Serial.println("Time 20 = " + A_Times[19]);
break;}
default:
// do the default = 0
// 4 string objects
Line1 = " Shot Timer v1 ";
Line2 = " is running ";
Line3 = " Countdown to start ";
Line4 = " in progress ";
}
}
The “junk” was still in the unused hits on the LCD. Here is what the serial monitor had.
I’m a noob so this could be retarded but… could a statement be written in the format loop where any location in the array above the number of hits up to 20 was set to N/A or something like that?
Give these 2 debug routines a try.
void FormatData()
{
// routine to format lines of data to be sent to LCD
// presently assume 4 lines of 20 characters
// switch formatting done based on display state
switch (DisplayState)
{
case 1:{
//this is for single A shooter mode
// display number of hits so far
String tmp = "A: # hits = ";
Line1 = tmp + A_count;
// now display the time of last hit in secs out to hundreths of secs
String tmp2 = TimeConvert(A_Times[A_count-1]); // convert hit time to XX.xx format
Line2 = "Hit time= " + tmp2 + " secs";
Line3 = " ";
Line4 = " ";
break;}
case 2:{
// this is A review mode hits 1-8
String tmp = TimeConvert(A_Times[0]); // convert hit time to XX.xx format
String tmp2 = TimeConvert(A_Times[4]); // convert hit time to XX.xx format
// right justify the display
if(tmp.length() < 4)
{
tmp = " " + tmp;
}
// right justify the display
if(tmp2.length() < 4)
{
tmp2 = " " + tmp;
}
Line1 = "A 1:" + tmp + "s 5:" + tmp2 + "s";
tmp = TimeConvert(A_Times[1]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[5]); // convert hit time to XX.xx format
Line2 = "A 2:" + tmp + "s 6:" + tmp2 + "s";
tmp = TimeConvert(A_Times[2]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[6]); // convert hit time to XX.xx format
Line3 = "A 3:" + tmp + "s 7:" + tmp2 + "s";
tmp = TimeConvert(A_Times[3]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[7]); // convert hit time to XX.xx format
Line4 = "A 4:" + tmp + "s 8:" + tmp2 + "s";
break;}
case 3:{
// this is A review mode hits 9-16
String tmp = TimeConvert(A_Times[8]); // convert hit time to XX.xx format
String tmp2 = TimeConvert(A_Times[12]); // convert hit time to XX.xx format
Line1 = "A 9:" + tmp + "s 13:" + tmp2 + "s";
tmp = TimeConvert(A_Times[9]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[13]); // convert hit time to XX.xx format
Line2 = "A 10:" + tmp + "s14:" + tmp2 + "s";
tmp = TimeConvert(A_Times[10]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[14]); // convert hit time to XX.xx format
Line3 = "A 11:" + tmp + "s15:" + tmp2 + "s";
tmp = TimeConvert(A_Times[11]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[15]); // convert hit time to XX.xx format
Line4 = "A 12:" + tmp + "s16:" + tmp2 + "s";
break;}
case 4:{
// this is A review mode hits 17-20
String tmp = TimeConvert(A_Times[16]); // convert hit time to XX.xx format
String tmp2 = TimeConvert(A_Times[18]); // convert hit time to XX.xx format
Line1 = "A 17:" + tmp + "s19:" + tmp2 + "s";
tmp = TimeConvert(A_Times[17]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[19]); // convert hit time to XX.xx format
Line2 = "A 18:" + tmp + "s20:" + tmp2 + "s";
Line3 = " ";
Line4 = " ";
break;}
default:
// do the default = 0
// 4 string objects
Line1 = " Shot Timer v1 ";
Line2 = " is running ";
Line3 = " Countdown to start ";
Line4 = " in progress ";
}
}
void SendTimes()
// temp routine to send data to serial monitor
{
Serial.println("Timer is stopped");
Serial.println("Here are the times for Shooter A");
Serial.print("Number of hits : ");
Serial.print("\t");
Serial.println(A_count);
Serial.println("A Hit and split times are : ");
int i = 0;
int k = 0;
for (i=0; i < MaxHits ; i++)
{
k = i + 1;
//Serial.print(A_count[k]);
Serial.print("\t");
Serial.print(A_Times[i]);
Serial.print("\t");
Serial.println(A_splits[i]);
}
Serial.println("Here are the times for Shooter B");
Serial.print("Number of hits : ");
Serial.print("\t");
Serial.println(B_count);
Serial.println("B Hit and split times are : ");
for (i=0; i < B_count ; i++)
{
k = i + 1;
//Serial.print(B_count[k]);
Serial.print("\t");
Serial.print(B_Times[i]);
Serial.print("\t");
Serial.println(B_splits[i]);
}
}
I added some “justify” code to Line1 only and made the PC printout go to the Maxhits number so we can verify that the hits are being cleared.
sspbass:
I’m a noob so this could be retarded but… could a statement be written in the format loop where any location in the array above the number of hits up to 20 was set to N/A or something like that?
Actually that gives me an idea … if we can get the zero’s to work. Then the convert routine could test for zeros and output blanks instead of 0.00. The output would get put into the Line automagically and we’d have a pretty result, done easily ! There’s no time in real life where a real hit time will = 0.
I see what you did to properly align the lines. It worked for line 1 on the first screen but not on line 2 of the first screen.
ETA: after a re-read I see that you did that on purpose.
sspbass:
I’m a noob so this could be retarded but… could a statement be written in the format loop where any location in the array above the number of hits up to 20 was set to N/A or something like that?
String TimeConvert(long time)
{
// takes the time as argument and returns the time for that hit as a XX.xx string
if (time != 0) // Make sure there's a value...
{
String tmp3 = String(int((time + 5)/10)); // round msecs into csecs
int k = tmp3.length(); // k will be index to last char in padded string
int km1 = k-1; // km1 will be index to next to last char
int km2 = k-2; // km2 will be position of period
tmp3 = tmp3 + '0'; // pad the end of the truncated string with a zero
//now move chars to make space to add a period
tmp3.setCharAt(k, tmp3.charAt(km1)); // move next-2-last to last position in string
tmp3.setCharAt(km1, tmp3.charAt(km2)); // move char to next-2-last position
// now insert period
tmp3.setCharAt(km2, '.');
// tmp3 now holds rounded time in secs XX.xx format
return tmp3;
}
else
{
String tmp3 = "N/A"; // If the time variable is zero pass N/A back as a string...
return tmp3;
}
}
I think this should be a little cleaner in the TimeConvert function… Though I might change “N/A” back to “0.00”, just because you might want to use this function later for something a little different and expecting a “N/A” might not be acceptable.
It works, oddly enough though it displays N/As instead of just N/A
sspbass:
It works, oddly enough though it displays N/As instead of just N/A
That’s because the “s” is part of the LineX code. The right justify should also be put into the convert function, now that I know it works. So the convert function will always return a 5 digit result, those digits being some combo of blanks and real hit times.
sspbass:
It works, oddly enough though it displays N/As instead of just N/A
Haha yea I bet it does!
String TimeConvert(long time)
{
// takes the time as argument and returns the time for that hit as a XX.xx string
if (time != 0) // Make sure there's a value...
{
String tmp3 = String(int((time + 5)/10)); // round msecs into csecs
int k = tmp3.length(); // k will be index to last char in padded string
int km1 = k-1; // km1 will be index to next to last char
int km2 = k-2; // km2 will be position of period
tmp3 = tmp3 + '0'; // pad the end of the truncated string with a zero
//now move chars to make space to add a period
tmp3.setCharAt(k, tmp3.charAt(km1)); // move next-2-last to last position in string
tmp3.setCharAt(km1, tmp3.charAt(km2)); // move char to next-2-last position
// now insert period
tmp3.setCharAt(km2, '.');
// tmp3 now holds rounded time in secs XX.xx format
return tmp3;
}
else
{
String tmp3 = "0.00"; // If the time variable is zero pass 0.00 back as a string...
return tmp3;
}
}
Use this one… Filling it in with zeros is probably better for now. :lol:
Almost!
In all honesty though it would probably be best to have nothing in the unused spots. It would be easier to read.
Ha !! Try this one. Blanks beats zeros … I hope !
String TimeConvert(long time)
{
// takes the time as argument and returns the time for that hit as a XX.xx string
if (time != 0) // Make sure there's a value...
{
String tmp3 = String(int((time + 5)/10)); // round msecs into csecs
int k = tmp3.length(); // k will be index to last char in padded string
int km1 = k-1; // km1 will be index to next to last char
int km2 = k-2; // km2 will be position of period
tmp3 = tmp3 + '0'; // pad the end of the truncated string with a zero
//now move chars to make space to add a period
tmp3.setCharAt(k, tmp3.charAt(km1)); // move next-2-last to last position in string
tmp3.setCharAt(km1, tmp3.charAt(km2)); // move char to next-2-last position
// now insert period
tmp3.setCharAt(km2, '.');
// add a blank or 2 as needed to get 5 digits with time right justified
if(tmp3.length() < 4)
{
tmp3 = " " + tmp;
}
if(tmp3.length() < 4)
{
tmp3 = " " + tmp;
}
// tmp3 now holds rounded time in secs XX.xx format
return tmp3;
}
else
{
String tmp3 = " "; // If the time variable is zero pass 5 blanks back as a string...
return tmp3;
}
}
And restore the FormatData() to this …
void FormatData()
{
// routine to format lines of data to be sent to LCD
// presently assume 4 lines of 20 characters
// switch formatting done based on display state
switch (DisplayState)
{
case 1:{
//this is for single A shooter mode
// display number of hits so far
String tmp = "A: # hits = ";
Line1 = tmp + A_count;
// now display the time of last hit in secs out to hundreths of secs
String tmp2 = TimeConvert(A_Times[A_count-1]); // convert hit time to XX.xx format
Line2 = "Hit time= " + tmp2 + " secs";
String tmp2 = TimeConvert(A_splits[A_count-1]); // convert split time
Line3 = "Split time= " + tmp2 + " s";
Line4 = " ";
break;}
case 2:{
// this is A review mode hits 1-8
String tmp = TimeConvert(A_Times[0]); // convert hit time to XX.xx format
String tmp2 = TimeConvert(A_Times[4]); // convert hit time to XX.xx format
Line1 = "A 1:" + tmp + "s 5:" + tmp2 + "s";
tmp = TimeConvert(A_Times[1]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[5]); // convert hit time to XX.xx format
Line2 = "A 2:" + tmp + "s 6:" + tmp2 + "s";
tmp = TimeConvert(A_Times[2]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[6]); // convert hit time to XX.xx format
Line3 = "A 3:" + tmp + "s 7:" + tmp2 + "s";
tmp = TimeConvert(A_Times[3]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[7]); // convert hit time to XX.xx format
Line4 = "A 4:" + tmp + "s 8:" + tmp2 + "s";
break;}
case 3:{
// this is A review mode hits 9-16
String tmp = TimeConvert(A_Times[8]); // convert hit time to XX.xx format
String tmp2 = TimeConvert(A_Times[12]); // convert hit time to XX.xx format
Line1 = "A 9:" + tmp + "s 13:" + tmp2 + "s";
tmp = TimeConvert(A_Times[9]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[13]); // convert hit time to XX.xx format
Line2 = "A 10:" + tmp + "s14:" + tmp2 + "s";
tmp = TimeConvert(A_Times[10]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[14]); // convert hit time to XX.xx format
Line3 = "A 11:" + tmp + "s15:" + tmp2 + "s";
tmp = TimeConvert(A_Times[11]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[15]); // convert hit time to XX.xx format
Line4 = "A 12:" + tmp + "s16:" + tmp2 + "s";
break;}
case 4:{
// this is A review mode hits 17-20
String tmp = TimeConvert(A_Times[16]); // convert hit time to XX.xx format
String tmp2 = TimeConvert(A_Times[18]); // convert hit time to XX.xx format
Line1 = "A 17:" + tmp + "s19:" + tmp2 + "s";
tmp = TimeConvert(A_Times[17]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[19]); // convert hit time to XX.xx format
Line2 = "A 18:" + tmp + "s20:" + tmp2 + "s";
Line3 = " ";
Line4 = " ";
break;}
default:
// do the default = 0
// 4 string objects
Line1 = " Shot Timer v1 ";
Line2 = " is running ";
Line3 = " Shooter: ";
Line4 = " STANDBY ";
}
}
sspbass:
Almost!
Hmmmm ???
Mee_n_Mac:
Ha !! Try this one. Blanks beats zeros … I hope !String TimeConvert(long time)
{
// takes the time as argument and returns the time for that hit as a XX.xx string
if (time != 0) // Make sure there's a value...
{
String tmp3 = String(int((time + 5)/10)); // round msecs into csecs
int k = tmp3.length(); // k will be index to last char in padded string
int km1 = k-1; // km1 will be index to next to last char
int km2 = k-2; // km2 will be position of period
tmp3 = tmp3 + '0'; // pad the end of the truncated string with a zero
//now move chars to make space to add a period
tmp3.setCharAt(k, tmp3.charAt(km1)); // move next-2-last to last position in string
tmp3.setCharAt(km1, tmp3.charAt(km2)); // move char to next-2-last position
// now insert period
tmp3.setCharAt(km2, '.');
// add a blank or 2 as needed to get 5 digits with time right justified
if(tmp3.length() < 4)
{
tmp3 = " " + tmp;
}
if(tmp3.length() < 4)
{
tmp3 = " " + tmp;
}
// tmp3 now holds rounded time in secs XX.xx format
return tmp3;
}
else
{
String tmp3 = " "; // If the time variable is zero pass 5 blanks back as a string...
return tmp3;
}
}
And restore the FormatData() to this ...
void FormatData()
{
// routine to format lines of data to be sent to LCD
// presently assume 4 lines of 20 characters
// switch formatting done based on display state
switch (DisplayState)
{
case 1:{
//this is for single A shooter mode
// display number of hits so far
String tmp = "A: # hits = ";
Line1 = tmp + A_count;
// now display the time of last hit in secs out to hundreths of secs
String tmp2 = TimeConvert(A_Times[A_count-1]); // convert hit time to XX.xx format
Line2 = “Hit time= " + tmp2 + " secs”;
String tmp2 = TimeConvert(A_splits[A_count-1]); // convert split time
Line3 = “Split time= " + tmp2 + " s”;
Line4 = " ";
break;}
case 2:{
// this is A review mode hits 1-8
String tmp = TimeConvert(A_Times[0]); // convert hit time to XX.xx format
String tmp2 = TimeConvert(A_Times[4]); // convert hit time to XX.xx format
Line1 = “A 1:” + tmp + “s 5:” + tmp2 + “s”;
tmp = TimeConvert(A_Times[1]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[5]); // convert hit time to XX.xx format
Line2 = “A 2:” + tmp + “s 6:” + tmp2 + “s”;
tmp = TimeConvert(A_Times[2]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[6]); // convert hit time to XX.xx format
Line3 = “A 3:” + tmp + “s 7:” + tmp2 + “s”;
tmp = TimeConvert(A_Times[3]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[7]); // convert hit time to XX.xx format
Line4 = “A 4:” + tmp + “s 8:” + tmp2 + “s”;
break;}
case 3:{
// this is A review mode hits 9-16
String tmp = TimeConvert(A_Times[8]); // convert hit time to XX.xx format
String tmp2 = TimeConvert(A_Times[12]); // convert hit time to XX.xx format
Line1 = “A 9:” + tmp + “s 13:” + tmp2 + “s”;
tmp = TimeConvert(A_Times[9]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[13]); // convert hit time to XX.xx format
Line2 = “A 10:” + tmp + “s14:” + tmp2 + “s”;
tmp = TimeConvert(A_Times[10]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[14]); // convert hit time to XX.xx format
Line3 = “A 11:” + tmp + “s15:” + tmp2 + “s”;
tmp = TimeConvert(A_Times[11]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[15]); // convert hit time to XX.xx format
Line4 = “A 12:” + tmp + “s16:” + tmp2 + “s”;
break;}
case 4:{
// this is A review mode hits 17-20
String tmp = TimeConvert(A_Times[16]); // convert hit time to XX.xx format
String tmp2 = TimeConvert(A_Times[18]); // convert hit time to XX.xx format
Line1 = “A 17:” + tmp + “s19:” + tmp2 + “s”;
tmp = TimeConvert(A_Times[17]); // convert hit time to XX.xx format
tmp2 = TimeConvert(A_Times[19]); // convert hit time to XX.xx format
Line2 = “A 18:” + tmp + “s20:” + tmp2 + “s”;
Line3 = " ";
Line4 = " ";
break;}
default:
// do the default = 0
// 4 string objects
Line1 = " Shot Timer v1 ";
Line2 = " is running ";
Line3 = " Shooter: ";
Line4 = " STANDBY ";
}
}
Now it’s giving me this again.