Skip to content

Overload set_envdata#14

Open
troelsy wants to merge 3 commits into
maarten-pennings:masterfrom
troelsy:float-env-data
Open

Overload set_envdata#14
troelsy wants to merge 3 commits into
maarten-pennings:masterfrom
troelsy:float-env-data

Conversation

@troelsy

@troelsy troelsy commented Feb 13, 2019

Copy link
Copy Markdown

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

troelsy commented Feb 13, 2019

Copy link
Copy Markdown
Author

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
Copy Markdown
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

troelsy commented Feb 13, 2019

Copy link
Copy Markdown
Author

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.

2 participants