Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for gyro_cal_on_first_arm #3938

Merged
merged 8 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1395,13 +1395,13 @@
"message": "This option configures the mixer to expect the motor direction to be reversed and the propellers to be on accordingly. <strong>Warning:</strong> This does not reverse the motor direction. Use the configuration tool for your ESCs or switch the ESC - motor wiring order to achieve this. Also, make sure to check with propellers off that your motors are rotating in the directions shown in the diagram above before attempting to arm."
},
"configurationAutoDisarmDelay": {
"message": "Disarm motors after set delay [seconds] (Requires MOTOR_STOP feature)"
"message": "Disarm motors after delay [seconds]"
},
"configurationDisarmKillSwitch": {
"message": "Disarm motors regardless of throttle value (When ARM is configured in Modes tab via AUX channel)"
"configurationAutoDisarmDelayHelp": {
"message": "Disarm motors after set delay [seconds] (Requires MOTOR_STOP feature)"
},
"configurationDisarmKillSwitchHelp": {
"message": "Arming is always disabled when the throttle is not low. Be careful as you could disarm accidentally with a switch while flying with this option active."
"configurationGyroCalOnFirstArm": {
"message": "Calibrate Gyro on first arm"
haslinghuis marked this conversation as resolved.
Show resolved Hide resolved
},
"configurationDigitalIdlePercent": {
"message": "Motor Idle ( %, static)"
Expand Down
5 changes: 0 additions & 5 deletions src/css/tabs/configuration.less
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,6 @@
margin-right: 10px;
font-weight: bold;
}
._smallAngle {
margin-top: 10px;
float: left;
width: 100%;
}
}
@media only screen and (max-width: 1055px) {
.tab-configuration {
Expand Down
1 change: 1 addition & 0 deletions src/js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ const FC = {
auto_disarm_delay: 0,
disarm_kill_switch: 0,
small_angle: 0,
gyro_cal_on_first_arm: 0,
};

this.FC_CONFIG = {
Expand Down
10 changes: 8 additions & 2 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,11 @@ MspHelper.prototype.process_data = function(dataHandler) {

case MSPCodes.MSP_ARMING_CONFIG:
FC.ARMING_CONFIG.auto_disarm_delay = data.readU8();
FC.ARMING_CONFIG.disarm_kill_switch = data.readU8();
data.readU8(); // was FC.ARMING_CONFIG.auto_disarm_kill_switch
FC.ARMING_CONFIG.small_angle = data.readU8();
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) {
FC.ARMING_CONFIG.gyro_cal_on_first_arm = data.readU8();
}
break;
case MSPCodes.MSP_LOOP_TIME:
FC.FC_CONFIG.loopTime = data.readU16();
Expand Down Expand Up @@ -1792,8 +1795,11 @@ MspHelper.prototype.crunch = function(code, modifierCode = undefined) {
break;
case MSPCodes.MSP_SET_ARMING_CONFIG:
buffer.push8(FC.ARMING_CONFIG.auto_disarm_delay)
.push8(FC.ARMING_CONFIG.disarm_kill_switch)
.push8(0) // was disarm_kill_switch
.push8(FC.ARMING_CONFIG.small_angle);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) {
buffer.push8(FC.ARMING_CONFIG.gyro_cal_on_first_arm);
}
break;
case MSPCodes.MSP_SET_LOOP_TIME:
buffer.push16(FC.FC_CONFIG.loopTime);
Expand Down
21 changes: 18 additions & 3 deletions src/js/tabs/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { mspHelper } from '../msp/MSPHelper';
import FC from '../fc';
import MSP from '../msp';
import MSPCodes from '../msp/MSPCodes';
import { API_VERSION_1_42, API_VERSION_1_43, API_VERSION_1_45 } from '../data_storage';
import { API_VERSION_1_42, API_VERSION_1_43, API_VERSION_1_45, API_VERSION_1_46 } from '../data_storage';
import { updateTabList } from '../utils/updateTabList';
import $ from 'jquery';

Expand Down Expand Up @@ -343,9 +343,21 @@ configuration.initialize = function (callback) {
$('input[name="roll"]').val(FC.CONFIG.accelerometerTrims[1]);
$('input[name="pitch"]').val(FC.CONFIG.accelerometerTrims[0]);

$('._smallAngle').show();
$('input[id="configurationSmallAngle"]').val(FC.ARMING_CONFIG.small_angle);

if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) {
$('input[id="configurationGyroCalOnFirstArm"]').prop('checked', FC.ARMING_CONFIG.gyro_cal_on_first_arm === 1);

if (FC.FEATURE_CONFIG.features.isEnabled('MOTOR_STOP')) {
$('input[id="configurationAutoDisarmDelay"]').val(FC.ARMING_CONFIG.auto_disarm_delay);
} else {
$('input[id="configurationAutoDisarmDelay"]').parent().hide();
}
} else {
$('input[id="configurationGyroCalOnFirstArm"]').parent().parent().hide();
$('input[id="configurationAutoDisarmDelay"]').parent().parent().hide();
}

// UI hooks

function checkUpdateGpsControls() {
Expand Down Expand Up @@ -395,7 +407,10 @@ configuration.initialize = function (callback) {
FC.CONFIG.accelerometerTrims[1] = parseInt($('input[name="roll"]').val());
FC.CONFIG.accelerometerTrims[0] = parseInt($('input[name="pitch"]').val());

// small angle configuration
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) {
FC.ARMING_CONFIG.gyro_cal_on_first_arm = $('input[id="configurationGyroCalOnFirstArm"]').is(':checked') ? 1 : 0;
FC.ARMING_CONFIG.auto_disarm_delay = parseInt($('input[id="configurationAutoDisarmDelay"]').val());
}
FC.ARMING_CONFIG.small_angle = parseInt($('input[id="configurationSmallAngle"]').val());

FC.SENSOR_ALIGNMENT.gyro_to_use = parseInt(orientation_gyro_to_use_e.val());
Expand Down
25 changes: 18 additions & 7 deletions src/tabs/configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,25 @@
<div class="helpicon cf_tip" i18n_title="configurationArmingHelp"></div>
</div>
<div class="spacer_box">
<div class="_smallAngle">
<div class="number">
<label>
<input type="number" id="configurationSmallAngle" step="1" min="1" max="180" />
<span i18n="configurationSmallAngle"></span>
<div class="helpicon cf_tip" i18n_title="configurationSmallAngleHelp"></div>
</label>
<div class="number">
<label>
<input type="number" id="configurationSmallAngle" step="1" min="1" max="180" />
<span i18n="configurationSmallAngle"></span>
<div class="helpicon cf_tip" i18n_title="configurationSmallAngleHelp"></div>
</label>
</div>
<div class="number">
<label>
<input type="number" id="configurationAutoDisarmDelay" step="1" min="0" max="60" />
<span i18n="configurationAutoDisarmDelay"></span>
<div class="helpicon cf_tip" i18n_title="configurationAutoDisarmDelayHelp"></div>
</label>
</div>
<div class="select">
<div style="float: left; height: 20px; margin-right: 15px; margin-left: 3px;">
<input type="checkbox" id="configurationGyroCalOnFirstArm" class="toggle" />
</div>
<span class="freelabel" i18n="configurationGyroCalOnFirstArm"></span>
</div>
</div>
</div>
Expand Down