SparkFun_ADXL345_Arduino_Library icon indicating copy to clipboard operation
SparkFun_ADXL345_Arduino_Library copied to clipboard

Addition of FIFO Control and Status

Open glenntamayo opened this issue 8 years ago • 2 comments

This library does not have methods to enable FIFO and select one of its modes. The setFIFOMode will select one of the four available modes - Bypass, FIFO, Stream and Trigger. The getFIFOMode will return the byte set in the FIFO_CTL register. The getFIFOStatus will return the number of data values stored in FIFO.

glenntamayo avatar Jul 04 '17 15:07 glenntamayo

It doesn't look like sparkfun have looked at this project in a while. :(

SDAMcIntyre avatar Jul 17 '17 09:07 SDAMcIntyre

Hi Glenn - Sorry, someone should have contacted you a lot sooner. This looks like a good addition. I have a few changes I need to see.

The use of magic decimal numbers is not ideal. It would be a lot easier for me to read and check if you used bit wise operators such as (and this is pseudo code, I haven't read the datasheet in many years):

writeTo(ADXL345_FIFO_CTL, (1<<FIFO_MODE_STREAM));

Or something of the like.

And passing in a String to any function is (almost always) a bad idea. Using the String constructor will add a lot of overhead any time someone links in the library. I would prefer the user call a function called

myAccelerometer.enableStreamMode();

that in turn called your setFIFOmode with a define. Such as:

ADXL345::enableStreamMode()
{
    setFIFOMode(FIFO_MODE_STREAM);
}

Again, sorry we're so late to the party and thank you for your contribution. If you're interested in continuing this PR, please change it with the above recommendations.

nseidle avatar Mar 21 '18 14:03 nseidle