1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-23 16:25:22 +03:00

Better representation of battery low

This commit is contained in:
Miguel Angel Mulero Martinez 2019-09-23 13:08:43 +02:00
parent 2395c7a216
commit eb65261126
2 changed files with 58 additions and 30 deletions

View file

@ -1827,7 +1827,7 @@ dialog {
color: white;
font-size: 10px;
margin-top: 20px;
width: 90px;
min-width: 90px;
float: right;
margin-right: 10px;
line-height: 12px;
@ -1851,8 +1851,7 @@ dialog {
margin-top: 10px;
margin-left: 14px;
height: 10px;
width: 30px;
/* width: 30px; */
width: 31px;
}
@ -1867,6 +1866,7 @@ dialog {
text-align: left;
color: silver;
margin-left: -8px;
padding-right: 4px
}
.quad-status-contents progress::-webkit-progress-bar {
@ -1880,12 +1880,26 @@ dialog {
.battery-status {
height: 11px;
position: relative;
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.20);
border-radius: 0px;
background-color: var(--accent);
/* border-radius: 4px; */
margin-top: 0px;
}
.battery-status.state-ok {
background-color: #59AA29;
}
.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 {
@ -1901,14 +1915,13 @@ dialog {
background-repeat: no-repeat;
}
.armedicon,
.failsafeicon,
.linkicon {
float: left;
margin-left: 8px;
margin-right: 2px;
margin-right: 8px;
margin-top: 6px;
display: block;
height: 18px;
width: 18px;
opacity: 0.8;
@ -1929,6 +1942,8 @@ dialog {
}
.bottomStatusIcons {
display: flex;
justify-content: space-between;
background-color: #272727;
height: 31px;
margin-top: 2px;

View file

@ -646,20 +646,42 @@ function update_live_status() {
});
}
}
if (ANALOG != undefined) {
var nbCells = Math.floor(ANALOG.voltage / BATTERY_CONFIG.vbatmaxcellvoltage) + 1;
if (ANALOG.voltage == 0)
if (ANALOG.voltage == 0) {
nbCells = 1;
}
var min = BATTERY_CONFIG.vbatmincellvoltage * nbCells;
var max = BATTERY_CONFIG.vbatmaxcellvoltage * nbCells;
var warn = BATTERY_CONFIG.vbatwarningcellvoltage * nbCells;
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
if (ANALOG.voltage < min && ANALOG.voltage > NO_BATTERY_VOLTAGE_MAXIMUM) {
$(".battery-status").addClass('state-empty').removeClass('state-ok').removeClass('state-warning');
$(".battery-status").css({
width: "100%",
});
} else {
$(".battery-status").css({
width: ((ANALOG.voltage - min) / (max - min) * 100) + "%",
display: 'inline-block'
});
if (ANALOG.voltage < warn) {
$(".battery-status").addClass('state-warning').removeClass('state-empty').removeClass('state-ok');
} else {
$(".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 + ")");
}
if (active) {
$(".linkicon").css({
'background-image': 'url(images/icons/cf_icon_link_active.svg)'
@ -670,15 +692,6 @@ function update_live_status() {
});
}
if (ANALOG.voltage < warn) {
$(".battery-status").css('background-color', '#D42133');
} else {
$(".battery-status").css('background-color', '#59AA29');
}
$(".battery-legend").text(ANALOG.voltage + " V");
}
statuswrapper.show();
GUI.timeout_remove('data_refresh');
startLiveDataRefreshTimer();