commit
9dd40c9d64
|
|
@ -9,4 +9,6 @@
|
||||||
0.07: Convert Yes/No On/Off in settings to checkboxes
|
0.07: Convert Yes/No On/Off in settings to checkboxes
|
||||||
0.08: Fix the wrapping of intervals/timeouts with parameters
|
0.08: Fix the wrapping of intervals/timeouts with parameters
|
||||||
Fix the widget drawing if widgets are hidden and Bangle.setLCDBrightness is called
|
Fix the widget drawing if widgets are hidden and Bangle.setLCDBrightness is called
|
||||||
0.09: Accidental version bump
|
0.09: Accidental version bump
|
||||||
|
0.10: Use charging state on boot for auto calibration
|
||||||
|
Log additional timestamp for trace log
|
||||||
|
|
|
||||||
|
|
@ -42,10 +42,10 @@
|
||||||
|
|
||||||
|
|
||||||
let logPower = (type, oldstate, state, app) => {
|
let logPower = (type, oldstate, state, app) => {
|
||||||
logFile.write("p," + type + ',' + (oldstate?1:0) + ',' + (state?1:0) + ',' + app + "\n");
|
logFile.write(Date.now() + ",p," + type + ',' + (oldstate?1:0) + ',' + (state?1:0) + ',' + app + "\n");
|
||||||
};
|
};
|
||||||
let logDeferred = (type, duration, source) => {
|
let logDeferred = (type, duration, source) => {
|
||||||
logFile.write(type + ',' + duration + ',' + source.replace(/\n/g, " ").replace(/,/g,"") + "\n");
|
logFile.write(Date.now() + "," + type + ',' + duration + ',' + source.replace(/\n/g, " ").replace(/,/g,"") + "\n");
|
||||||
};
|
};
|
||||||
|
|
||||||
let lastPowerOn = {};
|
let lastPowerOn = {};
|
||||||
|
|
@ -152,13 +152,14 @@
|
||||||
return v;
|
return v;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.autoCalibration){
|
if (settings.autoCalibration){
|
||||||
let chargeStart;
|
let chargeStart;
|
||||||
|
if (Bangle.isCharging()) chargeStart = Date.now();
|
||||||
Bangle.on("charging", (charging)=>{
|
Bangle.on("charging", (charging)=>{
|
||||||
if (charging) chargeStart = Date.now();
|
if (!chargeStart && charging) chargeStart = Date.now();
|
||||||
if (chargeStart && !charging && (Date.now() - chargeStart > 1000*60*60*3)) require("powermanager").setCalibration();
|
if (chargeStart && !charging && (Date.now() - chargeStart > 1000*60*60*3)) require("powermanager").setCalibration();
|
||||||
if (!charging) chargeStart = undefined;
|
if (!charging) chargeStart = undefined;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,15 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" href="../../css/spectre.min.css">
|
<link rel="stylesheet" href="../../css/spectre.min.css">
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.table_wrapper{
|
||||||
|
display: block;
|
||||||
|
overflow-x: auto;
|
||||||
|
margin-right: 0.8rem;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="content"></div>
|
<div id="content"></div>
|
||||||
|
|
@ -119,18 +128,21 @@ function viewDeferredTable(filename) {
|
||||||
<button class="btn btn-primary" id="back" style="float: right;margin-right: 5px;margin-left: 10px;">Back</button>
|
<button class="btn btn-primary" id="back" style="float: right;margin-right: 5px;margin-left: 10px;">Back</button>
|
||||||
<div>
|
<div>
|
||||||
This are functions used in timeouts and intervals and their accumulated execution times. Recorded in a time span of <b>${timeFormat(duration)}</b>. Timeouts/intervals have run for <b>${timeFormat(sum)} (${(sum/duration*100).toFixed(2)}%)</b>. Percentages are calculated from summarized timeout/interval running time.
|
This are functions used in timeouts and intervals and their accumulated execution times. Recorded in a time span of <b>${timeFormat(duration)}</b>. Timeouts/intervals have run for <b>${timeFormat(sum)} (${(sum/duration*100).toFixed(2)}%)</b>. Percentages are calculated from summarized timeout/interval running time.
|
||||||
</div>
|
</div>
|
||||||
<table class="table table-striped table-hover">
|
|
||||||
<thead>
|
<div class="table_wrapper">
|
||||||
<tr>
|
|
||||||
<th>Time</th>
|
<table class="table table-striped table-hover">
|
||||||
<th>Percentage</th>
|
<thead>
|
||||||
<th>Function</th>
|
<tr>
|
||||||
</tr>
|
<th>Time</th>
|
||||||
</thead>
|
<th>Percentage</th>
|
||||||
<tbody>\n`;
|
<th>Function</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>\n`;
|
||||||
htmlOverview += tableRows;
|
htmlOverview += tableRows;
|
||||||
htmlOverview += `</tbody></table>`;
|
htmlOverview += `</tbody></table></div>`;
|
||||||
domContent.innerHTML = htmlOverview;
|
domContent.innerHTML = htmlOverview;
|
||||||
domContent.querySelector("#back").addEventListener("click",event => {
|
domContent.querySelector("#back").addEventListener("click",event => {
|
||||||
show();
|
show();
|
||||||
|
|
@ -234,24 +246,46 @@ function viewDetailsTable(filename) {
|
||||||
Util.hideModal();
|
Util.hideModal();
|
||||||
|
|
||||||
var htmlOverview = `<h1>Detailed logging</h1>
|
var htmlOverview = `<h1>Detailed logging</h1>
|
||||||
|
|
||||||
This is a trace log of all logged power entries, first column denotes the type. p for power, i for interval and t for timeout. Power is logged with old state, new state and calling app if available. Functions are logged with execution duraion and source if available.
|
|
||||||
|
|
||||||
<button class="btn btn-primary" id="back" style="float: right;margin-right: 5px;">Back</button>
|
<button class="btn btn-primary" id="back" style="float: right;margin-right: 5px;">Back</button>
|
||||||
<table class="table table-striped table-hover">
|
<div>
|
||||||
<tbody>\n`;
|
This is a trace log of all logged entries. Power is logged with type, state transition (old → new) and calling app if available. Functions are logged with execution duration and source if available.
|
||||||
|
</div>
|
||||||
|
<div class="table_wrapper">
|
||||||
|
|
||||||
|
<table class="table table-striped table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Time</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Info</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>\n`;
|
||||||
let rows = data.trim().split("\n");
|
let rows = data.trim().split("\n");
|
||||||
|
let firstTimestamp;
|
||||||
for (var row of rows) {
|
for (var row of rows) {
|
||||||
let cols = row.split(",");
|
let cols = row.split(",");
|
||||||
htmlOverview += `<tr>
|
let col = 0;
|
||||||
<td>${cols[0]}</td>
|
if (!firstTimestamp) firstTimestamp = cols[0];
|
||||||
<td>${cols[1]}</td>
|
|
||||||
<td>${cols[2]}</td>
|
if (cols[1] == "p"){
|
||||||
<td>${cols[3]}</td>
|
cols[1] = "Power";
|
||||||
<td>${cols[4]}</td>
|
htmlOverview += `<tr>
|
||||||
</tr>`
|
<td>${timeFormat(cols[col++]-firstTimestamp)}</td>
|
||||||
|
<td>${cols[col++]}</td>
|
||||||
|
<td>${cols[col++]}</br>${cols[col++]} → ${cols[col++]}</br>${cols[col++]}</td>
|
||||||
|
</tr>`
|
||||||
|
} else {
|
||||||
|
htmlOverview += `<tr>
|
||||||
|
<td>${timeFormat(cols[col++]-firstTimestamp)}</td>
|
||||||
|
<td>${cols[col++]=="t"?"Timeout":"Interval"}</td>
|
||||||
|
<td>${new Number(cols[col++]).toFixed(0)}ms</br><pre>${cols[col++]}</pre></td>
|
||||||
|
</tr>`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
htmlOverview += `</tbody></table>`;
|
htmlOverview += `</tbody></table></div>`;
|
||||||
|
|
||||||
|
|
||||||
domContent.innerHTML = htmlOverview;
|
domContent.innerHTML = htmlOverview;
|
||||||
domContent.querySelector("#back").addEventListener("click",event => {
|
domContent.querySelector("#back").addEventListener("click",event => {
|
||||||
show();
|
show();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "powermanager",
|
"id": "powermanager",
|
||||||
"name": "Power Manager",
|
"name": "Power Manager",
|
||||||
"shortName": "Power Manager",
|
"shortName": "Power Manager",
|
||||||
"version": "0.09",
|
"version": "0.10",
|
||||||
"description": "Allow configuration of warnings and thresholds for battery charging and display.",
|
"description": "Allow configuration of warnings and thresholds for battery charging and display.",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"type": "bootloader",
|
"type": "bootloader",
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,19 @@
|
||||||
onchange: v => {
|
onchange: v => {
|
||||||
writeSettings("logDetails", v);
|
writeSettings("logDetails", v);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'Clear logs': function (){
|
||||||
|
E.showPrompt("Delete logs and reload?").then((v)=>{
|
||||||
|
if (v) {
|
||||||
|
require('Storage').open("powermanager.log","w").erase();
|
||||||
|
require("Storage").erase("powermanager.def.json");
|
||||||
|
require("Storage").erase("powermanager.hw.json");
|
||||||
|
load();
|
||||||
|
} else
|
||||||
|
E.showMenu(submenu_logging);
|
||||||
|
}).catch(()=>{
|
||||||
|
E.showMenu(submenu_logging);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue