From 51b297b46f00ca41e1a943bc01c33b5de1a4718a Mon Sep 17 00:00:00 2001 From: "gruvin@gmail.com" Date: Fri, 24 Aug 2012 01:57:00 +0000 Subject: [PATCH] re r1260 comments (bernet.andre) DSM2=PPM needs testing BIND & RANGECHECK. I have modified the DSM2=PPM code to implelent bind and range check the same way as for DSM2=SERIAL. NOTE: I have checked for clean compile but do not have hardware to test that the protocol is working correctly. PLEASE TEST. Thanks. --- src/pulses_avr.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/pulses_avr.cpp b/src/pulses_avr.cpp index 6d48eacb4..80a3b0dad 100644 --- a/src/pulses_avr.cpp +++ b/src/pulses_avr.cpp @@ -520,7 +520,7 @@ void setupPulsesDsm2() switch(g_model.ppmNCH) { case LPXDSM2: - dsmDat[0] = BIND_BIT; + dsmDat[0] = 0x00; break; case DSM2only: dsmDat[0] = 0x90; @@ -530,9 +530,20 @@ void setupPulsesDsm2() break; } } - if ((dsmDat[0] & BIND_BIT) && (!keyState(SW_Trainer))) dsmDat[0] &= ~BIND_BIT; // clear bind bit if trainer not pulled - // TODO find a way to do that, FUNC SWITCH: if ((!(dsmDat[0] & BIND_BIT)) && getSwitch(MAX_DRSWITCH-1, 0, 0)) dsmDat[0] |= RANGECHECK_BIT; // range check function - // else dsmDat[0] &= ~RANGECHECK_BIT; + + if (s_bind_allowed) s_bind_allowed--; + if (s_bind_allowed && keyState(SW_Trainer)) + { + s_bind_mode = true; + dsmDat[0] |= BIND_BIT; + } + else if (s_rangecheck_mode) + { + dsmDat[0] |= RANGECHECK_BIT; + } + else + s_bind_mode = false; + dsmDat[1] = g_model.modelId; // DSM2 Header second byte for model match for (uint8_t i=0; i