Closed pghj closed 6 months ago
Thank you for catching, definitely a (copy paste) BUG. Will fix asap, probably tomorrow.
Thanks for the quick response. It seems to me that the check can just be removed from both methods, because setChannelMask already tests the entire mask for changes.
Oops wrong button.
It seems to me that the check can just be removed from both methods, because setChannelMask already tests the entire mask for changes.
Good idea, would simplify code a bit. Will create a develop branch asap to prepare for a 0.3.0 version.
Propose code would also return false if the writing to the multiplexer failed.
bool TCA9548::enableChannel(uint8_t channel)
{
if (channel >= _channels) return false;
return setChannelMask(_mask | (0x01 << channel));
}
bool TCA9548::disableChannel(uint8_t channel)
{
if (channel >= _channels) return false;
return setChannelMask(_mask & ~(0x01 << channel));
}
@pghj Develop branch created, build-CI is running. Some more edits were made.
Propose code
Looks good. Can you also make it return the result of setChannelMask when calling selectChannel?
Will check after lunch
Propose code
Looks good. Can you also make it return the result of setChannelMask when calling selectChannel?
done
@pghj Do you have time to test the develop branch, otherwise I will merge it (as I see no issues for now).
@pghj I merged develop and released 0.3.0 .
Again thanks for reporting the issue!
I think disableChannel was copy-pasted from enableChannel, but the condition !isEnabled(channel) was not inverted by mistake.