/* * Authors (alphabetical order) * - Andre Bernet * - Andreas Weitl * - Bertrand Songis * - Bryan J. Rentoul (Gruvin) * - Cameron Weeks * - Erez Raviv * - Gabriel Birkus * - Jean-Pierre Parisy * - Karl Szmutny * - Michael Blandford * - Michal Hlavinka * - Pat Mackenzie * - Philip Moss * - Rob Thomson * - Thomas Husterer * * opentx is based on code named * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, * er9x by Erez Raviv: http://code.google.com/p/er9x/, * and the original (and ongoing) project by * Thomas Husterer, th9x: http://code.google.com/p/th9x/ * * 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) m_posHorz = -4; for (uint8_t i=0; i 0) { if (--s_editMode == 0) m_posHorz = 0; } else { popMenu(); } break; /* CASE_EVT_ROTARY_LEFT */ case EVT_KEY_REPT(KEY_LEFT): case EVT_KEY_FIRST(KEY_LEFT): if (s_editMode==1 && m_posHorz>0) m_posHorz--; 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 && m_posHorz<(crv.points-1)) m_posHorz++; 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); lcd_outdezAtt(5*FW-2, 7*FH, crv.points, LEFT|attr); lcd_putsAtt(lcdLastPos, 7*FH, crv.custom ? PSTR("pt'") : PSTR("pt"), attr); DrawCurve(); if (s_editMode>0) { uint8_t i = m_posHorz; point_t point = getPoint(i); if (s_editMode==1 || !BLINK_ON_PHASE) { // do selection square drawFilledRect(point.x-1, point.y-2, 5, 5, SOLID, FORCE); drawFilledRect(point.x, point.y-1, 3, 3, SOLID); } int8_t x = -100 + 200*i/(crv.points-1); if (crv.custom && i>0 && i