From dd09df994c8178de98c23110fb136e3ab83ddcb4 Mon Sep 17 00:00:00 2001 From: "gruvin@gmail.com" Date: Fri, 24 Aug 2012 09:08:28 +0000 Subject: [PATCH] Changes to DSM2=PPM code to hopefully fix bind and rangecheck lock-on bugs. --- src/pulses_avr.cpp | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/pulses_avr.cpp b/src/pulses_avr.cpp index dd0710c12..18ce6805f 100644 --- a/src/pulses_avr.cpp +++ b/src/pulses_avr.cpp @@ -430,7 +430,7 @@ FORCEINLINE void setupPulsesDsm2() *ptr = 0x10; break; default: - *ptr = 0x18; // DSMX bind mode + *ptr = 0x18; // DSMX break; } if (s_bind_allowed) s_bind_allowed--; @@ -451,8 +451,8 @@ FORCEINLINE void setupPulsesDsm2() for (uint8_t i=0; i>5)+512,1023); - *ptr++ = (i<<2) | ((pulse>>8)&0x03); - *ptr++ = pulse & 0xff; + *ptr++ = (i<<2) | ((pulse>>8)&0x03); // high nyble (4-bits) channel encoded + *ptr++ = pulse & 0xff; // low byte } pulses2MHzWPtr = (uint8_t *)ptr; @@ -526,20 +526,17 @@ void setupPulsesDsm2() pulses2MHzWPtr = pulses2MHz; // If more channels needed make sure the pulses union/array is large enough - if (dsmDat[0] & BAD_DATA) // first time through, setup header + switch(g_model.ppmNCH) { - switch(g_model.ppmNCH) - { - case LPXDSM2: - dsmDat[0] = 0x00; - break; - case DSM2only: - dsmDat[0] = 0x10; - break; - default: - dsmDat[0] = 0x18; // DSMX bind mode - break; - } + case LPXDSM2: + dsmDat[0] = 0x00; + break; + case DSM2only: + dsmDat[0] = 0x10; + break; + default: + dsmDat[0] = 0x18; // DSMX bind mode + break; } if (s_bind_allowed) s_bind_allowed--; @@ -559,8 +556,8 @@ void setupPulsesDsm2() for (uint8_t i=0; i>5)+512,1023); - dsmDat[2+2*i] = (i<<2) | ((pulse>>8)&0x03); - dsmDat[3+2*i] = pulse & 0xff; + dsmDat[2+2*i] = (i<<2) | ((pulse>>8)&0x03); // high nyble (4-bits) channel encoded + dsmDat[3+2*i] = pulse & 0xff; // low byte } for (counter=0; counter<14; counter++)