Skip to content

Commit

Permalink
Deprecate minthrottle to use motor_idle (#4196)
Browse files Browse the repository at this point in the history
* Depricate minthrottle

* Fix sonar

* Update toggle hide logic

* Rename digitalIdlePercent

* Move mincommand above maxthrottle

* Use widetip

* Update tooltip

* Change precision

* Fix camelCase
  • Loading branch information
haslinghuis authored Oct 8, 2024
1 parent ab5f510 commit 922adbe
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 34 deletions.
6 changes: 3 additions & 3 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1464,11 +1464,11 @@
"configurationGyroCalOnFirstArm": {
"message": "Calibrate Gyro on first arm"
},
"configurationDigitalIdlePercent": {
"configurationMotorIdle": {
"message": "Motor Idle (%)"
},
"configurationDigitalIdlePercentHelp": {
"message": "The Motor Idle value sets the idle speed of the motors when throttle is at minimum position.<br/><br/><strong>Dynamic Idle disabled</strong><br/><br/>The lowest throttle value sent to any motor, while armed, as a percentage of full throttle. Increase it to improve motor startup reliability, to avoid desyncs, and to improve PID responsiveness at low throttle.<br/><br/>Too low: the motors may not start up reliably, or desync at the end of a flip or roll or on hard throttle chops.<br/><br/>Too high: the craft may feel 'floaty'.<br/><br/><strong>Dynamic idle enabled</strong><br/><br/>The maximum throttle allowed, after arming, before takeoff. If RPM is less than dyn_idle_min_rpm, or zero, this throttle value will be sent to the motors. When the motors start spinning, throttle is adjusted to maintain the set RPM, but cannot exceed this value until the quad takes off.<br/><br/>Too low: the motors may not start up reliably.<br/><br/>Too high: the craft may shake on the ground before takeoff."
"configurationMotorIdleHelp": {
"message": "Sets the idle speed of the motors while armed and throttle is 'low' (below `min_check`).<br/><br/><strong class=\"message-positive\">Dynamic Idle not enabled</strong><br/><br/>Each motor gets `min_command` plus Motor Idle percent.<br/><br/><b>Idle too low</b>: motors may not start reliably, spin up slowly, or desync in flips or rolls.<br/><br/><b>Idle too high</b>: the craft may feel 'floaty'.<br/><br/><b>Note</b>: analog ESC's must be calibrated so the motors start just above `min_command`.<br/><br/><strong class=\"message-positive\">Dynamic Idle enabled</strong><br/><br/>On arming, the 'normal' idle value is sent to each motor, until they spin up.<br/><br/>Once spinning, the motor signal is adjusted to achieve the target RPM.<br/><br/>Before takeoff, the motor signal is limited to the Motor Idle percentage, and the set RPM may not be achieved. This is OK. When throttle is raised above the `airmode_motor_start_throttle` percentage, the limit is much higher, and the set RPM should be achieved at idle.<br/><br/><b>Idle too low</b>: motors may not start reliably<br/><br/><b>Idle too high</b>: shaking before takeoff (only if dynamic idle is also high)<br/><br/><b>Note</b>: Dynamic Idle requires DShot and DShot Telemetry."
},
"configurationMotorPoles": {
"message": "Motor poles",
Expand Down
2 changes: 1 addition & 1 deletion src/js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ const FC = {
use_unsyncedPwm: 0,
fast_pwm_protocol: 0,
motor_pwm_rate: 0,
digitalIdlePercent: 0,
motorIdle: 0,
gyroUse32kHz: 0,
motorPwmInversion: 0,
gyroHighFsr: 0,
Expand Down
4 changes: 2 additions & 2 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
FC.PID_ADVANCED_CONFIG.use_unsyncedPwm = data.readU8();
FC.PID_ADVANCED_CONFIG.fast_pwm_protocol = EscProtocols.ReorderPwmProtocols(FC.CONFIG.apiVersion, data.readU8());
FC.PID_ADVANCED_CONFIG.motor_pwm_rate = data.readU16();
FC.PID_ADVANCED_CONFIG.digitalIdlePercent = data.readU16() / 100;
FC.PID_ADVANCED_CONFIG.motorIdle = data.readU16() / 100;
data.readU8(); // gyroUse32Khz is not supported
// Introduced in 1.42
FC.PID_ADVANCED_CONFIG.motorPwmInversion = data.readU8();
Expand Down Expand Up @@ -2002,7 +2002,7 @@ MspHelper.prototype.crunch = function(code, modifierCode = undefined) {
.push8(FC.PID_ADVANCED_CONFIG.use_unsyncedPwm)
.push8(EscProtocols.ReorderPwmProtocols(FC.CONFIG.apiVersion, FC.PID_ADVANCED_CONFIG.fast_pwm_protocol))
.push16(FC.PID_ADVANCED_CONFIG.motor_pwm_rate)
.push16(FC.PID_ADVANCED_CONFIG.digitalIdlePercent * 100)
.push16(FC.PID_ADVANCED_CONFIG.motorIdle * 100)
.push8(0); // gyroUse32kHz not used

// Introduced in 1.42
Expand Down
35 changes: 18 additions & 17 deletions src/js/tabs/motors.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ motors.initialize = async function (callback) {
feature27: FC.FEATURE_CONFIG.features.isEnabled('ESC_SENSOR'),
dshotBidir: FC.MOTOR_CONFIG.use_dshot_telemetry,
motorPoles: FC.MOTOR_CONFIG.motor_poles,
digitalIdlePercent: FC.PID_ADVANCED_CONFIG.digitalIdlePercent,
motorIdle: FC.PID_ADVANCED_CONFIG.motorIdle,
idleMinRpm: FC.ADVANCED_TUNING.idleMinRpm,
_3ddeadbandlow: FC.MOTOR_3D_CONFIG.deadband3d_low,
_3ddeadbandhigh: FC.MOTOR_3D_CONFIG.deadband3d_high,
Expand Down Expand Up @@ -691,7 +691,7 @@ motors.initialize = async function (callback) {

unsyncedPWMSwitchElement.prop('checked', FC.PID_ADVANCED_CONFIG.use_unsyncedPwm !== 0).trigger("change");
$('input[name="unsyncedpwmfreq"]').val(FC.PID_ADVANCED_CONFIG.motor_pwm_rate);
$('input[name="digitalIdlePercent"]').val(FC.PID_ADVANCED_CONFIG.digitalIdlePercent);
$('input[name="motorIdle"]').val(FC.PID_ADVANCED_CONFIG.motorIdle);
$('input[name="idleMinRpm"]').val(FC.ADVANCED_TUNING.idleMinRpm);

dshotBidirElement.prop('checked', FC.MOTOR_CONFIG.use_dshot_telemetry).trigger("change");
Expand Down Expand Up @@ -755,24 +755,25 @@ motors.initialize = async function (callback) {
default:
}

const analogProtocolConfigured = protocolConfigured && !digitalProtocol;
const digitalProtocolConfigured = protocolConfigured && digitalProtocol;
const rpmFeaturesVisible = digitalProtocol && dshotBidirElement.is(':checked') || $("input[name='ESC_SENSOR']").is(':checked');

$('div.minthrottle').toggle(protocolConfigured && !digitalProtocol);
$('div.maxthrottle').toggle(protocolConfigured && !digitalProtocol);
$('div.mincommand').toggle(protocolConfigured && !digitalProtocol);
$('div.checkboxPwm').toggle(protocolConfigured && !digitalProtocol);
divUnsyncedPWMFreq.toggle(protocolConfigured && !digitalProtocol);
$('div.minthrottle').toggle(analogProtocolConfigured && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_47));
$('div.maxthrottle').toggle(analogProtocolConfigured);
$('div.mincommand').toggle(analogProtocolConfigured);
$('div.checkboxPwm').toggle(analogProtocolConfigured);
divUnsyncedPWMFreq.toggle(analogProtocolConfigured);

$('div.digitalIdlePercent').toggle(protocolConfigured && digitalProtocol);
$('div.idleMinRpm').toggle(protocolConfigured && digitalProtocol && FC.MOTOR_CONFIG.use_dshot_telemetry);
$('div.motorIdle').toggle(protocolConfigured
&& semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)
|| (digitalProtocolConfigured && FC.MOTOR_CONFIG.use_dshot_telemetry && FC.ADVANCED_TUNING.idleMinRpm));

if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_47) && FC.ADVANCED_TUNING.idleMinRpm && FC.MOTOR_CONFIG.use_dshot_telemetry) {
$('div.digitalIdlePercent').hide();
}
$('div.idleMinRpm').toggle(protocolConfigured && digitalProtocol && FC.MOTOR_CONFIG.use_dshot_telemetry);

$('.escSensor').toggle(protocolConfigured && digitalProtocol);
$('.escSensor').toggle(digitalProtocolConfigured);

$('div.checkboxDshotBidir').toggle(protocolConfigured && digitalProtocol);
$('div.checkboxDshotBidir').toggle(digitalProtocolConfigured);
$('div.motorPoles').toggle(protocolConfigured && rpmFeaturesVisible);

$('.escMotorStop').toggle(protocolConfigured);
Expand Down Expand Up @@ -1157,7 +1158,7 @@ motors.initialize = async function (callback) {
FC.PID_ADVANCED_CONFIG.fast_pwm_protocol = parseInt(escProtocolElement.val() - 1);
FC.PID_ADVANCED_CONFIG.use_unsyncedPwm = unsyncedPWMSwitchElement.is(':checked') ? 1 : 0;
FC.PID_ADVANCED_CONFIG.motor_pwm_rate = parseInt($('input[name="unsyncedpwmfreq"]').val());
FC.PID_ADVANCED_CONFIG.digitalIdlePercent = parseFloat($('input[name="digitalIdlePercent"]').val());
FC.PID_ADVANCED_CONFIG.motorIdle = parseFloat($('input[name="motorIdle"]').val());

await MSP.promise(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG));
await MSP.promise(MSPCodes.MSP_SET_MIXER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_MIXER_CONFIG));
Expand Down Expand Up @@ -1225,7 +1226,7 @@ motors.initialize = async function (callback) {
function setup_motor_output_reordering_dialog(callbackFunction, zeroThrottleValue)
{
const domDialogMotorOutputReorder = $('#dialogMotorOutputReorder');
const idleThrottleValue = zeroThrottleValue + FC.PID_ADVANCED_CONFIG.digitalIdlePercent * 1000 / 100;
const idleThrottleValue = zeroThrottleValue + FC.PID_ADVANCED_CONFIG.motorIdle * 1000 / 100;
const motorOutputReorderComponent = new MotorOutputReorderComponent($('#dialogMotorOutputReorderContent'),
callbackFunction, mixerList[FC.MIXER_CONFIG.mixer - 1].name,
zeroThrottleValue, idleThrottleValue);
Expand Down Expand Up @@ -1256,7 +1257,7 @@ motors.initialize = async function (callback) {
function SetupdescDshotDirectionDialog(callbackFunction, zeroThrottleValue)
{
const domEscDshotDirectionDialog = $('#escDshotDirectionDialog');
const idleThrottleValue = zeroThrottleValue + FC.PID_ADVANCED_CONFIG.digitalIdlePercent * 1000 / 100;
const idleThrottleValue = zeroThrottleValue + FC.PID_ADVANCED_CONFIG.motorIdle * 1000 / 100;
const motorConfig = {
numberOfMotors: self.numberOfValidOutputs,
motorStopValue: zeroThrottleValue,
Expand Down
22 changes: 11 additions & 11 deletions src/tabs/motors.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@
<span i18n="configurationMotorPolesLong"></span>
<div class="helpicon cf_tip" i18n_title="configurationMotorPolesHelp"></div>
</div>
<div class="number digitalIdlePercent">
<div class="number motorIdle">
<div class="numberspacer">
<input type="number" name="digitalIdlePercent" min="0.00" max="20.00" step="0.01"/>
<input type="number" name="motorIdle" min="0.0" max="20.0" step="0.1"/>
</div>
<span i18n="configurationDigitalIdlePercent"></span>
<div class="helpicon cf_tip" i18n_title="configurationDigitalIdlePercentHelp"></div>
<span i18n="configurationMotorIdle"></span>
<div class="helpicon cf_tip_wide" i18n_title="configurationMotorIdleHelp"></div>
</div>
<div class="number idleMinRpm">
<div class="numberspacer noarrows">
Expand All @@ -113,6 +113,13 @@
<span i18n="pidTuningIdleMinRpm"></span>
<div class="helpicon cf_tip" i18n_title="configurationMotorIdleRpmHelp"></div>
</div>
<div class="number mincommand">
<div class="numberspacer">
<input type="number" name="mincommand" min="0" max="2000" />
</div>
<span i18n="configurationThrottleMinimumCommand"></span>
<div class="helpicon cf_tip" i18n_title="configurationThrottleMinimumCommandHelp"></div>
</div>
<div class="number minthrottle">
<div class="numberspacer">
<input type="number" name="minthrottle" min="0" max="2000" />
Expand All @@ -126,13 +133,6 @@
</div>
<span i18n="configurationThrottleMaximum"></span>
</div>
<div class="number mincommand">
<div class="numberspacer">
<input type="number" name="mincommand" min="0" max="2000" />
</div>
<span i18n="configurationThrottleMinimumCommand"></span>
<div class="helpicon cf_tip" i18n_title="configurationThrottleMinimumCommandHelp"></div>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 922adbe

Please sign in to comment.