1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-24 00:35:26 +03:00

Better representation of battery low (#1683)

Better representation of battery low
This commit is contained in:
Michael Keller 2019-10-15 08:39:29 +13:00 committed by GitHub
commit 456ae7e540
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 30 deletions

View file

@ -1831,7 +1831,7 @@ dialog {
color: white; color: white;
font-size: 10px; font-size: 10px;
margin-top: 20px; margin-top: 20px;
width: 90px; min-width: 90px;
float: right; float: right;
margin-right: 10px; margin-right: 10px;
line-height: 12px; line-height: 12px;
@ -1855,8 +1855,7 @@ dialog {
margin-top: 10px; margin-top: 10px;
margin-left: 14px; margin-left: 14px;
height: 10px; height: 10px;
width: 30px; width: 31px;
/* width: 30px; */
} }
@ -1871,6 +1870,7 @@ dialog {
text-align: left; text-align: left;
color: silver; color: silver;
margin-left: -8px; margin-left: -8px;
padding-right: 4px
} }
.quad-status-contents progress::-webkit-progress-bar { .quad-status-contents progress::-webkit-progress-bar {
@ -1884,12 +1884,26 @@ dialog {
.battery-status { .battery-status {
height: 11px; height: 11px;
position: relative; }
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.20);
border-radius: 0px; .battery-status.state-ok {
background-color: var(--accent); background-color: #59AA29;
/* border-radius: 4px; */ }
margin-top: 0px; .battery-status.state-warning {
background-color: var(--error);
}
.battery-status.state-empty {
animation: error-blinker 1s linear infinite;
}
@keyframes error-blinker {
0% {
background-color: none;
}
50% {
background-color: var(--error);
}
} }
.battery-icon { .battery-icon {
@ -1905,14 +1919,13 @@ dialog {
background-repeat: no-repeat; background-repeat: no-repeat;
} }
.armedicon, .armedicon,
.failsafeicon, .failsafeicon,
.linkicon { .linkicon {
float: left;
margin-left: 8px; margin-left: 8px;
margin-right: 2px; margin-right: 8px;
margin-top: 6px; margin-top: 6px;
display: block;
height: 18px; height: 18px;
width: 18px; width: 18px;
opacity: 0.8; opacity: 0.8;
@ -1933,6 +1946,8 @@ dialog {
} }
.bottomStatusIcons { .bottomStatusIcons {
display: flex;
justify-content: space-between;
background-color: #272727; background-color: #272727;
height: 31px; height: 31px;
margin-top: 2px; margin-top: 2px;

View file

@ -646,37 +646,50 @@ function update_live_status() {
}); });
} }
} }
if (ANALOG != undefined) { if (ANALOG != undefined) {
var nbCells = Math.floor(ANALOG.voltage / BATTERY_CONFIG.vbatmaxcellvoltage) + 1; var nbCells = Math.floor(ANALOG.voltage / BATTERY_CONFIG.vbatmaxcellvoltage) + 1;
if (ANALOG.voltage == 0)
nbCells = 1; if (ANALOG.voltage == 0) {
nbCells = 1;
}
var min = BATTERY_CONFIG.vbatmincellvoltage * nbCells; var min = BATTERY_CONFIG.vbatmincellvoltage * nbCells;
var max = BATTERY_CONFIG.vbatmaxcellvoltage * nbCells; var max = BATTERY_CONFIG.vbatmaxcellvoltage * nbCells;
var warn = BATTERY_CONFIG.vbatwarningcellvoltage * nbCells; var warn = BATTERY_CONFIG.vbatwarningcellvoltage * nbCells;
$(".battery-status").css({ const NO_BATTERY_VOLTAGE_MAXIMUM = 0.5; // Maybe is better to add a call to MSP_BATTERY_STATE but is not available for all versions
width: ((ANALOG.voltage - min) / (max - min) * 100) + "%",
display: 'inline-block'
});
if (active) { if (ANALOG.voltage < min && ANALOG.voltage > NO_BATTERY_VOLTAGE_MAXIMUM) {
$(".linkicon").css({ $(".battery-status").addClass('state-empty').removeClass('state-ok').removeClass('state-warning');
'background-image': 'url(images/icons/cf_icon_link_active.svg)' $(".battery-status").css({
width: "100%",
}); });
} else { } else {
$(".linkicon").css({ $(".battery-status").css({
'background-image': 'url(images/icons/cf_icon_link_grey.svg)' width: ((ANALOG.voltage - min) / (max - min) * 100) + "%",
}); });
}
if (ANALOG.voltage < warn) { if (ANALOG.voltage < warn) {
$(".battery-status").css('background-color', '#D42133'); $(".battery-status").addClass('state-warning').removeClass('state-empty').removeClass('state-ok');
} else { } else {
$(".battery-status").css('background-color', '#59AA29'); $(".battery-status").addClass('state-ok').removeClass('state-warning').removeClass('state-empty');
}
} }
let cellsText = (ANALOG.voltage > NO_BATTERY_VOLTAGE_MAXIMUM)? nbCells + 'S' : 'USB';
$(".battery-legend").text(ANALOG.voltage.toFixed(2) + "V (" + cellsText + ")");
$(".battery-legend").text(ANALOG.voltage + " V"); }
if (active) {
$(".linkicon").css({
'background-image': 'url(images/icons/cf_icon_link_active.svg)'
});
} else {
$(".linkicon").css({
'background-image': 'url(images/icons/cf_icon_link_grey.svg)'
});
} }
statuswrapper.show(); statuswrapper.show();