Page 338 - 2
P. 338

uint32_t alt_change_timer;
              int8_t alt_change_flag;
              uint32_t alt_change;


            uint8_t alarmArray[ALRM_FAC_SIZE];              // array


            #if BARO
              int32_t baroPressure;
              int16_t baroTemperature;
              int32_t baroPressureSum;
            #endif


            void annexCode() { // this code is excetuted at each loop and won't interfere with control loop i
            f it lasts less than 650 microseconds
              static uint32_t calibratedAccTime;
              uint16_t tmp,tmp2;
              uint8_t axis,prop1,prop2;


              // PITCH & ROLL only dynamic PID adjustemnt,       depending on throttle value (or collective.pit
            ch value for heli)
              #ifdef HELICOPTER
                #define DYN_THR_PID_CHANNEL COLLECTIVE_PITCH
              #else
                #define DYN_THR_PID_CHANNEL THROTTLE
              #endif
              prop2 = 128; // prop2 was 100, is 128 now
              if (rcData[DYN_THR_PID_CHANNEL]>1500) { // breakpoint is fix: 1500
                if (rcData[DYN_THR_PID_CHANNEL]<2000) {
                  prop2 -=   ((uint16_t)conf.dynThrPID*(rcData[DYN_THR_PID_CHANNEL]-1500)>>9); //         /51
            2 instead of /500
                } else {
                  prop2 -= conf.dynThrPID;
                }
              }


              for(axis=0;axis<3;axis++) {
                tmp = min(abs(rcData[axis]-MIDRC),500);
                #if defined(DEADBAND)
                  if (tmp>DEADBAND) { tmp -= DEADBAND; }
                  else { tmp=0; }
                #endif
                if(axis!=2) { //ROLL & PITCH
                  tmp2 = tmp>>7; // 500/128 = 3.9 => range [0;3]
                  rcCommand[axis] = lookupPitchRollRC[tmp2] + ((tmp-(tmp2<<7)) * (lookupPitchRollRC[tmp
            2+1]-lookupPitchRollRC[tmp2])>>7);


                                                         - 338 -
   333   334   335   336   337   338   339   340   341   342   343