Module for GPSrec

Posted on
  • @Gordon would it be possible to get a module interface to the GPSrec App/Widget.

    I have just written some code to allow me to turn the recorder on / off through the gps watch face (Kitchen Combo) on a long BTN2 press. When the logger is off I can turn the GPS on through the gps face of kicthen combo. When I turn the logging on the widget will start to flash showing that logging is taking place. But when I turn the logger off through the code - it also turns the GPS off. What I need is a logging off but leave GPS on interface.

    This is the code I have used at the moment.

    GPS.prototype.toggleGpsLogging = function() {
      var settings = require("Storage").readJSON("gpsrec.json­",1)||{};
      if (settings == {}) return false;
    
      settings.recording = !settings.recording;
      require("Storage").write("gpsrec.json", settings);
    
      if (WIDGETS["gpsrec"])
        WIDGETS["gpsrec"].reload();
    
      return true;
    }
    
    GPS.prototype.loggingStatus = function() {
      var settings = require("Storage").readJSON("gpsrec.json­",1)||{};
      if (settings == {}) return "E-LOG";
      if (settings.recording) return "ON";
      return "OFF";
    }
    
    
  • I just pushed a change to the development BangleApps repo which will allow gpsrec to turn on/off (on recent firmwares) without turning GPS off. The code you have should then work as-is.

    It's good practice now to do Bangle.setGPSPower(on, 'appId') - then Bangle.js will keep the GPS on as long as at least one different app needs it - same for compass/etc.

    But yes, having a module in gpsrec that contains the code you had above to allow easy toggling would be great.

    What's "E-LOG" for out of interest? I guess ideally we'd just return a bool?

  • GPS.prototype.loggingStatus

    All this is doing is getting the status of whether gps logging is ON or OFF through the settings file.
    It returns E-LOG if it cant find the settings file.
    Its code I use internal to my App to check for an error condition.
    EG - if someone had not installed the GPS logger.

    Its time I worked out how to state app dependancies for my app.
    Until now gpsrec has not been a dependancy.

    It's good practice now to do Bangle.setGPSPower(on, 'appId') -

    Nice one. I was not aware of this. Does this work on current firmware ?
    I'll just update my app.

  • Thanks - just done a merge and works really well.

  • Does this work on current firmware ?

    I think it's in 2v09, but not 2v08.

    Also on latest firmwares you'll find GPS keeps running even between apps (without turning off).

    state app dependancies for my app.

    I think if you look at apps.json there are some examples of it being done. However I'd suggest that if possible you detect if the app is installed and if not, try and carry on regardless just with that functionality disabled?

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

Module for GPSrec

Posted by Avatar for HughB @HughB

Actions