mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Code cleanup: gaspressures.c
This patch does some cleaning up of code after the previous CCR patch that extracted the contents of gaspressures.c form profile.c 1) Inapplicable #defines were removed 2) static function types were reinstated where practically possible. 3) comments at the start of the file were expanded a bit. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
0e91352e96
commit
b1a92ccedf
3 changed files with 11 additions and 17 deletions
|
@ -9,23 +9,18 @@
|
||||||
* populate_pressure_information() -> calc_pressure_time()
|
* populate_pressure_information() -> calc_pressure_time()
|
||||||
* -> fill_missing_tank_pressures() -> fill_missing_segment_pressures()
|
* -> fill_missing_tank_pressures() -> fill_missing_segment_pressures()
|
||||||
* -> get_pr_interpolate_data()
|
* -> get_pr_interpolate_data()
|
||||||
|
*
|
||||||
|
* The pr_track_t related functions below implement a linked list that is used by
|
||||||
|
* the majority of the functions below. The linked list covers a part of the dive profile
|
||||||
|
* for which there are no cylinder pressure data. Each element in the linked list
|
||||||
|
* represents a segment between two consecutive points on the dive profile.
|
||||||
|
* pr_track_t is defined in gaspressures.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gettext.h"
|
|
||||||
#include <limits.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "dive.h"
|
#include "dive.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "divelist.h"
|
|
||||||
|
|
||||||
#include "profile.h"
|
#include "profile.h"
|
||||||
#include "gaspressures.h"
|
#include "gaspressures.h"
|
||||||
#include "deco.h"
|
|
||||||
#include "libdivecomputer/parser.h"
|
|
||||||
#include "libdivecomputer/version.h"
|
|
||||||
#include "membuffer.h"
|
|
||||||
|
|
||||||
|
|
||||||
static pr_track_t *pr_track_alloc(int start, int t_start)
|
static pr_track_t *pr_track_alloc(int start, int t_start)
|
||||||
{
|
{
|
||||||
|
@ -102,7 +97,7 @@ static void dump_pr_track(pr_track_t **track_pr)
|
||||||
* segments according to how big of a time_pressure area
|
* segments according to how big of a time_pressure area
|
||||||
* they have.
|
* they have.
|
||||||
*/
|
*/
|
||||||
void fill_missing_segment_pressures(pr_track_t *list)
|
static void fill_missing_segment_pressures(pr_track_t *list)
|
||||||
{
|
{
|
||||||
while (list) {
|
while (list) {
|
||||||
int start = list->start, end;
|
int start = list->start, end;
|
||||||
|
@ -160,7 +155,7 @@ void dump_pr_interpolate(int i, pr_interpolate_t interpolate_pr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
struct pr_interpolate_struct get_pr_interpolate_data(pr_track_t *segment, struct plot_info *pi, int cur)
|
static struct pr_interpolate_struct get_pr_interpolate_data(pr_track_t *segment, struct plot_info *pi, int cur)
|
||||||
{
|
{
|
||||||
struct pr_interpolate_struct interpolate;
|
struct pr_interpolate_struct interpolate;
|
||||||
int i;
|
int i;
|
||||||
|
@ -211,7 +206,7 @@ struct pr_interpolate_struct get_pr_interpolate_data(pr_track_t *segment, struct
|
||||||
return interpolate;
|
return interpolate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi, pr_track_t **track_pr)
|
static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi, pr_track_t **track_pr)
|
||||||
{
|
{
|
||||||
int cyl, i;
|
int cyl, i;
|
||||||
struct plot_data *entry;
|
struct plot_data *entry;
|
||||||
|
@ -284,7 +279,7 @@ void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi, pr_tra
|
||||||
* scale pressures, so it ends up being a unitless scaling
|
* scale pressures, so it ends up being a unitless scaling
|
||||||
* factor.
|
* factor.
|
||||||
*/
|
*/
|
||||||
inline int calc_pressure_time(struct dive *dive, struct divecomputer *dc, struct plot_data *a, struct plot_data *b)
|
static inline int calc_pressure_time(struct dive *dive, struct divecomputer *dc, struct plot_data *a, struct plot_data *b)
|
||||||
{
|
{
|
||||||
int time = b->sec - a->sec;
|
int time = b->sec - a->sec;
|
||||||
int depth = (a->depth + b->depth) / 2;
|
int depth = (a->depth + b->depth) / 2;
|
||||||
|
|
|
@ -27,6 +27,7 @@ struct pr_interpolate_struct {
|
||||||
int acc_pressure_time;
|
int acc_pressure_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -81,13 +81,11 @@ int get_maxtime(struct plot_info *pi);
|
||||||
* partial pressure graphs */
|
* partial pressure graphs */
|
||||||
int get_maxdepth(struct plot_info *pi);
|
int get_maxdepth(struct plot_info *pi);
|
||||||
|
|
||||||
|
|
||||||
#define SENSOR_PR 0
|
#define SENSOR_PR 0
|
||||||
#define INTERPOLATED_PR 1
|
#define INTERPOLATED_PR 1
|
||||||
#define SENSOR_PRESSURE(_entry) (_entry)->pressure[SENSOR_PR]
|
#define SENSOR_PRESSURE(_entry) (_entry)->pressure[SENSOR_PR]
|
||||||
#define INTERPOLATED_PRESSURE(_entry) (_entry)->pressure[INTERPOLATED_PR]
|
#define INTERPOLATED_PRESSURE(_entry) (_entry)->pressure[INTERPOLATED_PR]
|
||||||
#define GET_PRESSURE(_entry) (SENSOR_PRESSURE(_entry) ? SENSOR_PRESSURE(_entry) : INTERPOLATED_PRESSURE(_entry))
|
#define GET_PRESSURE(_entry) (SENSOR_PRESSURE(_entry) ? SENSOR_PRESSURE(_entry) : INTERPOLATED_PRESSURE(_entry))
|
||||||
|
|
||||||
#define SAC_WINDOW 45 /* sliding window in seconds for current SAC calculation */
|
#define SAC_WINDOW 45 /* sliding window in seconds for current SAC calculation */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
Loading…
Add table
Reference in a new issue