I am currently trying to customize the tracker-edge firmware (version 19) to increment a variable every time the device is woken by the IMU, specifically movement being the trigger and not high g, so imu_m and not imu_g. I am working with the Tracker SoM evaluation kit.
It is possible to do this from the "main.cpp" file alone? I have one idea discussed below but it involves modifying another file which I would prefer not to do.
I have read a number of posts and the most promising information I found so far is from this post: Customizing the IMU triggers.
However I still haven't managed to implement what I need.
This is what I gathered would work:
(The below code is from the "tracker_motion.cpp" file, but I added the variable "moveCount", this variable is declared in the "main.cpp" and is made accessible to the lines of code below via the "extern" keyword)
void TrackerMotion::loop()
{
MotionEvent motion_event;
size_t depth = MotionService::instance().getQueueDepth();
do {
MotionService::instance().waitOnEvent(motion_event, 0);
switch (motion_event.source)
{
case MotionSource::MOTION_HIGH_G:
TrackerLocation::instance().triggerLocPub(Trigger::NORMAL, "imu_g");
break;
case MotionSource::MOTION_MOVEMENT:
TrackerLocation::instance().triggerLocPub(Trigger::NORMAL,"imu_m");
moveCount++; // here is my added variable
break;
}
} while (--depth && (motion_event.source != MotionSource::MOTION_NONE));
}
this code has unfortunately not worked how I hoped so after careful deliberation, I decided to turn to the community. Any help would be much appreciated.