0

正规365体育投注I have a structure list defined at the beginning of a program and I want to add/ remove items in that list during execution. I have tried different thing like : sensor_list[3] = {INV_SENSOR_TYPE_RAW_ACCELEROMETER, 50000 }; but nothing seems to work. Any suggestion would be appreciate. Thanks

static const struct {
    uint8_t  type;
    uint32_t period_us; // ***  set period in  us  ***    ex 50000 = 20Hz   20000  = 50 HZ//
} sensor_list[] = {
#if USE_RAW_ACC
    { INV_SENSOR_TYPE_RAW_ACCELEROMETER, 50000 /* 20 Hz */ },
#endif
#if USE_RAW_GYR
    { INV_SENSOR_TYPE_RAW_GYROSCOPE,     50000 /* 20 Hz */ },
#endif
#if USE_CAL_ACC
    { INV_SENSOR_TYPE_ACCELEROMETER, 500000 /* 20 Hz */ },     
etc....

};
  • 2
    It seems your have implemented an array of anonymous structs. 1) always include a tag name in a struct definition because most debuggers cannot access the internal fields without the tag name. 2) This array is in memory and fixed. If you want it to be flexible, then use dynamic memory to allocate each entry in the struct and use a linked list format to collect all the instances of the struct into an array. – user3629249 Mar 26 at 23:41
  • Thanks for the answer. I will look at that. I am trying to modify an existing program. If you would be kind enough to point me to an exemple, I would appreciate. – S Lareau Mar 28 at 0:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.