Giter Site home page Giter Site logo

Comments (8)

RobTillaart avatar RobTillaart commented on May 28, 2024

Added value is too small

from dhtnew.

ilikegitlab avatar ilikegitlab commented on May 28, 2024

i would love a full integer version of the lib. Why on earth would one waste so a single byte too much for a horribly inaccurate sensor. Just ask the user of the lib to divide by 10.

There are some alternative libs, but none as feature rich as this one.

from dhtnew.

RobTillaart avatar RobTillaart commented on May 28, 2024

Thanks for this question.
I understand that a full integer version would same RAM and more importantly it would not need (to include) the floating point library.

Leaving the divide by 10 to the user is one strategy, the other is doing it in the library and

  • round T and H to appropriate integers
  • return Integer and decimal part separately
  • or let user divide.

For sake if usability rounding in the lib seems to fit the integer approach best if one wants to keep the interface as much the same as possible..

Two strategies, a derived class or a stand alone class.with its own repo.

@ilikegitlab
How would you name the new integer class?

from dhtnew.

RobTillaart avatar RobTillaart commented on May 28, 2024

@ilikegitlab
Created a new library - under development - https://github.com/RobTillaart/DHTINT

Build of the examples looks good, so please verify if this works for you.

from dhtnew.

RobTillaart avatar RobTillaart commented on May 28, 2024

If problems arise, please open an issue under - https://github.com/RobTillaart/DHTINT

from dhtnew.

ilikegitlab avatar ilikegitlab commented on May 28, 2024

@RobTillaart
thanks! That was fast. I would indeed have called it exactly that!

I wonder though: is it not tedious to maintain a completely different branch for this? I would probably have made DHTnew use ints internally and #ifdeffed float/int as an option. But its your call! and it perfect for my current project.

from dhtnew.

RobTillaart avatar RobTillaart commented on May 28, 2024

The library is experimental and it might merge in the future sometime. As I maintain ~150 libraries one more or less isn't such a big deal, especially because DHTNEW is pretty stable.

Using #ifdef is also an option but I prefer a separate class above (user configured) conditional code as it is more explicit for beginners why the behavior / accuracy changes.

Furthermore this allowed me to use an explicit example to see the difference in footprint, if the example still would do

Serial.println(dht.teperature(), 2);

even if the function would return an int the floating point library would still be #included.

Offset

There is one point that caught my attention and which is not resolved in the code.
I would still like to set an offset in tenth of degrees (by multiplying by 10 perhaps) to be able to calibrate more accurately.
That would also imply that the values, the offset and div 10 should be done later as now.
Now I have whole degrees as offset, it won't affect rounding, but I think it is possible to do better.
Think I should open an issue for that .

from dhtnew.

RobTillaart avatar RobTillaart commented on May 28, 2024

done - RobTillaart/DHTINT#2

from dhtnew.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.