• Hello everyone,
    2 questions

    I've written my own clock face and added a daily step count to the screen by using Bangle.getStepCount() but this just seems to just keep incrementing and not resetting to zero at the start of each day.

    Should it reset to zero?

    I've loaded the Pedometer widget, which does seem to reset but any suggestions on how I might use that step count on the screen rather than as a widget?

  • Hi,

    not sure if this helps you or if this is what you are searching for, but I'm using the health module, which is preinstalled on each bangle js 2 as far as I know. Using the code below works fine for me - also steps are set to zero each day :)

    In case health is not installed, I return 0. Probably ot would be better, to show a warning etc. instead ;)


    1 Attachment

    • Screenshot_20211230-180434.jpg
  • Thanks, I've made the changes to my code but get an error "module health not found" even after I've loaded the health tracking widget.
    Going to play around with it some more and try and find out what's happening.

    Thanks.

  • Ok interesting... and the Health tracking app is installed? I think this app provides this functionality...

  • Yes, a health tracking app is installed and I can see the number of steps as a graph.
    These are the health files on the Bangle2.


    1 Attachment

    • 2021-12-30.png
  • I would recommend this as the best way to get the daily step count into a clock.

    I would not recommend getting it from the health app as it might take a day before you get a count for a whole day.

    function getSteps() {
      if (WIDGETS.wpedom !== undefined) {
        return WIDGETS.wpedom.getSteps();
      }
      return '????';
    }
    

    Yes, the daily step count should reset each day at midnight, both in the health app and the pedometer widget.

  • For me the health app version works fine, steps are shown in realtime and I dont have to wait for a day :)

  • Thanks for your help and the code example, I've now got the basics working.
    I've added some coloured bars but this is what I've written.

    function getSteps() {
    if (WIDGETS.wpedom !== undefined) {

    return WIDGETS.wpedom.getSteps();
    

    }
    return '????';
    }

    g.clear(); // Clear the screen once, at startup

    // Load widgets
    Bangle.loadWidgets();

    //Set background
    // top box
    g.setColor("#00f"); //blue
    g.fillRect(0, 0, 176, 58);
    // middle box
    g.setColor("#ff0"); //yellow
    g.fillRect(0, 60, 176, 118);
    // bottom box
    g.setColor("#f00"); //red
    g.fillRect(0, 120, 176, 176);

    //Draw text string
    g.setFontAlign(0, 0).setFont("Vector", 55);
    g.drawString(getSteps(), 90, 95);

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

Should Bangle.getStepCount() reset to zero at the start of each day?

Posted by Avatar for RickyP @RickyP

Actions