From 7bdd900409e678b23b7518386205369f5f496d6f Mon Sep 17 00:00:00 2001 From: peabody124 Date: Thu, 4 Nov 2010 02:30:51 +0000 Subject: [PATCH] Flight/Manual: Cleaner solution to deal with timer wraparound git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2069 ebee16cc-31ac-478f-84a7-5cbb03baadba --- flight/OpenPilot/Modules/ManualControl/manualcontrol.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flight/OpenPilot/Modules/ManualControl/manualcontrol.c b/flight/OpenPilot/Modules/ManualControl/manualcontrol.c index 157e44b6c..85fb7c679 100644 --- a/flight/OpenPilot/Modules/ManualControl/manualcontrol.c +++ b/flight/OpenPilot/Modules/ManualControl/manualcontrol.c @@ -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;