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

Do not publish_state when underlying climateguard/RadSens library returns 0 for unknown value #4

Merged
merged 1 commit into from
Oct 30, 2022

Conversation

bakerkj
Copy link
Contributor

@bakerkj bakerkj commented Oct 29, 2022

The underlying climateguard/RadSens library returns 0 in case of error for both getRadIntensyDynamic() and getRadIntensyStatic().

As can be seen here https://github.com/climateguard/RadSens/blob/8323ad694bf10ec0a462e240815e8f31c517cf65/src/CG_RadSens.cpp

/*Get radiation intensity (dynamic period T < 123 sec).*/
float CG_RadSens::getRadIntensyDynamic()
{
    updatePulses();
    uint8_t res[3];
    if (i2c_read(RS_RAD_INTENSY_DYNAMIC_RG, res, 3))
    {
        float temp = (((uint32_t)res[0] << 16) | ((uint16_t)res[1] << 8) | res[2]) / 10.0;
        return temp;
    }
    else
    {
        return 0;
    }
}

This pull request skips publishing these erroneous values. This should address some of the issues identified in #3.

error; Treat these as unknown values and don't publish a value.
@maaad maaad merged commit 4259da1 into maaad:main Oct 30, 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