aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2014-10-27 18:19:54 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-10-27 09:32:44 -0700
commit5ec3d0dca03b13efbf07e898296a8aa64deacc98 (patch)
treeaaee2433e958286358edfb169162f4d89135402d /file.c
parent8b6d49092bb62fb70990b887dc8b739b22b1c9b4 (diff)
downloadsubsurface-5ec3d0dca03b13efbf07e898296a8aa64deacc98.tar.gz
Set old setpoint value, if new one is not recorded
Since the setpoint value is initialized as zero, we have to set the previous value if we do not have a current reading. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'file.c')
-rw-r--r--file.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/file.c b/file.c
index 175101575..77fca04ce 100644
--- a/file.c
+++ b/file.c
@@ -450,8 +450,8 @@ int parse_txt_file(const char *filename, const char *csv)
if (MATCH(memtxt.buffer, "MkVI_Config") == 0) {
int d, m, y;
int hh = 0, mm = 0, ss = 0;
- int prev_depth = 0, cur_sampletime = 0;
- bool has_depth = false;
+ int prev_depth = 0, cur_sampletime = 0, prev_setpoint;
+ bool has_depth = false, has_setpoint = false;
char *lineptr;
struct dive *dive;
@@ -522,6 +522,7 @@ int parse_txt_file(const char *filename, const char *csv)
sscanf(lineptr, "%d,%d,%d", &cur_sampletime, &type, &value);
has_depth = false;
+ has_setpoint = false;
sample = prepare_sample(dc);
sample->time.seconds = cur_sampletime;
@@ -548,6 +549,8 @@ int parse_txt_file(const char *filename, const char *csv)
add_sample_data(sample, POSEIDON_DILUENT, value);
break;
case 20:
+ has_setpoint = true;
+ prev_setpoint = value;
add_sample_data(sample, POSEIDON_SETPOINT, value);
break;
case 39:
@@ -575,6 +578,8 @@ int parse_txt_file(const char *filename, const char *csv)
if (!has_depth)
add_sample_data(sample, POSEIDON_DEPTH, prev_depth);
+ if (!has_setpoint)
+ add_sample_data(sample, POSEIDON_SETPOINT, prev_setpoint);
finish_sample(dc);
if (!lineptr || !*lineptr)