Bsongis/x7d companion support (#4028)
[opentx.git] / radio / src / gui / 128x64 / radio_trainer.cpp
blob6a3ccb200d30025d6cbe54e9af5792db9f25020d
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #include "opentx.h"
23 void menuRadioTrainer(event_t event)
25 uint8_t y;
26 bool slave = SLAVE_MODE();
28 MENU(STR_MENUTRAINER, menuTabGeneral, MENU_RADIO_TRAINER, (slave ? HEADER_LINE : HEADER_LINE+6), {HEADER_LINE_COLUMNS 2, 2, 2, 2, 0/*, 0*/});
30 if (slave) {
31 lcdDrawText(7*FW, 4*FH, STR_SLAVE);
33 else {
34 uint8_t attr;
35 uint8_t blink = ((s_editMode>0) ? BLINK|INVERS : INVERS);
37 lcdDrawText(3*FW, MENU_HEADER_HEIGHT+1, STR_MODESRC);
39 y = MENU_HEADER_HEIGHT + 1 + FH;
41 for (uint8_t i=0; i<NUM_STICKS; i++) {
42 uint8_t chan = channel_order(i+1);
43 volatile TrainerMix * td = &g_eeGeneral.trainer.mix[chan-1];
45 drawSource(0, y, MIXSRC_Rud-1+chan, (menuVerticalPosition==i && CURSOR_ON_LINE()) ? INVERS : 0);
47 for (uint8_t j=0; j<3; j++) {
49 attr = ((menuVerticalPosition==i && menuHorizontalPosition==j) ? blink : 0);
51 switch (j) {
52 case 0:
53 lcdDrawTextAtIndex(4*FW, y, STR_TRNMODE, td->mode, attr);
54 if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->mode, 0, 2);
55 break;
57 case 1:
58 lcdDrawNumber(11*FW, y, td->studWeight, attr|RIGHT);
59 if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->studWeight, -125, 125);
60 break;
62 case 2:
63 lcdDrawTextAtIndex(12*FW, y, STR_TRNCHN, td->srcChn, attr);
64 if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->srcChn, 0, 3);
65 break;
68 y += FH;
71 attr = (menuVerticalPosition==HEADER_LINE+4) ? blink : 0;
72 lcdDrawTextAlignedLeft(MENU_HEADER_HEIGHT+1+5*FH, STR_MULTIPLIER);
73 lcdDrawNumber(LEN_MULTIPLIER*FW+3*FW, MENU_HEADER_HEIGHT+1+5*FH, g_eeGeneral.PPM_Multiplier+10, attr|PREC1|RIGHT);
74 if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.PPM_Multiplier, -10, 40);
76 attr = (menuVerticalPosition==HEADER_LINE+5) ? INVERS : 0;
77 lcdDrawText(0*FW, MENU_HEADER_HEIGHT+1+6*FH, STR_CAL, attr);
78 for (uint8_t i=0; i<4; i++) {
79 uint8_t x = (i*8+16)*FW/2;
80 lcdDrawNumber(x, MENU_HEADER_HEIGHT+1+6*FH, (ppmInput[i]-g_eeGeneral.trainer.calib[i])/5, RIGHT);
83 if (attr) {
84 s_editMode = 0;
85 if (event==EVT_KEY_LONG(KEY_ENTER)){
86 memcpy(g_eeGeneral.trainer.calib, ppmInput, sizeof(g_eeGeneral.trainer.calib));
87 storageDirty(EE_GENERAL);
88 AUDIO_WARNING1();