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

Fix VTX ready status (#3538)

* Fix VTX ready status

* i18n is case-sensitive

* Cannot replicate

* Remove initial status
This commit is contained in:
Mark Haslinghuis 2023-08-02 22:12:28 +02:00 committed by GitHub
parent 92a8748621
commit 26e78ed97a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 26 deletions

View file

@ -27,39 +27,30 @@ const vtx = {
analyticsChanges: {},
updating: true,
env: new djv(),
get _DEVICE_STATUS_UPDATE_INTERVAL_NAME() {
return "vtx_device_status_request";
},
};
vtx.isVtxDeviceStatusNotReady = function()
{
vtx.isVtxDeviceStatusReady = function() {
const isReady = (null !== FC.VTX_DEVICE_STATUS) && (FC.VTX_DEVICE_STATUS.deviceIsReady);
return !isReady;
return !!isReady;
};
vtx.updateVtxDeviceStatus = function()
{
function vtxDeviceStatusReceived()
{
vtx.updateVtxDeviceStatus = function() {
function vtxDeviceStatusReceived() {
$("#vtx_type_description").text(TABS.vtx.getVtxTypeString());
}
function vtxDeviceStatusReady()
{
const vtxReady_e = $('.VTX_info span.colorToggle');
const isReady = vtx.isVtxDeviceStatusReady();
// update device ready state
vtxReady_e.text(FC.VTX_CONFIG.vtx_device_ready ? i18n.getMessage('vtxReadyTrue') : i18n.getMessage('vtxReadyFalse'));
vtxReady_e.toggleClass('ready', FC.VTX_CONFIG.vtx_device_ready);
vtxReady_e.text(isReady ? i18n.getMessage('vtxReadyTrue') : i18n.getMessage('vtxReadyFalse'));
vtxReady_e.toggleClass('ready', isReady);
}
MSP.send_message(MSPCodes.MSP2_GET_VTX_DEVICE_STATUS, false, false, vtxDeviceStatusReceived);
MSP.send_message(MSPCodes.MSP_VTX_CONFIG, false, false, vtxDeviceStatusReady);
};
vtx.getVtxTypeString = function()
{
vtx.getVtxTypeString = function() {
let result = i18n.getMessage(`vtxType_${FC.VTX_CONFIG.vtx_type}`);
const isSmartAudio = VtxDeviceTypes.VTXDEV_SMARTAUDIO === FC.VTX_CONFIG.vtx_type;
@ -118,11 +109,7 @@ vtx.initialize = function (callback) {
function vtxConfigReceived() {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
GUI.interval_add_condition(self._DEVICE_STATUS_UPDATE_INTERVAL_NAME,
TABS.vtx.updateVtxDeviceStatus,
1000, false,
TABS.vtx.isVtxDeviceStatusNotReady,
);
vtx.intervalId = setInterval(vtx.updateVtxDeviceStatus, 1000);
}
vtxtable_bands();
@ -306,7 +293,7 @@ vtx.initialize = function (callback) {
$("#vtx_type_description").text(self.getVtxTypeString());
$("#vtx_channel_description").text(FC.VTX_CONFIG.vtx_channel);
$("#vtx_frequency_description").text(FC.VTX_CONFIG.vtx_frequency);
$("#vtx_pit_mode_description").text(FC.VTX_CONFIG.vtx_pit_mode ? i18n.getMessage("Yes") : i18n.getMessage("No"));
$("#vtx_pit_mode_description").text(FC.VTX_CONFIG.vtx_pit_mode ? i18n.getMessage("yes") : i18n.getMessage("no"));
$("#vtx_pit_mode_frequency_description").text(FC.VTX_CONFIG.vtx_pit_mode_frequency);
$("#vtx_low_power_disarm_description").text(i18n.getMessage(`vtxLowPowerDisarmOption_${FC.VTX_CONFIG.vtx_low_power_disarm}`));
@ -915,6 +902,8 @@ vtx.initialize = function (callback) {
saveButton.html(i18n.getMessage('vtxButtonSaving')).addClass('disabled');
clearInterval(TABS.vtx.intervalId);
// Allow firmware to make relevant changes before initialization
setTimeout(() => {
saveButton.html(i18n.getMessage('vtxButtonSaved'));
@ -1048,7 +1037,7 @@ vtx.cleanup = function (callback) {
this.VTXTABLE_BAND_LIST = [];
this.VTXTABLE_POWERLEVEL_LIST = [];
GUI.interval_remove(this._DEVICE_STATUS_UPDATE_INTERVAL_NAME);
clearInterval(this.intervalId);
if (callback) {
callback();

View file

@ -130,7 +130,7 @@
<tbody>
<tr>
<td class="description_text" i18n="vtxDeviceReady"></td>
<td><span class="colorToggle" i18n="vtxReadyFalse"></span></td>
<td><span class="colorToggle"></span></td>
</tr>
<tr class="description vtx_type">
<td class="description_text" i18n="vtxType"></td>