Skip to content

Commit

Permalink
Creation
Browse files Browse the repository at this point in the history
  • Loading branch information
breadoven committed Mar 10, 2024
1 parent e4b95ef commit e72f76e
Show file tree
Hide file tree
Showing 46 changed files with 1,501 additions and 797 deletions.
2 changes: 1 addition & 1 deletion src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ main_sources(COMMON_SRC
drivers/pitotmeter/pitotmeter_ms4525.c
drivers/pitotmeter/pitotmeter_ms4525.h
drivers/pitotmeter/pitotmeter_dlvr_l10d.c
drivers/pitotmeter/pitotmeter_dlvr_l10d.h
drivers/pitotmeter/pitotmeter_dlvr_l10d.h
drivers/pitotmeter/pitotmeter_msp.c
drivers/pitotmeter/pitotmeter_msp.h
drivers/pitotmeter/pitotmeter_virtual.c
Expand Down
2 changes: 1 addition & 1 deletion src/main/blackbox/blackbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ typedef struct blackboxMainState_s {
int32_t mcSurfacePID[3];
int32_t mcSurfacePIDOutput;

int32_t fwAltPID[3];
int32_t fwAltPID[3]; // CR97
int32_t fwAltPIDOutput;
int32_t fwPosPID[3];
int32_t fwPosPIDOutput;
Expand Down
3 changes: 2 additions & 1 deletion src/main/cms/cms_menu_imu.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ static const OSD_Entry cmsx_menuPidAltMagEntries[] =
{
OSD_LABEL_DATA_ENTRY("-- ALT&MAG --", profileIndexString),

OSD_SETTING_ENTRY("FW ALT RESPONSE", SETTING_NAV_FW_ALT_CONTROL_RESPONSE), // CR97A

OTHER_PIDFF_ENTRY("ALT P", &cmsx_pidPosZ.P),
OTHER_PIDFF_ENTRY("ALT I", &cmsx_pidPosZ.I),
OTHER_PIDFF_ENTRY("ALT D", &cmsx_pidPosZ.D),
Expand Down Expand Up @@ -256,7 +258,6 @@ static const OSD_Entry cmsx_menuPidGpsnavEntries[] =
OTHER_PIDFF_ENTRY("VEL I", &cmsx_pidVelXY.I),
OTHER_PIDFF_ENTRY("VEL D", &cmsx_pidVelXY.D),
OTHER_PIDFF_ENTRY("VEL FF", &cmsx_pidVelXY.FF),

OSD_BACK_AND_END_ENTRY,
};

Expand Down
9 changes: 6 additions & 3 deletions src/main/cms/cms_menu_navigation.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ static const OSD_Entry cmsx_menuNavSettingsEntries[] =
OSD_SETTING_ENTRY("MC MAX BANK ANGLE", SETTING_NAV_MC_BANK_ANGLE),
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("USE FW YAW CONTROL", SETTING_NAV_USE_FW_YAW_CONTROL),
OSD_SETTING_ENTRY("LAND SENSITIVITY", SETTING_NAV_LAND_DETECT_SENSITIVITY),
OSD_SETTING_ENTRY("LANDING DISARM", SETTING_NAV_DISARM_ON_LANDING),
OSD_SETTING_ENTRY("MC DTERM ATT START", SETTING_NAV_MC_VEL_XY_DTERM_ATTENUATION_START), // CR47

OSD_BACK_AND_END_ENTRY,
};
Expand Down Expand Up @@ -106,7 +109,7 @@ static const CMS_Menu cmsx_menuRTH = {

static const OSD_Entry cmsx_menuFWCruiseEntries[] =
{
OSD_LABEL_ENTRY("-- CRUISE --"),
OSD_LABEL_ENTRY("-- GENERAL --"),

OSD_SETTING_ENTRY("CRUISE THROTTLE", SETTING_NAV_FW_CRUISE_THR),
OSD_SETTING_ENTRY("MIN THROTTLE", SETTING_NAV_FW_MIN_THR),
Expand Down Expand Up @@ -172,7 +175,7 @@ static const OSD_Entry cmsx_menuFWSettingsEntries[] =
OSD_LABEL_ENTRY("-- FIXED WING --"),

OSD_SUBMENU_ENTRY("AUTOLAUNCH", &cmsx_menuFWLaunch),
OSD_SUBMENU_ENTRY("CRUISE", &cmsx_menuFWCruise),
OSD_SUBMENU_ENTRY("GENERAL", &cmsx_menuFWCruise),

OSD_BACK_AND_END_ENTRY,
};
Expand All @@ -193,6 +196,7 @@ static const OSD_Entry cmsx_menuMissionSettingsEntries[] =
OSD_LABEL_ENTRY("-- MISSIONS --"),

OSD_SETTING_ENTRY("MC WP SLOWDOWN", SETTING_NAV_MC_WP_SLOWDOWN),
OSD_SETTING_ENTRY("MISSION RESTART", SETTING_NAV_WP_MISSION_RESTART),
OSD_SETTING_ENTRY("WP FAILSAFE DELAY", SETTING_FAILSAFE_MISSION_DELAY),
OSD_SETTING_ENTRY("WP LOAD ON BOOT", SETTING_NAV_WP_LOAD_ON_BOOT),
OSD_SETTING_ENTRY("WP REACHED RADIUS", SETTING_NAV_WP_RADIUS),
Expand All @@ -201,7 +205,6 @@ static const OSD_Entry cmsx_menuMissionSettingsEntries[] =
#ifdef USE_MULTI_MISSION
OSD_SETTING_ENTRY("MULTI MISSION NUMBER", SETTING_NAV_WP_MULTI_MISSION_INDEX),
#endif
OSD_SETTING_ENTRY("MISSION RESTART", SETTING_NAV_WP_MISSION_RESTART),
OSD_SETTING_ENTRY("WP TURN SMOOTHING", SETTING_NAV_FW_WP_TURN_SMOOTHING),
OSD_SETTING_ENTRY("WP TRACKING ACCURACY", SETTING_NAV_FW_WP_TRACKING_ACCURACY),
OSD_BACK_AND_END_ENTRY,
Expand Down
17 changes: 11 additions & 6 deletions src/main/common/fp_pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ float navPidApply3(
const float dt,
const float outMin,
const float outMax,
const pidControllerFlags_e pidFlags,
pidControllerFlags_e pidFlags, // CR99
const float gainScaler,
const float dTermScaler
) {
float newProportional, newDerivative, newFeedForward;
float error = 0.0f;

if (pid->errorLpfHz > 0.0f) {
error = pt1FilterApply4(&pid->error_filter_state, setpoint - measurement, pid->errorLpfHz, dt);
} else {
Expand Down Expand Up @@ -79,7 +79,12 @@ float navPidApply3(
}

newDerivative = newDerivative * gainScaler * dTermScaler;

// CR99
// zero integral if proportional saturated
// if (newProportional > outMax || newProportional < outMin) {
// pidFlags |= PID_ZERO_INTEGRATOR;
// }
// CR99
if (pidFlags & PID_ZERO_INTEGRATOR) {
pid->integrator = 0.0f;
}
Expand Down Expand Up @@ -107,7 +112,7 @@ float navPidApply3(
/* Update I-term */
if (
!(pidFlags & PID_ZERO_INTEGRATOR) &&
!(pidFlags & PID_FREEZE_INTEGRATOR)
!(pidFlags & PID_FREEZE_INTEGRATOR)
) {
const float newIntegrator = pid->integrator + (error * pid->param.kI * gainScaler * dt) + (backCalc * pid->param.kT * dt);

Expand All @@ -121,10 +126,10 @@ float navPidApply3(
pid->integrator = newIntegrator;
}
}

if (pidFlags & PID_LIMIT_INTEGRATOR) {
pid->integrator = constrainf(pid->integrator, outMin, outMax);
}
}

return outValConstrained;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/common/fp_pid.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ float navPidApply3(
const float dt,
const float outMin,
const float outMax,
const pidControllerFlags_e pidFlags,
pidControllerFlags_e pidFlags, // CR99
const float gainScaler,
const float dTermScaler
);
Expand Down
4 changes: 2 additions & 2 deletions src/main/drivers/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ int displayWriteChar(displayPort_t *instance, uint8_t x, uint8_t y, uint16_t c)

#ifdef USE_SIMULATOR
if (ARMING_FLAG(SIMULATOR_MODE_HITL)) {
//some FCs do not power max7456 from USB power
//driver can not read font metadata
//some FCs do not power max7456 from USB power
//driver can not read font metadata
//chip assumed to not support second bank of font
//artifical horizon, variometer and home direction are not drawn ( display.c: displayUpdateMaxChar())
//return dummy metadata to let all OSD elements to work in simulator mode
Expand Down
20 changes: 5 additions & 15 deletions src/main/fc/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ static void cliAssert(char *cmdline);
#endif

#ifdef USE_CLI_BATCH
static bool commandBatchActive = false;
static bool commandBatchError = false;
static uint8_t commandBatchErrorCount = 0;
static bool commandBatchActive = false;
static bool commandBatchError = false;
#endif

// sync this with features_e
Expand Down Expand Up @@ -258,7 +257,6 @@ static void cliPrintError(const char *str)
#ifdef USE_CLI_BATCH
if (commandBatchActive) {
commandBatchError = true;
commandBatchErrorCount++;
}
#endif
}
Expand All @@ -270,7 +268,6 @@ static void cliPrintErrorLine(const char *str)
#ifdef USE_CLI_BATCH
if (commandBatchActive) {
commandBatchError = true;
commandBatchErrorCount++;
}
#endif
}
Expand Down Expand Up @@ -373,7 +370,6 @@ static void cliPrintErrorVa(const char *format, va_list va)
#ifdef USE_CLI_BATCH
if (commandBatchActive) {
commandBatchError = true;
commandBatchErrorCount++;
}
#endif
}
Expand Down Expand Up @@ -665,7 +661,6 @@ static void cliAssert(char *cmdline)
#ifdef USE_CLI_BATCH
if (commandBatchActive) {
commandBatchError = true;
commandBatchErrorCount++;
}
#endif
}
Expand Down Expand Up @@ -3424,10 +3419,7 @@ static void cliDumpMixerProfile(uint8_t profileIndex, uint8_t dumpMask)
#ifdef USE_CLI_BATCH
static void cliPrintCommandBatchWarning(const char *warning)
{
char errorBuf[59];
tfp_sprintf(errorBuf, "%d ERRORS WERE DETECTED - Please review and fix before continuing!", commandBatchErrorCount);

cliPrintErrorLinef(errorBuf);
cliPrintErrorLinef("ERRORS WERE DETECTED - PLEASE REVIEW BEFORE CONTINUING");
if (warning) {
cliPrintErrorLinef(warning);
}
Expand All @@ -3437,7 +3429,6 @@ static void resetCommandBatch(void)
{
commandBatchActive = false;
commandBatchError = false;
commandBatchErrorCount = 0;
}

static void cliBatch(char *cmdline)
Expand All @@ -3446,7 +3437,6 @@ static void cliBatch(char *cmdline)
if (!commandBatchActive) {
commandBatchActive = true;
commandBatchError = false;
commandBatchErrorCount = 0;
}
cliPrintLine("Command batch started");
} else if (strncasecmp(cmdline, "end", 3) == 0) {
Expand Down Expand Up @@ -3694,8 +3684,8 @@ static void cliStatus(char *cmdline)
#if defined(AT32F43x)
cliPrintLine("AT32 system clocks:");
crm_clocks_freq_type clocks;
crm_clocks_freq_get(&clocks);
crm_clocks_freq_get(&clocks);

cliPrintLinef(" SYSCLK = %d MHz", clocks.sclk_freq / 1000000);
cliPrintLinef(" ABH = %d MHz", clocks.ahb_freq / 1000000);
cliPrintLinef(" ABP1 = %d MHz", clocks.apb1_freq / 1000000);
Expand Down
4 changes: 2 additions & 2 deletions src/main/fc/fc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ void tryArm(void)
return;
}
#endif

#ifdef USE_PROGRAMMING_FRAMEWORK
if (emergInflightRearmEnabled() || !isArmingDisabled() || emergencyArmingIsEnabled() ||
LOGIC_CONDITION_GLOBAL_FLAG(LOGIC_CONDITION_GLOBAL_FLAG_OVERRIDE_ARMING_SAFETY)) {
Expand Down Expand Up @@ -741,7 +740,7 @@ void processRx(timeUs_t currentTimeUs)
// Handle passthrough mode
if (STATE(FIXED_WING_LEGACY)) {
if ((IS_RC_MODE_ACTIVE(BOXMANUAL) && !navigationRequiresAngleMode() && !failsafeRequiresAngleMode()) || // Normal activation of passthrough
(!ARMING_FLAG(ARMED) && areSensorsCalibrating())){ // Backup - if we are not armed - enforce passthrough while calibrating
(!ARMING_FLAG(ARMED) && areSensorsCalibrating())){ // Backup - if we are not armed - enforce passthrough while calibrating
ENABLE_FLIGHT_MODE(MANUAL_MODE);
} else {
DISABLE_FLIGHT_MODE(MANUAL_MODE);
Expand Down Expand Up @@ -980,6 +979,7 @@ void taskMainPidLoop(timeUs_t currentTimeUs)
blackboxUpdate(micros());
}
#endif

}

// This function is called in a busy-loop, everything called from here should do it's own
Expand Down
1 change: 0 additions & 1 deletion src/main/fc/fc_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ typedef enum disarmReason_e {
DISARM_REASON_COUNT
} disarmReason_t;


void handleInflightCalibrationStickPosition(void);

void disarm(disarmReason_t disarmReason);
Expand Down
Loading

0 comments on commit e72f76e

Please sign in to comment.