Skip to content

Commit

Permalink
Increment minimal supported API to 1_44 (firmware 4.3) (4/4) (betafli…
Browse files Browse the repository at this point in the history
…ght#4011)

* Increment supported API - MSP and others

* Cleanup webstm32

* Cleanup AutoDetect

* Cleanup Setup

* Fix indentation
  • Loading branch information
haslinghuis authored Jun 7, 2024
1 parent 63b2eb0 commit e806299
Show file tree
Hide file tree
Showing 12 changed files with 304 additions and 422 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { i18n } from "../../js/localization.js";
import GUI from "../../js/gui.js";
import semver from "semver";
import EscDshotDirectionMotorDriver from "./EscDshotDirectionMotorDriver.js";
import DshotCommand from "../../js/utils/DshotCommand.js";
import FC from "../../js/fc.js";
import { API_VERSION_1_44 } from '../../js/data_storage.js';
import { getMixerImageSrc } from "../../js/utils/common.js";
import $ from "jquery";

Expand Down Expand Up @@ -339,12 +337,6 @@ class EscDshotDirectionComponent
this._domWrongMixerMessage.show();
}

if (!semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
// if BF4.2 or older - show the error message
anyError = true;
this._domWrongFirmwareMessage.show();
}

if (anyError) {
this._domMainContentBlock.hide();
this._domWarningContentBlock.hide();
Expand Down
8 changes: 1 addition & 7 deletions src/js/Features.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bit_check, bit_set, bit_clear } from "./bit";
import { API_VERSION_1_44, API_VERSION_1_45, API_VERSION_1_46 } from './data_storage';
import { API_VERSION_1_45, API_VERSION_1_46 } from './data_storage';
import semver from "semver";
import { tracking } from "./Analytics";
import $ from 'jquery';
Expand Down Expand Up @@ -32,12 +32,6 @@ const Features = function (config) {
{bit: 28, group: 'antiGravity', name: 'ANTI_GRAVITY', haveTip: true, hideName: true},
];

if (semver.lt(config.apiVersion, API_VERSION_1_44)) { // DYNAMIC_FILTER got removed from FEATURES in BF 4.3 / API 1.44
features.push(
{bit: 29, group: 'other', name: 'DYNAMIC_FILTER'},
);
}

self._features = features;

if (config.buildOptions?.length) {
Expand Down
73 changes: 33 additions & 40 deletions src/js/RateCurve.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import FC from "./fc";
import { API_VERSION_1_43 } from "./data_storage";
import semver from "semver";

const minRc = 1000;
const midRc = 1500;
const maxRc = 2000;

const RateCurve = function (useLegacyCurve) {
this.useLegacyCurve = useLegacyCurve;
this.maxAngularVel = null;
Expand Down Expand Up @@ -168,39 +167,37 @@ const RateCurve = function (useLegacyCurve) {

currentRates.superexpo = true;

if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
switch (FC.RC_TUNING.rates_type) {
case FC.RATES_TYPE.RACEFLIGHT:
currentRates.roll_rate *= 100;
currentRates.pitch_rate *= 100;
currentRates.yaw_rate *= 100;
currentRates.rc_rate *= 1000;
currentRates.rc_rate_yaw *= 1000;
currentRates.rc_rate_pitch *= 1000;
currentRates.rc_expo *= 100;
currentRates.rc_yaw_expo *= 100;
currentRates.rc_pitch_expo *= 100;

break;
case FC.RATES_TYPE.ACTUAL:
currentRates.roll_rate *= 1000;
currentRates.pitch_rate *= 1000;
currentRates.yaw_rate *= 1000;
currentRates.rc_rate *= 1000;
currentRates.rc_rate_yaw *= 1000;
currentRates.rc_rate_pitch *= 1000;

break;
case FC.RATES_TYPE.QUICKRATES:
currentRates.roll_rate *= 1000;
currentRates.pitch_rate *= 1000;
currentRates.yaw_rate *= 1000;

break;
default: // add future rates types here

break;
}
switch (FC.RC_TUNING.rates_type) {
case FC.RATES_TYPE.RACEFLIGHT:
currentRates.roll_rate *= 100;
currentRates.pitch_rate *= 100;
currentRates.yaw_rate *= 100;
currentRates.rc_rate *= 1000;
currentRates.rc_rate_yaw *= 1000;
currentRates.rc_rate_pitch *= 1000;
currentRates.rc_expo *= 100;
currentRates.rc_yaw_expo *= 100;
currentRates.rc_pitch_expo *= 100;

break;
case FC.RATES_TYPE.ACTUAL:
currentRates.roll_rate *= 1000;
currentRates.pitch_rate *= 1000;
currentRates.yaw_rate *= 1000;
currentRates.rc_rate *= 1000;
currentRates.rc_rate_yaw *= 1000;
currentRates.rc_rate_pitch *= 1000;

break;
case FC.RATES_TYPE.QUICKRATES:
currentRates.roll_rate *= 1000;
currentRates.pitch_rate *= 1000;
currentRates.yaw_rate *= 1000;

break;
default: // add future rates types here

break;
}

return currentRates;
Expand All @@ -212,11 +209,7 @@ RateCurve.prototype.rcCommandRawToDegreesPerSecond = function (rcData, rate, rcR

if (rate !== undefined && rcRate !== undefined && rcExpo !== undefined) {
let rcCommandf = this.rcCommand(rcData, 1, deadband);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
rcCommandf = rcCommandf / (500 - deadband);
} else {
rcCommandf = rcCommandf / 500;
}
rcCommandf /= (500 - deadband);

const rcCommandfAbs = Math.abs(rcCommandf);

Expand Down
5 changes: 0 additions & 5 deletions src/js/data_storage.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
export const API_VERSION_1_39 = '1.39.0';
export const API_VERSION_1_40 = '1.40.0';

export const API_VERSION_1_41 = '1.41.0';
export const API_VERSION_1_42 = '1.42.0';
export const API_VERSION_1_43 = '1.43.0';
export const API_VERSION_1_44 = '1.44.0';
export const API_VERSION_1_45 = '1.45.0';
export const API_VERSION_1_46 = '1.46.0';
Expand Down
90 changes: 35 additions & 55 deletions src/js/fc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bit_check } from "./bit";
import { API_VERSION_1_42, API_VERSION_1_43, API_VERSION_1_44, API_VERSION_1_45, API_VERSION_1_46 } from './data_storage';
import { API_VERSION_1_45, API_VERSION_1_46 } from './data_storage';
import semver from "semver";

const INITIAL_CONFIG = {
Expand Down Expand Up @@ -803,16 +803,10 @@ const FC = {
'SPEKTRUM2048/SRXL',
'TARGET_CUSTOM',
'FPORT',
'SPEKTRUM SRXL2',
'IRC GHOST',
];

if (semver.gte(apiVersion, API_VERSION_1_42)) {
serialRxTypes.push('SPEKTRUM SRXL2');
}

if (semver.gte(apiVersion, API_VERSION_1_44)) {
serialRxTypes.push('IRC GHOST');
}

if (semver.gte(apiVersion, API_VERSION_1_46)) {
// Default to NONE and move SPEKTRUM1024 to the end (firmware PR #12500)
serialRxTypes[0] = 'NONE';
Expand Down Expand Up @@ -907,12 +901,7 @@ const FC = {
},

boardHasFlashBootloader() {
let hasFlashBootloader = false;
if (semver.gte(this.CONFIG.apiVersion, API_VERSION_1_42)) {
hasFlashBootloader = bit_check(this.CONFIG.targetCapabilities, this.TARGET_CAPABILITIES_FLAGS.HAS_FLASH_BOOTLOADER);
}

return hasFlashBootloader;
return bit_check(this.CONFIG.targetCapabilities, this.TARGET_CAPABILITIES_FLAGS.HAS_FLASH_BOOTLOADER);
},

FILTER_TYPE_FLAGS: {
Expand All @@ -932,31 +921,30 @@ const FC = {
versionFilterDefaults.dterm_lowpass2_hz = 150;
versionFilterDefaults.dterm_lowpass2_type = this.FILTER_TYPE_FLAGS.BIQUAD;

if (semver.gte(this.CONFIG.apiVersion, API_VERSION_1_42)) {
versionFilterDefaults.gyro_lowpass_hz = 200;
versionFilterDefaults.gyro_lowpass_dyn_min_hz = 200;
versionFilterDefaults.gyro_lowpass_dyn_max_hz = 500;
versionFilterDefaults.gyro_lowpass_type = this.FILTER_TYPE_FLAGS.PT1;
versionFilterDefaults.gyro_lowpass2_hz = 250;
versionFilterDefaults.gyro_lowpass2_type = this.FILTER_TYPE_FLAGS.PT1;
versionFilterDefaults.dterm_lowpass_hz = 150;
versionFilterDefaults.dterm_lowpass_dyn_min_hz = 70;
versionFilterDefaults.dterm_lowpass_dyn_max_hz = 170;
versionFilterDefaults.dterm_lowpass_type = this.FILTER_TYPE_FLAGS.PT1;
versionFilterDefaults.dterm_lowpass2_hz = 150;
versionFilterDefaults.dterm_lowpass2_type = this.FILTER_TYPE_FLAGS.PT1;
}

if (semver.gte(this.CONFIG.apiVersion, API_VERSION_1_44)) {
versionFilterDefaults.dyn_notch_q = 300;
versionFilterDefaults.gyro_lowpass_hz = 250;
versionFilterDefaults.gyro_lowpass_dyn_min_hz = 250;
versionFilterDefaults.gyro_lowpass2_hz = 500;
versionFilterDefaults.dterm_lowpass_hz = 75;
versionFilterDefaults.dterm_lowpass_dyn_min_hz = 75;
versionFilterDefaults.dterm_lowpass_dyn_max_hz = 150;
}

// Introduced in 1.42
versionFilterDefaults.gyro_lowpass_hz = 200;
versionFilterDefaults.gyro_lowpass_dyn_min_hz = 200;
versionFilterDefaults.gyro_lowpass_dyn_max_hz = 500;
versionFilterDefaults.gyro_lowpass_type = this.FILTER_TYPE_FLAGS.PT1;
versionFilterDefaults.gyro_lowpass2_hz = 250;
versionFilterDefaults.gyro_lowpass2_type = this.FILTER_TYPE_FLAGS.PT1;
versionFilterDefaults.dterm_lowpass_hz = 150;
versionFilterDefaults.dterm_lowpass_dyn_min_hz = 70;
versionFilterDefaults.dterm_lowpass_dyn_max_hz = 170;
versionFilterDefaults.dterm_lowpass_type = this.FILTER_TYPE_FLAGS.PT1;
versionFilterDefaults.dterm_lowpass2_hz = 150;
versionFilterDefaults.dterm_lowpass2_type = this.FILTER_TYPE_FLAGS.PT1;

// Introduced in 1.44
versionFilterDefaults.dyn_notch_q = 300;
versionFilterDefaults.gyro_lowpass_hz = 250;
versionFilterDefaults.gyro_lowpass_dyn_min_hz = 250;
versionFilterDefaults.gyro_lowpass2_hz = 500;
versionFilterDefaults.dterm_lowpass_hz = 75;
versionFilterDefaults.dterm_lowpass_dyn_min_hz = 75;
versionFilterDefaults.dterm_lowpass_dyn_max_hz = 150;

// Introduced in 1.45
if (semver.gte(this.CONFIG.apiVersion, API_VERSION_1_45)) {
versionFilterDefaults.dyn_notch_min_hz = 100;
}
Expand All @@ -965,22 +953,14 @@ const FC = {
},

getPidDefaults() {
let versionPidDefaults = this.DEFAULT_PIDS;
// if defaults change they should go here
if (semver.eq(this.CONFIG.apiVersion, API_VERSION_1_43)) {
versionPidDefaults = [
42, 85, 35, 23, 90,
46, 90, 38, 25, 95,
45, 90, 0, 0, 90,
];
}
if (semver.gte(this.CONFIG.apiVersion, API_VERSION_1_44)) {
versionPidDefaults = [
45, 80, 40, 30, 120,
47, 84, 46, 34, 125,
45, 80, 0, 0, 120,
];
}
// Introduced in 1.44
const versionPidDefaults = [
45, 80, 40, 30, 120,
47, 84, 46, 34, 125,
45, 80, 0, 0, 120,
];

return versionPidDefaults;
},

Expand Down
Loading

0 comments on commit e806299

Please sign in to comment.