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

Fix HD selection in UI (#3106)

This commit is contained in:
haslinghuis 2022-12-05 04:23:58 +01:00 committed by GitHub
parent cc146068c9
commit a7b53afe13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 33 deletions

View file

@ -1729,6 +1729,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
OSD.data.VIDEO_BUFFER_CHARS['HD'] = OSD.data.VIDEO_COLS['HD'] * OSD.data.VIDEO_ROWS['HD']; OSD.data.VIDEO_BUFFER_CHARS['HD'] = OSD.data.VIDEO_COLS['HD'] * OSD.data.VIDEO_ROWS['HD'];
console.log(`Canvas ${OSD.data.VIDEO_COLS['HD']} x ${OSD.data.VIDEO_ROWS['HD']}`); console.log(`Canvas ${OSD.data.VIDEO_COLS['HD']} x ${OSD.data.VIDEO_ROWS['HD']}`);
break; break;
case MSPCodes.MSP_SET_OSD_CANVAS:
console.log('OSD Canvas config set');
break;
case MSPCodes.MSP_OSD_CONFIG: case MSPCodes.MSP_OSD_CONFIG:
break; break;
case MSPCodes.MSP_SET_OSD_CONFIG: case MSPCodes.MSP_SET_OSD_CONFIG:

View file

@ -2694,12 +2694,6 @@ OSD.GUI.preview = {
}, },
}; };
async function getCanvas() {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
return MSP.promise(MSPCodes.MSP_OSD_CANVAS);
}
}
const osd = { const osd = {
analyticsChanges: {}, analyticsChanges: {},
}; };
@ -2797,12 +2791,16 @@ osd.initialize = function(callback) {
// 2 way binding... sorta // 2 way binding... sorta
function updateOsdView() { function updateOsdView() {
// ask for the OSD canvas data // ask for the OSD canvas data
getCanvas(); let p;
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
p = MSP.promise(MSPCodes.MSP_OSD_CANVAS);
}
// ask for the OSD config data // ask for the OSD config data
MSP.promise(MSPCodes.MSP_OSD_CONFIG) p.then(() => MSP.promise(MSPCodes.MSP_OSD_CONFIG))
.then(function(info) { .then(info => {
OSD.chooseFields(); OSD.chooseFields();
@ -2838,9 +2836,7 @@ osd.initialize = function(callback) {
$videoTypes.find(':radio').click(function() { $videoTypes.find(':radio').click(function() {
OSD.data.video_system = $(this).data('type'); OSD.data.video_system = $(this).data('type');
MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeOther()) MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeOther())
.then(function() { .then(updateOsdView);
updateOsdView();
});
}); });
if (semver.gte(FC.CONFIG.apiVersion, "1.21.0")) { if (semver.gte(FC.CONFIG.apiVersion, "1.21.0")) {
@ -2861,9 +2857,7 @@ osd.initialize = function(callback) {
$unitMode.find(':radio').click(function() { $unitMode.find(':radio').click(function() {
OSD.data.unit_mode = $(this).data('type'); OSD.data.unit_mode = $(this).data('type');
MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeOther()) MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeOther())
.then(function() { .then(updateOsdView);
updateOsdView();
});
}); });
// alarms // alarms
$('.alarms-container').show(); $('.alarms-container').show();
@ -2875,9 +2869,7 @@ osd.initialize = function(callback) {
alarmInput.focusout(function() { alarmInput.focusout(function() {
OSD.data.alarms[$(this)[0].id].value = $(this)[0].value; OSD.data.alarms[$(this)[0].id].value = $(this)[0].value;
MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeOther()) MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeOther())
.then(function() { .then(updateOsdView);
updateOsdView();
});
}); });
const $input = $('<label/>').append(alarmInput); const $input = $('<label/>').append(alarmInput);
$alarms.append($input); $alarms.append($input);
@ -2911,9 +2903,7 @@ osd.initialize = function(callback) {
const idx = $(this)[0].id.split("_")[1]; const idx = $(this)[0].id.split("_")[1];
OSD.data.timers[idx].src = $(this)[0].selectedIndex; OSD.data.timers[idx].src = $(this)[0].selectedIndex;
MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeTimer(OSD.data.timers[idx])) MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeTimer(OSD.data.timers[idx]))
.then(function() { .then(updateOsdView);
updateOsdView();
});
}); });
sourceTimerTableData.append(src); sourceTimerTableData.append(src);
timerTableRow.append(sourceTimerTableData); timerTableRow.append(sourceTimerTableData);
@ -2934,9 +2924,7 @@ osd.initialize = function(callback) {
const idx = $(this)[0].id.split("_")[1]; const idx = $(this)[0].id.split("_")[1];
OSD.data.timers[idx].precision = $(this)[0].selectedIndex; OSD.data.timers[idx].precision = $(this)[0].selectedIndex;
MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeTimer(OSD.data.timers[idx])) MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeTimer(OSD.data.timers[idx]))
.then(function() { .then(updateOsdView);
updateOsdView();
});
}); });
precisionTimerTableData.append(precision); precisionTimerTableData.append(precision);
timerTableRow.append('<td></td>'); timerTableRow.append('<td></td>');
@ -2954,9 +2942,7 @@ osd.initialize = function(callback) {
const idx = $(this)[0].id.split("_")[1]; const idx = $(this)[0].id.split("_")[1];
OSD.data.timers[idx].alarm = $(this)[0].value; OSD.data.timers[idx].alarm = $(this)[0].value;
MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeTimer(OSD.data.timers[idx])) MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeTimer(OSD.data.timers[idx]))
.then(function() { .then(updateOsdView);
updateOsdView();
});
}); });
alarmTimerTableData.append(alarm); alarmTimerTableData.append(alarm);
timerTableRow.append('<td></td>'); timerTableRow.append('<td></td>');
@ -2998,9 +2984,7 @@ osd.initialize = function(callback) {
self.analyticsChanges[`OSDStatistic${fieldChanged.name}`] += fieldChanged.enabled ? 1 : -1; self.analyticsChanges[`OSDStatistic${fieldChanged.name}`] += fieldChanged.enabled ? 1 : -1;
MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeStatistics(fieldChanged)) MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeStatistics(fieldChanged))
.then(function() { .then(updateOsdView);
updateOsdView();
});
}), }),
); );
$field.append(`<label for="${field.name}" class="char-label">${titleizeField(field)}</label>`); $field.append(`<label for="${field.name}" class="char-label">${titleizeField(field)}</label>`);
@ -3042,9 +3026,7 @@ osd.initialize = function(callback) {
self.analyticsChanges[`OSDWarning${fieldChanged.name}`] += fieldChanged.enabled ? 1 : -1; self.analyticsChanges[`OSDWarning${fieldChanged.name}`] += fieldChanged.enabled ? 1 : -1;
MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeOther()) MSP.promise(MSPCodes.MSP_SET_OSD_CONFIG, OSD.msp.encodeOther())
.then(function() { .then(updateOsdView);
updateOsdView();
});
}), }),
); );