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

Added Convenience Methods #54

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

Conversation

greggubben
Copy link

I added some convenience methods to the library while maintaining backwards compatibility.
There are now methods in DHT.h with Celsius and Fahrenheit in the method names which in turn call the existing methods with the boolean flag set accordingly. This makes the calling program easier to read and reduces confusion around what the flag means without having to look at the library each time.

I also removed count from the constructor in DHT.cpp. For backwards compatibility, I added a overload in DHT.h that accepts it, ignores it, and calls the constructor without it.

// Note that count is now ignored as the DHT reading algorithm adjusts itself
// based on the speed of the processor.
DHT(uint8_t pin, uint8_t type, uint8_t count) {
DHT(pin, type);
Copy link

@dotdoom dotdoom Feb 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's quite accurate. What it does is a call to constructor DHT, but the instance constructed goes nowhere. Perhaps you wanted DHT(...): DHT(pin, type) { }; ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your feedback.

I am not sure I understand your comment.

The 3 arg constructor DHT(pin, type, count) calls the 2 arg constructor with DHT(pin, type) in the header. The 2 arg constructor is the header definition for the 2 arg constructor in the DHT.cpp file. I removed the 3 arg constructor that used to be in the DHT.cpp file.

Does that make sense or am misunderstanding your comment?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the right C++ syntax to delegate constructors.
It does call the constructor indeed, but it just constructs another
instance instead, which is then immediately discarded. See for example
https://en.wikipedia.org/wiki/C%2B%2B11#Object_construction_improvement

On Fri, Mar 4, 2016, 07:23 Gregg Ubben notifications@github.com wrote:

In DHT.h
#54 (comment)
:

@@ -37,11 +37,28 @@ written by Adafruit Industries

class DHT {
public:

  • DHT(uint8_t pin, uint8_t type, uint8_t count=6);
  • // Note that count is now ignored as the DHT reading algorithm adjusts itself
  • // based on the speed of the processor.
  • DHT(uint8_t pin, uint8_t type, uint8_t count) {
  • DHT(pin, type);
    

Thank you for your feedback.

I am not sure I understand your comment.

The 3 arg constructor DHT(pin, type, count) calls the 2 arg constructor
with DHT(pin, type) in the header. The 2 arg constructor is the header
definition for the 2 arg constructor in the DHT.cpp file. I removed the 3
arg constructor that used to be in the DHT.cpp file.

Does that make sense or am misunderstanding your comment?


Reply to this email directly or view it on GitHub
https://github.com/adafruit/DHT-sensor-library/pull/54/files#r54982620.

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