#include #include #include "helpers.h" #include "open9xGruvin9xeeprom.h" #include #include extern void getEEPROMZString(char *dst, const char *src, int size); extern RawSwitch open9xStockToSwitch(int8_t sw); t_Open9xGruvin9xFlightModeData_v207::operator FlightModeData () { FlightModeData c9x; for (int i=0; i> (2*i)) & 0x03); c9x.swtch = open9xStockToSwitch(swtch); getEEPROMZString(c9x.name, name, sizeof(name)); c9x.fadeIn = fadeIn; c9x.fadeOut = fadeOut; for (int i=0; i<2; i++) c9x.rotaryEncoders[i] = rotaryEncoders[i]; return c9x; } t_Open9xGruvin9xFlightModeData_v208::operator FlightModeData () { FlightModeData c9x; for (int i=0; i= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) { c9x.val1 = open9xV4207ToSource(v1).toValue(); } if (c9x.func >= LS_FN_EQUAL) { c9x.val2 = open9xV4207ToSource(v2).toValue(); } if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = open9xStockToSwitch(v1).toValue(); c9x.val2 = open9xStockToSwitch(v2).toValue(); } return c9x; } Open9xGruvin9xLogicalSwitchData_v209::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 = open9xV4209ToSource(v1).toValue(); } if (c9x.func >= LS_FN_EQUAL && c9x.func <= LS_FN_ELESS) { c9x.val2 = open9xV4209ToSource(v2).toValue(); } if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) { c9x.val1 = open9xStockToSwitch(v1).toValue(); c9x.val2 = open9xStockToSwitch(v2).toValue(); } return c9x; } t_Open9xGruvin9xCustomFunctionData_v203::operator CustomFunctionData () { CustomFunctionData c9x; c9x.swtch = open9xStockToSwitch(swtch); if (func < 16) { c9x.func = (AssignFunc)(func); c9x.enabled=param & 0x01; c9x.param = (param>>1)<<1; } else { c9x.param = param; if (func <= 20) c9x.func = (AssignFunc)(func); else if (func == 21) c9x.func = FuncInstantTrim; else if (func == 22) c9x.func = FuncPlaySound; else if (func == 23) c9x.func = FuncPlayHaptic; else if (func == 24) c9x.func = FuncReset; else if (func == 25) c9x.func = FuncVario; else if (func == 26) c9x.func = FuncPlayPrompt; else if (func == 27) c9x.func = FuncPlayValue; else if (func == 28) c9x.func = FuncLogs; else if (func == 29) c9x.func = FuncBacklight; else if (func >= 30 && func <= 34) c9x.func = AssignFunc(FuncAdjustGV1 + func - 30); else c9x.clear(); } return c9x; } t_Open9xGruvin9xCustomFunctionData_v210::operator CustomFunctionData () { CustomFunctionData c9x; c9x.swtch = open9xStockToSwitch(swtch); c9x.param = param; if (func < 22) { c9x.func = (AssignFunc)(func); c9x.enabled = delay; } else { if (func == 22) c9x.func = FuncPlaySound; else if (func == 23) c9x.func = FuncPlayHaptic; else if (func == 24) c9x.func = FuncReset; else if (func == 25) c9x.func = FuncVario; else if (func == 26) c9x.func = FuncPlayPrompt; else if (func == 27) c9x.func = FuncPlayValue; else if (func == 28) c9x.func = FuncLogs; else c9x.clear(); } return c9x; } t_Open9xGruvin9xSwashRingData_v208::operator SwashRingData () { SwashRingData c9x; c9x.invertELE = invertELE; c9x.invertAIL = invertAIL; c9x.invertCOL = invertCOL; c9x.type = type; c9x.collectiveSource = open9xV4207ToSource(collectiveSource); c9x.value = value; return c9x; } t_Open9xGruvin9xSwashRingData_v209::operator SwashRingData () { SwashRingData c9x; c9x.invertELE = invertELE; c9x.invertAIL = invertAIL; c9x.invertCOL = invertCOL; c9x.type = type; c9x.collectiveSource = open9xV4209ToSource(collectiveSource); c9x.value = value; return c9x; } t_Open9xGruvin9xModelData_v207::operator ModelData () { ModelData c9x; c9x.used = true; getEEPROMZString(c9x.name, name, sizeof(name)); for (int i=0; i<2; i++) c9x.timers[i] = timers[i]; 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].channelsCount = 8 + (2 * ppmNCH); c9x.thrTrim = thrTrim; c9x.trimInc = trimInc - 2; c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay; c9x.beepANACenter = beepANACenter; c9x.moduleData[0].ppmPulsePol = pulsePol; c9x.extendedLimits = extendedLimits; c9x.extendedTrims = extendedTrims; for (int i=0; i<5; i++) { c9x.flightModeData[i] = flightModeData[i]; for (int j=0; j 500) { c9x.flightModeData[i].trimRef[j] = c9x.flightModeData[i].trim[j] - 501; if (c9x.flightModeData[i].trimRef[j] >= i) c9x.flightModeData[i].trimRef[j] += 1; c9x.flightModeData[i].trim[j] = 0; } } } for (int i=0; i<32; i++) c9x.mixData[i] = mixData[i]; for (int i=0; i<16; i++) c9x.limitData[i] = limitData[i]; for (int i=0; i<14; i++) c9x.expoData[i] = expoData[i]; for (int i=0; i<8; 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<8; i++) { c9x.curves[8 + i].count = 9; for (int j = 0; j < 9; j++) { c9x.curves[8 + i].points[j].x = -100 + 25 * i; c9x.curves[8 + i].points[j].y = curves9[i][j]; } } for (int i=0; i<12; i++) c9x.logicalSw[i] = logicalSw[i]; for (int i=0; i<16; i++) c9x.customFn[i] = customFn[i]; c9x.swashRingData = swashR; c9x.frsky = frsky; c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; c9x.modelId = modelId; for (int line=0; line<4; line++) { for (int col=0; col<2; col++) { c9x.frsky.screens[1].body.lines[line].source[col] = (col==0 ? (frskyLines[line] & 0x0f) : ((frskyLines[line] & 0xf0) / 16)); c9x.frsky.screens[1].body.lines[line].source[col] += (((frskyLinesXtra >> (4*line+2*col)) & 0x03) * 16); } } return c9x; } t_Open9xGruvin9xModelData_v208::operator ModelData () { ModelData c9x; c9x.used = true; getEEPROMZString(c9x.name, name, sizeof(name)); for (int i=0; i<2; i++) c9x.timers[i] = timers[i]; switch(protocol) { case 1: c9x.moduleData[0].protocol = PPM16; break; case 2: c9x.moduleData[0].protocol = PPMSIM; break; case 3: c9x.moduleData[0].protocol = PXX_DJT; break; case 4: c9x.moduleData[0].protocol = DSM2; break; default: c9x.moduleData[0].protocol = PPM; break; } c9x.moduleData[0].channelsCount = 8 + (2 * ppmNCH); c9x.thrTrim = thrTrim; c9x.trimInc = trimInc - 2; c9x.disableThrottleWarning=disableThrottleWarning; c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay; c9x.beepANACenter = beepANACenter; c9x.moduleData[0].ppmPulsePol = pulsePol; c9x.extendedLimits = extendedLimits; c9x.extendedTrims = extendedTrims; for (int i=0; i<5; i++) { c9x.flightModeData[i] = flightModeData[i]; for (int j=0; j 500) { c9x.flightModeData[i].trimRef[j] = c9x.flightModeData[i].trim[j] - 501; if (c9x.flightModeData[i].trimRef[j] >= i) c9x.flightModeData[i].trimRef[j] += 1; c9x.flightModeData[i].trim[j] = 0; } } } for (int i=0; i<32; i++) c9x.mixData[i] = mixData[i]; for (int i=0; i<16; i++) c9x.limitData[i] = limitData[i]; for (int i=0; i<14; i++) c9x.expoData[i] = expoData[i]; for (int i=0; i<8; 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<8; i++) { c9x.curves[8 + i].count = 9; for (int j = 0; j < 9; j++) { c9x.curves[8 + i].points[j].x = -100 + 25 * i; c9x.curves[8 + i].points[j].y = curves9[i][j]; } } for (int i=0; i<12; i++) c9x.logicalSw[i] = logicalSw[i]; for (int i=0; i<16; i++) c9x.customFn[i] = customFn[i]; c9x.swashRingData = swashR; c9x.frsky = frsky; c9x.frsky.varioSource = varioSource; c9x.frsky.varioCenterMax = varioSpeedUpMin; c9x.frsky.varioCenterMin = varioSpeedDownMin; c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; c9x.modelId = modelId; for (int line=0; line<4; line++) { for (int col=0; col<2; col++) { c9x.frsky.screens[1].body.lines[line].source[col] = (col==0 ? (frskyLines[line] & 0x0f) : ((frskyLines[line] & 0xf0) / 16)); c9x.frsky.screens[1].body.lines[line].source[col] += (((frskyLinesXtra >> (4*line+2*col)) & 0x03) * 16); } } for (int i=0; i<16; i++) { c9x.limitData[i].ppmCenter = servoCenter[i]; } return c9x; } t_Open9xGruvin9xModelData_v209::operator ModelData () { ModelData c9x; c9x.used = true; getEEPROMZString(c9x.name, name, sizeof(name)); for (int i=0; i<2; i++) c9x.timers[i] = timers[i]; switch(protocol) { case 1: c9x.moduleData[0].protocol = PPM16; break; case 2: c9x.moduleData[0].protocol = PPMSIM; break; case 3: c9x.moduleData[0].protocol = PXX_DJT; break; case 4: c9x.moduleData[0].protocol = DSM2; break; default: c9x.moduleData[0].protocol = PPM; break; } c9x.moduleData[0].channelsCount = 8 + (2 * ppmNCH); c9x.thrTrim = thrTrim; c9x.trimInc = trimInc - 2; c9x.disableThrottleWarning=disableThrottleWarning; c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay; c9x.beepANACenter = beepANACenter; c9x.moduleData[0].ppmPulsePol = pulsePol; c9x.extendedLimits = extendedLimits; c9x.extendedTrims = extendedTrims; for (int i=0; i<5; i++) { c9x.flightModeData[i] = flightModeData[i]; for (int j=0; j 500) { c9x.flightModeData[i].trimRef[j] = c9x.flightModeData[i].trim[j] - 501; if (c9x.flightModeData[i].trimRef[j] >= i) c9x.flightModeData[i].trimRef[j] += 1; c9x.flightModeData[i].trim[j] = 0; } } } for (int i=0; i<32; i++) c9x.mixData[i] = mixData[i]; for (int i=0; i<16; i++) c9x.limitData[i] = limitData[i]; for (int i=0; i<14; i++) c9x.expoData[i] = expoData[i]; for (int i=0; i<8; 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<8; i++) { c9x.curves[8 + i].count = 9; for (int j = 0; j < 9; j++) { c9x.curves[8 + i].points[j].x = -100 + 25 * i; c9x.curves[8 + i].points[j].y = curves9[i][j]; } } for (int i=0; i<12; i++) c9x.logicalSw[i] = logicalSw[i]; for (int i=0; i<16; i++) c9x.customFn[i] = customFn[i]; c9x.swashRingData = swashR; c9x.frsky = frsky; c9x.frsky.varioSource = varioSource; c9x.frsky.varioCenterMax = varioSpeedUpMin; c9x.frsky.varioCenterMin = varioSpeedDownMin; c9x.switchWarningStates = switchWarningStates; c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.thrTraceSrc = thrTraceSrc; c9x.modelId = modelId; for (int line=0; line<4; line++) { for (int col=0; col<2; col++) { c9x.frsky.screens[1].body.lines[line].source[col] = (col==0 ? (frskyLines[line] & 0x0f) : ((frskyLines[line] & 0xf0) / 16)); c9x.frsky.screens[1].body.lines[line].source[col] += (((frskyLinesXtra >> (4*line+2*col)) & 0x03) * 16); } } for (int i=0; i<16; i++) { c9x.limitData[i].ppmCenter = servoCenter[i]; } return c9x; } t_Open9xGruvin9xModelData_v210::operator ModelData () { ModelData c9x; c9x.used = true; getEEPROMZString(c9x.name, name, sizeof(name)); for (int i=0; i<2; i++) c9x.timers[i] = timers[i]; switch(protocol) { case 1: c9x.moduleData[0].protocol = PPM16; break; case 2: c9x.moduleData[0].protocol = PPMSIM; break; case 3: c9x.moduleData[0].protocol = PXX_DJT; break; case 4: c9x.moduleData[0].protocol = DSM2; break; default: c9x.moduleData[0].protocol = PPM; break; } c9x.moduleData[0].channelsCount = 8 + (2 * ppmNCH); c9x.thrTrim = thrTrim; c9x.trimInc = trimInc - 2; c9x.disableThrottleWarning=disableThrottleWarning; c9x.moduleData[0].ppmDelay = 300 + 50 * ppmDelay; c9x.beepANACenter = beepANACenter; c9x.moduleData[0].ppmPulsePol = pulsePol; c9x.extendedLimits = extendedLimits; c9x.extendedTrims = extendedTrims; for (int i=0; i<5; i++) { c9x.flightModeData[i] = flightModeData[i]; for (int j=0; j 500) { c9x.flightModeData[i].trimRef[j] = c9x.flightModeData[i].trim[j] - 501; if (c9x.flightModeData[i].trimRef[j] >= i) c9x.flightModeData[i].trimRef[j] += 1; c9x.flightModeData[i].trim[j] = 0; } } } for (int i=0; i<32; i++) c9x.mixData[i] = mixData[i]; for (int i=0; i<16; i++) c9x.limitData[i] = limitData[i]; for (int i=0; i<14; i++) c9x.expoData[i] = expoData[i]; for (int i=0; i<8; i++) { CurveInfo crvinfo = curveinfo(this, i); c9x.curves[i].type = (crvinfo.custom ? CurveData::CURVE_TYPE_CUSTOM : CurveData::CURVE_TYPE_STANDARD); c9x.curves[i].count = crvinfo.points; for (int j=0; j 500) { c9x.flightModeData[i].trimRef[j] = c9x.flightModeData[i].trim[j] - 501; if (c9x.flightModeData[i].trimRef[j] >= i) c9x.flightModeData[i].trimRef[j] += 1; c9x.flightModeData[i].trim[j] = 0; } } } for (int i=0; i<32; i++) c9x.mixData[i] = mixData[i]; for (int i=0; i<16; i++) c9x.limitData[i] = limitData[i]; for (int i=0; i<14; i++) c9x.expoData[i] = expoData[i]; for (int i=0; i<8; i++) { CurveInfo crvinfo = curveinfo(this, i); c9x.curves[i].type = (crvinfo.custom ? CurveData::CURVE_TYPE_CUSTOM : CurveData::CURVE_TYPE_STANDARD); c9x.curves[i].count = crvinfo.points; for (int j=0; j