Jump to content
I2Cdevlib Forums

DMP dmp_get_pedometer_step_count


Recommended Posts

Hi all,

 

I'm a really newbie in this forum and in MPU6050 with Arduino, firstly thank for your awesome drivers works perfect and the code is pretty readable.

 

My small task is include the pedometer (step count,time walk) information in your driver, for that, i'm trying to include that functions from the original driver to your. 

 

/**
 *  @brief      Get current step count.
 *  @param[out] count   Number of steps detected.
 *  @return     0 if successful.
 */
int dmp_get_pedometer_step_count(unsigned long *count)
{
    unsigned char tmp[4];
    if (!count)
        return -1;


    if (mpu_read_mem(D_PEDSTD_STEPCTR, 4, tmp))
        return -1;


    count[0] = ((unsigned long)tmp[0] << 24) | ((unsigned long)tmp[1] << 16) |
        ((unsigned long)tmp[2] << 8) | tmp[3];
    return 0;
}

that's original function, so they used that function of mpu_read_mem to access to DMP memory ( ig I guess FIFO) with mem_Address= D_PEDSTD_STEPCTR  size 4bytes so it's a uint32t (cause it's a unsiged long),  and output in tmp.

 

They use: #define D_PEDSTD_STEPCTR        (768 + 0x60)

 

 

 

So studing the code I realize that to access to FIFO register in your Driver is with readmemory block??is good?

So in this case i modify with the next:

int MPU6050::dmp_get_pedometer_step_count(unsigned long *count)
{
    unsigned char tmp[4];
    if (!count)
        return -1;


    if (readMemoryBlock(&tmp,4,MPU6050_RA_MEM_R_W,D_PEDSTD_STEPCTR))
        return -1;


    count[0] = ((unsigned long)tmp[0] << 24) | ((unsigned long)tmp[1] << 16) |
        ((unsigned long)tmp[2] << 8) | tmp[3];
    return 0;
}

But sadly is not working at all i have problems with type data but also i don't know if it's correct or not. i'm not expert in this software sorry.

 

And if someone know some other way to solve could be nice to help me.

 

Thanks

 

pd.sorry my english

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...