Debugging Custom Clock Info Item

Posted on
  • Hi, my wife wants to see "Distance" so I am trying to add that function to a Clock Info item in my "Meander" app which 3 clock info items, but I cannot seem to get it to load. I'm not sure if this is the proper place to ask but can you all help me figure out why it's not working? I'm a noob coder.

    https://github.com/4o4R/Bangle-Meander

  • Hi! Yes, this is definitely the right place to ask.

    The first port of call is always to make sure you load your app with the Web IDE running and see if any errors appear.

    I guess you're adding the clockinfo here? https://github.com/4o4R/Bangle-Meander/blob/main/clean%20meander.app.js#L88-L92

    I'm pretty sure you're putting the clockinfo in the wrong place - if you just want to add it to your clock, it's best to start from the code from an app that creates its own clockinfos like: https://github.com/espruino/BangleApps/blob/master/apps/analogquadclk/app.js#L158-L210

    It does something like:

    let clockInfoItems = require("clock_info").load();
     let clockInfoItemsBangle = clockInfoItems.find(i=>i.name=="Bangle");
     if (clockInfoItemsBangle) {
          clockInfoItemsBangle.items.push({ name : "MyItem",
              get : () => {
              },
              show : function() {
              },
             hide : function() {
            });
        }
    

    ... or you could just make your own standalone clockinfo like is shown on https://www.espruino.com/Bangle.js+Clock+Info and then it'd work with any clock you install? That might be more sensible...

    However I'm not entirely sure where the distance module is defined for require("distance")? I don't see it used in any other apps.

    What kind of distance are you after? The distance from a run that you're currently doing in the Run app, or the distance that I think some clocks display which is based on the step count multiplied by an average step size?

  • Thank you! Yes, I am just trying to a step count multiplied by avg step size in miles (per wife request :). I'll see what I can do with this.

  • Great! Then it might be worth using the code above plus the code to handle the step count clockinfo: https://github.com/espruino/BangleApps/blob/master/apps/clock_info/lib.js#L81-L89

    Then adding the multiplication should be quite easy I hope!

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

Debugging Custom Clock Info Item

Posted by Avatar for user159234 @user159234

Actions