Retrieving state of the different SoC devices

Posted on
  • Hi all,
    currently we can easily check if the LCD is on with isLCDOn().

    As far as I can see there are (for now) no corresponding functions for

    • Compass
    • GPS
    • BLE
    • and HRM

    Is there another way of getting the status, e.g. by reading a pin status (which ones?) until we have convenience functions for this purpose?

  • Mon 2020.04.13

    Did not check for thoroughness for the specific pin request, but has this reference been reviewed?

    https://banglejs.com/reference
    https://banglejs.com/reference#l_Bangle_­getCompass
    https://banglejs.com/reference#l_Bangle_­GPS

  • I found them but wasn't sure if I could work with them in case they don't fire.

    I worked around with this code

    Bangle.on('mag', (() => {
      console.log("mag received");
      compassEventReceived = true;
    }));
        
    Bangle.on('GPS', (() => {
      console.log("GPS received");
      gpsEventReceived = true;
    }));
    
    Bangle.on('HRM', (() => {
      console.log("HRM received");
      hrmEventReceived = true;
    }));
    
    // Wait two seconds, that should be enough for each of the events to get raised once
    setTimeout(() => { 
      Bangle.on('mag', () => {});
      Bangle.on('GPS', () => {});
      Bangle.on('HRM', () => {});
    }, 2000);
    

    The only issue is removing the eventlisteners now. The code above fails to do that. I already posted another question for that, though ;)

  • Thanks - I'm afraid that would appear to be the best bet for now. I'll add that to the next firmware though.

    In terms of removing listeners, you need to have a named function so you can remove it...

    function magListener() {
      console.log("mag received");
      compassEventReceived = true;
    }
    Bangle.on('mag', magListener);
    // Wait two seconds, that should be enough for each of the events to get raised once
    setTimeout(() => { 
      Bangle.removeListener('mag', magListener);
    }, 2000);
    
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Retrieving state of the different SoC devices

Posted by Avatar for msdeibel @msdeibel

Actions