Subversion Repositories FlightCtrl

Rev

Rev 1221 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1221 Rev 1222
Line 95... Line 95...
95
volatile uint8_t ReceivedBytes = 0;
95
volatile uint8_t ReceivedBytes = 0;
96
volatile uint8_t *pRxData = 0;
96
volatile uint8_t *pRxData = 0;
97
volatile uint8_t RxDataLen = 0;
97
volatile uint8_t RxDataLen = 0;
Line 98... Line 98...
98
 
98
 
-
 
99
uint8_t PcAccess = 100;
99
uint8_t PcAccess = 100;
100
 
-
 
101
uint8_t MotorTest_Active  = 0;
100
uint8_t MotorTest[4] = {0,0,0,0};
102
uint8_t MotorTest[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
Line 101... Line 103...
101
uint8_t ConfirmFrame;
103
uint8_t ConfirmFrame;
102
 
104
 
103
typedef struct
105
typedef struct
Line 150... Line 152...
150
    "                ",
152
    "                ",
151
    "                ", //25
153
    "                ", //25
152
    "                ",
154
    "                ",
153
    "Kalman Max Drift",
155
    "Kalman Max Drift",
154
    "                ",
156
    "                ",
155
    "                ",
157
    "Navi Serial Data",
156
    "GPS Nick        ", //30
158
    "GPS Nick        ", //30
157
    "GPSS Roll       "
159
    "GPSS Roll       "
158
};
160
};
Line 483... Line 485...
483
                                CompassOffCourse = ((540 + CompassHeading - CompassCourse) % 360) - 180;
485
                                CompassOffCourse = ((540 + CompassHeading - CompassCourse) % 360) - 180;
484
                                break;
486
                                break;
485
                        #endif
487
                        #endif
Line 486... Line 488...
486
 
488
 
-
 
489
                        case 't':// motor test
-
 
490
                                if(RxDataLen > 20) //
487
                        case 't':// motor test
491
                                {
-
 
492
                                        memcpy(&MotorTest[0], (uint8_t*)pRxData, sizeof(MotorTest));
-
 
493
                                }
-
 
494
                                else
-
 
495
                                {
-
 
496
                                        memcpy(&MotorTest[0], (uint8_t*)pRxData, 4);
488
                                memcpy(&MotorTest[0], (uint8_t*)pRxData, sizeof(MotorTest));
497
                                }
-
 
498
                                //Request_MotorTest = TRUE;
489
                                //Request_MotorTest = TRUE;
499
                                MotorTest_Active = 255;
490
                                PcAccess = 255;
500
                                PcAccess = 255;
Line -... Line 501...
-
 
501
                                break;
-
 
502
 
-
 
503
                        case 'n':// "Get Mixer Table
-
 
504
                                while(!txd_complete); // wait for previous frame to be sent
-
 
505
                                SendOutData('N', FC_ADDRESS, 1, (uint8_t *) &Mixer, sizeof(Mixer));
-
 
506
                                break;
-
 
507
 
-
 
508
                        case 'm':// "Set Mixer Table
-
 
509
                                if(pRxData[0] == EEMIXER_REVISION)
-
 
510
                                {
-
 
511
                                        memcpy(&Mixer, (uint8_t*)pRxData, sizeof(Mixer));
-
 
512
                                        MixerTable_WriteToEEProm();
-
 
513
                                        while(!txd_complete); // wait for previous frame to be sent
-
 
514
                                        tempchar1 = 1;
-
 
515
                                }
-
 
516
                                else
-
 
517
                                {
-
 
518
                                        tempchar1 = 0;
-
 
519
                                }
-
 
520
                                SendOutData('M', FC_ADDRESS,  1, &tempchar1, 1);
491
                                break;
521
                                break;
492
 
522
 
493
                        case 'p': // get PPM channels
523
                        case 'p': // get PPM channels
Line 494... Line 524...
494
                                Request_PPMChannels = TRUE;
524
                                Request_PPMChannels = TRUE;
Line 502... Line 532...
502
                                // limit settings range
532
                                // limit settings range
503
                                if(pRxData[0] < 1) pRxData[0] = 1; // limit to 1
533
                                if(pRxData[0] < 1) pRxData[0] = 1; // limit to 1
504
                                else if(pRxData[0] > 5) pRxData[0] = 5; // limit to 5
534
                                else if(pRxData[0] > 5) pRxData[0] = 5; // limit to 5
505
                                // load requested parameter set
535
                                // load requested parameter set
506
                                ParamSet_ReadFromEEProm(pRxData[0]);
536
                                ParamSet_ReadFromEEProm(pRxData[0]);
507
 
-
 
508
                                tempchar1 = pRxData[0];
537
                                tempchar1 = pRxData[0];
509
                                tempchar2 = EEPARAM_VERSION;
538
                                tempchar2 = EEPARAM_REVISION;
510
                                while(!txd_complete); // wait for previous frame to be sent
539
                                while(!txd_complete); // wait for previous frame to be sent
511
                                SendOutData('Q', FC_ADDRESS,3, &tempchar1, sizeof(tempchar1), &tempchar2, sizeof(tempchar2), (uint8_t *) &ParamSet, sizeof(ParamSet));
540
                                SendOutData('Q', FC_ADDRESS,3, &tempchar1, sizeof(tempchar1), &tempchar2, sizeof(tempchar2), (uint8_t *) &ParamSet, sizeof(ParamSet));
512
                                break;
541
                                break;
Line 513... Line 542...
513
 
542
 
514
                        case 's': // save settings
543
                        case 's': // save settings
515
                                if(!(MKFlags & MKFLAG_MOTOR_RUN)) // save settings only if motors ar off
544
                                if(!(MKFlags & MKFLAG_MOTOR_RUN)) // save settings only if motors ar off
516
                                {
545
                                {
517
                                        if((1 <= pRxData[0]) && (pRxData[0] <= 5) && (pRxData[1] == EEPARAM_VERSION)) // check for setting to be in range and version of settings
546
                                        if((1 <= pRxData[0]) && (pRxData[0] <= 5) && (pRxData[1] == EEPARAM_REVISION)) // check for setting to be in range and version of settings
518
                                        {
547
                                        {
519
                                                memcpy(&ParamSet, (uint8_t*)&pRxData[2], sizeof(ParamSet));
548
                                                memcpy(&ParamSet, (uint8_t*)&pRxData[2], sizeof(ParamSet));
520
                                                ParamSet_WriteToEEProm(pRxData[0]);
549
                                                ParamSet_WriteToEEProm(pRxData[0]);
521
                                                TurnOver180Nick = (int32_t) ParamSet.AngleTurnOverNick * 2500L;
550
                                                TurnOver180Nick = (int32_t) ParamSet.AngleTurnOverNick * 2500L;
Line 678... Line 707...
678
                // the last state is 5 and should be send only once to avoid multiple flash writing
707
                // the last state is 5 and should be send only once to avoid multiple flash writing
679
                if(CompassCalState > 4)  CompassCalState = 0;
708
                if(CompassCalState > 4)  CompassCalState = 0;
680
                Compass_Timer = SetDelay(99);
709
                Compass_Timer = SetDelay(99);
681
        }
710
        }
682
        #endif
711
        #endif
-
 
712
 
683
        if(Request_MotorTest && txd_complete)
713
        if(Request_MotorTest && txd_complete)
684
        {
714
        {
685
                SendOutData('T', FC_ADDRESS, 0);
715
                SendOutData('T', FC_ADDRESS, 0);
686
                Request_MotorTest = FALSE;
716
                Request_MotorTest = FALSE;
687
        }
717
        }