From: Linus Torvalds Date: Thu, 10 Nov 2011 00:23:59 +0000 (-0500) Subject: Merge branch 'bugfixes' of git://github.com/dirkhh/subsurface X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=34d79509617685c0df39abf0775f7065ec52e8e8;hp=-c;p=ext%2Fsubsurface.git Merge branch 'bugfixes' of git://github.com/dirkhh/subsurface * 'bugfixes' of git://github.com/dirkhh/subsurface: Fix breakage caused by Linus' changes to tank pressure handling --- 34d79509617685c0df39abf0775f7065ec52e8e8 diff --combined profile.c index f1f3761,7fc7850..32a47f9 --- a/profile.c +++ b/profile.c @@@ -513,7 -513,7 +513,7 @@@ static void plot_single_temp_text(struc { 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 -523,7 +523,7 @@@ 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,23 -537,14 +537,23 @@@ 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); } @@@ -657,6 -648,8 +657,8 @@@ static void plot_pressure_value(struct plot_text(gc, &tro, sec, mbar, "%d %s", pressure, unit); } + #define GET_PRESSURE(_entry) (SENSOR_PRESSURE(_entry) ? : INTERPOLATED_PRESSURE(_entry)) + static void plot_cylinder_pressure_text(struct graphics_context *gc, struct plot_info *pi) { int i; @@@ -671,14 -664,19 +673,19 @@@ /* only loop over the actual events from the dive computer * plus the second synthetic event at the start (to make sure - * we get "time=0" right) */ + * we get "time=0" right) + * sadly with a recent change that first entry may no longer + * have any pressure reading - in that case just grab the + * pressure from the second entry */ + if (GET_PRESSURE(pi->entry + 1) == 0 && GET_PRESSURE(pi->entry + 2) !=0) + INTERPOLATED_PRESSURE(pi->entry + 1) = GET_PRESSURE(pi->entry + 2); for (i = 1; i < pi->nr; i++) { entry = pi->entry + i; if (!entry->same_cylinder) { cyl = entry->cylinderindex; if (!seen_cyl[cyl]) { - mbar = SENSOR_PRESSURE(entry) ? : INTERPOLATED_PRESSURE(entry); + mbar = GET_PRESSURE(entry); plot_pressure_value(gc, mbar, entry->sec, LEFT, BOTTOM); seen_cyl[cyl] = TRUE; } @@@ -686,14 -684,13 +693,13 @@@ /* remember the last pressure and time of * the previous cylinder */ cyl = (entry - 1)->cylinderindex; - last_pressure[cyl] = - SENSOR_PRESSURE(entry - 1) ? : INTERPOLATED_PRESSURE(entry - 1); + last_pressure[cyl] = GET_PRESSURE(entry - 1); last_time[cyl] = (entry - 1)->sec; } } } cyl = entry->cylinderindex; - last_pressure[cyl] = SENSOR_PRESSURE(entry) ? : INTERPOLATED_PRESSURE(entry); + last_pressure[cyl] = GET_PRESSURE(entry); last_time[cyl] = entry->sec; for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) { @@@ -780,7 -777,7 +786,7 @@@ static struct plot_info *analyze_plot_i /* Do pressure min/max based on the non-surface data */ for (i = 0; i < nr; i++) { struct plot_data *entry = pi->entry+i; - int pressure = SENSOR_PRESSURE(entry) ? : INTERPOLATED_PRESSURE(entry); + int pressure = GET_PRESSURE(entry); int temperature = entry->temperature; if (pressure) { @@@ -1167,10 -1164,17 +1173,17 @@@ static struct plot_info *create_plot_in pr_track->end = pr; } } - /* Fill in the last two entries with empty values but valid times */ + /* Fill in the last two entries with empty values but valid times + * without creating a false cylinder change event */ i = nr + 2; pi->entry[i].sec = sec + 20; + pi->entry[i].same_cylinder = 1; + pi->entry[i].cylinderindex = pi->entry[i-1].cylinderindex; + INTERPOLATED_PRESSURE(pi->entry + i) = GET_PRESSURE(pi->entry + i - 1); pi->entry[i+1].sec = sec + 40; + pi->entry[i+1].same_cylinder = 1; + pi->entry[i+1].cylinderindex = pi->entry[i-1].cylinderindex; + INTERPOLATED_PRESSURE(pi->entry + i + 1) = GET_PRESSURE(pi->entry + i - 1); /* the number of actual entries - some computers have lots of * depth 0 samples at the end of a dive, we want to make sure * we have exactly one of them at the end */