From e1e604ee1263e72d03e17c178b32cda07b3e39c3 Mon Sep 17 00:00:00 2001 From: device111 <48546979+device111@users.noreply.github.com> Date: Sun, 24 May 2020 16:14:49 +0200 Subject: [PATCH] update veml7700 libary --- lib/Adafruit_VEML7700/Adafruit_VEML7700.cpp | 24 --------------------- lib/Adafruit_VEML7700/Adafruit_VEML7700.h | 3 ++- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/lib/Adafruit_VEML7700/Adafruit_VEML7700.cpp b/lib/Adafruit_VEML7700/Adafruit_VEML7700.cpp index b719af9fa..27a9fc3a6 100644 --- a/lib/Adafruit_VEML7700/Adafruit_VEML7700.cpp +++ b/lib/Adafruit_VEML7700/Adafruit_VEML7700.cpp @@ -76,30 +76,6 @@ boolean Adafruit_VEML7700::begin(TwoWire *theWire) { return true; } -float Adafruit_VEML7700::alternate_pow(float a, float b) -{ - // https://martin.ankerl.com/2012/01/25/optimized-approximative-pow-in-c-and-cpp/ - // calculate approximation with fraction of the exponent - int e = abs((int)b); - union { - double d; - int x[2]; - } u = { a }; - u.x[1] = (int)((b - e) * (u.x[1] - 1072632447) + 1072632447); - u.x[0] = 0; - // exponentiation by squaring with the exponent's integer part - // double r = u.d makes everything much slower, not sure why - double r = 1.0; - while (e) { - if (e & 1) { - r *= a; - } - a *= a; - e >>= 1; - } - return r * u.d; -} - float Adafruit_VEML7700::normalize_resolution(float value) { // adjust for gain (1x is normalized) switch (getGain()) { diff --git a/lib/Adafruit_VEML7700/Adafruit_VEML7700.h b/lib/Adafruit_VEML7700/Adafruit_VEML7700.h index 13a0bded5..4ff8f3f78 100644 --- a/lib/Adafruit_VEML7700/Adafruit_VEML7700.h +++ b/lib/Adafruit_VEML7700/Adafruit_VEML7700.h @@ -62,6 +62,7 @@ #define VEML7700_POWERSAVE_MODE3 0x02 ///< Power saving mode 3 #define VEML7700_POWERSAVE_MODE4 0x03 ///< Power saving mode 4 +extern float FastPrecisePowf(const float x, const float y); /*! * @brief Class that stores state and functions for interacting with @@ -110,7 +111,7 @@ private: *PowerSave_Enable, *PowerSave_Mode; float normalize_resolution(float value); - float alternate_pow(float a, float b); + static inline float alternate_pow(float a, float b) { return FastPrecisePowf(a, b); } Adafruit_I2CDevice *i2c_dev;