Skip to content

Conversation

@Andersama
Copy link
Contributor

Changes the return types of a few functions to pass along a timestamp to blockTillConversionComplete.
A few overloads are added to blockTillConversionComplete.

Example usage:

sensors.setWaitForConversion(false);
DallasTemperature::request_t request = sensors.requestTemperatures();
// do other work
sensors.blockTillConversionComplete(sensors.getResolution(), request);
// or
sensors.blockTillConversionComplete(sensors.getResolution(), request.timestamp);

Note: The struct isn't strictly necessary. I figured I should make each request function return the same struct to avoid confusion. requestTemperatures() could easily return just an unsigned long. I added a conversion operator to bool so that on the off chance anyone is using an older library their usage shouldn't break, I left the bool first for any binary compatibility issues for similar reasons. I'm not particularly happy with how long DallasTemperature::request_t is compared to unsigned long. I was considering result_t over request_t, but that's simple enough to change and obviously feel free to edit.

I added one new overload for the new request type which isn't strictly needed, but I figured would be nice to have / a good example of how the request struct can be used. It specifically handles the case where the request struct indicates the probe was disconnected when the request was made to avoid any unnecessary wait.

Changes the return types of a few functions to pass along a timestamp to blockTillConversionComplete
A few overloads are added to blockTillConversionComplete

Example usage:

sensors.setWaitForConversion(false);
DallasTemperature::result_t request = sensors.requestTemperatures();

sensors.blockTillConversionComplete(sensors.getResolution(), request);
or
sensors.blockTillConversionComplete(sensors.getResolution(), request.timestamp);
@Andersama Andersama force-pushed the request-timestamps branch from e8053ca to 8004027 Compare June 19, 2022 17:53
@milesburton milesburton merged commit ea08fc3 into milesburton:master Jul 5, 2022
@Andersama Andersama mentioned this pull request Jul 7, 2022
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