Cosmetics
[opentx.git] / radio / src / gui / 480x272 / radio_diagkeys.cpp
blobc952775a900aa9181470a3975861166e9b4baf10
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 constexpr coord_t TRIM_COLUMN = LCD_W - 120;
24 constexpr coord_t TRIM_MINUS_COLUMN = TRIM_COLUMN + 60;
25 constexpr coord_t TRIM_PLUS_COLUMN = TRIM_MINUS_COLUMN + 20;
26 constexpr coord_t SWITCHES_COLUMN = LCD_W / 2 - 20;
28 #if defined(KEYS_GPIO_PIN_PGUP)
29 constexpr uint8_t KEY_START = 0;
30 #else
31 constexpr uint8_t KEY_START = 1;
32 #endif
34 void displayKeyState(coord_t x, coord_t y, uint8_t key)
36 uint8_t t = keys[key].state();
37 lcdDrawChar(x, y, t + '0', t ? INVERS : 0);
40 bool menuRadioDiagKeys(event_t event)
42 SIMPLE_SUBMENU(STR_MENU_RADIO_SWITCHES, ICON_MODEL_SETUP, 1);
44 lcdDrawText(TRIM_COLUMN, MENU_HEADER_HEIGHT + 1, "Trims");
45 lcdDrawText(TRIM_MINUS_COLUMN, MENU_HEADER_HEIGHT + 1, "-");
46 lcdDrawText(TRIM_PLUS_COLUMN, MENU_HEADER_HEIGHT + 1, "+");
48 for (uint8_t i = 0; i < NUM_TRIMS_KEYS; i++) {
49 const uint8_t trimMap[NUM_TRIMS_KEYS] = {6, 7, 4 , 5, 2, 3, 0, 1, 8, 9, 10, 11};
50 coord_t y = MENU_HEADER_HEIGHT + 1 + FH + FH * (i / 2);
51 if (i & 1) {
52 lcdDrawText(TRIM_COLUMN, y, "T", 0);
53 lcdDrawNumber(lcdNextPos, y, i / 2 + 1, 0);
55 displayKeyState(i & 1 ? TRIM_PLUS_COLUMN : TRIM_MINUS_COLUMN, y, TRM_BASE + trimMap[i]);
58 for (uint8_t i = KEY_START; i <= 6; i++) {
59 coord_t y = MENU_HEADER_HEIGHT + 1 + FH * (i - KEY_START);
60 lcdDrawTextAtIndex(MENUS_MARGIN_LEFT, y, STR_VKEYS, (i), 0);
61 displayKeyState(70, y, i);
64 for (uint8_t i = 0; i <= NUM_SWITCHES; i++) {
65 if (SWITCH_EXISTS(i)) {
66 coord_t y = MENU_HEADER_HEIGHT + 1 + FH * i;
67 getvalue_t val = getValue(MIXSRC_FIRST_SWITCH + i);
68 getvalue_t sw = ((val < 0) ? 3 * i + 1 : ((val == 0) ? 3 * i + 2 : 3 * i + 3));
69 drawSwitch(SWITCHES_COLUMN, y, sw, 0, false);
73 #if defined(ROTARY_ENCODER_NAVIGATION)
74 coord_t y = MENU_HEADER_HEIGHT + FH * (8 - KEY_START);
75 lcdDrawText(MENUS_MARGIN_LEFT, y, STR_ROTARY_ENCODER);
76 lcdDrawNumber(70, y, rotencValue, 0);
77 #endif
79 return true;