1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-25 09:16:01 +03:00

first build

This commit is contained in:
breadoven 2023-08-05 22:28:12 +01:00
parent fd59159f71
commit 6eb19f2135
8 changed files with 88 additions and 78 deletions

View file

@ -3272,6 +3272,16 @@ Max allowed above the ground altitude for terrain following mode
--- ---
### nav_mc_althold_throttle
If set to STICK the FC remembers the throttle stick position when enabling ALTHOLD and treats it as the neutral midpoint for holding altitude. If set to MID_STICK or HOVER the neutral midpoint is set to the mid stick position or the hover throttle position respectively.
| Default | Min | Max |
| --- | --- | --- |
| STICK | | |
---
### nav_mc_bank_angle ### nav_mc_bank_angle
Maximum banking angle (deg) that multicopter navigation is allowed to set. Machine must be able to satisfy this angle without loosing altitude Maximum banking angle (deg) that multicopter navigation is allowed to set. Machine must be able to satisfy this angle without loosing altitude
@ -3742,16 +3752,6 @@ Enables or Disables the use of the heading PID controller on fixed wing. Heading
--- ---
### nav_use_midthr_for_althold
If set to OFF, the FC remembers your throttle stick position when enabling ALTHOLD and treats it as a neutral midpoint for holding altitude
| Default | Min | Max |
| --- | --- | --- |
| OFF | OFF | ON |
---
### nav_user_control_mode ### nav_user_control_mode
Defines how Pitch/Roll input from RC receiver affects flight in POSHOLD mode: ATTI - pitch/roll controls attitude like in ANGLE mode; CRUISE - pitch/roll controls velocity in forward and right direction. Defines how Pitch/Roll input from RC receiver affects flight in POSHOLD mode: ATTI - pitch/roll controls attitude like in ANGLE mode; CRUISE - pitch/roll controls velocity in forward and right direction.

View file

@ -48,7 +48,7 @@ static const OSD_Entry cmsx_menuNavSettingsEntries[] =
OSD_SETTING_ENTRY("MAX NAV CLIMB RATE", SETTING_NAV_AUTO_CLIMB_RATE), OSD_SETTING_ENTRY("MAX NAV CLIMB RATE", SETTING_NAV_AUTO_CLIMB_RATE),
OSD_SETTING_ENTRY("MAX AH CLIMB RATE", SETTING_NAV_MANUAL_CLIMB_RATE), OSD_SETTING_ENTRY("MAX AH CLIMB RATE", SETTING_NAV_MANUAL_CLIMB_RATE),
OSD_SETTING_ENTRY("MC MAX BANK ANGLE", SETTING_NAV_MC_BANK_ANGLE), OSD_SETTING_ENTRY("MC MAX BANK ANGLE", SETTING_NAV_MC_BANK_ANGLE),
OSD_SETTING_ENTRY("MID THR FOR AH", SETTING_NAV_USE_MIDTHR_FOR_ALTHOLD), OSD_SETTING_ENTRY("MC ALTHOLD THROT", SETTING_NAV_MC_ALTHOLD_THROTTLE),
OSD_SETTING_ENTRY("MC HOVER THR", SETTING_NAV_MC_HOVER_THR), OSD_SETTING_ENTRY("MC HOVER THR", SETTING_NAV_MC_HOVER_THR),
OSD_SETTING_ENTRY("LANDING DISARM", SETTING_NAV_DISARM_ON_LANDING), OSD_SETTING_ENTRY("LANDING DISARM", SETTING_NAV_DISARM_ON_LANDING),

View file

@ -1058,7 +1058,7 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF
legacyLedConfig |= ledConfig->led_function << shiftCount; legacyLedConfig |= ledConfig->led_function << shiftCount;
shiftCount += 4; shiftCount += 4;
legacyLedConfig |= (ledConfig->led_overlay & 0x3F) << (shiftCount); legacyLedConfig |= (ledConfig->led_overlay & 0x3F) << (shiftCount);
shiftCount += 6; shiftCount += 6;
legacyLedConfig |= (ledConfig->led_color) << (shiftCount); legacyLedConfig |= (ledConfig->led_color) << (shiftCount);
shiftCount += 4; shiftCount += 4;
legacyLedConfig |= (ledConfig->led_direction) << (shiftCount); legacyLedConfig |= (ledConfig->led_direction) << (shiftCount);
@ -1289,7 +1289,7 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF
sbufWriteU16(dst, navConfig()->general.max_manual_speed); sbufWriteU16(dst, navConfig()->general.max_manual_speed);
sbufWriteU16(dst, navConfig()->general.max_manual_climb_rate); sbufWriteU16(dst, navConfig()->general.max_manual_climb_rate);
sbufWriteU8(dst, navConfig()->mc.max_bank_angle); sbufWriteU8(dst, navConfig()->mc.max_bank_angle);
sbufWriteU8(dst, navConfig()->general.flags.use_thr_mid_for_althold); sbufWriteU8(dst, navConfig()->mc.althold_throttle_type);
sbufWriteU16(dst, currentBatteryProfile->nav.mc.hover_throttle); sbufWriteU16(dst, currentBatteryProfile->nav.mc.hover_throttle);
break; break;
@ -2255,7 +2255,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src)
navConfigMutable()->general.max_manual_speed = sbufReadU16(src); navConfigMutable()->general.max_manual_speed = sbufReadU16(src);
navConfigMutable()->general.max_manual_climb_rate = sbufReadU16(src); navConfigMutable()->general.max_manual_climb_rate = sbufReadU16(src);
navConfigMutable()->mc.max_bank_angle = sbufReadU8(src); navConfigMutable()->mc.max_bank_angle = sbufReadU8(src);
navConfigMutable()->general.flags.use_thr_mid_for_althold = sbufReadU8(src); navConfigMutable()->mc.althold_throttle_type = sbufReadU8(src);
currentBatteryProfileMutable->nav.mc.hover_throttle = sbufReadU16(src); currentBatteryProfileMutable->nav.mc.hover_throttle = sbufReadU16(src);
} else } else
return MSP_RESULT_ERROR; return MSP_RESULT_ERROR;
@ -2757,7 +2757,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src)
ledConfig->led_position = legacyConfig & 0xFF; ledConfig->led_position = legacyConfig & 0xFF;
ledConfig->led_function = (legacyConfig >> 8) & 0xF; ledConfig->led_function = (legacyConfig >> 8) & 0xF;
ledConfig->led_overlay = (legacyConfig >> 12) & 0x3F; ledConfig->led_overlay = (legacyConfig >> 12) & 0x3F;
ledConfig->led_color = (legacyConfig >> 18) & 0xF; ledConfig->led_color = (legacyConfig >> 18) & 0xF;
ledConfig->led_direction = (legacyConfig >> 22) & 0x3F; ledConfig->led_direction = (legacyConfig >> 22) & 0x3F;
ledConfig->led_params = (legacyConfig >> 28) & 0xF; ledConfig->led_params = (legacyConfig >> 28) & 0xF;
@ -3482,7 +3482,7 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu
#ifdef USE_SIMULATOR #ifdef USE_SIMULATOR
case MSP_SIMULATOR: case MSP_SIMULATOR:
tmp_u8 = sbufReadU8(src); // Get the Simulator MSP version tmp_u8 = sbufReadU8(src); // Get the Simulator MSP version
// Check the MSP version of simulator // Check the MSP version of simulator
if (tmp_u8 != SIMULATOR_MSP_VERSION) { if (tmp_u8 != SIMULATOR_MSP_VERSION) {
break; break;
@ -3508,7 +3508,7 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu
// Review: Many states were affected. Reboot? // Review: Many states were affected. Reboot?
disarm(DISARM_SWITCH); // Disarm to prevent motor output!!! disarm(DISARM_SWITCH); // Disarm to prevent motor output!!!
} }
} else { } else {
if (!ARMING_FLAG(SIMULATOR_MODE_HITL)) { // Just once if (!ARMING_FLAG(SIMULATOR_MODE_HITL)) { // Just once
#ifdef USE_BARO #ifdef USE_BARO
@ -3518,7 +3518,7 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu
DISABLE_ARMING_FLAG(ARMING_DISABLED_HARDWARE_FAILURE); DISABLE_ARMING_FLAG(ARMING_DISABLED_HARDWARE_FAILURE);
baroStartCalibration(); baroStartCalibration();
} }
#endif #endif
#ifdef USE_MAG #ifdef USE_MAG
if (compassConfig()->mag_hardware != MAG_NONE) { if (compassConfig()->mag_hardware != MAG_NONE) {
@ -3578,7 +3578,7 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu
} else { } else {
sbufAdvance(src, sizeof(uint16_t) * XYZ_AXIS_COUNT); sbufAdvance(src, sizeof(uint16_t) * XYZ_AXIS_COUNT);
} }
// Get the acceleration in 1G units // Get the acceleration in 1G units
acc.accADCf[X] = ((int16_t)sbufReadU16(src)) / 1000.0f; acc.accADCf[X] = ((int16_t)sbufReadU16(src)) / 1000.0f;
acc.accADCf[Y] = ((int16_t)sbufReadU16(src)) / 1000.0f; acc.accADCf[Y] = ((int16_t)sbufReadU16(src)) / 1000.0f;
@ -3586,7 +3586,7 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu
acc.accVibeSq[X] = 0.0f; acc.accVibeSq[X] = 0.0f;
acc.accVibeSq[Y] = 0.0f; acc.accVibeSq[Y] = 0.0f;
acc.accVibeSq[Z] = 0.0f; acc.accVibeSq[Z] = 0.0f;
// Get the angular velocity in DPS // Get the angular velocity in DPS
gyro.gyroADCf[X] = ((int16_t)sbufReadU16(src)) / 16.0f; gyro.gyroADCf[X] = ((int16_t)sbufReadU16(src)) / 16.0f;
gyro.gyroADCf[Y] = ((int16_t)sbufReadU16(src)) / 16.0f; gyro.gyroADCf[Y] = ((int16_t)sbufReadU16(src)) / 16.0f;
@ -3621,7 +3621,7 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu
simulatorData.airSpeed = sbufReadU16(src); simulatorData.airSpeed = sbufReadU16(src);
} else { } else {
if (SIMULATOR_HAS_OPTION(HITL_EXTENDED_FLAGS)) { if (SIMULATOR_HAS_OPTION(HITL_EXTENDED_FLAGS)) {
sbufReadU16(src); sbufReadU16(src);
} }
} }

View file

@ -190,6 +190,9 @@ tables:
- name: nav_fw_wp_turn_smoothing - name: nav_fw_wp_turn_smoothing
values: ["OFF", "ON", "ON-CUT"] values: ["OFF", "ON", "ON-CUT"]
enum: wpFwTurnSmoothing_e enum: wpFwTurnSmoothing_e
- name: nav_mc_althold_throttle
values: ["STICK", "MID_STICK", "HOVER"]
enum: navMcAltHoldThrottle_e
constants: constants:
RPYL_PID_MIN: 0 RPYL_PID_MIN: 0
@ -2310,11 +2313,11 @@ groups:
default_value: OFF default_value: OFF
field: general.flags.landing_bump_detection field: general.flags.landing_bump_detection
type: bool type: bool
- name: nav_use_midthr_for_althold - name: nav_mc_althold_throttle
description: "If set to OFF, the FC remembers your throttle stick position when enabling ALTHOLD and treats it as a neutral midpoint for holding altitude" description: "If set to STICK the FC remembers the throttle stick position when enabling ALTHOLD and treats it as the neutral midpoint for holding altitude. If set to MID_STICK or HOVER the neutral midpoint is set to the mid stick position or the hover throttle position respectively."
default_value: OFF default_value: "STICK"
field: general.flags.use_thr_mid_for_althold field: mc.althold_throttle_type
type: bool table: nav_mc_althold_throttle
- name: nav_extra_arming_safety - name: nav_extra_arming_safety
description: "If set to ON drone won't arm if no GPS fix and any navigation mode like RTH or POSHOLD is configured. ALLOW_BYPASS allows the user to momentarily disable this check by holding yaw high (left stick held at the bottom right in mode 2) when switch arming is used" description: "If set to ON drone won't arm if no GPS fix and any navigation mode like RTH or POSHOLD is configured. ALLOW_BYPASS allows the user to momentarily disable this check by holding yaw high (left stick held at the bottom right in mode 2) when switch arming is used"
default_value: "ALLOW_BYPASS" default_value: "ALLOW_BYPASS"

View file

@ -542,7 +542,7 @@ void osdFormatAltitudeSymbol(char *buff, int32_t alt)
buff[0] = ' '; buff[0] = ' ';
} }
#ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it and change the values #ifndef DISABLE_MSP_BF_COMPAT // IF BFCOMPAT is not supported, there's no need to check for it and change the values
if (isBfCompatibleVideoSystem(osdConfig())) { if (isBfCompatibleVideoSystem(osdConfig())) {
totalDigits++; totalDigits++;
digits++; digits++;
@ -636,8 +636,8 @@ static inline void osdFormatFlyTime(char *buff, textAttributes_t *attr)
} }
} }
/** /**
* Trim whitespace from string. * Trim whitespace from string.
* Used in Stats screen on lines with multiple values. * Used in Stats screen on lines with multiple values.
*/ */
char *osdFormatTrimWhiteSpace(char *buff) char *osdFormatTrimWhiteSpace(char *buff)
@ -648,7 +648,7 @@ char *osdFormatTrimWhiteSpace(char *buff)
while(isspace((unsigned char)*buff)) buff++; while(isspace((unsigned char)*buff)) buff++;
// All spaces? // All spaces?
if(*buff == 0) if(*buff == 0)
return buff; return buff;
// Trim trailing spaces // Trim trailing spaces
@ -1094,7 +1094,7 @@ void osdCrosshairPosition(uint8_t *x, uint8_t *y)
* Check if this OSD layout is using scaled or unscaled throttle. * Check if this OSD layout is using scaled or unscaled throttle.
* If both are used, it will default to scaled. * If both are used, it will default to scaled.
*/ */
bool osdUsingScaledThrottle(void) bool osdUsingScaledThrottle(void)
{ {
bool usingScaledThrottle = OSD_VISIBLE(osdLayoutsConfig()->item_pos[currentLayout][OSD_SCALED_THROTTLE_POS]); bool usingScaledThrottle = OSD_VISIBLE(osdLayoutsConfig()->item_pos[currentLayout][OSD_SCALED_THROTTLE_POS]);
bool usingRCThrottle = OSD_VISIBLE(osdLayoutsConfig()->item_pos[currentLayout][OSD_THROTTLE_POS]); bool usingRCThrottle = OSD_VISIBLE(osdLayoutsConfig()->item_pos[currentLayout][OSD_THROTTLE_POS]);
@ -2022,6 +2022,10 @@ static bool osdDrawSingleElement(uint8_t item)
TEXT_ATTRIBUTES_ADD_BLINK(elemAttr); TEXT_ATTRIBUTES_ADD_BLINK(elemAttr);
} }
if (STATE(MULTIROTOR) && posControl.flags.isAdjustingAltitude) {
TEXT_ATTRIBUTES_ADD_INVERTED(elemAttr);
TEXT_ATTRIBUTES_ADD_BLINK(elemAttr);
}
break; break;
} }
@ -2979,7 +2983,7 @@ static bool osdDrawSingleElement(uint8_t item)
tfp_sprintf(buff, "%s%c", buff, SYM_AH_MI); tfp_sprintf(buff, "%s%c", buff, SYM_AH_MI);
} }
if (!efficiencyValid) { if (!efficiencyValid) {
buff[0] = buff[1] = buff[2] = buff[3] = '-'; buff[0] = buff[1] = buff[2] = buff[3] = '-';
buff[digits] = SYM_MAH_MI_0; // This will overwrite the "-" at buff[3] if not in BFCOMPAT mode buff[digits] = SYM_MAH_MI_0; // This will overwrite the "-" at buff[3] if not in BFCOMPAT mode
buff[digits + 1] = SYM_MAH_MI_1; buff[digits + 1] = SYM_MAH_MI_1;
buff[digits + 2] = '\0'; buff[digits + 2] = '\0';
@ -2993,7 +2997,7 @@ static bool osdDrawSingleElement(uint8_t item)
tfp_sprintf(buff, "%s%c", buff, SYM_AH_NM); tfp_sprintf(buff, "%s%c", buff, SYM_AH_NM);
} }
if (!efficiencyValid) { if (!efficiencyValid) {
buff[0] = buff[1] = buff[2] = buff[3] = '-'; buff[0] = buff[1] = buff[2] = buff[3] = '-';
buff[digits] = SYM_MAH_NM_0; buff[digits] = SYM_MAH_NM_0;
buff[digits + 1] = SYM_MAH_NM_1; buff[digits + 1] = SYM_MAH_NM_1;
buff[digits + 2] = '\0'; buff[digits + 2] = '\0';
@ -3009,7 +3013,7 @@ static bool osdDrawSingleElement(uint8_t item)
tfp_sprintf(buff, "%s%c", buff, SYM_AH_KM); tfp_sprintf(buff, "%s%c", buff, SYM_AH_KM);
} }
if (!efficiencyValid) { if (!efficiencyValid) {
buff[0] = buff[1] = buff[2] = buff[3] = '-'; buff[0] = buff[1] = buff[2] = buff[3] = '-';
buff[digits] = SYM_MAH_KM_0; buff[digits] = SYM_MAH_KM_0;
buff[digits + 1] = SYM_MAH_KM_1; buff[digits + 1] = SYM_MAH_KM_1;
buff[digits + 2] = '\0'; buff[digits + 2] = '\0';
@ -4094,7 +4098,7 @@ static void osdUpdateStats(void)
static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page) static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page)
{ {
const char * disarmReasonStr[DISARM_REASON_COUNT] = { "UNKNOWN", "TIMEOUT", "STICKS", "SWITCH", "SWITCH", "KILLSW", "FAILSAFE", "NAV SYS", "LANDING"}; const char * disarmReasonStr[DISARM_REASON_COUNT] = { "UNKNOWN", "TIMEOUT", "STICKS", "SWITCH", "SWITCH", "KILLSW", "FAILSAFE", "NAV SYS", "LANDING"};
uint8_t top = 1; // Start one line down leaving space at the top of the screen. uint8_t top = 1; // Start one line down leaving space at the top of the screen.
size_t multiValueLengthOffset = 0; size_t multiValueLengthOffset = 0;
const uint8_t statNameX = osdDisplayIsHD() ? 11 : 1; const uint8_t statNameX = osdDisplayIsHD() ? 11 : 1;
@ -4116,14 +4120,14 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page)
} }
if (isSinglePageStatsCompatible || page == 0) { if (isSinglePageStatsCompatible || page == 0) {
if (feature(FEATURE_GPS)) { if (feature(FEATURE_GPS)) {
if (isSinglePageStatsCompatible) { if (isSinglePageStatsCompatible) {
displayWrite(osdDisplayPort, statNameX, top, "MAX/AVG SPEED :"); displayWrite(osdDisplayPort, statNameX, top, "MAX/AVG SPEED :");
osdFormatVelocityStr(buff, stats.max_3D_speed, true, false); osdFormatVelocityStr(buff, stats.max_3D_speed, true, false);
osdLeftAlignString(buff); osdLeftAlignString(buff);
strcat(osdFormatTrimWhiteSpace(buff),"/"); strcat(osdFormatTrimWhiteSpace(buff),"/");
multiValueLengthOffset = strlen(buff); multiValueLengthOffset = strlen(buff);
displayWrite(osdDisplayPort, statValuesX, top, buff); displayWrite(osdDisplayPort, statValuesX, top, buff);
osdGenerateAverageVelocityStr(buff); osdGenerateAverageVelocityStr(buff);
osdLeftAlignString(buff); osdLeftAlignString(buff);
displayWrite(osdDisplayPort, statValuesX + multiValueLengthOffset, top++, buff); displayWrite(osdDisplayPort, statValuesX + multiValueLengthOffset, top++, buff);
@ -4160,7 +4164,7 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page)
osdLeftAlignString(buff); osdLeftAlignString(buff);
strcat(osdFormatTrimWhiteSpace(buff), "%/"); strcat(osdFormatTrimWhiteSpace(buff), "%/");
multiValueLengthOffset = strlen(buff); multiValueLengthOffset = strlen(buff);
displayWrite(osdDisplayPort, statValuesX, top, buff); displayWrite(osdDisplayPort, statValuesX, top, buff);
itoa(stats.min_rssi_dbm, buff, 10); itoa(stats.min_rssi_dbm, buff, 10);
tfp_sprintf(buff, "%s%c", buff, SYM_DBM); tfp_sprintf(buff, "%s%c", buff, SYM_DBM);
osdLeftAlignString(buff); osdLeftAlignString(buff);
@ -4175,7 +4179,7 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page)
itoa(stats.min_rssi_dbm, buff, 10); itoa(stats.min_rssi_dbm, buff, 10);
tfp_sprintf(buff, "%s%c", buff, SYM_DBM); tfp_sprintf(buff, "%s%c", buff, SYM_DBM);
displayWrite(osdDisplayPort, statValuesX, top++, buff); displayWrite(osdDisplayPort, statValuesX, top++, buff);
} }
displayWrite(osdDisplayPort, statNameX, top, "MIN LQ :"); displayWrite(osdDisplayPort, statNameX, top, "MIN LQ :");
itoa(stats.min_lq, buff, 10); itoa(stats.min_lq, buff, 10);
@ -4201,7 +4205,7 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page)
displayWrite(osdDisplayPort, statNameX, top, "DISARMED BY :"); displayWrite(osdDisplayPort, statNameX, top, "DISARMED BY :");
displayWrite(osdDisplayPort, statValuesX, top++, disarmReasonStr[getDisarmReason()]); displayWrite(osdDisplayPort, statValuesX, top++, disarmReasonStr[getDisarmReason()]);
} }
if (isSinglePageStatsCompatible || page == 1) { if (isSinglePageStatsCompatible || page == 1) {
if (osdConfig()->stats_min_voltage_unit == OSD_STATS_MIN_VOLTAGE_UNIT_BATTERY) { if (osdConfig()->stats_min_voltage_unit == OSD_STATS_MIN_VOLTAGE_UNIT_BATTERY) {
displayWrite(osdDisplayPort, statNameX, top, "MIN BATTERY VOLT :"); displayWrite(osdDisplayPort, statNameX, top, "MIN BATTERY VOLT :");
@ -4323,20 +4327,20 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page)
} }
} }
const float max_gforce = accGetMeasuredMaxG(); const float max_gforce = accGetMeasuredMaxG();
displayWrite(osdDisplayPort, statNameX, top, "MAX G-FORCE :"); displayWrite(osdDisplayPort, statNameX, top, "MAX G-FORCE :");
osdFormatCentiNumber(buff, max_gforce * 100, 0, 2, 0, 3); osdFormatCentiNumber(buff, max_gforce * 100, 0, 2, 0, 3);
displayWrite(osdDisplayPort, statValuesX, top++, buff); displayWrite(osdDisplayPort, statValuesX, top++, buff);
const acc_extremes_t *acc_extremes = accGetMeasuredExtremes(); const acc_extremes_t *acc_extremes = accGetMeasuredExtremes();
const float acc_extremes_min = acc_extremes[Z].min; const float acc_extremes_min = acc_extremes[Z].min;
const float acc_extremes_max = acc_extremes[Z].max; const float acc_extremes_max = acc_extremes[Z].max;
displayWrite(osdDisplayPort, statNameX, top, "MIN/MAX Z G-FORCE:"); displayWrite(osdDisplayPort, statNameX, top, "MIN/MAX Z G-FORCE:");
osdFormatCentiNumber(buff, acc_extremes_min * 100, 0, 2, 0, 4); osdFormatCentiNumber(buff, acc_extremes_min * 100, 0, 2, 0, 4);
osdLeftAlignString(buff); osdLeftAlignString(buff);
strcat(osdFormatTrimWhiteSpace(buff),"/"); strcat(osdFormatTrimWhiteSpace(buff),"/");
multiValueLengthOffset = strlen(buff); multiValueLengthOffset = strlen(buff);
displayWrite(osdDisplayPort, statValuesX, top, buff); displayWrite(osdDisplayPort, statValuesX, top, buff);
osdFormatCentiNumber(buff, acc_extremes_max * 100, 0, 2, 0, 3); osdFormatCentiNumber(buff, acc_extremes_max * 100, 0, 2, 0, 3);
osdLeftAlignString(buff); osdLeftAlignString(buff);
displayWrite(osdDisplayPort, statValuesX + multiValueLengthOffset, top++, buff); displayWrite(osdDisplayPort, statValuesX + multiValueLengthOffset, top++, buff);
@ -4546,41 +4550,41 @@ static void osdRefresh(timeUs_t currentTimeUs)
statsCurrentPage = 0; statsCurrentPage = 0;
statsAutoPagingEnabled = osdConfig()->stats_page_auto_swap_time > 0 ? true : false; statsAutoPagingEnabled = osdConfig()->stats_page_auto_swap_time > 0 ? true : false;
osdShowStats(statsSinglePageCompatible, statsCurrentPage); osdShowStats(statsSinglePageCompatible, statsCurrentPage);
osdSetNextRefreshIn(STATS_SCREEN_DISPLAY_TIME); osdSetNextRefreshIn(STATS_SCREEN_DISPLAY_TIME);
} }
armState = ARMING_FLAG(ARMED); armState = ARMING_FLAG(ARMED);
} }
// This block is entered when we're showing the "Splash", "Armed" or "Stats" screens // This block is entered when we're showing the "Splash", "Armed" or "Stats" screens
if (resumeRefreshAt) { if (resumeRefreshAt) {
// Handle events only when the "Stats" screen is being displayed. // Handle events only when the "Stats" screen is being displayed.
if (statsDisplayed) { if (statsDisplayed) {
// Manual paging stick commands are only applicable to multi-page stats. // Manual paging stick commands are only applicable to multi-page stats.
// ****************************** // ******************************
// For single-page stats, this effectively disables the ability to cancel the // For single-page stats, this effectively disables the ability to cancel the
// automatic paging/updates with the stick commands. So unless stats_page_auto_swap_time // automatic paging/updates with the stick commands. So unless stats_page_auto_swap_time
// is set to 0 or greater than 4 (saved settings display interval is 5 seconds), then // is set to 0 or greater than 4 (saved settings display interval is 5 seconds), then
// "Saved Settings" should display if it is active within the refresh interval. // "Saved Settings" should display if it is active within the refresh interval.
// ****************************** // ******************************
// With multi-page stats, "Saved Settings" could also be missed if the user // With multi-page stats, "Saved Settings" could also be missed if the user
// has canceled automatic paging using the stick commands, because that is only // has canceled automatic paging using the stick commands, because that is only
// updated when osdShowStats() is called. So, in that case, they would only see // updated when osdShowStats() is called. So, in that case, they would only see
// the "Saved Settings" message if they happen to manually change pages using the // the "Saved Settings" message if they happen to manually change pages using the
// stick commands within the interval the message is displayed. // stick commands within the interval the message is displayed.
bool manualPageUpRequested = false; bool manualPageUpRequested = false;
bool manualPageDownRequested = false; bool manualPageDownRequested = false;
if (!statsSinglePageCompatible) { if (!statsSinglePageCompatible) {
// These methods ensure the paging stick commands are held for a brief period // These methods ensure the paging stick commands are held for a brief period
// Otherwise it can result in a race condition where the stats are // Otherwise it can result in a race condition where the stats are
// updated too quickly and can result in partial blanks, etc. // updated too quickly and can result in partial blanks, etc.
if (osdIsPageUpStickCommandHeld()) { if (osdIsPageUpStickCommandHeld()) {
manualPageUpRequested = true; manualPageUpRequested = true;
statsAutoPagingEnabled = false; statsAutoPagingEnabled = false;
} else if (osdIsPageDownStickCommandHeld()) { } else if (osdIsPageDownStickCommandHeld()) {
manualPageDownRequested = true; manualPageDownRequested = true;
statsAutoPagingEnabled = false; statsAutoPagingEnabled = false;
} }
} }
@ -4603,7 +4607,7 @@ static void osdRefresh(timeUs_t currentTimeUs)
// Process manual page change events for multi-page stats. // Process manual page change events for multi-page stats.
if (manualPageUpRequested) { if (manualPageUpRequested) {
osdShowStats(statsSinglePageCompatible, 1); osdShowStats(statsSinglePageCompatible, 1);
statsCurrentPage = 1; statsCurrentPage = 1;
} else if (manualPageDownRequested) { } else if (manualPageDownRequested) {
osdShowStats(statsSinglePageCompatible, 0); osdShowStats(statsSinglePageCompatible, 0);
statsCurrentPage = 0; statsCurrentPage = 0;
@ -4612,7 +4616,7 @@ static void osdRefresh(timeUs_t currentTimeUs)
} }
// Handle events when either "Splash", "Armed" or "Stats" screens are displayed. // Handle events when either "Splash", "Armed" or "Stats" screens are displayed.
if ((currentTimeUs > resumeRefreshAt) || OSD_RESUME_UPDATES_STICK_COMMAND) { if ((currentTimeUs > resumeRefreshAt) || OSD_RESUME_UPDATES_STICK_COMMAND) {
// Time elapsed or canceled by stick commands. // Time elapsed or canceled by stick commands.
// Exit to normal OSD operation. // Exit to normal OSD operation.
displayClearScreen(osdDisplayPort); displayClearScreen(osdDisplayPort);
@ -4622,7 +4626,7 @@ static void osdRefresh(timeUs_t currentTimeUs)
// Continue "Splash", "Armed" or "Stats" screens. // Continue "Splash", "Armed" or "Stats" screens.
displayHeartbeat(osdDisplayPort); displayHeartbeat(osdDisplayPort);
} }
return; return;
} }

View file

@ -107,7 +107,6 @@ PG_RESET_TEMPLATE(navConfig_t, navConfig,
.general = { .general = {
.flags = { .flags = {
.use_thr_mid_for_althold = SETTING_NAV_USE_MIDTHR_FOR_ALTHOLD_DEFAULT,
.extra_arming_safety = SETTING_NAV_EXTRA_ARMING_SAFETY_DEFAULT, .extra_arming_safety = SETTING_NAV_EXTRA_ARMING_SAFETY_DEFAULT,
.user_control_mode = SETTING_NAV_USER_CONTROL_MODE_DEFAULT, .user_control_mode = SETTING_NAV_USER_CONTROL_MODE_DEFAULT,
.rth_alt_control_mode = SETTING_NAV_RTH_ALT_MODE_DEFAULT, .rth_alt_control_mode = SETTING_NAV_RTH_ALT_MODE_DEFAULT,
@ -176,9 +175,10 @@ PG_RESET_TEMPLATE(navConfig_t, navConfig,
.braking_bank_angle = SETTING_NAV_MC_BRAKING_BANK_ANGLE_DEFAULT, // Max braking angle .braking_bank_angle = SETTING_NAV_MC_BRAKING_BANK_ANGLE_DEFAULT, // Max braking angle
#endif #endif
.posDecelerationTime = SETTING_NAV_MC_POS_DECELERATION_TIME_DEFAULT, // posDecelerationTime * 100 .posDecelerationTime = SETTING_NAV_MC_POS_DECELERATION_TIME_DEFAULT, // posDecelerationTime * 100
.posResponseExpo = SETTING_NAV_MC_POS_EXPO_DEFAULT, // posResponseExpo * 100 .posResponseExpo = SETTING_NAV_MC_POS_EXPO_DEFAULT, // posResponseExpo * 100
.slowDownForTurning = SETTING_NAV_MC_WP_SLOWDOWN_DEFAULT, .slowDownForTurning = SETTING_NAV_MC_WP_SLOWDOWN_DEFAULT,
.althold_throttle_type = SETTING_NAV_MC_ALTHOLD_THROTTLE_DEFAULT, // STICK
}, },
// Fixed wing // Fixed wing

View file

@ -175,6 +175,12 @@ typedef enum {
WP_TURN_SMOOTHING_CUT, WP_TURN_SMOOTHING_CUT,
} wpFwTurnSmoothing_e; } wpFwTurnSmoothing_e;
typedef enum {
MC_ALT_HOLD_STICK,
MC_ALT_HOLD_MID,
MC_ALT_HOLD_HOVER,
} navMcAltHoldThrottle_e;
typedef struct positionEstimationConfig_s { typedef struct positionEstimationConfig_s {
uint8_t automatic_mag_declination; uint8_t automatic_mag_declination;
uint8_t reset_altitude_type; // from nav_reset_type_e uint8_t reset_altitude_type; // from nav_reset_type_e
@ -217,7 +223,6 @@ typedef struct navConfig_s {
struct { struct {
struct { struct {
uint8_t use_thr_mid_for_althold; // Don't remember throttle when althold was initiated, assume that throttle is at Thr Mid = zero climb rate
uint8_t extra_arming_safety; // from navExtraArmingSafety_e uint8_t extra_arming_safety; // from navExtraArmingSafety_e
uint8_t user_control_mode; // NAV_GPS_ATTI or NAV_GPS_CRUISE uint8_t user_control_mode; // NAV_GPS_ATTI or NAV_GPS_CRUISE
uint8_t rth_alt_control_mode; // Controls the logic for choosing the RTH altitude uint8_t rth_alt_control_mode; // Controls the logic for choosing the RTH altitude
@ -286,7 +291,8 @@ typedef struct navConfig_s {
uint8_t posDecelerationTime; // Brake time parameter uint8_t posDecelerationTime; // Brake time parameter
uint8_t posResponseExpo; // Position controller expo (taret vel expo for MC) uint8_t posResponseExpo; // Position controller expo (taret vel expo for MC)
bool slowDownForTurning; // Slow down during WP missions when changing heading on next waypoint bool slowDownForTurning; // Slow down during WP missions when changing heading on next waypoint
uint8_t althold_throttle_type; // throttle zero datum type for alt hold
} mc; } mc;
struct { struct {

View file

@ -177,19 +177,16 @@ bool adjustMulticopterAltitudeFromRCInput(void)
void setupMulticopterAltitudeController(void) void setupMulticopterAltitudeController(void)
{ {
const bool throttleIsLow = throttleStickIsLow(); const bool throttleIsLow = throttleStickIsLow();
const uint8_t throttleType = navConfig()->mc.althold_throttle_type;
if (navConfig()->general.flags.use_thr_mid_for_althold) { if (throttleType == MC_ALT_HOLD_STICK && !throttleIsLow) {
// Only use current throttle if not LOW - use Thr Mid otherwise
altHoldThrottleRCZero = rcCommand[THROTTLE];
} else if (throttleType == MC_ALT_HOLD_HOVER) {
altHoldThrottleRCZero = currentBatteryProfile->nav.mc.hover_throttle;
} else {
altHoldThrottleRCZero = rcLookupThrottleMid(); altHoldThrottleRCZero = rcLookupThrottleMid();
} }
else {
// If throttle is LOW - use Thr Mid anyway
if (throttleIsLow) {
altHoldThrottleRCZero = rcLookupThrottleMid();
}
else {
altHoldThrottleRCZero = rcCommand[THROTTLE];
}
}
// Make sure we are able to satisfy the deadband // Make sure we are able to satisfy the deadband
altHoldThrottleRCZero = constrain(altHoldThrottleRCZero, altHoldThrottleRCZero = constrain(altHoldThrottleRCZero,