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:
committed by
Bertrand Songis
parent
c79994d812
commit
4880c029b7
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user