diff --git a/sonoff/support.ino b/sonoff/support.ino index 317d25065..c10c81eb0 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -674,6 +674,12 @@ double FastPrecisePow(double a, double b) return r * u.d; } +float FastPrecisePowf(const float x, const float y) +{ +// return (float)(pow((double)x, (double)y)); + return (float)FastPrecisePow(x, y); +} + uint32_t SqrtInt(uint32_t num) { if (num <= 1) { diff --git a/sonoff/xdrv_04_light.ino b/sonoff/xdrv_04_light.ino index 391702b52..a25b63d0e 100644 --- a/sonoff/xdrv_04_light.ino +++ b/sonoff/xdrv_04_light.ino @@ -718,10 +718,6 @@ void LightStateClass::HsToRgb(uint16_t hue, uint8_t sat, uint8_t *r_r, uint8_t * #define POW FastPrecisePowf -float FastPrecisePowf(float a, float b) { - return (float) FastPrecisePow(a,b); -} - void LightStateClass::RgbToXy(uint8_t i_r, uint8_t i_g, uint8_t i_b, float *r_x, float *r_y) { float x = 0.31271f; // default medium white float y = 0.32902f; diff --git a/sonoff/xsns_27_apds9960.ino b/sonoff/xsns_27_apds9960.ino index 7594a5322..909bb607e 100644 --- a/sonoff/xsns_27_apds9960.ino +++ b/sonoff/xsns_27_apds9960.ino @@ -374,21 +374,11 @@ void calculateColorTemperature(void) n = (xc - 0.3320F) / (0.1858F - yc); /* Calculate the final CCT */ - color_data.cct = (449.0F * powf(n, 3)) + (3525.0F * powf(n, 2)) + (6823.3F * n) + 5520.33F; + color_data.cct = (449.0F * FastPrecisePowf(n, 3)) + (3525.0F * FastPrecisePowf(n, 2)) + (6823.3F * n) + 5520.33F; return; } -/** -* Taken from the Adafruit-Library -* @brief Implements missing powf function -*/ - -float powf(const float x, const float y) -{ - return (float)(pow((double)x, (double)y)); -} - /******************************************************************************* * Getters and setters for register values ******************************************************************************/