Skip to content

Waiting for the HX711 using a spinlock? #125

Description

@amotl

Hi @bogde,

along the lines of #123, I am also thinking about giving the current implementation for waiting for the HX711 to become ready

HX711/HX711.cpp

Lines 55 to 60 in 899dc7c

long HX711::read() {
// wait for the chip to become ready
while (!is_ready()) {
// Will do nothing on Arduino but prevent resets of ESP8266 (Watchdog Issue)
yield();
}

a minor facelift. As the outcome might also slightly amend the behavior of the library with respect to current userspace code in the wild, I would propose adding this on top of #123 to at least ship both aspects at once in order to make transitioning easier.

I didn't want to change the semantics related to this together with the infrastructural improvements carried out with #123. Also, I felt changes to that would be worth a discussion if you would have any strong opinions about that, so I ask for your understanding to spawn yet another issue apart from the main "spring-cleaning" thread.

In general, I propose a non-blocking interface like the one @thomasfredericks outlined in #96 with HX711_timeout_example.ino.

This might also help with things like #76 or #111. In general, I would try to design the interface that it would not be possible to deadlock so easily by default without knowing about the implementation details of the read() method. So, it might also become more of a topic for improving the documentation accordingly besides actual code refactoring.

What do you think about that?

With kind regards,
Andreas.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions