mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
Print the end temperature of the dive
Currently we print the temperature every five minutes. Especially with dive computers that keep rather frequent temperature samples that means that we have one more interesting data point that we don't label: the surface temperature at the end of the dive. This patch adds some logic to try to print the last temperature sample that was recorded before the dive ended - unless that same value has already been printed (to avoid silly duplications on dive computers with less frequent sampling) Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
b49c878a74
commit
efb1fa44b8
1 changed files with 27 additions and 12 deletions
39
profile.c
39
profile.c
|
@ -328,35 +328,50 @@ static int setup_temperature_limits(struct dive *dive, struct graphics_context *
|
||||||
return maxtemp > mintemp;
|
return maxtemp > mintemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void plot_single_temp_text(struct graphics_context *gc, int sec, temperature_t temperature)
|
||||||
|
{
|
||||||
|
int deg;
|
||||||
|
const char *unit;
|
||||||
|
static const text_render_options_t tro = {12, 0.2, 0.2, 1.0, LEFT, TOP};
|
||||||
|
|
||||||
|
if (output_units.temperature == FAHRENHEIT) {
|
||||||
|
deg = to_F(temperature);
|
||||||
|
unit = "F";
|
||||||
|
} else {
|
||||||
|
deg = to_C(temperature);
|
||||||
|
unit = "C";
|
||||||
|
}
|
||||||
|
plot_text(gc, &tro, sec, temperature.mkelvin, "%d %s", deg, unit);
|
||||||
|
}
|
||||||
|
|
||||||
static void plot_temperature_text(struct dive *dive, struct graphics_context *gc)
|
static void plot_temperature_text(struct dive *dive, struct graphics_context *gc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
static const text_render_options_t tro = {12, 0.2, 0.2, 1.0, LEFT, TOP};
|
|
||||||
|
|
||||||
int last = 0;
|
int last = 0;
|
||||||
|
temperature_t last_temperature, last_printed_temp;
|
||||||
|
|
||||||
if (!setup_temperature_limits(dive, gc))
|
if (!setup_temperature_limits(dive, gc))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < dive->samples; i++) {
|
for (i = 0; i < dive->samples; i++) {
|
||||||
const char *unit;
|
|
||||||
struct sample *sample = dive->sample+i;
|
struct sample *sample = dive->sample+i;
|
||||||
|
if (sample->time.seconds > dive->duration.seconds)
|
||||||
|
break; /* let's not plot surface temp events */
|
||||||
int mkelvin = sample->temperature.mkelvin;
|
int mkelvin = sample->temperature.mkelvin;
|
||||||
int sec, deg;
|
int sec;
|
||||||
if (!mkelvin)
|
if (!mkelvin)
|
||||||
continue;
|
continue;
|
||||||
|
last_temperature = sample->temperature;
|
||||||
sec = sample->time.seconds;
|
sec = sample->time.seconds;
|
||||||
if (sec < last)
|
if (sec < last)
|
||||||
continue;
|
continue;
|
||||||
last = sec + 300;
|
last = sec + 300;
|
||||||
if (output_units.temperature == FAHRENHEIT) {
|
plot_single_temp_text(gc,sec,sample->temperature);
|
||||||
deg = to_F(sample->temperature);
|
last_printed_temp = last_temperature ;
|
||||||
unit = "F";
|
}
|
||||||
} else {
|
/* it would be nice to print the end temperature, if it's different */
|
||||||
deg = to_C(sample->temperature);
|
if (last_temperature.mkelvin != last_printed_temp.mkelvin) {
|
||||||
unit = "C";
|
plot_single_temp_text(gc,dive->duration.seconds,last_temperature);
|
||||||
}
|
|
||||||
plot_text(gc, &tro, sec, mkelvin, "%d %s", deg, unit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue