Quote:
Originally Posted by ac7ss
An idea for the instant speed problem. (Stolen from the space shuttle software.) Take 3 time readings (time between pulses) and average the 2 that are closest in value to each other.
If you have the following 3 values: 100 45 47, have it throw out the 100 and return a value of 46.
I have some experience in optimizing code. Would you mind if I look at the source and help save some memory?
|
Thanks, that's a great idea, I'll try it
Please optimize this if you can, it uses lots of memory
Code:
void doDisplay0_60() {
switch ( g_Mode060 ) {
// STAGE VEHCLE INTRO
case 0:
LCD::LcdCommandWrite(B00000001); // clear display, set cursor position to zero
LCD::print("STAGE VEHICLE...");
if( instantmph() < 1000ul )
g_Mode060 = 1;
g_StartTime060 = 0;
g_StopTime060 = 0;
break;
// ON YOUR MARK GET SET AND GO
case 1:
LCD::LcdCommandWrite(B00000001); // clear display, set cursor position to zero
LCD::print("..ON YOUR MARK..");
LCD::gotoXY(1,1);
LCD::print("...GET SET... ");
delay2(2000);
LCD::LcdCommandWrite(B00000001);
LCD::print(" G0! ");
delay2(3000);
// Start the Timer and compensate for the delay
g_StartTime060 = millis2() - 3000;
g_Mode060 = 2;
break;
// ITS GO TIME
case 2:
// Timer's already started
// IF NOT AT 60 mph yet, DSPLAY BIG TIMER
if( instantmph() < 60000ul )
bigNum( instantmph() ,"CUR","SPD");
// Else, move on
else {
g_Mode060 = 3;
LCD::LcdCommandWrite(B00000001);
}
break;
case 3:
// Lets stop the timer,
// But only once
if( g_StopTime060 == 0 ) {
g_StopTime060 = millis2() - 500; // reads 500 high due to processing
}
LCD::print("0 to 60 in...");
LCD::gotoXY(1,1);
LCD::print(format((g_StopTime060 - g_StartTime060)));
LCD::print(" Seconds");
g_Mode060 = 0;
delay2(5000);
break;
}
} // end doDisplay0_60