View Single Post
Old 11-11-2009, 09:58 AM   #25 (permalink)
mluckham
EcoModding Lurker
 
Join Date: Feb 2009
Location: Ontario, Canada
Posts: 35
Thanks: 2
Thanked 14 Times in 7 Posts
Thanks very much, I'll test it. I made an additional change, to save the calculated values:

Quote:
// set values for math-less calibration method
unsigned long tmptankdistance = tank.distance(); // take a snapshot, in case update occurs during the updates
unsigned long tmptankfuel = tank.fuel();
int tmpdirty = 0;

parms[calibrationDistanceIdx] = tmptankdistance; // distance x 1000, for updating parms[vssPulsesPerDistanceUnitIdx]
parms[calibrationFuelIdx] = tmptankfuel; // fuel x 1000, for updating parms[microSecondsPerFuelUnitIdx]

initGuino(); // edit parms[] array

// math-less calibration method:
// if user has altered distance or fuel values to be different from tank, recalculate VSS and INJECTOR parameters
if (parms[calibrationDistanceIdx] != tmptankdistance)
{
parms[vssPulsesPerDistanceUnitIdx] = recalculate(parms[vssPulsesPerDistanceUnitIdx], tmptankdistance, parms[calibrationDistanceIdx]);
tmpdirty = 1;
}

if (parms[calibrationFuelIdx] != tmptankfuel)
{
parms[microSecondsPerFuelUnitIdx] = recalculate(parms[microSecondsPerFuelUnitIdx], tmptankfuel, parms[calibrationFuelIdx]);
tmpdirty = 1;
}

if (tmpdirty)
save(); // save recalculated settings

Last edited by mluckham; 11-11-2009 at 10:16 AM.. Reason: added code snippet
  Reply With Quote