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/blob/master/apps/batchart/widget.js
function logBatteryData() { const previousWriteLogName = "bcprvday"; const previousWriteDay = require("Storage").read(previousWriteLogName); 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(previousWriteLogName, 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(",")].join(",")+"\n"); } }
@msdeibel started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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/blob/master/apps/batchart/widget.js