aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-07-18 22:26:38 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-07-19 10:13:51 -0700
commit7e11a3537102697604dbb971a0f3800b25db5ffe (patch)
treebbe09e35746d217b062d941bd963b783dd3c2713 /core
parent48c2929f480b74f50d97ea6790161e2a5446929d (diff)
downloadsubsurface-7e11a3537102697604dbb971a0f3800b25db5ffe.tar.gz
core: add a special NO_SENSOR value for sample::sensor
The sensor member of sample refers to a cylinder from which the pressure was read. However, some dives don't even have a cylinder. Therefore, introduce a special NO_SENSOR value for these dives. Since the cylinder is given as a uint8_t, 0xff seems to be a sensible choice. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r--core/dive.c5
-rw-r--r--core/profile.c4
-rw-r--r--core/sample.h4
3 files changed, 8 insertions, 5 deletions
diff --git a/core/dive.c b/core/dive.c
index 351476bb8..36b1376fa 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -1657,9 +1657,10 @@ static void sample_renumber(struct sample *s, int i, const int mapping[])
int j;
for (j = 0; j < MAX_SENSORS; j++) {
- int sensor;
+ int sensor = -1;
- sensor = mapping[s->sensor[j]];
+ if (s->sensor[j] != NO_SENSOR)
+ sensor = mapping[s->sensor[j]];
if (sensor == -1) {
// Remove sensor and gas pressure info
if (i == 0) {
diff --git a/core/profile.c b/core/profile.c
index d20d068e3..2db4c54c3 100644
--- a/core/profile.c
+++ b/core/profile.c
@@ -566,9 +566,9 @@ static void populate_plot_entries(const struct dive *dive, const struct divecomp
} else {
entry->pressures.o2 = sample->setpoint.mbar / 1000.0;
}
- if (sample->pressure[0].mbar)
+ if (sample->pressure[0].mbar && sample->sensor[0] != NO_SENSOR)
set_plot_pressure_data(pi, idx, SENSOR_PR, sample->sensor[0], sample->pressure[0].mbar);
- if (sample->pressure[1].mbar)
+ if (sample->pressure[1].mbar && sample->sensor[1] != NO_SENSOR)
set_plot_pressure_data(pi, idx, SENSOR_PR, sample->sensor[1], sample->pressure[1].mbar);
if (sample->temperature.mkelvin)
entry->temperature = lasttemp = sample->temperature.mkelvin;
diff --git a/core/sample.h b/core/sample.h
index 75c7bb1b4..1732b4d02 100644
--- a/core/sample.h
+++ b/core/sample.h
@@ -9,6 +9,8 @@ extern "C" {
#endif
#define MAX_SENSORS 2
+#define NO_SENSOR ((uint8_t)-1)
+
struct sample // BASE TYPE BYTES UNITS RANGE DESCRIPTION
{ // --------- ----- ----- ----- -----------
duration_t time; // int32_t 4 seconds (0-34 yrs) elapsed dive time up to this sample
@@ -23,7 +25,7 @@ struct sample // BASE TYPE BYTES UNITS RANGE
o2pressure_t setpoint; // uint16_t 2 mbar (0-65 bar) O2 partial pressure (will be setpoint)
o2pressure_t o2sensor[3]; // uint16_t 6 mbar (0-65 bar) Up to 3 PO2 sensor values (rebreather)
bearing_t bearing; // int16_t 2 degrees (-1 no val, 0-360 deg) compass bearing
- uint8_t sensor[MAX_SENSORS]; // uint8_t 1 sensorID (0-255) ID of cylinder pressure sensor
+ uint8_t sensor[MAX_SENSORS]; // uint8_t 1 sensorID (0-254) ID of cylinder pressure sensor
uint16_t cns; // uint16_t 1 % (0-64k %) cns% accumulated
uint8_t heartbeat; // uint8_t 1 beats/m (0-255) heart rate measurement
volume_t sac; // 4 ml/min predefined SAC