X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=profile.c;h=f0ae0c9311c5eba3c3bc24130c01d8b02c36eb59;hb=4891fa812f04da1f46075433d28fa0f33145e125;hp=7fc7850394f6c0312364cca5e390a5ff833375f8;hpb=0d7ad02f87ad02d3b9836c07230f2ddb3f1d3e14;p=ext%2Fsubsurface.git diff --git a/profile.c b/profile.c index 7fc7850..f0ae0c9 100644 --- a/profile.c +++ b/profile.c @@ -21,8 +21,7 @@ struct plot_info { int nr; int maxtime; int meandepth, maxdepth; - int minpressure, maxpressure; - int endpressure; /* start pressure better be max pressure */ + int maxpressure; int mintemp, maxtemp; struct plot_data { unsigned int same_cylinder:1; @@ -102,9 +101,9 @@ static void dump_pi (struct plot_info *pi) int i; printf("pi:{nr:%d maxtime:%d meandepth:%d maxdepth:%d \n" - " minpressure:%d maxpressure:%d endpressure:%d mintemp:%d maxtemp:%d\n", + " maxpressure:%d mintemp:%d maxtemp:%d\n", pi->nr, pi->maxtime, pi->meandepth, pi->maxdepth, - pi->minpressure, pi->maxpressure, pi->endpressure, pi->mintemp, pi->maxtemp); + pi->maxpressure, pi->mintemp, pi->maxtemp); for (i = 0; i < pi->nr; i++) printf(" entry[%d]:{same_cylinder:%d cylinderindex:%d sec:%d pressure:{%d,%d}\n" " temperature:%d depth:%d smoothed:%d}\n", @@ -513,7 +512,7 @@ static void plot_single_temp_text(struct graphics_context *gc, int sec, int mkel { double deg; const char *unit; - static const text_render_options_t tro = {12, 0.2, 0.2, 1.0, LEFT, TOP}; + static const text_render_options_t tro = {12, 0.6, 0.6, 1.0, LEFT, TOP}; deg = get_temp_units(mkelvin, &unit); @@ -523,7 +522,7 @@ static void plot_single_temp_text(struct graphics_context *gc, int sec, int mkel static void plot_temperature_text(struct graphics_context *gc, struct plot_info *pi) { int i; - int last = 0, sec = 0; + int last = -300, sec = 0; int last_temperature = 0, last_printed_temp = 0; if (!setup_temperature_limits(gc, pi)) @@ -537,14 +536,23 @@ static void plot_temperature_text(struct graphics_context *gc, struct plot_info continue; last_temperature = mkelvin; sec = entry->sec; - if (sec < last + 300) + /* don't print a temperature + * if it's been less than 5min and less than a 2K change OR + * if it's been less than 2min OR if the change from the + * last print is less than .4K (and therefore less than 1F */ + if (((sec < last + 300) && (abs(mkelvin - last_printed_temp) < 2000)) || + (sec < last + 120) || + (abs(mkelvin - last_printed_temp) < 400)) continue; last = sec; plot_single_temp_text(gc,sec,mkelvin); last_printed_temp = mkelvin; } - /* it would be nice to print the end temperature, if it's different */ - if (abs(last_temperature - last_printed_temp) > 500) + /* it would be nice to print the end temperature, if it's + * different or if the last temperature print has been more + * than a quarter of the dive back */ + if ((abs(last_temperature - last_printed_temp) > 500) || + ((double)last / (double)sec < 0.75)) plot_single_temp_text(gc, sec, last_temperature); } @@ -690,7 +698,8 @@ static void plot_cylinder_pressure_text(struct graphics_context *gc, struct plot } } cyl = entry->cylinderindex; - last_pressure[cyl] = GET_PRESSURE(entry); + if (GET_PRESSURE(entry)) + last_pressure[cyl] = GET_PRESSURE(entry); last_time[cyl] = entry->sec; for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) { @@ -781,8 +790,6 @@ static struct plot_info *analyze_plot_info(struct plot_info *pi) int temperature = entry->temperature; if (pressure) { - if (!pi->minpressure || pressure < pi->minpressure) - pi->minpressure = pressure; if (pressure > pi->maxpressure) pi->maxpressure = pressure; } @@ -928,6 +935,7 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi, if (!nlist) { /* just continue without calculating * interpolated values */ + INTERPOLATED_PRESSURE(entry) = cur_pr[entry->cylinderindex]; list = NULL; continue; } @@ -1183,8 +1191,15 @@ static struct plot_info *create_plot_info(struct dive *dive, int nr_samples, str pi->nr++; pi->maxtime = pi->entry[lastindex].sec; - pi->endpressure = pi->minpressure = dive->cylinder[0].end.mbar; - pi->maxpressure = dive->cylinder[0].start.mbar; + /* Analyze_plot_info() will do the sample max pressures, + * this handles the manual pressures + */ + pi->maxpressure = 0; + for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) { + unsigned int mbar = dive->cylinder[cyl].start.mbar; + if (mbar > pi->maxpressure) + pi->maxpressure = mbar; + } pi->meandepth = dive->meandepth.mm;