diff options
Diffstat (limited to 'core/dive.c')
-rw-r--r-- | core/dive.c | 52 |
1 files changed, 2 insertions, 50 deletions
diff --git a/core/dive.c b/core/dive.c index ce730da28..64cf48a58 100644 --- a/core/dive.c +++ b/core/dive.c @@ -1306,17 +1306,12 @@ static void fixup_dc_cylinder_index(struct dive *dive, struct divecomputer *dc) } } -/* - * Simplify dc pressure information: - * (a) Remove redundant pressure information - * (b) Remove linearly interpolated pressure data - */ +/* Remove redundant pressure information */ static void simplify_dc_pressures(struct dive *dive, struct divecomputer *dc) { - int i, j; + int i; int lastindex = -1; int lastpressure = 0, lasto2pressure = 0; - int pressure_delta[MAX_CYLINDERS] = { INT_MAX, }; for (i = 0; i < dc->samples; i++) { struct sample *sample = dc->sample + i; @@ -1325,60 +1320,17 @@ static void simplify_dc_pressures(struct dive *dive, struct divecomputer *dc) int index; index = sample->sensor; - if (index == lastindex) { /* Remove duplicate redundant pressure information */ if (pressure == lastpressure) sample->cylinderpressure.mbar = 0; if (o2_pressure == lasto2pressure) sample->o2cylinderpressure.mbar = 0; - /* check for simply linear data in the samples - +INT_MAX means uninitialized, -INT_MAX means not linear */ - if (pressure_delta[index] != -INT_MAX && lastpressure) { - if (pressure_delta[index] == INT_MAX) { - pressure_delta[index] = abs(pressure - lastpressure); - } else { - int cur_delta = abs(pressure - lastpressure); - if (cur_delta && abs(cur_delta - pressure_delta[index]) > 150) { - /* ok the samples aren't just a linearisation - * between start and end */ - pressure_delta[index] = -INT_MAX; - } - } - } } lastindex = index; lastpressure = pressure; lasto2pressure = o2_pressure; } - - /* if all the samples for a cylinder have pressure data that - * is basically equidistant throw out the sample cylinder pressure - * information but make sure we still have a valid start and end - * pressure - * this happens when DivingLog decides to linearalize the - * pressure between beginning and end and for strange reasons - * decides to put that in the sample data as if it came from - * the dive computer; we don't want that (we'll visualize with - * constant SAC rate instead) - * WARNING WARNING - I have only seen this in single tank dives - * --- maybe I should try to create a multi tank dive and see what - * --- divinglog does there - but the code right now is only tested - * --- for the single tank case */ - for (j = 0; j < MAX_CYLINDERS; j++) { - if (abs(pressure_delta[j]) != INT_MAX) { - cylinder_t *cyl = dive->cylinder + j; - for (i = 0; i < dc->samples; i++) - if (dc->sample[i].sensor == j) - dc->sample[i].cylinderpressure.mbar = 0; - if (!cyl->start.mbar) - cyl->start.mbar = cyl->sample_start.mbar; - if (!cyl->end.mbar) - cyl->end.mbar = cyl->sample_end.mbar; - cyl->sample_start.mbar = 0; - cyl->sample_end.mbar = 0; - } - } } /* FIXME! sensor -> cylinder mapping? */ |