Esempio n. 1
0
t_Ersky9xTrainerMix::operator TrainerMix()
{
  TrainerMix c9x;
  c9x.src = srcChn;
  c9x.swtch = er9xToSwitch(swtch);
  c9x.weight = (25 * studWeight) / 8;
  c9x.mode = mode;
  return c9x;
}
Esempio n. 2
0
Ersky9xLogicalSwitchData_v11::operator LogicalSwitchData ()
{
  LogicalSwitchData c9x;
  c9x.func = func;
  c9x.val1 = v1;
  c9x.val2 = v2;

  if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
    c9x.val1 = ersky9xToSource_v11(v1).toValue();
  }

  if (c9x.func >= LS_FN_EQUAL) {
    c9x.val2 = ersky9xToSource_v11(v2).toValue();
  }

  if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
    c9x.val1 = er9xToSwitch(v1).toValue();
    c9x.val2 = er9xToSwitch(v2).toValue();
  }

  return c9x;
}
Esempio n. 3
0
t_Ersky9xModelData_v11::operator ModelData ()
{
  ModelData c9x;
  c9x.used = true;
  getEEPROMString(c9x.name, name, sizeof(name));
  for (int i=0; i<2; i++) {
    c9x.timers[i].mode = getErSky9xTimerMode(timer[i].tmrModeA);
    c9x.timers[i].val = timer[i].tmrVal;
  }
  switch(protocol) {
    case 1:
      c9x.moduleData[0].protocol = PXX_DJT;
      break;
    case 2:
      c9x.moduleData[0].protocol = DSM2;
      break;
    case 3:
      c9x.moduleData[0].protocol = PPM16;
      break;
    default:
      c9x.moduleData[0].protocol = PPM;
      break;
  }
  c9x.moduleData[0].ppmFrameLength=ppmFrameLength;
  c9x.moduleData[0].channelsCount = 8 + 2 * ppmNCH;
  c9x.thrTrim = thrTrim;
  c9x.trimInc = trimInc-2;
  c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay;
  c9x.funcSw[0].func = FuncInstantTrim;
  if (trimSw) {
    c9x.funcSw[0].swtch = er9xToSwitch(trimSw);
  }
  c9x.beepANACenter = beepANACenter;
  c9x.moduleData[0].ppmPulsePol = pulsePol;
  c9x.extendedLimits = extendedLimits;
  c9x.swashRingData.invertELE = swashInvertELE;
  c9x.swashRingData.invertAIL = swashInvertAIL;
  c9x.swashRingData.invertCOL = swashInvertCOL;
  c9x.swashRingData.type = swashType;
  c9x.swashRingData.collectiveSource = ersky9xToSource_v11(swashCollectiveSource);
  c9x.swashRingData.value = swashRingValue;
  for (int i=0; i<ERSKY9X_MAX_MIXERS_V11; i++)
    c9x.mixData[i] = mixData[i];
  for (int i=0; i<ERSKY9X_NUM_CHNOUT_V11; i++)
    c9x.limitData[i] = limitData[i];

  // expoData
  int e = 0;
  for (int ch = 0; ch < 4 && e < C9X_MAX_EXPOS; ch++) {
    for (int dr = 0, pos = 0; dr < 3 && e < C9X_MAX_EXPOS; dr++, pos++) {
      if ((dr == 0 && !expoData[ch].drSw1) || (dr == 1 && !expoData[ch].drSw2))
        dr = 2;
      if (dr == 2 && !expoData[ch].expo[0][0][0] && !expoData[ch].expo[0][0][1] && !expoData[ch].expo[0][1][0] && !expoData[ch].expo[0][1][1])
        break;
      if (expoData[ch].drSw1 && !expoData[ch].drSw2) {
        c9x.expoData[e].swtch = er9xToSwitch(dr == 0 ? expoData[ch].drSw1 : 0);
        pos = dr == 0 ? 1 : 0;
      }
      else {
        c9x.expoData[e].swtch = er9xToSwitch(dr == 0 ? -expoData[ch].drSw1 : (dr == 1 ? -expoData[ch].drSw2 : 0));
      }
      c9x.expoData[e].chn = ch;
      if (expoData[ch].expo[pos][0][0]) {
        c9x.expoData[e].curve.type = CurveReference::CURVE_REF_EXPO;
        c9x.expoData[e].curve.value = expoData[ch].expo[pos][0][0];
      }
      c9x.expoData[e].weight = 100 + expoData[ch].expo[pos][1][0];
      if (expoData[ch].expo[pos][0][0] == expoData[ch].expo[pos][0][1] && expoData[ch].expo[pos][1][0] == expoData[ch].expo[pos][1][1]) {
        c9x.expoData[e++].mode = 3;
      }
      else {
        c9x.expoData[e].mode = 2;
        if (e < C9X_MAX_EXPOS - 1) {
          c9x.expoData[e + 1].swtch = c9x.expoData[e].swtch;
          c9x.expoData[++e].chn = ch;
          c9x.expoData[e].mode = 1;
          if (expoData[ch].expo[pos][0][1]) {
            c9x.expoData[e].curve.type = CurveReference::CURVE_REF_EXPO;
            c9x.expoData[e].curve.value = expoData[ch].expo[pos][0][1];
          }
          c9x.expoData[e++].weight = 100 + expoData[ch].expo[pos][1][1];
        }
      }
    }
  }

  for (int i=0; i<NUM_STICKS; i++)
    c9x.flightModeData[0].trim[i] = trim[i];

  for (int i=0; i<ERSKY9X_MAX_CURVE5; i++) {
    c9x.curves[i].count = 5;
    for (int j = 0; j < 5; j++) {
      c9x.curves[i].points[j].x = -100 + 50 * i;
      c9x.curves[i].points[j].y = curves5[i][j];
    }
  }
  for (int i=0; i<ERSKY9X_MAX_CURVE9; i++) {
    c9x.curves[ERSKY9X_MAX_CURVE5 + i].count = 9;
    for (int j = 0; j < 9; j++) {
      c9x.curves[ERSKY9X_MAX_CURVE5 + i].points[j].x = -100 + 25 * i;
      c9x.curves[ERSKY9X_MAX_CURVE5 + i].points[j].y = curves9[i][j];
    }
  }

  for (int i=0; i<ERSKY9X_NUM_CSW_V11; i++)
    c9x.customSw[i] = customSw[i];

  // for (int i=0; i<ERSKY9X_NUM_CHNOUT_V11; i++)
  //  c9x.safetySw[i] = safetySw[i];

  c9x.frsky = frsky;
  c9x.frsky.usrProto=FrSkyUsrProto;
  c9x.frsky.FrSkyGpsAlt=FrSkyGpsAlt;
  // for (int i=0; i<8; i++) {
  //   c9x.frskyalarms[i].frskyAlarmLimit=frskyAlarms.alarmData[i].frskyAlarmLimit;
  //   c9x.frskyalarms[i].frskyAlarmSound=frskyAlarms.alarmData[i].frskyAlarmSound;
  //   c9x.frskyalarms[i].frskyAlarmType=frskyAlarms.alarmData[i].frskyAlarmType;
  // }
  // for (int i=0; i<8; i++) {
  //   c9x.customdisplay[i]=customDisplayIndex[i];
  // }
  for (int i=0; i<5;i++) {
    c9x.flightModeData[0].gvars[i]=gvars[i].gvar;
    // c9x.gvsource[i]=gvars[i].gvsource;
  }
  return c9x;
}
Esempio n. 4
0
t_Ersky9xMixData_v10::operator MixData ()
{
  MixData c9x;
  c9x.destCh = destCh;
  c9x.weight = weight;
  c9x.swtch = er9xToSwitch(swtch);

  if (srcRaw == 0) {
    c9x.srcRaw = RawSource(SOURCE_TYPE_NONE);
  }
  else if (srcRaw <= 7) {
    c9x.srcRaw = RawSource(SOURCE_TYPE_STICK, srcRaw-1);
  }
  else if (srcRaw == 8) {
    c9x.srcRaw = RawSource(SOURCE_TYPE_MAX);
  }
  else if (srcRaw == 9) {
    if (swtch < 0) {
      c9x.srcRaw = RawSource(SOURCE_TYPE_SWITCH, swtch < -3 ? -swtch-3 : -swtch);
      c9x.weight = -weight;
    }
    else if (swtch > 0) {
      c9x.srcRaw = RawSource(SOURCE_TYPE_SWITCH, swtch > 3 ? swtch-3 : swtch);
    }
    else {
      c9x.srcRaw = RawSource(SOURCE_TYPE_MAX);
    }
    if (mltpx != MLTPX_REP)
      c9x.swtch = RawSwitch(SWITCH_TYPE_NONE);
  }
  else if (srcRaw == 37) {
    c9x.srcRaw = RawSource(SOURCE_TYPE_SWITCH, 0);
  }
  else if (srcRaw <= 12) {
    c9x.srcRaw = RawSource(SOURCE_TYPE_CYC, srcRaw-10);
  }
  else if (srcRaw <= 20) {
    c9x.srcRaw = RawSource(SOURCE_TYPE_PPM, srcRaw-13);
  }
  else {
    c9x.srcRaw = RawSource(SOURCE_TYPE_CH, srcRaw-21);
  }

  if (curve > 6) {
    c9x.curve.type = CurveReference::CURVE_REF_CUSTOM;
    c9x.curve.value = curve - 6;
  }
  else if (curve > 0) {
    c9x.curve.type = CurveReference::CURVE_REF_FUNC;
    c9x.curve.value = curve;
  }

  c9x.delayUp = delayUp;
  c9x.delayDown = delayDown;
  c9x.speedUp = speedUp;
  c9x.speedDown = speedDown;
  c9x.carryTrim = carryTrim;
  c9x.mltpx = (MltpxValue)mltpx;
  c9x.mixWarn = mixWarn;
  // c9x.enableFmTrim=enableFmTrim;
  c9x.sOffset = sOffset;
  return c9x;
}
Esempio n. 5
0
t_Er9xMixData::operator MixData ()
{
  MixData c9x;
  c9x.destCh = destCh;
  if (abs(weight)>125) {
    int gvar;
    if (weight>0) {
      gvar=weight-125;
    } else {
      gvar=weight+131;
    }
    gvar+=10000;
    c9x.weight=gvar;
  } else {
    c9x.weight = weight;
  }
  if (abs(sOffset)>125) {
    int gvar;
    if (sOffset>0) {
      gvar=sOffset-125;
    } else {
      gvar=sOffset+131;
    }
    gvar+=10000;
    c9x.sOffset=gvar;
  } else {
    c9x.sOffset=sOffset;
  }  
  c9x.swtch = er9xToSwitch(swtch);

  if (srcRaw == 0) {
    c9x.srcRaw = RawSource(SOURCE_TYPE_NONE);
  }
  else if (srcRaw <= 7) {
    c9x.srcRaw = RawSource(SOURCE_TYPE_STICK, srcRaw-1);
  }
  else if (srcRaw == 8) {
    c9x.srcRaw = RawSource(SOURCE_TYPE_MAX);
  }
  else if (srcRaw == 9) {
    if (swtch < 0) {
      c9x.srcRaw = RawSource(SOURCE_TYPE_SWITCH, swtch < -3 ? -swtch-3 : -swtch);
      c9x.weight = -weight;
    }
    else if (swtch > 0) {
      c9x.srcRaw = RawSource(SOURCE_TYPE_SWITCH, swtch > 3 ? swtch-3 : swtch);
    }
    else {
      c9x.srcRaw = RawSource(SOURCE_TYPE_MAX);
    }
    if (mltpx != MLTPX_REP)
      c9x.swtch = RawSwitch(SWITCH_TYPE_NONE);
  }
  else if (srcRaw <= 12) {
    c9x.srcRaw = RawSource(SOURCE_TYPE_CYC, srcRaw-10);
  }
  else if (srcRaw <= 20) {
    c9x.srcRaw = RawSource(SOURCE_TYPE_PPM, srcRaw-13);
  }
  else if (srcRaw <=37) {
    c9x.srcRaw = RawSource(SOURCE_TYPE_CH, srcRaw-21);
  } 
  else {
    c9x.srcRaw = RawSource(SOURCE_TYPE_GVAR, srcRaw-38);    
  }

  if (differential==1) {
    c9x.curve.type = CurveReference::CURVE_REF_DIFF;
    c9x.curve.value = differential;
  }
  else if (curve > 6) {
    c9x.curve.type = CurveReference::CURVE_REF_CUSTOM;
    c9x.curve.value = curve - 6;
  }
  else if (curve > 0) {
    c9x.curve.type = CurveReference::CURVE_REF_FUNC;
    c9x.curve.value = curve;
  }

  // c9x.lateOffset=lateOffset;
  c9x.delayUp = delayUp;
  c9x.delayDown = delayDown;
  c9x.speedUp = speedUp;
  c9x.speedDown = speedDown;
  c9x.carryTrim = carryTrim;
  c9x.mltpx = (MltpxValue)mltpx;
  c9x.mixWarn = mixWarn;
  // c9x.enableFmTrim=enableFmTrim;
  return c9x;
}
Esempio n. 6
0
t_Er9xModelData::operator ModelData ()
{
  ModelData c9x;
  c9x.used = true;
  getEEPROMString(c9x.name, name, sizeof(name));
  c9x.timers[0].mode = getEr9xTimerMode(tmrMode);
  c9x.timers[0].val = tmrVal;
  switch(protocol) {
    case 1:
      c9x.moduleData[0].protocol = PXX_DJT;
      break;
    case 2:
      c9x.moduleData[0].protocol = DSM2;
      break;
    case 3:
      c9x.moduleData[0].protocol = PPM16;
      break;
    default:
      c9x.moduleData[0].protocol = PPM;
      break;
  }
  c9x.moduleData[0].ppmFrameLength=ppmFrameLength;
  c9x.moduleData[0].channelsCount = 8 + 2 * ppmNCH;
  c9x.thrTrim = thrTrim;
  c9x.trimInc = trimInc-2;
  c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay;
  c9x.customFn[0].func = FuncInstantTrim;
  if (trimSw) {
    c9x.customFn[0].swtch = er9xToSwitch(trimSw);
  }
  c9x.beepANACenter = beepANACenter;
  c9x.moduleData[0].ppmPulsePol = pulsePol;
  c9x.extendedLimits = extendedLimits;
  c9x.swashRingData.elevatorWeight = swashInvertELE ? -100 : 100;
  c9x.swashRingData.aileronWeight = swashInvertAIL ? -100 : 100;
  c9x.swashRingData.collectiveWeight = swashInvertCOL ? -100 : 100;
  c9x.swashRingData.type = swashType;
  c9x.swashRingData.collectiveSource = er9xToSource(swashCollectiveSource);
  c9x.swashRingData.value = swashRingValue;

  for (int i=0; i<ER9X_MAX_MIXERS; i++) {
    Er9xMixData mix = mixData[i];
    c9x.mixData[i] = mix;
  }

  for (int i=0; i<ER9X_NUM_CHNOUT; i++)
    c9x.limitData[i] = limitData[i];

  // expoData
  int e = 0;
  for (int ch = 0; ch < 4 && e < C9X_MAX_EXPOS; ch++) {
    for (int dr = 0, pos = 0; dr < 3 && e < C9X_MAX_EXPOS; dr++, pos++) {
      if ((dr == 0 && !expoData[ch].drSw1) || (dr == 1 && !expoData[ch].drSw2))
        dr = 2;
      if (dr == 2 && !expoData[ch].expo[0][0][0] && !expoData[ch].expo[0][0][1] && !expoData[ch].expo[0][1][0] && !expoData[ch].expo[0][1][1])
        break;
      if (expoData[ch].drSw1 && !expoData[ch].drSw2) {
        c9x.expoData[e].swtch = er9xToSwitch(dr == 0 ? expoData[ch].drSw1 : 0);
        pos = dr == 0 ? 1 : 0;
      }
      else {
        c9x.expoData[e].swtch = er9xToSwitch(dr == 0 ? -expoData[ch].drSw1 : (dr == 1 ? -expoData[ch].drSw2 : 0));
      }
      c9x.expoData[e].chn = ch;
      if (expoData[ch].expo[pos][0][0]) {
        c9x.expoData[e].curve.type = CurveReference::CURVE_REF_EXPO;
        c9x.expoData[e].curve.value = expoData[ch].expo[pos][0][0];
      }
      c9x.expoData[e].weight = 100 + expoData[ch].expo[pos][1][0];
      if (expoData[ch].expo[pos][0][0] == expoData[ch].expo[pos][0][1] && expoData[ch].expo[pos][1][0] == expoData[ch].expo[pos][1][1]) {
        c9x.expoData[e++].mode = 3;
      }
      else {
        c9x.expoData[e].mode = 2;
        if (e < C9X_MAX_EXPOS - 1) {
          c9x.expoData[e + 1].swtch = c9x.expoData[e].swtch;
          c9x.expoData[++e].chn = ch;
          c9x.expoData[e].mode = 1;
          if (expoData[ch].expo[pos][0][1]) {
            c9x.expoData[e].curve.type = CurveReference::CURVE_REF_EXPO;
            c9x.expoData[e].curve.value = expoData[ch].expo[pos][0][1];
          }
          c9x.expoData[e++].weight = 100 + expoData[ch].expo[pos][1][1];
        }
      }
    }
  }

  for (int i=0; i<NUM_STICKS; i++)
    c9x.flightModeData[0].trim[i] = trim[i];

  for (int i=0; i<ER9X_MAX_CURVE5; i++) {
    c9x.curves[i].count = 5;
    for (int j = 0; j < 5; j++) {
      c9x.curves[i].points[j].x = -100 + 50 * i;
      c9x.curves[i].points[j].y = curves5[i][j];
    }
  }
  for (int i=0; i<ER9X_MAX_CURVE9; i++) {
    c9x.curves[ER9X_MAX_CURVE5 + i].count = 9;
    for (int j = 0; j < 9; j++) {
      c9x.curves[ER9X_MAX_CURVE5 + i].points[j].x = -100 + 25 * i;
      c9x.curves[ER9X_MAX_CURVE5 + i].points[j].y = curves9[i][j];
    }
  }

  for (int i=0; i<ER9X_NUM_CSW; i++)
    c9x.logicalSw[i] = logicalSw[i];

  // for (int i=0; i<ER9X_NUM_CHNOUT; i++)
  //   c9x.safetySw[i] = safetySw[i];

  c9x.frsky = frsky;
  c9x.frsky.usrProto=FrSkyUsrProto;
  return c9x;
}