From 212b02dfc693ea06b40a01a5fa346424a3a37c00 Mon Sep 17 00:00:00 2001 From: "bsongis@gmail.com" Date: Wed, 22 May 2013 09:08:15 +0000 Subject: [PATCH] [Taranis] Failsafe settings changed for NOPULSES and HOLD --- src/protocols/pxx_arm.cpp | 43 ++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/src/protocols/pxx_arm.cpp b/src/protocols/pxx_arm.cpp index df754dbe7..2394995c9 100644 --- a/src/protocols/pxx_arm.cpp +++ b/src/protocols/pxx_arm.cpp @@ -168,14 +168,12 @@ void setupPulsesPXX(unsigned int port) else { flag1 = (g_model.moduleData[port].rfProtocol << 6) | pxxFlag[port]; - if (g_model.moduleData[port].failsafeMode != FAILSAFE_HOLD) { - if (failsafeCounter[port]-- == 0) { - failsafeCounter[port] = 1000; - flag1 |= PXX_SEND_FAILSAFE; - } - if (failsafeCounter[port] == 0 && g_model.moduleData[port].channelsCount > 0) { - flag1 |= PXX_SEND_FAILSAFE; - } + if (failsafeCounter[port]-- == 0) { + failsafeCounter[port] = 1000; + flag1 |= PXX_SEND_FAILSAFE; + } + if (failsafeCounter[port] == 0 && g_model.moduleData[port].channelsCount > 0) { + flag1 |= PXX_SEND_FAILSAFE; } } @@ -192,31 +190,26 @@ void setupPulsesPXX(unsigned int port) } for (int i=0; i<8; i++) { if (flag1 & PXX_SEND_FAILSAFE) { - if (g_model.moduleData[port].failsafeMode == FAILSAFE_NOPULSES) { - if (i < sendUpperChannels) - chan = 3072; - else - chan = 1024; + if (g_model.moduleData[port].failsafeMode == FAILSAFE_HOLD) { + chan = 2047; + } + else if (g_model.moduleData[port].failsafeMode == FAILSAFE_NOPULSES) { + chan = 0; } else { - if (i < sendUpperChannels) { + if (i < sendUpperChannels) chan = limit(2048, PPM_CH_CENTER(8+g_model.moduleData[port].channelsStart+i) - PPM_CENTER + (g_model.moduleData[port].failsafeChannels[8+g_model.moduleData[port].channelsStart+i] * 512 / 682) + 3072, 4095); - if (chan == 3072) chan = 3073; - } - else { - chan = limit(0, PPM_CH_CENTER(g_model.moduleData[port].channelsStart+i) - PPM_CENTER + (g_model.moduleData[port].failsafeChannels[g_model.moduleData[port].channelsStart+i] * 512 / 682) + 1024, 2047); - if (chan == 1024) chan = 1025; - } + else + chan = limit(1, PPM_CH_CENTER(g_model.moduleData[port].channelsStart+i) - PPM_CENTER + (g_model.moduleData[port].failsafeChannels[g_model.moduleData[port].channelsStart+i] * 512 / 682) + 1024, 2046); } } else { if (i < sendUpperChannels) - chan = limit(2048, PPM_CH_CENTER(8+g_model.moduleData[port].channelsStart+i) - PPM_CENTER + (channelOutputs[8+g_model.moduleData[port].channelsStart+i] * 512 / 682) + 3072, 4095); + chan = limit(2048, PPM_CH_CENTER(8+g_model.moduleData[port].channelsStart+i) - PPM_CENTER + (channelOutputs[8+g_model.moduleData[port].channelsStart+i] * 512 / 682) + 3072, 4095); + else if (i < NUM_CHANNELS(port)) + chan = limit(1, PPM_CH_CENTER(g_model.moduleData[port].channelsStart+i) - PPM_CENTER + (channelOutputs[g_model.moduleData[port].channelsStart+i] * 512 / 682) + 1024, 2046); else - if(i >= NUM_CHANNELS(port)) - chan = 1024; - else - chan = limit(0, PPM_CH_CENTER(g_model.moduleData[port].channelsStart+i) - PPM_CENTER + (channelOutputs[g_model.moduleData[port].channelsStart+i] * 512 / 682) + 1024, 2047); + chan = 1024; } if (i & 1) {