1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-24 00:35:18 +03:00

Companion didn't compile

This commit is contained in:
bsongis 2014-12-08 21:36:47 +01:00
parent 4c2c85fe9f
commit 7ee2f911a8
7 changed files with 72 additions and 39 deletions

View file

@ -1048,7 +1048,7 @@ void menuModelSetup(uint8_t event)
MENU_CHECK(menuTabModel, e_ModelSetup, MODEL_SETUP_MAX_LINES); MENU_CHECK(menuTabModel, e_ModelSetup, MODEL_SETUP_MAX_LINES);
#if defined(DSM2) || defined(PXX) #if defined(CPUARM) && (defined(DSM2) || defined(PXX))
if (menuEvent) { if (menuEvent) {
moduleFlag[0] = 0; moduleFlag[0] = 0;
#if NUM_MODULES > 1 #if NUM_MODULES > 1
@ -1829,7 +1829,7 @@ void menuModelSetup(uint8_t event)
uint8_t newFlag = 0; uint8_t newFlag = 0;
if (attr && m_posHorz>0 && editMode>0) { if (attr && m_posHorz>0 && editMode>0) {
// send reset code // send reset code
newFlag = PXX_SEND_RXNUM; newFlag = MODULE_BIND;
} }
moduleFlag[0] = newFlag; moduleFlag[0] = newFlag;
} }
@ -1837,7 +1837,7 @@ void menuModelSetup(uint8_t event)
#if defined(DSM2) #if defined(DSM2)
if (IS_DSM2_PROTOCOL(protocol)) { if (IS_DSM2_PROTOCOL(protocol)) {
lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+4*FW, y, STR_MODULE_RANGE, m_posHorz!=0 ? attr : 0); lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+4*FW, y, STR_MODULE_RANGE, m_posHorz!=0 ? attr : 0);
dsm2Flag = (attr && m_posHorz>0 && editMode>0) ? DSM2_RANGECHECK_FLAG : 0; // [MENU] key toggles range check mode moduleFlag[0] = (attr && m_posHorz>0 && editMode>0) ? MODULE_RANGECHECK : 0; // [MENU] key toggles range check mode
} }
#endif #endif
} }

View file

@ -577,7 +577,7 @@ void menuMainView(uint8_t event)
#endif #endif
#if defined(DSM2) #if defined(DSM2)
if (dsm2BindEnable) { if (moduleFlag[0] == MODULE_BIND) {
// Issue 98 // Issue 98
lcd_putsAtt(15*FW, 0, PSTR("BIND"), 0); lcd_putsAtt(15*FW, 0, PSTR("BIND"), 0);
} }

View file

@ -640,7 +640,7 @@ enum SwitchConfig {
#define LEN_ANA_NAME 3 #define LEN_ANA_NAME 3
#define ALTERNATE_VIEW 0x10 #define ALTERNATE_VIEW 0x10
PACK(typedef struct t_EEGeneral { PACK(typedef struct {
uint8_t version; uint8_t version;
uint16_t variant; uint16_t variant;
CalibData calib[NUM_STICKS+NUM_POTS]; CalibData calib[NUM_STICKS+NUM_POTS];

View file

@ -48,7 +48,6 @@ uint8_t dsm2Stream[64]; // Likely more than we need
uint8_t *dsm2StreamPtr; uint8_t *dsm2StreamPtr;
uint8_t dsm2SerialByte ; uint8_t dsm2SerialByte ;
uint8_t dsm2SerialBitCount; uint8_t dsm2SerialBitCount;
uint8_t dsm2BindEnable = 0;
uint8_t dsm2BindTimer = DSM2_BIND_TIMEOUT; uint8_t dsm2BindTimer = DSM2_BIND_TIMEOUT;
#endif #endif
@ -170,14 +169,19 @@ void setupPulsesDSM2(unsigned int port)
else if (moduleFlag[port] == MODULE_RANGECHECK) else if (moduleFlag[port] == MODULE_RANGECHECK)
dsmDat[0] |= DSM2_SEND_RANGECHECK; dsmDat[0] |= DSM2_SEND_RANGECHECK;
#else #else
dsm2BindEnable = 0;
if (dsm2BindTimer > 0) { if (dsm2BindTimer > 0) {
dsm2BindTimer--; dsm2BindTimer--;
if (switchState(SW_DSM2_BIND)) { if (switchState(SW_DSM2_BIND)) {
dsm2BindEnable = DSM2_SEND_BIND; moduleFlag[port] = MODULE_BIND;
dsmDat[0] |= DSM2_SEND_BIND; dsmDat[0] |= DSM2_SEND_BIND;
} }
} }
else if (moduleFlag[port] == MODULE_RANGECHECK) {
dsmDat[0] |= DSM2_SEND_RANGECHECK;
}
else {
moduleFlag[port] = 0;
}
#endif #endif
dsmDat[1] = g_model.header.modelId; // DSM2 Header second byte for model match dsmDat[1] = g_model.header.modelId; // DSM2 Header second byte for model match

View file

@ -58,7 +58,6 @@ enum ModuleFlag
#if defined(DSM2) && !defined(PCBTARANIS) #if defined(DSM2) && !defined(PCBTARANIS)
#define DSM2_BIND_TIMEOUT 255 // 255*11ms #define DSM2_BIND_TIMEOUT 255 // 255*11ms
extern uint8_t dsm2BindTimer; extern uint8_t dsm2BindTimer;
extern uint8_t dsm2BindEnable; // needed to display BIND on screen
#endif #endif
#if defined(CPUARM) #if defined(CPUARM)

View file

@ -40,11 +40,24 @@ uint16_t nextMixerEndTime = 0;
#define SCHEDULE_MIXER_END(delay) nextMixerEndTime = getTmr16KHz() + (delay) - 2*16/*2ms*/ #define SCHEDULE_MIXER_END(delay) nextMixerEndTime = getTmr16KHz() + (delay) - 2*16/*2ms*/
#if defined(DSM2) #if defined(DSM2)
// DSM2 control bits // DSM2 control bits
#define DSM2_CHANS 6 #define DSM2_CHANS 6
#define FRANCE_BIT 0x10 #define FRANCE_BIT 0x10
#define DSMX_BIT 0x08 #define DSMX_BIT 0x08
#define BAD_DATA 0x47 #define BAD_DATA 0x47
#define DSM2_SEND_BIND (1 << 7)
#define DSM2_SEND_RANGECHECK (1 << 5)
uint8_t dsm2BindTimer = DSM2_BIND_TIMEOUT;
#endif
#if defined(PXX)
#define PXX_SEND_BIND 0x01
#define PXX_SEND_FAILSAFE (1 << 4)
#define PXX_SEND_RANGECHECK (1 << 5)
#endif
#if defined(DSM2) || defined(PXX)
uint8_t moduleFlag[NUM_MODULES] = { 0 };
#endif #endif
uint8_t s_current_protocol[1] = { 255 }; uint8_t s_current_protocol[1] = { 255 };
@ -233,7 +246,6 @@ uint8_t PcmByte ;
uint8_t PcmBitCount ; uint8_t PcmBitCount ;
uint16_t PcmCrc ; uint16_t PcmCrc ;
uint8_t PcmOnesCount ; uint8_t PcmOnesCount ;
uint8_t moduleFlag[NUM_MODULES] = { 0 };
void crc( uint8_t data ) void crc( uint8_t data )
{ {
@ -316,7 +328,6 @@ uint16_t scaleForPXX( uint8_t i )
void setupPulsesPXX() void setupPulsesPXX()
{ {
uint8_t i ;
uint16_t chan ; uint16_t chan ;
uint16_t chan_1 ; uint16_t chan_1 ;
@ -328,16 +339,19 @@ void setupPulsesPXX()
PcmOnesCount = 0 ; PcmOnesCount = 0 ;
putPcmHead() ; putPcmHead() ;
putPcmByte( g_model.header.modelId ) ; // putPcmByte( g_model.rxnum ) ; // putPcmByte( g_model.header.modelId ) ; // putPcmByte( g_model.rxnum ) ; //
putPcmByte( pxxFlag[0] ) ; // First byte of flags uint8_t flag1 = 0;
if (moduleFlag[0] == MODULE_BIND)
flag1 |= (g_eeGeneral.countryCode << 1) | PXX_SEND_BIND;
else if (moduleFlag[0] == MODULE_RANGECHECK)
flag1 |= PXX_SEND_RANGECHECK;
putPcmByte(flag1) ; // First byte of flags
putPcmByte( 0 ) ; // Second byte of flags putPcmByte( 0 ) ; // Second byte of flags
pxxFlag[0] = 0; // reset flag after send for (uint8_t i=0; i<8; i+=2) { // First 8 channels only
for ( i = 0 ; i < 8 ; i += 2 ) // First 8 channels only chan = scaleForPXX(i);
{ chan_1 = scaleForPXX(i+1);
chan = scaleForPXX(i); putPcmByte( chan ) ; // Low byte of channel
chan_1 = scaleForPXX(i+1); putPcmByte( ( ( chan >> 8 ) & 0x0F ) | ( chan_1 << 4) ) ; // 4 bits each from 2 channels
putPcmByte( chan ) ; // Low byte of channel putPcmByte( chan_1 >> 4 ) ; // High byte of channel
putPcmByte( ( ( chan >> 8 ) & 0x0F ) | ( chan_1 << 4) ) ; // 4 bits each from 2 channels
putPcmByte( chan_1 >> 4 ) ; // High byte of channel
} }
putPcmByte(0); putPcmByte(0);
chan = PcmCrc ; // get the crc chan = PcmCrc ; // get the crc
@ -398,13 +412,21 @@ FORCEINLINE void setupPulsesDSM2()
break; break;
} }
if (s_bind_allowed) s_bind_allowed--; if (dsm2BindTimer > 0) {
if (s_bind_allowed && switchState(SW_DSM2_BIND)) dsm2BindTimer--;
dsm2Flag = DSM2_BIND_FLAG; if (switchState(SW_DSM2_BIND)) {
else moduleFlag[0] = MODULE_BIND;
dsm2Flag &= ~DSM2_BIND_FLAG; *ptr |= DSM2_SEND_BIND;
}
}
else if (moduleFlag[0] == MODULE_RANGECHECK) {
*ptr |= DSM2_SEND_RANGECHECK;
}
else {
moduleFlag[0] = 0;
}
*ptr++ |= dsm2Flag; ptr++;
*ptr++ = g_model.header.modelId; *ptr++ = g_model.header.modelId;
for (uint8_t i=0; i<DSM2_CHANS; i++) { for (uint8_t i=0; i<DSM2_CHANS; i++) {
@ -502,7 +524,6 @@ void sendByteDsm2(uint8_t b) //max 10changes 0 10 10 10 10 1
void setupPulsesDSM2() void setupPulsesDSM2()
{ {
static uint8_t dsmDat[2+6*2] = {0xFF,0x00, 0x00,0xAA, 0x05,0xFF, 0x09,0xFF, 0x0D,0xFF, 0x13,0x54, 0x14,0xAA}; static uint8_t dsmDat[2+6*2] = {0xFF,0x00, 0x00,0xAA, 0x05,0xFF, 0x09,0xFF, 0x0D,0xFF, 0x13,0x54, 0x14,0xAA};
uint8_t counter;
pulses2MHzWPtr = pulses2MHz; pulses2MHzWPtr = pulses2MHz;
@ -519,13 +540,20 @@ void setupPulsesDSM2()
break; break;
} }
if (s_bind_allowed) s_bind_allowed--; if (dsm2BindTimer > 0) {
if (s_bind_allowed && switchState(SW_DSM2_BIND)) dsm2BindTimer--;
dsm2Flag = DSM2_BIND_FLAG; if (switchState(SW_DSM2_BIND)) {
else moduleFlag[0] = MODULE_BIND;
dsm2Flag &= ~DSM2_BIND_FLAG; dsmDat[0] |= DSM2_SEND_BIND;
}
}
else if (moduleFlag[0] == MODULE_RANGECHECK) {
dsmDat[0] |= DSM2_SEND_RANGECHECK;
}
else {
moduleFlag[0] = 0;
}
dsmDat[0] |= dsm2Flag;
dsmDat[1] = g_model.header.modelId; // DSM2 Header second byte for model match dsmDat[1] = g_model.header.modelId; // DSM2 Header second byte for model match
for (uint8_t i=0; i<DSM2_CHANS; i++) { for (uint8_t i=0; i<DSM2_CHANS; i++) {
@ -534,7 +562,7 @@ void setupPulsesDSM2()
dsmDat[3+2*i] = pulse & 0xff; // low byte dsmDat[3+2*i] = pulse & 0xff; // low byte
} }
for (counter=0; counter<14; counter++) { for (uint8_t counter=0; counter<14; counter++) {
sendByteDsm2(dsmDat[counter]); sendByteDsm2(dsmDat[counter]);
} }

View file

@ -45,6 +45,8 @@ extern uint8_t *pulses2MHzWPtr;
extern uint16_t nextMixerEndTime; extern uint16_t nextMixerEndTime;
extern uint8_t moduleFlag[NUM_MODULES];
#define MAX_MIXER_DELTA (50*16) /* 50ms max as an interval between 2 mixer calculations */ #define MAX_MIXER_DELTA (50*16) /* 50ms max as an interval between 2 mixer calculations */
void startPulses(); void startPulses();