"step" fires a bit too easily [Resolved]

Posted on
  • Okay, I am a numpty... I think I hit enter by mistake and now I can't seem to edit the original post anymore... here is what I wanted to say

    I finally got around to incorporating the 'step' event in my code and it seems to fire rather easily, e.g. even when I am typing with the watch on.

    Now of course step calculation with accelerometer is buggy in every sport watch I have seen, so I am fine that we have to 'train' the Bangle better. So in this respect I have a few requests:

    1. Can the callback get the 'raw' values based on which the decision is being made? That way we can dig in and try to find patterns to get it closer to real.

    2. I noticed the callback function doesn't seem to be in the right context. This could just be my code but the only difference between how I have assigned callbacks for HRM or gps events, is there is a dedicate power call for each. I'll try to use the good ol' _this and fix it.

    I didn't feel like filing a bug in repo because I didn't have anything positive to contribute on how to fix it. So apologies if this is in the wrong place.

  • Mon 2020.02.17

    'I am a numpty'

    Have heard of that idiom used in Australian television, but just learned that Oxford added it as a reference first used by the Scottish. From either of those countries?

    'the callback function doesn't seem to be in the right context

    If it hadn't been discovered before @PiOfThings, clicking on the 'Right Arrow' following the function name 'event.Bangle.step' heading, will lead one to the source.

    https://banglejs.com/reference#l_Bangle_­step

    click on Right Arrow - following function name above leads to:

    https://github.com/espruino/Espruino/blo­b/master/libs/banglejs/jswrap_bangle.c#L­85

     

    'get the 'raw' values'  

    https://banglejs.com/reference#l_Bangle_­GPS-raw

  • Can the callback get the 'raw' values based on which the decision is being made? That way we can dig in and try to find patterns to get it closer to real.

    The raw values it works from are just the accelerometer values, so you can take a look at the accel event. However you can tweak the step counter from JS - check out Bangle.setOptions - https://banglejs.com/reference#l_Bangle_­setOptions with stepCounterThresholdLow and stepCounterThresholdHigh...

    I noticed the callback function doesn't seem to be in the right context.

    Can you give me an example? this is set to Bangle on all the events that get queued up. If you need this set to something else then you should be able to either use arrow functions, or the _this hack you suggest...

  • Thanks @Gordon... I did start using the getAccel on every step event to get the accelerometer values. Now I am treating the 'step' event as a throttle for the 'accel' event. I tried logging accel event, and it turned out to be a firehose that filled up the internal memory very quickly. So the plan is to try and find patterns in accel data and then 'tune' the event appropriately.

    Getting some exciting accel readings at current sensitivity level. I will also play around with the Options.

    The issue with context was a non-issue. It is still to do with file save but again, separate thread :-)... I have removed it from the title and marked this one as resolved.

    Cheers.

  • Great! The step counting is itself pretty simple - it basically looks at the magnitude of the acceleration and then detects when it varies from 1G by more than a certain amount (which is configurable by stepCounterThreshold*). accel readings come in at 12.5 Hz so shouldn't be too painful to work with. Maybe you could consider keeping the last 10/20 readings in an array and then plotting that array whenever you get a step event.

    I'd be interested in other methods of doing it, but it would appear to be the normal way these things work.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

"step" fires a bit too easily [Resolved]

Posted by Avatar for PiOfThings @PiOfThings

Actions