mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-15 07:29:15 +01:00
OP-192 Flight/ManualControl: Correctly convert to ms in timeout code so system
will automatically disarm after 30 seconds without motor. This behavior will need to be parameterized for planes which might idle for a while. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2181 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
3069f81000
commit
4f21bee0d7
@ -283,13 +283,18 @@ static void manualControlTask(void *parameters)
|
||||
ManualControlCommandSet(&cmd);
|
||||
}
|
||||
|
||||
if(cmd.Throttle < 0 && !lowThrottleDetected) {
|
||||
if((cmd.Throttle < 0) && !lowThrottleDetected) {
|
||||
lowThrottleDetected = 1;
|
||||
lowThrottleStart = lastSysTime;
|
||||
} else if (cmd.Throttle)
|
||||
} else if (cmd.Throttle >= 0)
|
||||
lowThrottleDetected = 0;
|
||||
else if((cmd.Throttle < 0) && (timeDifferenceMs(lowThrottleStart, lastSysTime) > ARMED_TIMEOUT_MS))
|
||||
else if((cmd.Throttle < 0) && (timeDifferenceMs(lowThrottleStart, lastSysTime) > ARMED_TIMEOUT_MS)) {
|
||||
cmd.Armed = MANUALCONTROLCOMMAND_ARMED_FALSE;
|
||||
ManualControlCommandSet(&cmd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Look for arm or disarm signal */
|
||||
if ((cmd.Throttle <= 0.05) && (cmd.Roll <= -0.95)) {
|
||||
@ -363,8 +368,8 @@ static float scaleChannel(int16_t value, int16_t max, int16_t min, int16_t neutr
|
||||
|
||||
static uint32_t timeDifferenceMs(portTickType start_time, portTickType end_time) {
|
||||
if(end_time > start_time)
|
||||
return (end_time - start_time) / portTICK_RATE_MS;
|
||||
return ((((portTICK_RATE_MS) -1) - start_time) + end_time) / portTICK_RATE_MS;
|
||||
return (end_time - start_time) * portTICK_RATE_MS;
|
||||
return ((((portTICK_RATE_MS) -1) - start_time) + end_time) * portTICK_RATE_MS;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user