summaryrefslogtreecommitdiffstats
path: root/core/profile.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-07-05 23:29:34 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-07-18 05:50:22 -0700
commitf145b116f0a390d0ccd5440a0d5cb58d70aa5165 (patch)
treead0c3ee7792ae5a3134177ba5c4f4e236517e46c /core/profile.h
parent39ede7e9e85e92cfd5b93e32237c6899e595fcfa (diff)
downloadsubsurface-f145b116f0a390d0ccd5440a0d5cb58d70aa5165.tar.gz
Cleanup: make the plot-pressure type an enum
Sadly, this doesn't give any type safety. But at least it documents the function arguments. Make the last item in the enum as a number-of-pressure-entries sentinel. Use that to size the pressure-values array. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/profile.h')
-rw-r--r--core/profile.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/core/profile.h b/core/profile.h
index 8636be2fd..447b72ec4 100644
--- a/core/profile.h
+++ b/core/profile.h
@@ -16,17 +16,20 @@ typedef enum {
CRAZY
} velocity_t;
+enum plot_pressure {
+ SENSOR_PR = 0,
+ INTERPOLATED_PR = 1,
+ NUM_PLOT_PRESSURES = 2
+};
+
struct membuffer;
struct divecomputer;
struct plot_info;
struct plot_data {
unsigned int in_deco : 1;
int sec;
- /*
- * pressure[x][0] is sensor pressure for cylinder x
- * pressure[x][1] is interpolated pressure
- */
- int pressure[MAX_CYLINDERS][2];
+ /* One pressure item per cylinder and pressure type */
+ int pressure[MAX_CYLINDERS][NUM_PLOT_PRESSURES];
int temperature;
/* Depth info */
int depth;
@@ -95,15 +98,12 @@ int get_maxtime(struct plot_info *pi);
* partial pressure graphs */
int get_maxdepth(struct plot_info *pi);
-#define SENSOR_PR 0
-#define INTERPOLATED_PR 1
-
-static inline int get_plot_pressure_data(const struct plot_data *entry, int sensor, int idx)
+static inline int get_plot_pressure_data(const struct plot_data *entry, enum plot_pressure sensor, int idx)
{
return entry->pressure[idx][sensor];
}
-static inline void set_plot_pressure_data(struct plot_data *entry, int sensor, int idx, int value)
+static inline void set_plot_pressure_data(struct plot_data *entry, enum plot_pressure sensor, int idx, int value)
{
entry->pressure[idx][sensor] = value;
}