vanderbiltrobotics / loadcell

0 stars 0 forks source link

separate the loadcell value from the read success/fail flag #3

Open AWatk opened 6 years ago

AWatk commented 6 years ago

https://github.com/vanderbiltrobotics/loadcell/blob/a466c2e6b498ede84c17b5829522f91719adbeb6/HX711.h#L48

related to #1 #2

an action such as reading the value of a sensor has the chance of failure. To make it more explicit whether the sensor was successfully read, many times the return value of the function is a boolean indicating success or failure. The value being read is then passed by reference instead.

example:

bool read(&value);

or there could be a private variable such as value_

// .h
bool read();

//.cpp
bool read(){

   //do stuff
   value_ = XXX;
   return SUCCESS/FAIL
}