mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-07 12:07:09 +03:00
add battery indicator
This commit is contained in:
1
components/wifi-manager/battery-0.svg
Normal file
1
components/wifi-manager/battery-0.svg
Normal 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 |
1
components/wifi-manager/battery-1.svg
Normal file
1
components/wifi-manager/battery-1.svg
Normal 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 |
1
components/wifi-manager/battery-2.svg
Normal file
1
components/wifi-manager/battery-2.svg
Normal 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 |
1
components/wifi-manager/battery-3.svg
Normal file
1
components/wifi-manager/battery-3.svg
Normal 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 |
1
components/wifi-manager/battery-4.svg
Normal file
1
components/wifi-manager/battery-4.svg
Normal 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 |
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user