add battery indicator

This commit is contained in:
Christian Herzog
2019-12-27 20:31:09 +01:00
parent 17a063592f
commit 992c8d2679
8 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 8v8h-17v-8h17zm2-2h-21v12h21v-12zm1 9h.75c.69 0 1.25-.56 1.25-1.25v-3.5c0-.69-.56-1.25-1.25-1.25h-.75v6z"/></svg>

After

Width:  |  Height:  |  Size: 209 B

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 8v8h-17v-8h17zm2-2h-21v12h21v-12zm1 9h.75c.69 0 1.25-.56 1.25-1.25v-3.5c0-.69-.56-1.25-1.25-1.25h-.75v6zm-16-6h-3v6h3v-6z"/></svg>

After

Width:  |  Height:  |  Size: 226 B

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 8v8h-17v-8h17zm2-2h-21v12h21v-12zm1 9h.75c.69 0 1.25-.56 1.25-1.25v-3.5c0-.69-.56-1.25-1.25-1.25h-.75v6zm-16-6h-3v6h3v-6zm4 0h-3v6h3v-6z"/></svg>

After

Width:  |  Height:  |  Size: 241 B

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 8v8h-17v-8h17zm2-2h-21v12h21v-12zm1 9h.75c.69 0 1.25-.56 1.25-1.25v-3.5c0-.69-.56-1.25-1.25-1.25h-.75v6zm-16-6h-3v6h3v-6zm4 0h-3v6h3v-6zm4 0h-3v6h3v-6z"/></svg>

After

Width:  |  Height:  |  Size: 256 B

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 8v8h-17v-8h17zm2-2h-21v12h21v-12zm1 9h.75c.69 0 1.25-.56 1.25-1.25v-3.5c0-.69-.56-1.25-1.25-1.25h-.75v6zm-16-6h-3v6h3v-6zm4 0h-3v6h3v-6zm4 0h-3v6h3v-6zm4 0h-3v6h3v-6z"/></svg>

After

Width:  |  Height:  |  Size: 271 B

View File

@@ -706,6 +706,24 @@ function checkStatus(){
lastMsg = msg;
}
}
if (data.hasOwnProperty('Voltage')) {
var voltage = data['Voltage'];
var i;
if (voltage > 0) {
if (inRange(voltage, 5.8, 6.2) || inRange(voltage, 8.8, 9.2)) {
i = 0;
} else if (inRange(voltage, 6.2, 6.8) || inRange(voltage, 9.2, 10.0)) {
i = 1;
} else if (inRange(voltage, 6.8, 7.1) || inRange(voltage, 10.0, 10.5)) {
i = 2;
} else if (inRange(voltage, 7.1, 7.5) || inRange(voltage, 10.5, 11.0)) {
i = 3;
} else {
i = 4;
}
$("#battery").html('<img src="battery-'+i+'.svg" />');
}
}
blockAjax = false;
})
.fail(function(xhr, ajaxOptions, thrownError) {
@@ -778,3 +796,7 @@ function showMessage(message, severity) {
});
});
}
function inRange(x, min, max) {
return ((x-min)*(x-max) <= 0);
}

View File

@@ -24,6 +24,7 @@
</head>
<body>
<div id="battery"></div>
<ul id="navbar" class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#tab-wifi">WiFi</a>

View File

@@ -308,6 +308,19 @@ span#flash-status {
font-size: 120%;
}
#battery {
padding-top: 7px;
float: right;
}
ul#navbar {
border-bottom: 0px;
}
#content {
border-top: 1px solid black;
}
.footer {
position: fixed;
left: 0;