Massive cleaning (#5538)
[opentx.git] / radio / src / gui / 480x272 / layouts / layout2x4.cpp
blobb5bd79861f7036e8052b8919c30cbf13b0e14271
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 const uint8_t LBM_LAYOUT_2x4[] = {
24 #include "mask_layout2x4.lbm"
27 const ZoneOption OPTIONS_LAYOUT_2x4[] = {
28 { "Top bar", ZoneOption::Bool },
29 { "Flight mode", ZoneOption::Bool },
30 { "Sliders", ZoneOption::Bool },
31 { "Trims", ZoneOption::Bool },
32 { "Panel1 background", ZoneOption::Bool },
33 { " Color", ZoneOption::Color },
34 { "Panel2 background", ZoneOption::Bool },
35 { " Color", ZoneOption::Color },
36 { NULL, ZoneOption::Bool }
39 class Layout2x4: public Layout
41 public:
42 Layout2x4(const LayoutFactory * factory, Layout::PersistentData * persistentData):
43 Layout(factory, persistentData)
47 virtual void create()
49 Layout::create();
50 persistentData->options[0].boolValue = true;
51 persistentData->options[1].boolValue = true;
52 persistentData->options[2].boolValue = true;
53 persistentData->options[3].boolValue = true;
54 persistentData->options[4].boolValue = true;
55 persistentData->options[5].unsignedValue = RGB(77, 112, 203);
56 persistentData->options[6].boolValue = false;
57 persistentData->options[7].unsignedValue = RGB(77, 112, 203);
60 virtual unsigned int getZonesCount() const
62 return 8;
65 virtual Zone getZone(unsigned int index) const
67 Zone zone;
68 zone.x = (index >= 4) ? 260 : 60;
69 zone.y = 56 + (index % 4) * 42;
70 zone.w = 160;
71 zone.h = 32;
72 return zone;
75 virtual void refresh();
78 void Layout2x4::refresh()
80 theme->drawBackground();
82 if (persistentData->options[0].boolValue) {
83 drawTopBar();
86 if (persistentData->options[1].boolValue) {
87 // Flight mode
88 lcdDrawSizedText(LCD_W / 2 - getTextWidth(g_model.flightModeData[mixerCurrentFlightMode].name,
89 sizeof(g_model.flightModeData[mixerCurrentFlightMode].name),
90 ZCHAR | SMLSIZE) / 2,
91 237,
92 g_model.flightModeData[mixerCurrentFlightMode].name,
93 sizeof(g_model.flightModeData[mixerCurrentFlightMode].name), ZCHAR | SMLSIZE);
96 if (persistentData->options[2].boolValue) {
97 // Pots and rear sliders positions
98 drawMainPots();
101 if (persistentData->options[3].boolValue) {
102 // Trims
103 drawTrims(mixerCurrentFlightMode);
106 if (persistentData->options[4].boolValue) {
107 lcdSetColor(persistentData->options[5].unsignedValue);
108 lcdDrawSolidFilledRect(50, 50, 180, 170, CUSTOM_COLOR);
111 if (persistentData->options[6].boolValue) {
112 lcdSetColor(persistentData->options[7].unsignedValue);
113 lcdDrawSolidFilledRect(250, 50, 180, 170, CUSTOM_COLOR);
116 Layout::refresh();
119 BaseLayoutFactory<Layout2x4> layout2x4("Layout2x4", LBM_LAYOUT_2x4, OPTIONS_LAYOUT_2x4);