aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/CMakeLists.txt1
-rw-r--r--core/dive.c1
-rw-r--r--core/dive.h11
-rw-r--r--core/divelist.c1
-rw-r--r--core/interpolate.h16
-rw-r--r--core/planner.c1
-rw-r--r--core/profile.c1
-rw-r--r--packaging/ios/Subsurface-mobile.pro1
8 files changed, 22 insertions, 11 deletions
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index 276185fff..1ed24019c 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -119,6 +119,7 @@ set(SUBSURFACE_CORE_LIB_SRCS
import-shearwater.c
import-suunto.c
import-seac.c
+ interpolate.h
libdivecomputer.c
libdivecomputer.h
liquivision.c
diff --git a/core/dive.c b/core/dive.c
index 1fe0d44f2..177c91990 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -15,6 +15,7 @@
#include "errorhelper.h"
#include "event.h"
#include "extradata.h"
+#include "interpolate.h"
#include "qthelper.h"
#include "membuffer.h"
#include "picture.h"
diff --git a/core/dive.h b/core/dive.h
index 0b0597477..3e30ff521 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -21,17 +21,6 @@ extern const char *cylinderuse_text[NUM_GAS_USE];
extern const char *divemode_text_ui[];
extern const char *divemode_text[];
-/* Linear interpolation between 'a' and 'b', when we are 'part'way into the 'whole' distance from a to b */
-static inline int interpolate(int a, int b, int part, int whole)
-{
- /* It is doubtful that we actually need floating point for this, but whatever */
- if (whole) {
- double x = (double)a * (whole - part) + (double)b * part;
- return (int)lrint(x / whole);
- }
- return (a+b)/2;
-}
-
struct dive_site;
struct dive_site_table;
struct dive_table;
diff --git a/core/divelist.c b/core/divelist.c
index 7cbb5535c..5d87ccbcb 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -10,6 +10,7 @@
#include "event.h"
#include "filterpreset.h"
#include "fulltext.h"
+#include "interpolate.h"
#include "planner.h"
#include "qthelper.h"
#include "gettext.h"
diff --git a/core/interpolate.h b/core/interpolate.h
new file mode 100644
index 000000000..acb213acd
--- /dev/null
+++ b/core/interpolate.h
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef INTERPOLATE_H
+#define INTERPOLATE_H
+
+/* Linear interpolation between 'a' and 'b', when we are 'part'way into the 'whole' distance from a to b */
+static inline int interpolate(int a, int b, int part, int whole)
+{
+ /* It is doubtful that we actually need floating point for this, but whatever */
+ if (whole) {
+ double x = (double)a * (whole - part) + (double)b * part;
+ return (int)lrint(x / whole);
+ }
+ return (a+b)/2;
+}
+
+#endif
diff --git a/core/planner.c b/core/planner.c
index bfadf4b7f..341fa6dad 100644
--- a/core/planner.c
+++ b/core/planner.c
@@ -17,6 +17,7 @@
#include "deco.h"
#include "errorhelper.h"
#include "event.h"
+#include "interpolate.h"
#include "planner.h"
#include "subsurface-time.h"
#include "gettext.h"
diff --git a/core/profile.c b/core/profile.c
index 05aae3b64..48be68309 100644
--- a/core/profile.c
+++ b/core/profile.c
@@ -12,6 +12,7 @@
#include "display.h"
#include "divelist.h"
#include "event.h"
+#include "interpolate.h"
#include "sample.h"
#include "subsurface-string.h"
diff --git a/packaging/ios/Subsurface-mobile.pro b/packaging/ios/Subsurface-mobile.pro
index 0c922e3b6..6557a45fc 100644
--- a/packaging/ios/Subsurface-mobile.pro
+++ b/packaging/ios/Subsurface-mobile.pro
@@ -201,6 +201,7 @@ HEADERS += \
../../commands/command_edit_trip.h \
../../commands/command_filter.h \
../../commands/command_pictures.h \
+ ../../core/interpolate.h \
../../core/libdivecomputer.h \
../../core/cloudstorage.h \
../../core/configuredivecomputerthreads.h \