From 428c986c915345ad7056d90e17851af9d58927ec Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Wed, 27 Mar 2019 14:46:31 +0100 Subject: [PATCH] Compilation fixes --- radio/src/gui/128x64/model_failsafe.cpp | 2 +- radio/src/gui/212x64/model_failsafe.cpp | 177 ++++++++++++++++++ radio/src/gui/212x64/model_module_options.cpp | 21 +++ .../src/gui/212x64/model_receiver_options.cpp | 21 +++ radio/src/gui/212x64/model_setup.cpp | 154 --------------- radio/src/gui/480x272/model_failsafe.cpp | 138 ++++++++++++++ .../src/gui/480x272/model_module_options.cpp | 21 +++ .../gui/480x272/model_receiver_options.cpp | 21 +++ radio/src/gui/480x272/model_setup.cpp | 115 ------------ 9 files changed, 400 insertions(+), 270 deletions(-) create mode 100644 radio/src/gui/212x64/model_failsafe.cpp create mode 100644 radio/src/gui/212x64/model_module_options.cpp create mode 100644 radio/src/gui/212x64/model_receiver_options.cpp create mode 100644 radio/src/gui/480x272/model_failsafe.cpp create mode 100644 radio/src/gui/480x272/model_module_options.cpp create mode 100644 radio/src/gui/480x272/model_receiver_options.cpp diff --git a/radio/src/gui/128x64/model_failsafe.cpp b/radio/src/gui/128x64/model_failsafe.cpp index 905b293f7..2896e8c95 100644 --- a/radio/src/gui/128x64/model_failsafe.cpp +++ b/radio/src/gui/128x64/model_failsafe.cpp @@ -93,7 +93,7 @@ void menuModelFailsafe(event_t event) } } - uint8_t xValue = x+LCD_W-4-wbar; + const coord_t xValue = x+LCD_W-4-wbar; if (failsafeValue == FAILSAFE_CHANNEL_HOLD) { lcdDrawText(xValue, y, STR_HOLD, RIGHT|flags); failsafeValue = 0; diff --git a/radio/src/gui/212x64/model_failsafe.cpp b/radio/src/gui/212x64/model_failsafe.cpp new file mode 100644 index 000000000..059e25736 --- /dev/null +++ b/radio/src/gui/212x64/model_failsafe.cpp @@ -0,0 +1,177 @@ +/* + * 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 + +extern uint8_t g_moduleIdx; + +void menuModelFailsafe(event_t event) +{ + static uint8_t maxNameLen = 4; + static int8_t lastModel = g_eeGeneral.currModel; + const coord_t barH = (LCD_H - FH) / 8 - 1; + const int lim = (g_model.extendedLimits ? (512 * LIMIT_EXT_PERCENT / 100) : 512) * 2; + const uint8_t channelStart = g_model.moduleData[g_moduleIdx].channelsStart; + uint8_t cols = 1; + uint8_t colW = LCD_W; + + if (lastModel != g_eeGeneral.currModel) { + lastModel = g_eeGeneral.currModel; + maxNameLen = 4; + } + + if (event == EVT_KEY_LONG(KEY_ENTER)) { + killEvents(event); + event = 0; + + if (menuVerticalPosition < sentModuleChannels(g_moduleIdx)) { + if (s_editMode) { + g_model.failsafeChannels[menuVerticalPosition] = channelOutputs[menuVerticalPosition+channelStart]; + s_editMode = 0; + } + else { + int16_t & failsafe = g_model.failsafeChannels[menuVerticalPosition]; + if (failsafe < FAILSAFE_CHANNEL_HOLD) + failsafe = FAILSAFE_CHANNEL_HOLD; + else if (failsafe == FAILSAFE_CHANNEL_HOLD) + failsafe = FAILSAFE_CHANNEL_NOPULSE; + else + failsafe = 0; + } + } + else { + // "Outputs => Failsafe" menu item + setCustomFailsafe(g_moduleIdx); + } + + storageDirty(EE_MODEL); + AUDIO_WARNING1(); + SEND_FAILSAFE_NOW(g_moduleIdx); + } + + SIMPLE_SUBMENU_NOTITLE(sentModuleChannels(g_moduleIdx) + 1); + SET_SCROLLBAR_X(0); + + if (sentModuleChannels(g_moduleIdx) > 8) { + cols = 2; + colW = LCD_W / cols - 1; + // Column separator + if (menuVerticalPosition >= sentModuleChannels(g_moduleIdx)) { + lcdDrawSolidVerticalLine(colW, FH, LCD_H - (FH*2 + FH/2 + 2)); + } + else { + lcdDrawSolidVerticalLine(colW, FH, LCD_H - FH); + } + } + + lcdDrawTextAlignedCenter(0, FAILSAFESET); + lcdInvertLine(0); + + coord_t x = colW; + for (uint8_t col = 0; col < cols; col++) { + + coord_t y = FH + 1; + uint8_t line = (menuVerticalPosition >= sentModuleChannels(g_moduleIdx) ? 2 : 0); + uint8_t ch = line + col*8; + + for (; line < 8; line++) { + const int32_t channelValue = channelOutputs[ch+channelStart]; + int32_t failsafeValue = g_model.failsafeChannels[8*col+line]; + uint8_t lenLabel = ZLEN(g_model.limitData[ch+channelStart].name); + uint8_t barW = colW - FW * maxNameLen - FWNUM * 3; // default bar width + +#if defined(PPM_UNIT_PERCENT_PREC1) + barW -= FWNUM + 1; +#endif + barW += (barW % 2); + + // Channel name if present, number if not + if (lenLabel > 0) { + if (lenLabel > maxNameLen) + maxNameLen = lenLabel; + lcdDrawSizedText(x - colW, y, g_model.limitData[ch+channelStart].name, sizeof(g_model.limitData[ch+channelStart].name), ZCHAR | SMLSIZE); + } + else { + putsChn(x - colW, y, ch+1, SMLSIZE); + } + + // Value + LcdFlags flags = TINSIZE; + if (menuVerticalPosition == ch) { + flags |= INVERS; + if (s_editMode) { + if (failsafeValue == FAILSAFE_CHANNEL_HOLD || failsafeValue == FAILSAFE_CHANNEL_NOPULSE) { + s_editMode = 0; + } + else { + flags |= BLINK; + CHECK_INCDEC_MODELVAR(event, g_model.failsafeChannels[8*col+line], -lim, +lim); + } + } + } + + const coord_t xValue = x - barW; + if (failsafeValue == FAILSAFE_CHANNEL_HOLD) { + lcdDrawText(xValue, y, STR_HOLD, RIGHT|flags); + failsafeValue = 0; + } + else if (failsafeValue == FAILSAFE_CHANNEL_NOPULSE) { + lcdDrawText(xValue, y, STR_NONE, RIGHT|flags); + failsafeValue = 0; + } + else { +#if defined(PPM_UNIT_US) + lcdDrawNumber(xValue, y, PPM_CH_CENTER(ch)+failsafeValue/2, RIGHT|flags); +#elif defined(PPM_UNIT_PERCENT_PREC1) + lcdDrawNumber(xValue, y, calcRESXto1000(failsafeValue), RIGHT|PREC1|flags); +#else + lcdDrawNumber(xValue, y, calcRESXto1000(failsafeValue)/10, RIGHT|flags); +#endif + } + + // Gauge + lcdDrawRect(x - barW, y, barW - 1, barH); + barW = barW / 2 - 1; + const coord_t lenChannel = limit(1, (abs(channelValue) * barW + lim / 2) / lim, barW); + const coord_t lenFailsafe = limit(1, (abs(failsafeValue) * barW + lim / 2) / lim, barW); + const coord_t barX = x - barW - 2; + const coord_t xChannel = (channelValue >= 0) ? barX : barX - lenChannel + 1; + const coord_t xFailsafe = (failsafeValue > 0) ? barX : barX - lenFailsafe + 1; + lcdDrawHorizontalLine(xChannel, y+1, lenChannel, DOTTED, 0); + lcdDrawHorizontalLine(xChannel, y+2, lenChannel, DOTTED, 0); + lcdDrawSolidHorizontalLine(xFailsafe, y+3, lenFailsafe); + lcdDrawSolidHorizontalLine(xFailsafe, y+4, lenFailsafe); + + if (++ch >= sentModuleChannels(g_moduleIdx)) + break; + + y += barH + 1; + + } // channels + + x += colW + 2; + + } // columns + + if (menuVerticalPosition >= sentModuleChannels(g_moduleIdx)) { + // Outputs => Failsafe + lcdDrawText(CENTER_OFS, LCD_H - (FH + 1), STR_OUTPUTS2FAILSAFE, INVERS); + } +} diff --git a/radio/src/gui/212x64/model_module_options.cpp b/radio/src/gui/212x64/model_module_options.cpp new file mode 100644 index 000000000..f72d3594f --- /dev/null +++ b/radio/src/gui/212x64/model_module_options.cpp @@ -0,0 +1,21 @@ +/* + * 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 diff --git a/radio/src/gui/212x64/model_receiver_options.cpp b/radio/src/gui/212x64/model_receiver_options.cpp new file mode 100644 index 000000000..f72d3594f --- /dev/null +++ b/radio/src/gui/212x64/model_receiver_options.cpp @@ -0,0 +1,21 @@ +/* + * 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 diff --git a/radio/src/gui/212x64/model_setup.cpp b/radio/src/gui/212x64/model_setup.cpp index ef98e47a2..02626db28 100644 --- a/radio/src/gui/212x64/model_setup.cpp +++ b/radio/src/gui/212x64/model_setup.cpp @@ -1258,157 +1258,3 @@ void menuModelSetup(event_t event) } } } - -void menuModelFailsafe(event_t event) -{ - static uint8_t maxNameLen = 4; - static int8_t lastModel = g_eeGeneral.currModel; - const coord_t barH = (LCD_H - FH) / 8 - 1; - const int lim = (g_model.extendedLimits ? (512 * LIMIT_EXT_PERCENT / 100) : 512) * 2; - const uint8_t channelStart = g_model.moduleData[g_moduleIdx].channelsStart; - uint8_t cols = 1; - uint8_t colW = LCD_W; - - if (lastModel != g_eeGeneral.currModel) { - lastModel = g_eeGeneral.currModel; - maxNameLen = 4; - } - - if (event == EVT_KEY_LONG(KEY_ENTER)) { - killEvents(event); - event = 0; - - if (menuVerticalPosition < sentModuleChannels(g_moduleIdx)) { - if (s_editMode) { - g_model.failsafeChannels[menuVerticalPosition] = channelOutputs[menuVerticalPosition+channelStart]; - s_editMode = 0; - } - else { - int16_t & failsafe = g_model.failsafeChannels[menuVerticalPosition]; - if (failsafe < FAILSAFE_CHANNEL_HOLD) - failsafe = FAILSAFE_CHANNEL_HOLD; - else if (failsafe == FAILSAFE_CHANNEL_HOLD) - failsafe = FAILSAFE_CHANNEL_NOPULSE; - else - failsafe = 0; - } - } - else { - // "Outputs => Failsafe" menu item - setCustomFailsafe(g_moduleIdx); - } - - storageDirty(EE_MODEL); - AUDIO_WARNING1(); - SEND_FAILSAFE_NOW(g_moduleIdx); - } - - SIMPLE_SUBMENU_NOTITLE(sentModuleChannels(g_moduleIdx)+1); - SET_SCROLLBAR_X(0); - - if (sentModuleChannels(g_moduleIdx) > 8) { - cols = 2; - colW = LCD_W / cols - 1; - // Column separator - if (menuVerticalPosition >= sentModuleChannels(g_moduleIdx)) { - lcdDrawSolidVerticalLine(colW, FH, LCD_H - (FH*2 + FH/2 + 2)); - } - else { - lcdDrawSolidVerticalLine(colW, FH, LCD_H - FH); - } - } - - lcdDrawTextAlignedCenter(0, FAILSAFESET); - lcdInvertLine(0); - - coord_t x = colW; - for (uint8_t col = 0; col < cols; col++) { - - coord_t y = FH + 1; - uint8_t line = (menuVerticalPosition >= sentModuleChannels(g_moduleIdx) ? 2 : 0); - uint8_t ch = line + col*8; - - for (; line < 8; line++) { - const int32_t channelValue = channelOutputs[ch+channelStart]; - int32_t failsafeValue = g_model.failsafeChannels[8*col+line]; - uint8_t lenLabel = ZLEN(g_model.limitData[ch+channelStart].name); - uint8_t barW = colW - FW * maxNameLen - FWNUM * 3; // default bar width - -#if defined(PPM_UNIT_PERCENT_PREC1) - barW -= FWNUM + 1; -#endif - barW += (barW % 2); - - // Channel name if present, number if not - if (lenLabel > 0) { - if (lenLabel > maxNameLen) - maxNameLen = lenLabel; - lcdDrawSizedText(x - colW, y, g_model.limitData[ch+channelStart].name, sizeof(g_model.limitData[ch+channelStart].name), ZCHAR | SMLSIZE); - } - else { - putsChn(x - colW, y, ch+1, SMLSIZE); - } - - // Value - LcdFlags flags = TINSIZE; - if (menuVerticalPosition == ch) { - flags |= INVERS; - if (s_editMode) { - if (failsafeValue == FAILSAFE_CHANNEL_HOLD || failsafeValue == FAILSAFE_CHANNEL_NOPULSE) { - s_editMode = 0; - } - else { - flags |= BLINK; - CHECK_INCDEC_MODELVAR(event, g_model.failsafeChannels[8*col+line], -lim, +lim); - } - } - } - - const coord_t xValue = x - barW; - if (failsafeValue == FAILSAFE_CHANNEL_HOLD) { - lcdDrawText(xValue, y, STR_HOLD, RIGHT|flags); - failsafeValue = 0; - } - else if (failsafeValue == FAILSAFE_CHANNEL_NOPULSE) { - lcdDrawText(xValue, y, STR_NONE, RIGHT|flags); - failsafeValue = 0; - } - else { -#if defined(PPM_UNIT_US) - lcdDrawNumber(xValue, y, PPM_CH_CENTER(ch)+failsafeValue/2, RIGHT|flags); -#elif defined(PPM_UNIT_PERCENT_PREC1) - lcdDrawNumber(xValue, y, calcRESXto1000(failsafeValue), RIGHT|PREC1|flags); -#else - lcdDrawNumber(xValue, y, calcRESXto1000(failsafeValue)/10, RIGHT|flags); -#endif - } - - // Gauge - lcdDrawRect(x - barW, y, barW - 1, barH); - barW = barW / 2 - 1; - const coord_t lenChannel = limit(1, (abs(channelValue) * barW + lim / 2) / lim, barW); - const coord_t lenFailsafe = limit(1, (abs(failsafeValue) * barW + lim / 2) / lim, barW); - const coord_t barX = x - barW - 2; - const coord_t xChannel = (channelValue >= 0) ? barX : barX - lenChannel + 1; - const coord_t xFailsafe = (failsafeValue > 0) ? barX : barX - lenFailsafe + 1; - lcdDrawHorizontalLine(xChannel, y+1, lenChannel, DOTTED, 0); - lcdDrawHorizontalLine(xChannel, y+2, lenChannel, DOTTED, 0); - lcdDrawSolidHorizontalLine(xFailsafe, y+3, lenFailsafe); - lcdDrawSolidHorizontalLine(xFailsafe, y+4, lenFailsafe); - - if (++ch >= sentModuleChannels(g_moduleIdx)) - break; - - y += barH + 1; - - } // channels - - x += colW + 2; - - } // columns - - if (menuVerticalPosition >= sentModuleChannels(g_moduleIdx)) { - // Outputs => Failsafe - lcdDrawText(CENTER_OFS, LCD_H - (FH + 1), STR_OUTPUTS2FAILSAFE, INVERS); - } -} diff --git a/radio/src/gui/480x272/model_failsafe.cpp b/radio/src/gui/480x272/model_failsafe.cpp new file mode 100644 index 000000000..bcc04d7a5 --- /dev/null +++ b/radio/src/gui/480x272/model_failsafe.cpp @@ -0,0 +1,138 @@ +/* + * 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 + +extern uint8_t g_moduleIdx; + +bool menuModelFailsafe(event_t event) +{ + uint8_t ch = 0; + const uint8_t channelStart = g_model.moduleData[g_moduleIdx].channelsStart; + const int lim = (g_model.extendedLimits ? (512 * LIMIT_EXT_PERCENT / 100) : 512) * 2; + const uint8_t SLIDER_W = 128; + const uint8_t cols = sentModuleChannels(g_moduleIdx) > 8 ? 2 : 1; + + if (event == EVT_KEY_LONG(KEY_ENTER)) { + killEvents(event); + event = 0; + + if (menuVerticalPosition < sentModuleChannels(g_moduleIdx)) { + if (s_editMode) { + g_model.failsafeChannels[menuVerticalPosition] = channelOutputs[menuVerticalPosition+channelStart]; + s_editMode = 0; + } + else { + int16_t & failsafe = g_model.failsafeChannels[menuVerticalPosition]; + if (failsafe < FAILSAFE_CHANNEL_HOLD) + failsafe = FAILSAFE_CHANNEL_HOLD; + else if (failsafe == FAILSAFE_CHANNEL_HOLD) + failsafe = FAILSAFE_CHANNEL_NOPULSE; + else + failsafe = 0; + } + } + else { + // "Outputs => Failsafe" menu item + setCustomFailsafe(g_moduleIdx); + } + + storageDirty(EE_MODEL); + AUDIO_WARNING1(); + SEND_FAILSAFE_NOW(g_moduleIdx); + } + + SIMPLE_SUBMENU_WITH_OPTIONS("FAILSAFE", ICON_STATS_ANALOGS, sentModuleChannels(g_moduleIdx)+1, OPTION_MENU_NO_SCROLLBAR); + drawStringWithIndex(50, 3+FH, "Module", g_moduleIdx+1, MENU_TITLE_COLOR); + + for (uint8_t col=0; col < cols; col++) { + for (uint8_t line=0; line < 8; line++) { + coord_t x = col*(LCD_W/2); + const coord_t y = MENU_CONTENT_TOP - FH + line*(FH+2); + const int32_t channelValue = channelOutputs[ch+channelStart]; + int32_t failsafeValue = g_model.failsafeChannels[8*col+line]; + + // Channel name if present, number if not + if (g_model.limitData[ch+channelStart].name[0] != '\0') { + putsChn(x+MENUS_MARGIN_LEFT, y-3, ch+1, TINSIZE); + lcdDrawSizedText(x+MENUS_MARGIN_LEFT, y+5, g_model.limitData[ch+channelStart].name, sizeof(g_model.limitData[ch+channelStart].name), ZCHAR|SMLSIZE); + } + else { + putsChn(x+MENUS_MARGIN_LEFT, y, ch+1, 0); + } + + // Value + LcdFlags flags = RIGHT; + if (menuVerticalPosition == ch) { + flags |= INVERS; + if (s_editMode) { + if (failsafeValue == FAILSAFE_CHANNEL_HOLD || failsafeValue == FAILSAFE_CHANNEL_NOPULSE) { + s_editMode = 0; + } + else { + flags |= BLINK; + CHECK_INCDEC_MODELVAR(event, g_model.failsafeChannels[8*col+line], -lim, +lim); + } + } + } + + x += (LCD_W/2)-4-MENUS_MARGIN_LEFT-SLIDER_W; + + if (failsafeValue == FAILSAFE_CHANNEL_HOLD) { + lcdDrawText(x, y+2, "HOLD", flags|SMLSIZE); + failsafeValue = 0; + } + else if (failsafeValue == FAILSAFE_CHANNEL_NOPULSE) { + lcdDrawText(x, y+2, "NONE", flags|SMLSIZE); + failsafeValue = 0; + } + else { +#if defined(PPM_UNIT_US) + lcdDrawNumber(x, y, PPM_CH_CENTER(ch)+failsafeValue/2, flags); +#elif defined(PPM_UNIT_PERCENT_PREC1) + lcdDrawNumber(x, y, calcRESXto1000(failsafeValue), PREC1|flags); +#else + lcdDrawNumber(x, y, calcRESXto1000(failsafeValue)/10, flags); +#endif + } + + // Gauge + x += 4; + lcdDrawRect(x, y+3, SLIDER_W+1, 12); + const coord_t lenChannel = limit((uint8_t)1, uint8_t((abs(channelValue) * SLIDER_W/2 + lim/2) / lim), uint8_t(SLIDER_W/2)); + const coord_t lenFailsafe = limit((uint8_t)1, uint8_t((abs(failsafeValue) * SLIDER_W/2 + lim/2) / lim), uint8_t(SLIDER_W/2)); + x += SLIDER_W/2; + const coord_t xChannel = (channelValue>0) ? x : x+1-lenChannel; + const coord_t xFailsafe = (failsafeValue>0) ? x : x+1-lenFailsafe; + lcdDrawSolidFilledRect(xChannel, y+4, lenChannel, 5, TEXT_COLOR); + lcdDrawSolidFilledRect(xFailsafe, y+9, lenFailsafe, 5, ALARM_COLOR); + + if (++ch >= sentModuleChannels(g_moduleIdx)) { + + // draw that menu at the bottom center + flags = CENTERED | (menuVerticalPosition == ch ? INVERS : 0); + lcdDrawSizedText(LCD_W/2, MENU_CONTENT_TOP - FH + 8*(FH+2), STR_OUTPUTS2FAILSAFE, 20, flags); + break; + } + } + } + + return true; +} diff --git a/radio/src/gui/480x272/model_module_options.cpp b/radio/src/gui/480x272/model_module_options.cpp new file mode 100644 index 000000000..f72d3594f --- /dev/null +++ b/radio/src/gui/480x272/model_module_options.cpp @@ -0,0 +1,21 @@ +/* + * 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 diff --git a/radio/src/gui/480x272/model_receiver_options.cpp b/radio/src/gui/480x272/model_receiver_options.cpp new file mode 100644 index 000000000..f72d3594f --- /dev/null +++ b/radio/src/gui/480x272/model_receiver_options.cpp @@ -0,0 +1,21 @@ +/* + * 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 diff --git a/radio/src/gui/480x272/model_setup.cpp b/radio/src/gui/480x272/model_setup.cpp index 5ac81e2e8..1311235ea 100644 --- a/radio/src/gui/480x272/model_setup.cpp +++ b/radio/src/gui/480x272/model_setup.cpp @@ -1200,118 +1200,3 @@ bool menuModelSetup(event_t event) return true; } - -bool menuModelFailsafe(event_t event) -{ - uint8_t ch = 0; - const uint8_t channelStart = g_model.moduleData[g_moduleIdx].channelsStart; - const int lim = (g_model.extendedLimits ? (512 * LIMIT_EXT_PERCENT / 100) : 512) * 2; - const uint8_t SLIDER_W = 128; - const uint8_t cols = sentModuleChannels(g_moduleIdx) > 8 ? 2 : 1; - - if (event == EVT_KEY_LONG(KEY_ENTER)) { - killEvents(event); - event = 0; - - if (menuVerticalPosition < sentModuleChannels(g_moduleIdx)) { - if (s_editMode) { - g_model.failsafeChannels[menuVerticalPosition] = channelOutputs[menuVerticalPosition+channelStart]; - s_editMode = 0; - } - else { - int16_t & failsafe = g_model.failsafeChannels[menuVerticalPosition]; - if (failsafe < FAILSAFE_CHANNEL_HOLD) - failsafe = FAILSAFE_CHANNEL_HOLD; - else if (failsafe == FAILSAFE_CHANNEL_HOLD) - failsafe = FAILSAFE_CHANNEL_NOPULSE; - else - failsafe = 0; - } - } - else { - // "Outputs => Failsafe" menu item - setCustomFailsafe(g_moduleIdx); - } - - storageDirty(EE_MODEL); - AUDIO_WARNING1(); - SEND_FAILSAFE_NOW(g_moduleIdx); - } - - SIMPLE_SUBMENU_WITH_OPTIONS("FAILSAFE", ICON_STATS_ANALOGS, sentModuleChannels(g_moduleIdx)+1, OPTION_MENU_NO_SCROLLBAR); - drawStringWithIndex(50, 3+FH, "Module", g_moduleIdx+1, MENU_TITLE_COLOR); - - for (uint8_t col=0; col < cols; col++) { - for (uint8_t line=0; line < 8; line++) { - coord_t x = col*(LCD_W/2); - const coord_t y = MENU_CONTENT_TOP - FH + line*(FH+2); - const int32_t channelValue = channelOutputs[ch+channelStart]; - int32_t failsafeValue = g_model.failsafeChannels[8*col+line]; - - // Channel name if present, number if not - if (g_model.limitData[ch+channelStart].name[0] != '\0') { - putsChn(x+MENUS_MARGIN_LEFT, y-3, ch+1, TINSIZE); - lcdDrawSizedText(x+MENUS_MARGIN_LEFT, y+5, g_model.limitData[ch+channelStart].name, sizeof(g_model.limitData[ch+channelStart].name), ZCHAR|SMLSIZE); - } - else { - putsChn(x+MENUS_MARGIN_LEFT, y, ch+1, 0); - } - - // Value - LcdFlags flags = RIGHT; - if (menuVerticalPosition == ch) { - flags |= INVERS; - if (s_editMode) { - if (failsafeValue == FAILSAFE_CHANNEL_HOLD || failsafeValue == FAILSAFE_CHANNEL_NOPULSE) { - s_editMode = 0; - } - else { - flags |= BLINK; - CHECK_INCDEC_MODELVAR(event, g_model.failsafeChannels[8*col+line], -lim, +lim); - } - } - } - - x += (LCD_W/2)-4-MENUS_MARGIN_LEFT-SLIDER_W; - - if (failsafeValue == FAILSAFE_CHANNEL_HOLD) { - lcdDrawText(x, y+2, "HOLD", flags|SMLSIZE); - failsafeValue = 0; - } - else if (failsafeValue == FAILSAFE_CHANNEL_NOPULSE) { - lcdDrawText(x, y+2, "NONE", flags|SMLSIZE); - failsafeValue = 0; - } - else { -#if defined(PPM_UNIT_US) - lcdDrawNumber(x, y, PPM_CH_CENTER(ch)+failsafeValue/2, flags); -#elif defined(PPM_UNIT_PERCENT_PREC1) - lcdDrawNumber(x, y, calcRESXto1000(failsafeValue), PREC1|flags); -#else - lcdDrawNumber(x, y, calcRESXto1000(failsafeValue)/10, flags); -#endif - } - - // Gauge - x += 4; - lcdDrawRect(x, y+3, SLIDER_W+1, 12); - const coord_t lenChannel = limit((uint8_t)1, uint8_t((abs(channelValue) * SLIDER_W/2 + lim/2) / lim), uint8_t(SLIDER_W/2)); - const coord_t lenFailsafe = limit((uint8_t)1, uint8_t((abs(failsafeValue) * SLIDER_W/2 + lim/2) / lim), uint8_t(SLIDER_W/2)); - x += SLIDER_W/2; - const coord_t xChannel = (channelValue>0) ? x : x+1-lenChannel; - const coord_t xFailsafe = (failsafeValue>0) ? x : x+1-lenFailsafe; - lcdDrawSolidFilledRect(xChannel, y+4, lenChannel, 5, TEXT_COLOR); - lcdDrawSolidFilledRect(xFailsafe, y+9, lenFailsafe, 5, ALARM_COLOR); - - if (++ch >= sentModuleChannels(g_moduleIdx)) { - - // draw that menu at the bottom center - flags = CENTERED | (menuVerticalPosition == ch ? INVERS : 0); - lcdDrawSizedText(LCD_W/2, MENU_CONTENT_TOP - FH + 8*(FH+2), STR_OUTPUTS2FAILSAFE, 20, flags); - break; - } - } - } - - return true; -}