Can anyone explain to me how to use the standby() function of the SparkFun_MMA8452Q_Arduino_Library? I am trying to write to a specific register in order to enable transient acceleration detection and having no luck. I have researched online and watched several YouTube videos on Arduino libraries and nothing seems to apply directly to my case. Each library seems to have its own exceptions or special cases and I am new to using the higher functions of libraries.
Any help would be appreciated, my gut tells me that I am missing something fundamental.
To ensure I’m following correctly, you’re asking about this snippet of code in the src files, correct?
// SET STANDBY MODE
// Sets the MMA8452 to standby mode. It must be in standby to change most register settings
void MMA8452Q::standby()
[
byte c = readRegister(CTRL_REG1);
writeRegister(CTRL_REG1, c & ~(0x01)); //Clear the active bit to go into standby
]
*the [ ] brackets replace the curly brackets in this code. There is a small bug with PHP3 that doesn’t like curly brakets in the “code” snippets.
Just so that you are aware, we are unable to provide full support for custom code or modifications. However, I’ll try to help as much as I can.
That is the code in question. I have since posting done more research and I believe that standby() is “private” and as such I cannot use this method from within my sketch? Is that correct? Ultimately, I need help determine how to configure transients so that I can de-couple gravity from my acceleration measurements.
That function is a private function and can’t be called directly. So you are correct in that regard. From this point, you’ll need to write custom code to accomplish your desired goal.
Unfortunately, this is beyond the scope of our Technical Support. However, this is a great question for the community.
So are you saying that I need to write custom code in order to configure the transient settings? Or were you referring to the standby() method and accessing it?
At this point, yes. You could modify the source code to call the private standby() function. Or you can write a whole function that runs all that you need. [Here is an example similar to what I’m saying.
I just want to make sure that we are not getting off track here…
I now know that I cannot access the standby() method, and I now presume that I do not need to as the Scale and ODR examples do not need to access standby() from the example sketches. So now my question is, how to I go about configuring the transient registers? Is this possible within the MMA8452Q_Arduino_Library as is?
Again, I am trying to de-couple gravity from my dynamic acceleration readings.
My apologies if I haven’t answered your question fully. I was trying to support your questions about the standby() function itself.
Unfortunately, the scope of your question regarding the transient registers is beyond our Technical Support. This is still a great question for the community. We are just unable to support the larger scope of your question.