Skip to content

Commit 38fffb1

Browse files
jefdriesenmikeller
authored andcommitted
Ignore zero pressure values
Occasionally there are a few samples with a zero pressure value at the begin and/or the end of a dive. Those values result in an incorrect begin/end pressure. Fixed by ignoring the zero pressure values.
1 parent fd11873 commit 38fffb1

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

src/shearwater_predator_parser.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -591,14 +591,15 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
591591
if (pressure < 0xFFF0) {
592592
unsigned int battery = 1u << (pressure >> 12);
593593
pressure &= 0x0FFF;
594-
if (!tank[id].active) {
595-
tank[id].active = 1;
596-
tank[id].beginpressure = pressure;
594+
if (pressure) {
595+
if (!tank[id].active) {
596+
tank[id].active = 1;
597+
tank[id].beginpressure = pressure;
598+
tank[id].endpressure = pressure;
599+
}
597600
tank[id].endpressure = pressure;
598601
tank[id].battery = 0;
599602
}
600-
tank[id].endpressure = pressure;
601-
tank[id].battery |= battery;
602603
}
603604
}
604605
}
@@ -610,12 +611,14 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
610611
unsigned int id = 2 + i;
611612
if (pressure < 0xFFF0) {
612613
pressure &= 0x0FFF;
613-
if (!tank[id].active) {
614-
tank[id].active = 1;
615-
tank[id].beginpressure = pressure;
614+
if (pressure) {
615+
if (!tank[id].active) {
616+
tank[id].active = 1;
617+
tank[id].beginpressure = pressure;
618+
tank[id].endpressure = pressure;
619+
}
616620
tank[id].endpressure = pressure;
617621
}
618-
tank[id].endpressure = pressure;
619622
}
620623
}
621624
}
@@ -1233,9 +1236,11 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
12331236
unsigned int id = (parser->aimode == AI_HPCCR ? 4 : 0) + i;
12341237
if (pressure < 0xFFF0) {
12351238
pressure &= 0x0FFF;
1236-
sample.pressure.tank = parser->tankidx[id];
1237-
sample.pressure.value = pressure * 2 * PSI / BAR;
1238-
if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
1239+
if (pressure) {
1240+
sample.pressure.tank = parser->tankidx[id];
1241+
sample.pressure.value = pressure * 2 * PSI / BAR;
1242+
if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
1243+
}
12391244
}
12401245
}
12411246

@@ -1259,9 +1264,11 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
12591264
unsigned int id = 2 + i;
12601265
if (pressure < 0xFFF0) {
12611266
pressure &= 0x0FFF;
1262-
sample.pressure.tank = parser->tankidx[id];
1263-
sample.pressure.value = pressure * 2 * PSI / BAR;
1264-
if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
1267+
if (pressure) {
1268+
sample.pressure.tank = parser->tankidx[id];
1269+
sample.pressure.value = pressure * 2 * PSI / BAR;
1270+
if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata);
1271+
}
12651272
}
12661273
}
12671274
}

0 commit comments

Comments
 (0)