aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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