Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add private pow function in VEML7700 lib for future use #8525

Merged
merged 1 commit into from
May 24, 2020
Merged

add private pow function in VEML7700 lib for future use #8525

merged 1 commit into from
May 24, 2020

Conversation

device111
Copy link
Contributor

@device111 device111 commented May 24, 2020

alternate pow function in VEML7700 libary for future use in Tasmota to calculate normalized Lux and normalized white values.

Description:

Related issue (if applicable): fixes #

Checklist:

  • The pull request is done against the latest dev branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR.
  • The code change is tested and works on core ESP8266 V.2.7.1
  • The code change is tested and works on core ESP32 V.1.12.0
  • I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

alternate pow function for future use in Tasmota to calculate normalized Lux and normalized white values.
@arendst arendst merged commit 130a168 into arendst:development May 24, 2020
@device111 device111 changed the title add private pow function in lib for future use add private pow function in VEML7700 lib for future use May 24, 2020
@s-hadinger
Copy link
Collaborator

s-hadinger commented May 24, 2020

@device111 It's the same implementation as FastPrecisePow() in support_float.ino. Could you please use this instead to avoid duplication of code?

@arendst
Copy link
Owner

arendst commented May 24, 2020

I think the problem is accessing the function from the library won't work.

@device111
Copy link
Contributor Author

yes, the problem is calling from the libary. My first thought was to delete the functions from lib and implement the affected pow functions in the driver, but that would break the idea of libarys.

@device111
Copy link
Contributor Author

@theo
is it planed in the future, to transfer the related (pow, log, ..) functions in support_float.ino to a c++ lib?

@s-hadinger
Copy link
Collaborator

Actually it works if you add the following in 'Adafruit_VEML7700.h`:

Before the class definitio:

extern float FastPrecisePowf(const float x, const float y);

Then replace the definition of the function with:

  static inline float alternate_pow(float a, float b) { return FastPrecisePowf(a, b); }

You can then completely remove the Adafruit_VEML7700::alternate_pow() implementation.

@device111
Copy link
Contributor Author

yes, the pow changes are only made for the future developement of the driver.
but the code from above are good. I will change it.
thanks!

@s-hadinger
Copy link
Collaborator

By the way, if it does not hurt the precision, replace all floating points literal with floats. Otherwise calculation is done by the compiler using double and code goes huge.

For ex, replace

    lux = 6.0135e-13*alternate_pow(lux,4) -  9.3924e-9*alternate_pow(lux,3) + 8.1488e-5*alternate_pow(lux,2) + 1.0023*lux;

with

    lux = 6.0135e-13f*alternate_pow(lux,4) -  9.3924e-9f*alternate_pow(lux,3) + 8.1488e-5f*alternate_pow(lux,2) + 1.0023f*lux;

@device111
Copy link
Contributor Author

ok, in the next pr i will change it.
thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants