From f2d778e74e713ee8bb49e131e9e5e1350394a363 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Sun, 15 May 2016 08:30:32 +0200 Subject: [PATCH] Curves fix for #3317 ported to 'next' --- radio/src/gui/horus/menu_model_curves.cpp | 41 ++++++++++++--------- radio/src/gui/taranis/menu_model_curves.cpp | 10 ++--- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/radio/src/gui/horus/menu_model_curves.cpp b/radio/src/gui/horus/menu_model_curves.cpp index 4a4bf5860..dddd8dc43 100644 --- a/radio/src/gui/horus/menu_model_curves.cpp +++ b/radio/src/gui/horus/menu_model_curves.cpp @@ -53,13 +53,6 @@ point_t getPoint(uint8_t i) void drawCurve(int x, int y, int width) { drawFunction(curveFn, x, y, width); - - /*int i = 0; - do { - point_t point = getPoint(i++); - if (point.x == 0) break; - lcdDrawSolidFilledRect(point.x-offset, point.y-1, 3, 3, TEXT_COLOR); // do markup square - } while(1);*/ } extern int8_t * curveEnd[MAX_CURVES]; @@ -81,6 +74,18 @@ bool moveCurve(uint8_t index, int8_t shift) return true; } +int8_t getCurveX(int noPoints, int point) +{ + return -100 + div_and_round((point*2000) / (noPoints-1), 10); +} + +void resetCustomCurveX(int8_t * points, int noPoints) +{ + for (int i=0; i 0 ? 3+crv.points : -3-crv.points); if (newType == CURVE_TYPE_CUSTOM) { - for (int i=0; i<3+crv.points; i++) - points[5+crv.points+i] = -100 + ((i+1)*200) / (4+crv.points); + resetCustomCurveX(points, 5+crv.points); } crv.type = newType; } diff --git a/radio/src/gui/taranis/menu_model_curves.cpp b/radio/src/gui/taranis/menu_model_curves.cpp index 498605634..baa4e0f96 100644 --- a/radio/src/gui/taranis/menu_model_curves.cpp +++ b/radio/src/gui/taranis/menu_model_curves.cpp @@ -35,8 +35,8 @@ struct point_t { point_t getPoint(uint8_t i) { point_t result = {0, 0}; - CurveInfo &crv = g_model.curves[s_curveChan]; - int8_t *points = curveAddress(s_curveChan); + CurveInfo & crv = g_model.curves[s_curveChan]; + int8_t * points = curveAddress(s_curveChan); bool custom = (crv.type == CURVE_TYPE_CUSTOM); uint8_t count = 5+crv.points; if (i < count) { @@ -82,7 +82,7 @@ bool moveCurve(uint8_t index, int8_t shift) int8_t getCurveX(int noPoints, int point) { - return -100 + div10_and_round( (point*2000) / (noPoints-1) ); + return -100 + div_and_round((point*2000) / (noPoints-1), 10); } void resetCustomCurveX(int8_t * points, int noPoints) @@ -106,7 +106,7 @@ void displayPresetChoice(uint8_t event) int dx = 2000 / (5+crv.points-1); for (uint8_t i=0; i<5+crv.points; i++) { int x = -1000 + i * dx; - points[i] = div10_and_round(div100_and_round(k * x)); + points[i] = div_and_round(div_and_round(k * x, 100), 10); } if (crv.type == CURVE_TYPE_CUSTOM) { resetCustomCurveX(points, 5+crv.points); @@ -114,7 +114,7 @@ void displayPresetChoice(uint8_t event) } } -void onCurveOneMenu(const char *result) +void onCurveOneMenu(const char * result) { if (result == STR_CURVE_PRESET) { POPUP_INPUT(STR_PRESET, displayPresetChoice, 0, -4, 4);