/* * Copyright (C) OpenTX * * Based on code named * th9x - http://code.google.com/p/th9x * er9x - http://code.google.com/p/er9x * gruvin9x - http://code.google.com/p/gruvin9x * * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include "../../opentx.h" uint8_t s_curveChan; int16_t curveFn(int16_t x) { return applyCustomCurve(x, s_curveChan); } struct point_t { coord_t x; coord_t y; }; point_t getPoint(uint8_t i) { point_t result = {0, 0}; CurveInfo crv = curveInfo(s_curveChan); int8_t *points = crv.crv; bool custom = crv.custom; uint8_t count = crv.points; if (i < count) { result.x = X0-1-WCHART+i*WCHART/(count/2); result.y = (LCD_H-1) - (100 + points[i]) * (LCD_H-1) / 200; if (custom && i>0 && i NUM_POINTS-5*MAX_CURVES) { AUDIO_WARNING2(); return false; } int8_t *crv = curveAddress(index); if (shift < 0) { for (uint8_t i=0; i 4) menuHorizontalPosition = -4; for (uint8_t i=0; i 0) { if (--s_editMode == 0) menuHorizontalPosition = 0; } else { popMenu(); } break; /* CASE_EVT_ROTARY_LEFT */ case EVT_KEY_REPT(KEY_LEFT): case EVT_KEY_FIRST(KEY_LEFT): if (s_editMode==1 && menuHorizontalPosition>0) menuHorizontalPosition--; if (s_editMode <= 0) { if (crv.custom) { moveCurve(s_curveChan, -crv.points+2); } else if (crv.points > MIN_POINTS) { moveCurve(s_curveChan, -1, (crv.points+1)/2); } else { AUDIO_WARNING2(); } return; } break; /* CASE_EVT_ROTARY_RIGHT */ case EVT_KEY_REPT(KEY_RIGHT): case EVT_KEY_FIRST(KEY_RIGHT): if (s_editMode==1 && menuHorizontalPosition<(crv.points-1)) menuHorizontalPosition++; if (s_editMode <= 0) { if (!crv.custom) { moveCurve(s_curveChan, crv.points-2, crv.points); } else if (crv.points < MAX_POINTS) { if (moveCurve(s_curveChan, 1)) { for (int8_t i=crv.points+crv.points-2; i>=0; i--) { if (i%2) crv.crv[i] = (crv.crv[i/2] + crv.crv[1+i/2]) / 2; else crv.crv[i] = crv.crv[i/2]; } } } else { AUDIO_WARNING2(); } } break; } lcd_putsLeft(7*FH, STR_TYPE); uint8_t attr = (s_editMode <= 0 ? INVERS : 0); lcdDrawNumber(5*FW-2, 7*FH, crv.points, LEFT|attr); lcdDrawText(lcdLastPos, 7*FH, crv.custom ? PSTR("pt'") : PSTR("pt"), attr); DrawCurve(); if (s_editMode>0) { uint8_t i = menuHorizontalPosition; point_t point = getPoint(i); if (s_editMode==1 || !BLINK_ON_PHASE) { // do selection square lcdDrawFilledRect(point.x-1, point.y-2, 5, 5, SOLID, FORCE); lcdDrawFilledRect(point.x, point.y-1, 3, 3, SOLID); } int8_t x = -100 + 200*i/(crv.points-1); if (crv.custom && i>0 && i