Skip to content

Commit 380601b

Browse files
authored
rename d_min related values (betaflight#775)
* rename d_min related values * add semver checks
1 parent 97236d1 commit 380601b

File tree

6 files changed

+70
-102
lines changed

6 files changed

+70
-102
lines changed

index.html

Lines changed: 28 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ <h5 class="modal-title-revision"></h5>
714714
</table>
715715

716716
<table id="pid_main" class="pid_tuning">
717-
<tr class = "pid_labels">
717+
<tr class = "pid_labels">
718718
<th name="Blank">
719719
<label>&nbsp;</label>
720720
</th>
@@ -724,74 +724,34 @@ <h5 class="modal-title-revision"></h5>
724724
<th name="Integral">
725725
<label>I</label>
726726
</th>
727-
<th name="D_Max">
728-
<label>D_Max</label>
729-
</th>
730-
<th name="Derivative">
727+
<th id="derivativeColumn" name="Derivative">
731728
<label>D</label>
732729
</th>
730+
<th id="dMaxColumn" name="D_Max">
731+
<label>D Max</label>
732+
</th>
733733
<th name="Feedforward">
734734
<label>FF</label>
735735
</th>
736736
</tr>
737-
<tr class="rollPID">
738-
<!-- 0 -->
739-
<td>Roll</td>
740-
<td>
741-
<input type="text" name="p" step="1" min="0" max="255" />
742-
</td>
743-
<td>
744-
<input type="text" name="i" step="1" min="0" max="255" />
745-
</td>
746-
<td>
747-
<input type="text" name="d" step="1" min="0" max="255" />
748-
</td>
749-
<td>
750-
<input type="text" name="d_min_roll" step="1" min="0" max="255" />
751-
</td>
752-
<td>
753-
<input type="text" name="f" step="1" min="0" max="255" />
754-
</td>
755-
</tr>
756-
<tr class="pitchPID">
757-
<!-- 1 -->
758-
<td>Pitch</td>
759-
<td>
760-
<input type="text" name="p" step="1" min="0" max="255" />
761-
</td>
762-
<td>
763-
<input type="text" name="i" step="1" min="0" max="255" />
764-
</td>
765-
<td>
766-
<input type="text" name="d" step="1" min="0" max="255" />
767-
</td>
768-
<td>
769-
<input type="text" name="d_min_pitch" step="1" min="0" max="255" />
770-
</td>
771-
<td>
772-
<input type="text" name="f" step="1" min="0" max="255" />
773-
</td>
774-
</tr>
775-
<tr class="yawPID">
776-
<!-- 2 -->
777-
<td>Yaw</td>
778-
<td>
779-
<input type="text" name="p" step="1" min="0" max="255" />
780-
</td>
781-
<td>
782-
<input type="text" name="i" step="1" min="0" max="255" />
783-
</td>
784-
<td>
785-
<input type="text" name="d" step="1" min="0" max="255" />
786-
</td>
787-
<td>
788-
<input type="text" name="d_min_yaw" step="1" min="0" max="255" />
789-
</td>
790-
<td>
791-
<input type="text" name="f" step="1" min="0" max="255" />
792-
</td>
793-
</tr>
794-
</table>
737+
<tbody id="pid_tbody"></tbody>
738+
</table>
739+
<script>
740+
const axes = ['Roll', 'Pitch', 'Yaw'];
741+
const pidTbody = document.getElementById('pid_tbody');
742+
743+
axes.forEach(axis => {
744+
const row = `<tr class="${axis.toLowerCase()}PID">
745+
<td>${axis}</td>
746+
<td><input type="text" name="p" step="1" min="0" max="255" /></td>
747+
<td><input type="text" name="i" step="1" min="0" max="255" /></td>
748+
<td><input type="text" name="d" step="1" min="0" max="255" /></td>
749+
<td><input type="text" name="dMax" step="1" min="0" max="255" /></td>
750+
<td><input type="text" name="f" step="1" min="0" max="255" /></td>
751+
</tr>`;
752+
pidTbody.innerHTML += row;
753+
});
754+
</script>
795755

796756
<table id="pid_baro_header" class="parameter cf">
797757
<thead>
@@ -928,8 +888,8 @@ <h5 class="modal-title-revision"></h5>
928888
<label>D gain</label>
929889
<input type="text" step="1" min="0" max="200" />
930890
</td>
931-
<td name="simplified_dmax_gain" class="bf-only">
932-
<label>Dmax</label>
891+
<td name="simplified_d_max_gain" class="bf-only">
892+
<label>D Max</label>
933893
<input type="text" step="1" min="0" max="200" />
934894
</td>
935895
</tr>
@@ -995,19 +955,19 @@ <h5 class="modal-title-revision"></h5>
995955
</tbody>
996956
</table>
997957

998-
<table id="d_min" class="parameter cf">
958+
<table id="d_max" class="parameter cf">
999959
<thead>
1000960
<tr>
1001961
<th colspan="5">D Max</th>
1002962
</tr>
1003963
</thead>
1004964
<tbody>
1005965
<tr>
1006-
<td name="d_min_gain" class="bf-only">
966+
<td name="d_max_gain" class="bf-only">
1007967
<label>Gain</label>
1008968
<input type="text" step="1" min="0" max="100" />
1009969
</td>
1010-
<td name="d_min_advance" class="bf-only">
970+
<td name="d_max_advance" class="bf-only">
1011971
<label>Advance</label>
1012972
<input type="text" step="1" min="0" max="200" />
1013973
</td>

src/flightlog_fielddefs.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ export const DEBUG_MODE_COMPLETE = makeReadOnly([
309309
"RX_SPECTRUM_SPI",
310310
"DSHOT_RPM_TELEMETRY",
311311
"RPM_FILTER",
312-
"D_MIN",
312+
"D_MAX",
313313
"AC_CORRECTION",
314314
"AC_ERROR",
315315
"DUAL_GYRO_SCALED",
@@ -520,13 +520,12 @@ export function adjustFieldDefsList(firmwareType, firmwareVersion) {
520520
DEBUG_MODE.splice(DEBUG_MODE.indexOf("DUAL_GYRO_COMBINED"), 1);
521521
}
522522
if (semver.gte(firmwareVersion, "4.3.0")) {
523-
DEBUG_MODE.splice(
524-
DEBUG_MODE.indexOf("FF_INTERPOLATED"),
525-
1,
526-
"FEEDFORWARD"
527-
);
523+
DEBUG_MODE.splice(DEBUG_MODE.indexOf("FF_INTERPOLATED"), 1, "FEEDFORWARD");
528524
DEBUG_MODE.splice(DEBUG_MODE.indexOf("FF_LIMIT"), 1, "FEEDFORWARD_LIMIT");
529525
}
526+
if (semver.lt(firmwareVersion, "4.6.0")) {
527+
DEBUG_MODE.splice(DEBUG_MODE.indexOf("D_MAX"), 1, "D_MIN");
528+
}
530529

531530
DEBUG_MODE = makeReadOnly(DEBUG_MODE);
532531

src/flightlog_fields_presenter.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,8 @@ const DEBUG_FRIENDLY_FIELD_NAMES_INITIAL = {
695695
"debug[6]": "Not Used",
696696
"debug[7]": "Not Used",
697697
},
698-
D_MIN: {
699-
"debug[all]": "D_MIN",
698+
D_MAX: {
699+
"debug[all]": "D_MAX",
700700
"debug[0]": "Gyro Factor [roll]",
701701
"debug[1]": "Setpoint Factor [roll]",
702702
"debug[2]": "Actual D [roll]",
@@ -1850,7 +1850,7 @@ FlightLogFieldPresenter.decodeDebugFieldToFriendly = function (
18501850
).toFixed(0)} hz`;
18511851
case "RPM_FILTER":
18521852
return `${(value * 60).toFixed(0)}rpm / ${value.toFixed(0)} Hz`;
1853-
case "D_MIN":
1853+
case "D_MAX":
18541854
switch (fieldName) {
18551855
case "debug[0]": // roll gyro factor
18561856
case "debug[1]": // roll setpoint Factor
@@ -2506,7 +2506,7 @@ FlightLogFieldPresenter.ConvertDebugFieldValue = function (
25062506
return toFriendly ? (value * 200) / pole : (value * pole) / 200;
25072507
case "RPM_FILTER":
25082508
return toFriendly ? value * 60 : value / 60;
2509-
case "D_MIN":
2509+
case "D_MAX":
25102510
switch (fieldName) {
25112511
case "debug[0]": // roll gyro factor
25122512
case "debug[1]": // roll setpoint Factor

src/flightlog_parser.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ export function FlightLogParser(logData) {
284284
pidSumLimit: null, // PID sum limit
285285
pidSumLimitYaw: null, // PID sum limit yaw
286286
use_integrated_yaw: null, // Use integrated yaw
287-
d_min: [null, null, null], // D_Min [P, I, D]
288-
d_min_gain: null, // D_Min gain - D_Max in 4.3
289-
d_min_advance: null, // D_Min advance - D_Max in 4.3
287+
d_max: [null, null, null], // D_MAX [ROLL, PITCH, YAW]
288+
d_max_gain: null, // D_MAX gain
289+
d_max_advance: null, // D_MAX advance
290290
iterm_relax: null, // ITerm Relax mode
291291
iterm_relax_type: null, // ITerm Relax type
292292
iterm_relax_cutoff: null, // ITerm Relax cutoff
@@ -326,7 +326,7 @@ export function FlightLogParser(logData) {
326326
simplified_pi_gain: null,
327327
simplified_i_gain: null,
328328
simplified_d_gain: null,
329-
simplified_dmax_gain: null,
329+
simplified_d_max_gain: null,
330330
simplified_feedforward_gain: null,
331331
simplified_pitch_d_gain: null,
332332
simplified_pitch_pi_gain: null,
@@ -370,8 +370,8 @@ export function FlightLogParser(logData) {
370370
dterm_lpf2_static_hz: "dterm_lpf2_hz",
371371
dterm_setpoint_weight: "dtermSetpointWeight",
372372
digital_idle_value: "digitalIdleOffset",
373-
d_max_gain: "d_min_gain",
374-
d_max_advance: "d_min_advance",
373+
simplified_dmax_gain: "simplified_d_max_gain",
374+
d_max: "d_min",
375375
dshot_idle_value: "digitalIdleOffset",
376376
dyn_idle_min_rpm: "dynamic_idle_min_rpm",
377377
feedforward_transition: "ff_transition",
@@ -696,8 +696,8 @@ export function FlightLogParser(logData) {
696696
case "anti_gravity_cutoff_hz":
697697
case "abs_control_gain":
698698
case "use_integrated_yaw":
699-
case "d_min_gain":
700-
case "d_min_advance":
699+
case "d_max_gain":
700+
case "d_max_advance":
701701
case "dshot_bidir":
702702
case "gyro_rpm_notch_harmonics":
703703
case "gyro_rpm_notch_q":
@@ -732,6 +732,7 @@ export function FlightLogParser(logData) {
732732
case "simplified_i_gain":
733733
case "simplified_d_gain":
734734
case "simplified_dmax_gain":
735+
case "simplified_d_max_gain":
735736
case "simplified_feedforward_gain":
736737
case "simplified_pitch_d_gain":
737738
case "simplified_pitch_pi_gain":
@@ -869,11 +870,12 @@ export function FlightLogParser(logData) {
869870
that.sysConfig.magPID = parseCommaSeparatedString(fieldValue, 3); //[parseInt(fieldValue, 10), null, null];
870871
break;
871872
case "d_min":
872-
// Add Dmin values as Derivative numbers to PID array
873-
var dMinValues = parseCommaSeparatedString(fieldValue);
874-
that.sysConfig["rollPID"].push(dMinValues[0]);
875-
that.sysConfig["pitchPID"].push(dMinValues[1]);
876-
that.sysConfig["yawPID"].push(dMinValues[2]);
873+
case "d_max":
874+
// Add D MAX values as Derivative numbers to PID array
875+
var dMaxValues = parseCommaSeparatedString(fieldValue);
876+
that.sysConfig["rollPID"].push(dMaxValues[0]);
877+
that.sysConfig["pitchPID"].push(dMaxValues[1]);
878+
that.sysConfig["yawPID"].push(dMaxValues[2]);
877879
break;
878880
case "ff_weight":
879881
// Add feedforward values to the PID array

src/graph_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ GraphConfig.getDefaultCurveForField = function (flightLog, fieldName) {
707707
"debug[2]",
708708
"debug[3]"
709709
);
710-
case "D_MIN":
710+
case "D_MAX":
711711
switch (fieldName) {
712712
case "debug[0]": // roll gyro factor
713713
case "debug[1]": // roll setpoint Factor

src/header_dialog.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ export function HeaderDialog(dialog, onSave) {
698698
max: "999.9.9",
699699
},
700700
{
701-
name: "simplified_dmax_gain",
701+
name: "simplified_d_max_gain",
702702
type: FIRMWARE_TYPE_BETAFLIGHT,
703703
min: "4.3.0",
704704
max: "999.9.9",
@@ -1692,24 +1692,31 @@ export function HeaderDialog(dialog, onSave) {
16921692
setParameter("rcSmoothingActiveCutoffsThr", "0", 0);
16931693
}
16941694

1695-
// D_MIN and rate_limits
1695+
// D_MAX and rate_limits
16961696
if (
16971697
activeSysConfig.firmwareType == FIRMWARE_TYPE_BETAFLIGHT &&
16981698
semver.gte(activeSysConfig.firmwareVersion, "4.0.0")
16991699
) {
1700-
setParameter("d_min_roll", sysConfig.d_min[0], 0);
1701-
setParameter("d_min_pitch", sysConfig.d_min[1], 0);
1702-
setParameter("d_min_yaw", sysConfig.d_min[2], 0);
1703-
setParameter("d_min_gain", sysConfig.d_min_gain, 0);
1704-
setParameter("d_min_advance", sysConfig.d_min_advance, 0);
1705-
$("#d_min").show();
1700+
setParameter("d_max_roll", sysConfig.d_max[0], 0);
1701+
setParameter("d_max_pitch", sysConfig.d_max[1], 0);
1702+
setParameter("d_max_yaw", sysConfig.d_max[2], 0);
1703+
setParameter("d_max_gain", sysConfig.d_max_gain, 0);
1704+
setParameter("d_max_advance", sysConfig.d_max_advance, 0);
1705+
$("#d_max").show();
17061706

17071707
setParameter("rate_limits_roll", sysConfig.rate_limits[0], 0);
17081708
setParameter("rate_limits_pitch", sysConfig.rate_limits[1], 0);
17091709
setParameter("rate_limits_yaw", sysConfig.rate_limits[2], 0);
17101710
$("#rate_limits").show();
1711+
1712+
if (semver.lt(activeSysConfig.firmwareVersion, "4.6.0")) {
1713+
const derivativeColumn = document.getElementById("derivativeColumn");
1714+
const dMaxColumn = document.getElementById("dMaxColumn");
1715+
const parent = derivativeColumn.parentNode;
1716+
parent.insertBefore(dMaxColumn, derivativeColumn); // Меняем местами
1717+
}
17111718
} else {
1712-
$("#d_min").hide();
1719+
$("#d_max").hide();
17131720
$("#rate_limits").hide();
17141721
}
17151722

@@ -1823,7 +1830,7 @@ export function HeaderDialog(dialog, onSave) {
18231830
setParameter("simplified_pi_gain", sysConfig.simplified_pi_gain, 0);
18241831
setParameter("simplified_i_gain", sysConfig.simplified_i_gain, 0);
18251832
setParameter("simplified_d_gain", sysConfig.simplified_d_gain, 0);
1826-
setParameter("simplified_dmax_gain", sysConfig.simplified_dmax_gain, 0);
1833+
setParameter("simplified_d_max_gain", sysConfig.simplified_d_max_gain, 0);
18271834
setParameter(
18281835
"simplified_feedforward_gain",
18291836
sysConfig.simplified_feedforward_gain,

0 commit comments

Comments
 (0)