Open RobTillaart opened 3 weeks ago
Perhaps most users are not interested in error handling. They just want results in the easiest way possible. For those users it is handy to keep readADC() that returns the adc value. Changing this function will break API and cause annoyance to existing users so I would keep that interface.
The longer timeout is no problem because that will never result in extra delays as long as all is OK. And it does not need any changes in user code anyway.
The alternative readADC(&Value) return 0 if OK, errorcode when error: This would make user code a little more complicated. It is no longer possible to put the call in an if() statement as you would want to preserve the error code. And you still need to call getError() if you want to clear the internal error code. So you get code like:
int Value;
int Rc = readADC(Value);
if(Rc == ADS1X15_OK )
Handle value
else
Handle Error
So at the end, I would keep the interface as-is. Don't break user code. And update the examples to show how to use the API in the easy way and how to use it in a proper error-handling way.
in #82 a proposal is made to improve the API
An alternative could be