forked from FOSS/BangleApps
using filenames based on date
parent
c1f2ca5b78
commit
a81c367827
|
@ -30,3 +30,4 @@
|
||||||
Altitude graphing now uses barometer altitude if it exists
|
Altitude graphing now uses barometer altitude if it exists
|
||||||
plotTrack in widget allows track to be drawn in the background (doesn't block execution)
|
plotTrack in widget allows track to be drawn in the background (doesn't block execution)
|
||||||
0.24: Can now specify `setRecording(true, {force:...` to not show a menu
|
0.24: Can now specify `setRecording(true, {force:...` to not show a menu
|
||||||
|
0.25: Now record filename based on date
|
|
@ -33,10 +33,8 @@ function updateSettings() {
|
||||||
function getTrackNumber(filename) {
|
function getTrackNumber(filename) {
|
||||||
var trackNum = 0;
|
var trackNum = 0;
|
||||||
var matches = filename.match(/^recorder\.log(.*)\.csv$/);
|
var matches = filename.match(/^recorder\.log(.*)\.csv$/);
|
||||||
if (matches) {
|
if (matches) return matches[1];
|
||||||
trackNum = parseInt(matches[1]||0);
|
return 0;
|
||||||
}
|
|
||||||
return trackNum;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showMainMenu() {
|
function showMainMenu() {
|
||||||
|
@ -62,23 +60,13 @@ function showMainMenu() {
|
||||||
WIDGETS["recorder"].setRecording(v).then(function() {
|
WIDGETS["recorder"].setRecording(v).then(function() {
|
||||||
//print("Record start Complete");
|
//print("Record start Complete");
|
||||||
loadSettings();
|
loadSettings();
|
||||||
print("Recording: "+settings.recording);
|
//print("Recording: "+settings.recording);
|
||||||
showMainMenu();
|
showMainMenu();
|
||||||
});
|
});
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/*LANG*/'File #': {
|
/*LANG*/'File' : {value:getTrackNumber(settings.file)},
|
||||||
value: getTrackNumber(settings.file),
|
|
||||||
min: 0,
|
|
||||||
max: 99,
|
|
||||||
step: 1,
|
|
||||||
onchange: v => {
|
|
||||||
settings.recording = false; // stop recording if we change anything
|
|
||||||
settings.file = "recorder.log"+v+".csv";
|
|
||||||
updateSettings();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/*LANG*/'View Tracks': ()=>{viewTracks();},
|
/*LANG*/'View Tracks': ()=>{viewTracks();},
|
||||||
/*LANG*/'Time Period': {
|
/*LANG*/'Time Period': {
|
||||||
value: settings.period||10,
|
value: settings.period||10,
|
||||||
|
@ -110,7 +98,7 @@ function viewTracks() {
|
||||||
var found = false;
|
var found = false;
|
||||||
require("Storage").list(/^recorder\.log.*\.csv$/,{sf:true}).forEach(filename=>{
|
require("Storage").list(/^recorder\.log.*\.csv$/,{sf:true}).forEach(filename=>{
|
||||||
found = true;
|
found = true;
|
||||||
menu[/*LANG*/"Track "+getTrackNumber(filename)] = ()=>viewTrack(filename,false);
|
menu[/*LANG*/getTrackNumber(filename)] = ()=>viewTrack(filename,false);
|
||||||
});
|
});
|
||||||
if (!found)
|
if (!found)
|
||||||
menu[/*LANG*/"No Tracks found"] = function(){};
|
menu[/*LANG*/"No Tracks found"] = function(){};
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "recorder",
|
"id": "recorder",
|
||||||
"name": "Recorder",
|
"name": "Recorder",
|
||||||
"shortName": "Recorder",
|
"shortName": "Recorder",
|
||||||
"version": "0.24",
|
"version": "0.25",
|
||||||
"description": "Record GPS position, heart rate and more in the background, then download to your PC.",
|
"description": "Record GPS position, heart rate and more in the background, then download to your PC.",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"tags": "tool,outdoors,gps,widget",
|
"tags": "tool,outdoors,gps,widget",
|
||||||
|
|
|
@ -244,7 +244,7 @@
|
||||||
if (!options.force) { // if not forced, ask the question
|
if (!options.force) { // if not forced, ask the question
|
||||||
g.reset(); // work around bug in 2v17 and earlier where bg color wasn't reset
|
g.reset(); // work around bug in 2v17 and earlier where bg color wasn't reset
|
||||||
return E.showPrompt(
|
return E.showPrompt(
|
||||||
/*LANG*/"Overwrite\nLog " + settings.file.match(/\d+/)[0] + "?",
|
/*LANG*/"Overwrite\nLog " + settings.file.match(/^recorder\.log(.*)\.csv$/)[1] + "?",
|
||||||
{ title:/*LANG*/"Recorder",
|
{ title:/*LANG*/"Recorder",
|
||||||
buttons:{/*LANG*/"Yes":"overwrite",/*LANG*/"No":"cancel",/*LANG*/"New":"new",/*LANG*/"Append":"append"}
|
buttons:{/*LANG*/"Yes":"overwrite",/*LANG*/"No":"cancel",/*LANG*/"New":"new",/*LANG*/"Append":"append"}
|
||||||
}).then(selection=>{
|
}).then(selection=>{
|
||||||
|
@ -260,11 +260,13 @@
|
||||||
// wipe the file
|
// wipe the file
|
||||||
require("Storage").open(settings.file,"r").erase();
|
require("Storage").open(settings.file,"r").erase();
|
||||||
} else if (options.force=="new") {
|
} else if (options.force=="new") {
|
||||||
// new file - find the max log file number and add one
|
// new file - use the current date
|
||||||
var maxNumber=0;
|
var date=(new Date()).toISOString().substr(0,10).replace(/-/g,""), trackNo=10;
|
||||||
require("Storage").list(/recorder.log.*/).forEach( fn => maxNumber = Math.max(maxNumber, fn.match(/\d+/)[0]) );
|
var newFileName;
|
||||||
var newFileName = "recorder.log" + (maxNumber + 1) + ".csv";
|
do { // while a file exists, add one to the letter after the date
|
||||||
// FIXME: use date?
|
newFileName = "recorder.log" + date + trackNo.toString(36) + ".csv";
|
||||||
|
trackNo++;
|
||||||
|
} while (require("Storage").list(newFileName).length);
|
||||||
settings.file = newFileName;
|
settings.file = newFileName;
|
||||||
} else throw new Error("Unknown options.force, "+options.force);
|
} else throw new Error("Unknown options.force, "+options.force);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue