diff --git a/UAV-ControlSystem/src/tasks_main.c b/UAV-ControlSystem/src/tasks_main.c index 4392405..624ded6 100644 --- a/UAV-ControlSystem/src/tasks_main.c +++ b/UAV-ControlSystem/src/tasks_main.c @@ -163,6 +163,7 @@ bool systemTaskRxCliCheck(uint32_t currentDeltaTime) return false; } +//TODO: change the name of this task. Could be something like void systemTaskSerial(void) { static bool readyToCalibrate = true; @@ -180,23 +181,30 @@ void systemTaskSerial(void) // mpu6000_read_acc_offset(&accelProfile); // } // } + + //If we are ready to accept a new calibration value. You can only perform one calibration until the sticks have been centered once until the next calibration if(readyToCalibrate) { + //If any calibration is performed set readyToCalibrate to false so it cant just increase indefinitely when holding the sticks in a certain position if (flags_IsSet_ID(systemFlags_stickLeft_id)) { accRollFineTune -= calibrationAmount; + readyToCalibrate = false; } else if (flags_IsSet_ID(systemFlags_stickRight_id)) { accRollFineTune += calibrationAmount; + readyToCalibrate = false; } else if (flags_IsSet_ID(systemFlags_stickUp_id)) { accPitchFineTune -= calibrationAmount; + readyToCalibrate = false; } else if (flags_IsSet_ID(systemFlags_stickDown_id)) { accPitchFineTune += calibrationAmount; + readyToCalibrate = false; } }