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

Overload set_envdata #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

troelsy
Copy link

@troelsy troelsy commented Feb 13, 2019

Overload set_envdata with (float temperature, float humidity) for direct celsius and RH input and automatic data type conversion to uint16.

I use a temperature and humidity sensor/library that gives the temperature and humidity as floating points. I made a conversion function to the uint16 data type specified in the datasheet and thought somebody else might like it as well.

…put and automatic data type conversion to uint16
@troelsy
Copy link
Author

troelsy commented Feb 13, 2019

I see there is a similar pull request with the code from SparkFun. I did see the code from SparkFun before making my own, but I found it a bit hard to follow, which is why I made it. I can't tell which one performs the fastest though - I'll let that up to you to decide.

@maarten-pennings
Copy link
Owner

Hi @troelsy thanks for your contribution.
I have two considerations.

One is that I deliberately left out floating point operations in my library, so that I do not force my users to link in the float runtime library, which has a relatively large foot print in small microcontrollers. How do you feel about that?

Secondly, if the users wants to use float in his embedded application (e.g. the microcontroller has plenty of flash), it is rather easy too use the library. I believe something like this would work:
set_envdata( (float_t+25)*256, float_h*512 )
Do you agree this works? Can we make a macro for this?

Please let me know what you think.

@troelsy
Copy link
Author

troelsy commented Feb 13, 2019

Huh, I should have thought about multiplying both parts - that's a lot easier than splitting them up. Shouldn't they both be multiplied by 512?

Wouldn't it still make sense to have the overloaded function? The compiler will eliminate it, if it is unused.

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.

None yet

2 participants