1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Flight/Manual: Cleaner solution to deal with timer wraparound

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2069 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2010-11-04 02:30:51 +00:00 committed by peabody124
parent 1f87715719
commit 7bdd900409

View File

@ -275,14 +275,14 @@ static void manualControlTask(void *parameters)
/* Look for arm or disarm signal */
if ((cmd.Throttle <= 0.05) && (cmd.Roll <= -0.95)) {
if ((armedDisarmStart == 0) || (lastSysTime < armedDisarmStart)) // store when started, deal with rollover
if (armedDisarmStart == 0) // store when started, deal with rollover
armedDisarmStart = lastSysTime;
else if ((lastSysTime - armedDisarmStart) > (1000 * portTICK_RATE_MS))
else if (timeDifferenceMs(armedDisarmStart, lastSysTime) > ARMED_TIME_MS)
cmd.Armed = MANUALCONTROLCOMMAND_ARMED_TRUE;
} else if ((cmd.Throttle <= 0.05) && (cmd.Roll >= 0.95)) {
if ((armedDisarmStart == 0) || (lastSysTime < armedDisarmStart)) // store when started, deal with rollover
if (armedDisarmStart == 0)
armedDisarmStart = lastSysTime;
else if ((lastSysTime - armedDisarmStart) > (1000 * portTICK_RATE_MS))
else if (timeDifferenceMs(armedDisarmStart, lastSysTime) > ARMED_TIME_MS)
cmd.Armed = MANUALCONTROLCOMMAND_ARMED_FALSE;
} else {
armedDisarmStart = 0;