Schwabe/fix curve overflow (#4951)

* Fix curve editing function not checking if there is space for the curve

* Fix compile error
This commit is contained in:
Arne Schwabe
2017-05-24 18:42:56 +02:00
committed by Bertrand Songis
parent c79994d812
commit 4880c029b7
4 changed files with 59 additions and 38 deletions
+13 -11
View File
@@ -117,14 +117,15 @@ bool menuModelCurveOne(event_t event)
if (attr) {
uint8_t newType = checkIncDecModelZero(event, crv.type, CURVE_TYPE_LAST);
if (newType != crv.type) {
for (int i=1; i<4+crv.points; i++) {
for (int i = 1; i < 4 + crv.points; i++) {
points[i] = calcRESXto100(applyCustomCurve(calc100toRESX(-100 + i * 200 / (4 + crv.points)), s_curveChan));
}
moveCurve(s_curveChan, checkIncDec_Ret > 0 ? 3+crv.points : -3-crv.points);
if (newType == CURVE_TYPE_CUSTOM) {
resetCustomCurveX(points, 5+crv.points);
if (moveCurve(s_curveChan, checkIncDec_Ret > 0 ? 3 + crv.points : -3 - crv.points)) {
if (newType == CURVE_TYPE_CUSTOM) {
resetCustomCurveX(points, 5 + crv.points);
}
crv.type = newType;
}
crv.type = newType;
}
}
@@ -140,13 +141,14 @@ bool menuModelCurveOne(event_t event)
newPoints[4+count] = points[4+crv.points];
for (int i=1; i<4+count; i++)
newPoints[i] = calcRESXto100(applyCustomCurve(calc100toRESX(-100 + (i*200) / (4+count)), s_curveChan));
moveCurve(s_curveChan, checkIncDec_Ret*(crv.type==CURVE_TYPE_CUSTOM?2:1));
for (int i=0; i<5+count; i++) {
points[i] = newPoints[i];
if (crv.type == CURVE_TYPE_CUSTOM && i!=0 && i!=4+count)
points[5+count+i-1] = -100 + (i*200) / (4+count);
if (moveCurve(s_curveChan, checkIncDec_Ret*(crv.type==CURVE_TYPE_CUSTOM?2:1))) {
for (int i = 0; i < 5 + count; i++) {
points[i] = newPoints[i];
if (crv.type == CURVE_TYPE_CUSTOM && i != 0 && i != 4 + count)
points[5 + count + i - 1] = -100 + (i * 200) / (4 + count);
}
crv.points = count;
}
crv.points = count;
}
}