From 3dde380bb7eefc825d6302c4d27c5658c140ae23 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Tue, 27 Jan 2026 16:38:20 +0300 Subject: [PATCH] Add parameters for list of modes bound to rc switch Parameters: CTL_FLT_MODE_0, CTL_FLT_MODE_1, CTL_FLT_MODE_2. Also fix a bug with incorrect choosing the mode from controlMode. --- flix/control.ino | 7 ++++--- flix/parameters.ino | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/flix/control.ino b/flix/control.ino index 8f6d8e6..50601cb 100644 --- a/flix/control.ino +++ b/flix/control.ino @@ -52,6 +52,7 @@ PID pitchPID(PITCH_P, PITCH_I, PITCH_D); PID yawPID(YAW_P, 0, 0); Vector maxRate(ROLLRATE_MAX, PITCHRATE_MAX, YAWRATE_MAX); float tiltMax = TILT_MAX; +int flightModes[] = {STAB, STAB, STAB}; // map for rc mode switch extern const int MOTOR_REAR_LEFT, MOTOR_REAR_RIGHT, MOTOR_FRONT_RIGHT, MOTOR_FRONT_LEFT; extern float controlRoll, controlPitch, controlThrottle, controlYaw, controlMode; @@ -65,9 +66,9 @@ void control() { } void interpretControls() { - if (controlMode < 0.25) mode = STAB; - if (controlMode < 0.75) mode = STAB; - if (controlMode > 0.75) mode = STAB; + if (controlMode < 0.25) mode = flightModes[0]; + else if (controlMode < 0.75) mode = flightModes[1]; + else if (controlMode > 0.75) mode = flightModes[2]; if (mode == AUTO) return; // pilot is not effective in AUTO mode diff --git a/flix/parameters.ino b/flix/parameters.ino index 77aa21a..a8a83f9 100644 --- a/flix/parameters.ino +++ b/flix/parameters.ino @@ -49,6 +49,9 @@ Parameter parameters[] = { {"CTL_R_RATE_MAX", &maxRate.x}, {"CTL_Y_RATE_MAX", &maxRate.z}, {"CTL_TILT_MAX", &tiltMax}, + {"CTL_FLT_MODE_0", &flightModes[0]}, + {"CTL_FLT_MODE_1", &flightModes[1]}, + {"CTL_FLT_MODE_2", &flightModes[2]}, // imu {"IMU_ROT_ROLL", &imuRotation.x}, {"IMU_ROT_PITCH", &imuRotation.y},