You are reading a single comment by @msdeibel and its replies. Click here to read the full conversation.
  • Here's what I implemented. I'll leave it here for further reference.
    The full code can be found at https://github.com/msdeibel/BangleApps/b­lob/master/apps/batchart/widget.js

    function logBatteryData() {
          const previousWriteLogName = "bcprvday";
          const previousWriteDay = require("Storage").read(previousWriteLog­Name);
          const currentWriteDay = new Date().getDay();
    
          const logFileName = "bclog" + currentWriteDay;
    
          // Change log target on day change
          if (previousWriteDay != currentWriteDay) {
            //Remove a log file containing data from a week ago
            require("Storage").erase(logFileName);
            require("Storage").write(previousWriteLo­gName, currentWriteDay);
          }
    
          var bcLogFileA = require("Storage").open(logFileName, "a");
          if (bcLogFileA) {
            console.log([getTime().toFixed(0), E.getBattery(), E.getTemperature(), getEnabledConsumersValue()].join(","));
            bcLogFileA.write([[getTime().toFixed(0),­ E.getBattery(), E.getTemperature(), getEnabledConsumersValue()].join(",")].j­oin(",")+"\n");
          }
      }
    
About

Avatar for msdeibel @msdeibel started