Profile: use pressure data functions in save_profiles_buffer

The save_profiles_buffer() function was accessing the pressure
data directly. Instead, use the already existing funcions to
make transition to dynamically allocated pressure data more
seamless.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-07-06 16:15:39 +02:00 committed by Dirk Hohndel
parent 4c9532dc51
commit 7c6a904bbf

View file

@ -31,16 +31,15 @@ static void put_video_time(struct membuffer *b, int secs)
put_format(b, "%d:%02d:%02d.000,", hours, mins, secs); put_format(b, "%d:%02d:%02d.000,", hours, mins, secs);
} }
static void put_pd(struct membuffer *b, struct plot_data *entry) static void put_pd(struct membuffer *b, const struct plot_info *pi, int idx)
{ {
if (!entry) const struct plot_data *entry = pi->entry + idx;
return;
put_int(b, entry->in_deco); put_int(b, entry->in_deco);
put_int(b, entry->sec); put_int(b, entry->sec);
for (int c = 0; c < MAX_CYLINDERS; c++) { for (int c = 0; c < MAX_CYLINDERS; c++) {
put_int(b, entry->pressure[c][0]); put_int(b, get_plot_sensor_pressure(pi, idx, c));
put_int(b, entry->pressure[c][1]); put_int(b, get_plot_interpolated_pressure(pi, idx, c));
} }
put_int(b, entry->temperature); put_int(b, entry->temperature);
put_int(b, entry->depth); put_int(b, entry->depth);
@ -208,7 +207,7 @@ static void save_profiles_buffer(struct membuffer *b, bool select_only)
put_format(b, "\n"); put_format(b, "\n");
for (int i = 0; i < pi.nr; i++) { for (int i = 0; i < pi.nr; i++) {
put_pd(b, &pi.entry[i]); put_pd(b, &pi, i);
put_format(b, "\n"); put_format(b, "\n");
} }
put_format(b, "\n"); put_format(b, "\n");