String WiFiManager::getPassword() {
    if(_pass == "") {
//        DEBUG_PRINT("Reading EEPROM Password");
        _pass = getEEPROMString(32, 64);
//        DEBUG_PRINT("Password: ");
//        DEBUG_PRINT(_pass);
    }
    return _pass;
}
String WiFiManager::getSSID() {
    if(_ssid == "") {
//        DEBUG_PRINT("Reading EEPROM SSID");
        _ssid = getEEPROMString(0, 32);
//        DEBUG_PRINT("SSID: ");
//        DEBUG_PRINT(_ssid);
    }
    return _ssid;
}
Ejemplo n.º 3
0
Ersky9xGeneral::operator GeneralSettings ()
{
  GeneralSettings result;
  
  result.version = myVers;
  
  for (int i=0; i<NUM_STICKSnPOTS; i++) {
    result.calibMid[i] = calibMid[i];
    result.calibSpanNeg[i] = calibSpanNeg[i];
    result.calibSpanPos[i] = calibSpanPos[i];
  }

  result.currModel = currModel;
  result.contrast = contrast;
  result.vBatWarn = vBatWarn;
  result.vBatCalib = vBatCalib;

  result.backlightMode = 0;
  if (lightSw == 22) {
    result.backlightMode = 4;
  }
  else if (lightAutoOff) {
    result.backlightMode |= 1;
    result.backlightDelay = lightAutoOff;
  }
  else if (lightOnStickMove) {
    result.backlightMode |= 2;
    result.backlightDelay = lightOnStickMove;
  }

  result.trainer = trainer;
  result.view = std::min((uint8_t)4, view);
  result.disableThrottleWarning = disableThrottleWarning;
  result.switchWarning = disableSwitchWarning ? 0 : -1;
  result.disableMemoryWarning = disableMemoryWarning;

  switch (beeperVal) {
    case 0:
      result.beeperMode = e_quiet;
      break;
    case 1:
      result.beeperMode = e_no_keys;
      break;
    default:
      result.beeperMode = e_all;
      result.beeperLength = beeperVal - 4;
      break;
  }

  result.disableAlarmWarning = disableAlarmWarning;
  result.stickMode = std::max((uint8_t)0, std::min(stickMode, (uint8_t)3));
  result.inactivityTimer = inactivityTimer + 10;
  result.minuteBeep = minuteBeep;
  result.preBeep = preBeep;
  result.flashBeep = flashBeep;
  result.splashMode = disableSplashScreen;
  result.disablePotScroll=(disablePotScroll==1);
  result.disableBG=(disableBG==1);
  result.templateSetup = templateSetup;
  result.PPM_Multiplier = PPM_Multiplier;
  getEEPROMString(result.ownerName, ownerName, sizeof(ownerName));
  result.optrexDisplay = optrexDisplay;
  result.speakerPitch = speakerPitch;
  result.hapticStrength = hapticStrength - 3;
  result.speakerMode = speakerMode;
  result.switchWarningStates = switchWarningStates;
  result.speakerVolume = volume;
  result.backlightBright = bright ;
  result.currentCalib = current_calib;
  return result;
}
Ejemplo n.º 4
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;
}
Ejemplo n.º 5
0
t_Th9xModelData::operator ModelData ()
{
  ModelData c9x;
  c9x.used = true;
  getEEPROMString(c9x.name, name, sizeof(name));
  /*switch(tmrMode) {
    case 1:
      c9x.timers[0].mode = TMRMODE_ABS;
      break;
    case 2:
      c9x.timers[0].mode = TMRMODE_THs;
      break;
    case 3:
      c9x.timers[0].mode = TMRMODE_THp;
      break;
    default:
      c9x.timers[0].mode = TMRMODE_OFF;
      break;
  }*/
  // c9x.timers[0].dir = tmrDir;
  c9x.timers[0].val = tmrVal;
  /*c9x.protocol = (Protocol)protocol;
  c9x.moduleData[0].channelsCount = 8 + 2 * ppmNCH;
  c9x.thrTrim = thrTrim;
  c9x.thrExpo = thrExpo;
  c9x.trimInc = trimInc;
  c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay;
  c9x.funcSw[0].func = FuncTrims2Offsets;
  if (trimSw) {
    c9x.funcSw[0].swtch = trimSw;
  }
  c9x.beepANACenter = beepANACenter;
  c9x.pulsePol = pulsePol;
  c9x.extendedLimits = extendedLimits;
  c9x.swashRingData.invertELE = swashInvertELE;
  c9x.swashRingData.invertAIL = swashInvertAIL;
  c9x.swashRingData.invertCOL = swashInvertCOL;
  c9x.swashRingData.type = swashType;
  c9x.swashRingData.collectiveSource = swashCollectiveSource;
  c9x.swashRingData.value = swashRingValue;*/
  for (int i=0; i<TH9X_NUM_CHNOUT; i++)
    c9x.limitData[i] = limitData[i];
  for (int i=0; i<TH9X_MAX_EXPOS; i++)
    c9x.expoData[i] = expoTab[i];
  for (int i=0; i<TH9X_MAX_MIXERS; i++)
    c9x.mixData[i] = mixData[i];
  for (int i=0; i<NUM_STICKS; i++)
    c9x.phaseData[0].trim[i] = trimData[i].itrim;
  for (int i=0; i<TH9X_MAX_CURVES3; i++) {
    c9x.curves[i].count = 3;
    for (int j=0; j<3; j++) {
      c9x.curves[i].points[j].x = -100 + 100*i;
      c9x.curves[i].points[j].y = curves3[i][j];
    }
  }
  for (int i=0; i<TH9X_MAX_CURVES5; i++) {
    c9x.curves[i+TH9X_MAX_CURVES3].count = 5;
    for (int j=0; j<5; j++) {
      c9x.curves[i+TH9X_MAX_CURVES3].points[j].x = -100 + 50*i;
      c9x.curves[i+TH9X_MAX_CURVES3].points[j].y = curves5[i][j];
    }
  }
  for (int i=0; i<TH9X_MAX_CURVES9; i++) {
    c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].count = 5;
    for (int j=0; j<9; j++) {
      c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].points[j].x = -100 + 50*i;
      c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].points[j].y = curves9[i][j];
    }
  }

  return c9x;
}
Ejemplo n.º 6
0
Er9xGeneral::operator GeneralSettings ()
{
  GeneralSettings result;
  result.version = myVers;
  for (int i=0; i<NUM_STICKSnPOTS; i++) {
    result.calibMid[i] = calibMid[i];
    result.calibSpanNeg[i] = calibSpanNeg[i];
    result.calibSpanPos[i] = calibSpanPos[i];
  }

  result.currModel = currModel;
  result.contrast = contrast;
  result.vBatWarn = vBatWarn;
  result.vBatCalib = vBatCalib;
  result.trainer = trainer;
  result.blightinv=blightinv;
  result.stickScroll=stickScroll;
  result.crosstrim=crosstrim;
  result.hideNameOnSplash=hideNameOnSplash;
  result.enablePpmsim=enablePpmsim;

  result.view = std::min((uint8_t)4, view);
  result.disableThrottleWarning = disableThrottleWarning;
  result.switchWarning = disableSwitchWarning ? 0 : -1;
  result.disableMemoryWarning = disableMemoryWarning;

  switch (beeperVal) {
    case 0:
      result.beeperMode = GeneralSettings::BEEPER_QUIET;
      break;
    case 1:
      result.beeperMode = GeneralSettings::BEEPER_NOKEYS;
      break;
    default:
      result.beeperMode = GeneralSettings::BEEPER_ALL;
      result.beeperLength = beeperVal - 4;
      break;
  }

  result.disableAlarmWarning = disableAlarmWarning;
  result.stickMode = std::max((uint8_t)0, std::min(stickMode, (uint8_t)3));
  result.inactivityTimer = inactivityTimer + 10;
  result.minuteBeep = minuteBeep;
  result.preBeep = preBeep;
  result.flashBeep = flashBeep;
  result.splashMode = disableSplashScreen;
  result.disablePotScroll=(disablePotScroll==1);
  result.disableBG=(disableBG==1);
  result.frskyinternalalarm = frskyinternalalarm;

  result.backlightMode = 0;
  if (lightSw == 22) {
    result.backlightMode = 4;
  }
  else if (lightAutoOff) {
    result.backlightMode |= 1;
    result.backlightDelay = lightAutoOff;
  }
  else if (lightOnStickMove) {
    result.backlightMode |= 2;
    result.backlightDelay = lightOnStickMove;
  }

  result.templateSetup = templateSetup;
  result.PPM_Multiplier = PPM_Multiplier;
  getEEPROMString(result.ownerName, ownerName, sizeof(ownerName));
  result.speakerPitch = speakerPitch;
  result.hapticStrength = hapticStrength - 3;
  result.speakerMode = speakerMode;
  result.switchWarningStates =switchWarningStates;
  return result;
}
Ejemplo n.º 7
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;
}