From d93b63d85ce02f6deb9b7146ab9e04415ebb9ed4 Mon Sep 17 00:00:00 2001 From: bsongis Date: Mon, 9 Jun 2014 23:06:59 +0200 Subject: [PATCH] Fixes #1237 --- .../src/firmwares/opentx/opentxeeprom.cpp | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index bf6e2faef..3a55cc2c7 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -1247,13 +1247,20 @@ class CurvesField: public TransformedField { for (int i=0; itype == CurveData::CURVE_TYPE_CUSTOM ? curve->count * 2 - 2 : curve->count); - if (offset+size > maxPoints) { - EEPROMWarnings += ::QObject::tr("OpenTX only accepts %1 points in all curves").arg(maxPoints) + "\n"; - break; + if (IS_TARANIS(board) && version >= 216) { + offset += (curve->type == CurveData::CURVE_TYPE_CUSTOM ? curve->count * 2 - 2 : curve->count); + if (offset > maxPoints) { + EEPROMWarnings += ::QObject::tr("OpenTX only accepts %1 points in all curves").arg(maxPoints) + "\n"; + break; + } } - if (!IS_TARANIS(board) || version < 216) { - _curves[i] = offset - (5*i); + else { + offset += (curve->type == CurveData::CURVE_TYPE_CUSTOM ? curve->count * 2 - 2 : curve->count) - 5; + if (offset > maxPoints - 5 * maxCurves) { + EEPROMWarnings += ::QObject::tr("openTx only accepts %1 points in all curves").arg(maxPoints) + "\n"; + break; + } + _curves[i] = offset; } for (int j=0; jcount; j++) { *cur++ = curve->points[j].y; @@ -1263,7 +1270,6 @@ class CurvesField: public TransformedField { *cur++ = curve->points[j].x; } } - offset += size; } }