Page 349 - 2
P. 349

writePLog();
                #endif
              }
            }


            // ******** Main Loop *********
            void loop () {
              static uint8_t rcDelayCommand; // this indicates the number of time (multiple of RC measurem
            ent at 50Hz) the sticks must be maintained to run or switch off motors
              static uint8_t rcSticks;     // this hold sticks position for command combos
              uint8_t axis,i;
              int16_t error,errorAngle;
              int16_t delta;
              int16_t PTerm = 0,ITerm = 0,DTerm, PTermACC, ITermACC;
              static int16_t lastGyro[2] = {0,0};
              static int16_t errorAngleI[2] = {0,0};
              #if PID_CONTROLLER == 1
              static int32_t errorGyroI_YAW;
              static int16_t delta1[2],delta2[2];
              static int16_t errorGyroI[2] = {0,0};
              #elif PID_CONTROLLER == 2
              static int16_t delta1[3],delta2[3];
              static int32_t errorGyroI[3] = {0,0,0};
              static int16_t lastError[3] = {0,0,0};
              int16_t deltaSum;
              int16_t AngleRateTmp, RateError;
              #endif
              static uint16_t rcTime = 0;
              static int16_t initialThrottleHold;
              int16_t rc;
              int32_t prop = 0;


              #if defined(SERIAL_RX)
                if (spekFrameFlags == 0x01) readSerial_RX();
              #endif
              #if defined(OPENLRSv2MULTI)
                Read_OpenLRS_RC();
              #endif


              #if defined(SERIAL_RX)
              if ((spekFrameDone == 0x01) || ((int16_t)(currentTime-rcTime) >0 )) {
                spekFrameDone = 0x00;
              #else
              if ((int16_t)(currentTime-rcTime) >0 ) { // 50Hz
              #endif


                                                         - 349 -
   344   345   346   347   348   349   350   351   352   353   354