From 85fbb97286c2f74e1651cc2943b24ef85105925a Mon Sep 17 00:00:00 2001 From: philmoz Date: Fri, 5 Apr 2024 20:54:18 +1100 Subject: [PATCH] feat(color): move ADC Filter and Center Beep settings to 'Other' page (#4745) --- radio/src/gui/colorlcd/model_setup.cpp | 134 ++++++++++++++++++-- radio/src/gui/colorlcd/preflight_checks.cpp | 86 ------------- radio/src/translations/cn.h | 6 +- radio/src/translations/cz.h | 2 +- radio/src/translations/da.h | 2 +- radio/src/translations/de.h | 2 +- radio/src/translations/en.h | 2 +- radio/src/translations/fr.h | 2 +- radio/src/translations/he.h | 2 +- radio/src/translations/it.h | 2 +- radio/src/translations/pl.h | 2 +- radio/src/translations/ru.h | 2 +- radio/src/translations/se.h | 2 +- radio/src/translations/tw.h | 6 +- 14 files changed, 141 insertions(+), 111 deletions(-) diff --git a/radio/src/gui/colorlcd/model_setup.cpp b/radio/src/gui/colorlcd/model_setup.cpp index 6360feb67..334471f44 100644 --- a/radio/src/gui/colorlcd/model_setup.cpp +++ b/radio/src/gui/colorlcd/model_setup.cpp @@ -24,6 +24,14 @@ #include "button_matrix.h" #include "filechoice.h" #include "libopenui.h" + +#include "hal/adc_driver.h" +#include "storage/modelslist.h" +#include "trainer_setup.h" +#include "module_setup.h" +#include "timer_setup.h" +#include "trims_setup.h" +#include "throttle_params.h" #include "preflight_checks.h" #include "throttle_params.h" #include "timer_setup.h" @@ -264,7 +272,120 @@ class ModelViewOptions : public Page } }; -void ModelSetupPage::build(Window *window) +#if LCD_W > LCD_H +#define SW_BTNS 8 +#define SW_BTN_W 56 +#else +#define SW_BTNS 4 +#define SW_BTN_W 72 +#endif + +struct CenterBeepsMatrix : public ButtonMatrix { + CenterBeepsMatrix(Window* parent, const rect_t& rect) : + ButtonMatrix(parent, rect) + { + // Setup button layout & texts + uint8_t btn_cnt = 0; + + auto max_sticks = adcGetMaxInputs(ADC_INPUT_MAIN); + auto max_pots = adcGetMaxInputs(ADC_INPUT_FLEX); + max_analogs = max_sticks + max_pots; + + for (uint8_t i = 0; i < max_analogs; i++) { + // multipos cannot be centered + if (i < max_sticks || (IS_POT_SLIDER_AVAILABLE(i - max_sticks) && + !IS_POT_MULTIPOS(i - max_sticks))) { + ana_idx[btn_cnt] = i; + btn_cnt++; + } + } + + initBtnMap(min((int)btn_cnt, SW_BTNS), btn_cnt); + + uint8_t btn_id = 0; + for (uint8_t i = 0; i < max_analogs; i++) { + if (i < max_sticks || (IS_POT_SLIDER_AVAILABLE(i - max_sticks) && + !IS_POT_MULTIPOS(i - max_sticks))) { + setTextAndState(btn_id); + btn_id++; + } + } + + update(); + + lv_obj_set_width(lvobj, min((int)btn_cnt, SW_BTNS) * SW_BTN_W + 4); + + uint8_t rows = ((btn_cnt - 1) / SW_BTNS) + 1; + lv_obj_set_height(lvobj, (rows * 36) + 4); + + lv_obj_set_style_pad_all(lvobj, 4, LV_PART_MAIN); + + lv_obj_set_style_pad_row(lvobj, 4, LV_PART_MAIN); + lv_obj_set_style_pad_column(lvobj, 4, LV_PART_MAIN); + } + + void onPress(uint8_t btn_id) + { + if (btn_id >= max_analogs) return; + uint8_t i = ana_idx[btn_id]; + BFBIT_FLIP(g_model.beepANACenter, bfBit(i)); + setTextAndState(btn_id); + SET_DIRTY(); + } + + bool isActive(uint8_t btn_id) + { + if (btn_id >= max_analogs) return false; + uint8_t i = ana_idx[btn_id]; + return bfSingleBitGet(g_model.beepANACenter, i) != 0; + } + + void setTextAndState(uint8_t btn_id) + { + auto max_sticks = adcGetMaxInputs(ADC_INPUT_MAIN); + if (ana_idx[btn_id] < max_sticks) + setText(btn_id, getAnalogShortLabel(ana_idx[btn_id])); + else + setText(btn_id, + getAnalogLabel(ADC_INPUT_FLEX, ana_idx[btn_id] - max_sticks)); + setChecked(btn_id); + } + + private: + uint8_t max_analogs; + uint8_t ana_idx[MAX_ANALOG_INPUTS]; +}; + +class ModelOtherOptions : public Page +{ + public: + ModelOtherOptions() : Page(ICON_MODEL_SETUP) + { + header->setTitle(STR_MENU_MODEL_SETUP); + header->setTitle2(STR_MENU_OTHER); + + body->padAll(PAD_SMALL); + + body->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_ZERO); + + FlexGridLayout grid(line_col_dsc, line_row_dsc, PAD_SMALL); + + // Model ADC jitter filter + auto line = body->newLine(grid); + new StaticText(line, rect_t{}, STR_JITTER_FILTER); + new Choice(line, rect_t{}, STR_ADCFILTERVALUES, 0, 2, + GET_SET_DEFAULT(g_model.jitterFilter)); + + // Center beeps + line = body->newLine(grid); + new StaticText(line, rect_t{}, STR_BEEPCTR); + line = body->newLine(grid); + line->padLeft(4); + new CenterBeepsMatrix(line, rect_t{}); + } +}; + +void ModelSetupPage::build(Window * window) { window->setFlexLayout(LV_FLEX_FLOW_COLUMN, 0); @@ -313,14 +434,7 @@ void ModelSetupPage::build(Window *window) // TODO: show bitmap thumbnail instead? new ModelBitmapEdit(line, rect_t{}); - // Model ADC jitter filter - line = window->newLine(grid); - new StaticText(line, rect_t{}, STR_JITTER_FILTER); - new Choice(line, rect_t{}, STR_ADCFILTERVALUES, 0, 2, - GET_SET_DEFAULT(g_model.jitterFilter)); - - static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), - LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; static const lv_coord_t row_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; FlexGridLayout grid2(col_dsc, row_dsc); @@ -370,4 +484,6 @@ void ModelSetupPage::build(Window *window) new SubScreenButton(line, STR_USBJOYSTICK_LABEL, []() { new ModelUSBJoystickPage(); }); #endif + + new SubScreenButton(line, STR_MENU_OTHER, []() { new ModelOtherOptions(); }); } diff --git a/radio/src/gui/colorlcd/preflight_checks.cpp b/radio/src/gui/colorlcd/preflight_checks.cpp index 1a61fc301..548dc5319 100644 --- a/radio/src/gui/colorlcd/preflight_checks.cpp +++ b/radio/src/gui/colorlcd/preflight_checks.cpp @@ -103,17 +103,6 @@ struct PotWarnMatrix : public ButtonMatrix { uint8_t pot_idx[MAX_POTS]; }; -struct CenterBeepsMatrix : public ButtonMatrix { - CenterBeepsMatrix(Window* parent, const rect_t& rect); - void onPress(uint8_t btn_id); - bool isActive(uint8_t btn_id); - void setTextAndState(uint8_t btn_id); - - private: - uint8_t max_analogs; - uint8_t ana_idx[MAX_ANALOG_INPUTS]; -}; - PreflightChecks::PreflightChecks() : Page(ICON_MODEL_SETUP) { header->setTitle(STR_MENU_MODEL_SETUP); @@ -195,14 +184,6 @@ PreflightChecks::PreflightChecks() : Page(ICON_MODEL_SETUP) make_conditional(pwm, pots_wm); } } - - // Center beeps - line = body->newLine(grid); - line->padTop(0); - new StaticText(line, rect_t{}, STR_BEEPCTR); - line = body->newLine(grid); - line->padLeft(4); - new CenterBeepsMatrix(line, rect_t{}); } static std::string switchWarninglabel(swsrc_t index) @@ -339,70 +320,3 @@ bool PotWarnMatrix::isActive(uint8_t btn_id) if (btn_id >= MAX_POTS) return false; return (g_model.potsWarnEnabled & (1 << pot_idx[btn_id])) != 0; } - -CenterBeepsMatrix::CenterBeepsMatrix(Window* parent, const rect_t& r) : - ButtonMatrix(parent, r) -{ - // Setup button layout & texts - uint8_t btn_cnt = 0; - - auto max_sticks = adcGetMaxInputs(ADC_INPUT_MAIN); - auto max_pots = adcGetMaxInputs(ADC_INPUT_FLEX); - max_analogs = max_sticks + max_pots; - - for (uint8_t i = 0; i < max_analogs; i++) { - // multipos cannot be centered - if (i < max_sticks || (IS_POT_SLIDER_AVAILABLE(i - max_sticks) && - !IS_POT_MULTIPOS(i - max_sticks))) { - ana_idx[btn_cnt] = i; - btn_cnt++; - } - } - - initBtnMap(min((int)btn_cnt, SW_BTNS), btn_cnt); - - uint8_t btn_id = 0; - for (uint8_t i = 0; i < max_analogs; i++) { - if (i < max_sticks || (IS_POT_SLIDER_AVAILABLE(i - max_sticks) && - !IS_POT_MULTIPOS(i - max_sticks))) { - setTextAndState(btn_id); - btn_id++; - } - } - - update(); - - lv_obj_set_width(lvobj, min((int)btn_cnt, SW_BTNS) * SW_BTN_W + 4); - - uint8_t rows = ((btn_cnt - 1) / SW_BTNS) + 1; - lv_obj_set_height(lvobj, (rows * 36) + 4); - - padAll(PAD_SMALL); -} - -void CenterBeepsMatrix::setTextAndState(uint8_t btn_id) -{ - auto max_sticks = adcGetMaxInputs(ADC_INPUT_MAIN); - if (ana_idx[btn_id] < max_sticks) - setText(btn_id, getAnalogShortLabel(ana_idx[btn_id])); - else - setText(btn_id, - getAnalogLabel(ADC_INPUT_FLEX, ana_idx[btn_id] - max_sticks)); - setChecked(btn_id); -} - -void CenterBeepsMatrix::onPress(uint8_t btn_id) -{ - if (btn_id >= max_analogs) return; - uint8_t i = ana_idx[btn_id]; - BFBIT_FLIP(g_model.beepANACenter, bfBit(i)); - setTextAndState(btn_id); - SET_DIRTY(); -} - -bool CenterBeepsMatrix::isActive(uint8_t btn_id) -{ - if (btn_id >= max_analogs) return false; - uint8_t i = ana_idx[btn_id]; - return bfSingleBitGet(g_model.beepANACenter, i) != 0; -} diff --git a/radio/src/translations/cn.h b/radio/src/translations/cn.h index 3065c4360..72681b445 100644 --- a/radio/src/translations/cn.h +++ b/radio/src/translations/cn.h @@ -271,7 +271,7 @@ #define TR_TTRACE TR("输入源", INDENT "输入源") #define TR_TTRIM TR("油门微调仅怠速", INDENT "油门微调只调整怠速") #define TR_TTRIM_SW TR("微调选择", INDENT "微调选择") -#define TR_BEEPCTR TR("中点蜂鸣", "中点蜂鸣") +#define TR_BEEPCTR TR("中点提示音", "中点蜂鸣提示音") #define TR_USE_GLOBAL_FUNCS TR("全局功能", "全局功能可介入") #define TR_PPMFRAME INDENT "PPM帧" #define TR_REFRESHRATE TR(INDENT "刷新率", INDENT "刷新速率") @@ -1109,7 +1109,7 @@ #define TR_CURRENTSENSOR "传感器" #define TR_AUTOOFFSET "自动偏移值" #define TR_ONLYPOSITIVE "正向" -#define TR_FILTER "滤波" +#define TR_FILTER "滤波器" #define TR_TELEMETRYFULL TR("项目已满!", "回传项目已满!") #define TR_INVERTED_SERIAL INDENT "反向" #define TR_IGNORE_INSTANCE TR(INDENT "忽略ID", INDENT "忽略ID鉴别") @@ -1153,7 +1153,7 @@ #define TR_MENU_OTHER "其它" #define TR_MENU_INVERT "反向" #define TR_AUDIO_MUTE TR("自动静音","音频停播时自动静音") -#define TR_JITTER_FILTER "模拟输入滤波" +#define TR_JITTER_FILTER "ADC滤波器" #define TR_DEAD_ZONE "死区" #define TR_RTC_CHECK TR("检查时间电池", "检查时间驱动电池电压") #define TR_AUTH_FAILURE "验证失败" diff --git a/radio/src/translations/cz.h b/radio/src/translations/cz.h index 1fac9de90..4aee290e6 100644 --- a/radio/src/translations/cz.h +++ b/radio/src/translations/cz.h @@ -285,7 +285,7 @@ #define TR_TTRACE TR("StopaPlynu", INDENT "Stopa plynu") #define TR_TTRIM TR3("TrimVolnob.", INDENT "Trim jen volnoběh", "Trim jen pro volnoběh") #define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "Trim spínač") -#define TR_BEEPCTR TR3("Středy \200\201", "Pípat středy \200\201", "Pípat středy") +#define TR_BEEPCTR TR("Pípat střed", "Pípnutí při středové poloze") #define TR_USE_GLOBAL_FUNCS TR("Glob.Funkce", "Použít globální funkce") #define TR_PROTOCOL "Protokol" #define TR_PPMFRAME INDENT "PPM modulace" diff --git a/radio/src/translations/da.h b/radio/src/translations/da.h index 72aa29ff8..b18fcb823 100644 --- a/radio/src/translations/da.h +++ b/radio/src/translations/da.h @@ -278,7 +278,7 @@ #define TR_TTRACE TR("T-kilde", INDENT "kilde") #define TR_TTRIM TR("T-trim-tomg", INDENT "Trim tomgang alene") #define TR_TTRIM_SW TR("T-trim-ko", INDENT "Trim kontakt") -#define TR_BEEPCTR TR("Ctr Bip", "Center Bip") +#define TR_BEEPCTR TR("Bip ctr pos", "Bip ved center position") #define TR_USE_GLOBAL_FUNCS TR("Glob.Funk.", "Brug global funk.") #define TR_PROTOCOL TR("Proto", "Protokol") #define TR_PPMFRAME INDENT "PPM frame" diff --git a/radio/src/translations/de.h b/radio/src/translations/de.h index e00e827e3..0a0820229 100644 --- a/radio/src/translations/de.h +++ b/radio/src/translations/de.h @@ -276,7 +276,7 @@ #define TR_TTRACE TR("Gasquelle", INDENT "Gas-Timerquelle") #define TR_TTRIM TR("Gastrim", INDENT "Gas-Leerlauftrim") #define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "Trim switch") -#define TR_BEEPCTR TR("MittePieps", "Mittelstell. -Pieps") +#define TR_BEEPCTR TR("MittePieps", "Pieps in Mittelstellung") #define TR_USE_GLOBAL_FUNCS TR("Glob. Funkt.", "Globale Funkt verw.") #define TR_PROTOCOL TR("Protok.", "Protokoll") #define TR_PPMFRAME INDENT "PPM-Frame" diff --git a/radio/src/translations/en.h b/radio/src/translations/en.h index c6b62af77..b1ef68333 100644 --- a/radio/src/translations/en.h +++ b/radio/src/translations/en.h @@ -275,7 +275,7 @@ #define TR_TTRACE TR("T-Source", INDENT "Source") #define TR_TTRIM TR("T-Trim-Idle", INDENT "Trim idle only") #define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "Trim switch") -#define TR_BEEPCTR TR("Ctr Beep", "Center Beep") +#define TR_BEEPCTR TR("Ctr Beep", "Beep when centered") #define TR_USE_GLOBAL_FUNCS TR("Glob.Funcs", "Use global funcs") #define TR_PROTOCOL TR("Proto", "Protocol") #define TR_PPMFRAME INDENT "PPM frame" diff --git a/radio/src/translations/fr.h b/radio/src/translations/fr.h index 5dd8d5d19..ff762fb05 100644 --- a/radio/src/translations/fr.h +++ b/radio/src/translations/fr.h @@ -282,7 +282,7 @@ #define TR_TTRACE TR("Source gaz", INDENT "Source") #define TR_TTRIM TR("Trim gaz", INDENT "Trim ralenti uniq.") #define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "Trim switch") -#define TR_BEEPCTR TR("Bip centr.", "Bip centrage") +#define TR_BEEPCTR TR("Ctr Beep", "Bip quand centré") #define TR_USE_GLOBAL_FUNCS TR("Fonc. glob.", "Fonct. Globales") #define TR_PROTOCOL TR("Proto.", "Protocole") #define TR_PPMFRAME INDENT "Trame PPM" diff --git a/radio/src/translations/he.h b/radio/src/translations/he.h index 6ea53637e..5b257ad03 100644 --- a/radio/src/translations/he.h +++ b/radio/src/translations/he.h @@ -279,7 +279,7 @@ #define TR_TTRACE TR("T-Source", INDENT "מקור") #define TR_TTRIM TR("T-Trim-Idle", INDENT "Trim idle only") #define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "מתג קיזוז") -#define TR_BEEPCTR TR("Ctr Beep", "Center Beep") +#define TR_BEEPCTR TR("Ctr Beep", "ציפצוף במרכז") #define TR_USE_GLOBAL_FUNCS TR("Glob.Funcs", "שימוש בפונקציות גלובליות") #define TR_PROTOCOL TR("Proto", "Protocol") #define TR_PPMFRAME INDENT "PPM frame" diff --git a/radio/src/translations/it.h b/radio/src/translations/it.h index 3e5b40450..b2d6454ff 100644 --- a/radio/src/translations/it.h +++ b/radio/src/translations/it.h @@ -275,7 +275,7 @@ #define TR_TTRACE TR("Sor. Mot.", INDENT "Sorgente Motore") #define TR_TTRIM TR("Trim Mot.", INDENT "Trim Motore") #define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "Trim switch") -#define TR_BEEPCTR TR("Beep al c.", "Beep al centro") +#define TR_BEEPCTR TR("Beep Ctr", "Beep quando centrato") #define TR_USE_GLOBAL_FUNCS TR("Funz. Glob.", "Usa Funz. Globali") #define TR_PROTOCOL TR("Protoc.", "Protocollo") #define TR_PPMFRAME INDENT "Frame PPM" diff --git a/radio/src/translations/pl.h b/radio/src/translations/pl.h index a26d38895..195085316 100644 --- a/radio/src/translations/pl.h +++ b/radio/src/translations/pl.h @@ -272,7 +272,7 @@ #define TR_TTRACE TR("Źród gaz", INDENT "Źródło gazu ") #define TR_TTRIM TR("TryGaz", INDENT "TrymWolnObrotó") #define TR_TTRIM_SW TR("T-Trim-Sw", INDENT "Trim switch") -#define TR_BEEPCTR TR("ŚrodBeep", "Pikn.Środka") +#define TR_BEEPCTR TR("Dźwięk środ.", "Dźwięk środ. położenia") #define TR_USE_GLOBAL_FUNCS TR("Funk.Glb.","Użyj Funkcji Glb") #define TR_PROTOCOL TR("Proto", "Protokół") #define TR_PPMFRAME INDENT "Ramka PPM" diff --git a/radio/src/translations/ru.h b/radio/src/translations/ru.h index 82d3c9bc8..949575a7a 100644 --- a/radio/src/translations/ru.h +++ b/radio/src/translations/ru.h @@ -277,7 +277,7 @@ #define TR_TTRACE TR("Т-источник", INDENT "Источник") #define TR_TTRIM TR("Т-трим-ХХ", INDENT "Только трим хх") #define TR_TTRIM_SW TR("Т-трим-перек", INDENT "Трим перек") -#define TR_BEEPCTR TR("Цент. звук", "Звук в центре") +#define TR_BEEPCTR TR("Звук на цен", "Звук на центре") #define TR_USE_GLOBAL_FUNCS TR("Глоб. функц", "Глоб функц") #define TR_PROTOCOL TR("Проток", "Протокол") #define TR_PPMFRAME INDENT "Фрейм PPM" diff --git a/radio/src/translations/se.h b/radio/src/translations/se.h index 4c0bfa6c8..c79a9ad04 100644 --- a/radio/src/translations/se.h +++ b/radio/src/translations/se.h @@ -288,7 +288,7 @@ #define TR_TTRACE TR("Källa", INDENT "Källa") #define TR_TTRIM TR("Gastrimm", INDENT "Trimma endast tomgång") #define TR_TTRIM_SW TR("Trimmknp", INDENT "Trimmknapp") -#define TR_BEEPCTR TR("Cent.pip", "Centerpip") +#define TR_BEEPCTR TR("Cntr. pip", "Pip när centrerad") #define TR_USE_GLOBAL_FUNCS TR("Glob.funk.", "Anv. globala funk.") #define TR_PROTOCOL TR("Proto.", "Protokoll") #define TR_PPMFRAME INDENT "PPM-paket" diff --git a/radio/src/translations/tw.h b/radio/src/translations/tw.h index 5e9d05592..c00d38728 100644 --- a/radio/src/translations/tw.h +++ b/radio/src/translations/tw.h @@ -276,7 +276,7 @@ #define TR_TTRACE TR("輸入源", INDENT "輸入源") #define TR_TTRIM TR("油門微調僅怠速", INDENT "油門微調只調整怠速") #define TR_TTRIM_SW TR("微調選擇", INDENT "微調選擇") -#define TR_BEEPCTR TR("中點蜂鳴", "中點蜂鳴") +#define TR_BEEPCTR TR("中點提示音", "中點蜂鳴提示音") #define TR_USE_GLOBAL_FUNCS TR("全局功能", "全局功能可介入") #define TR_PPMFRAME INDENT "PPM幀" #define TR_REFRESHRATE TR(INDENT "刷新率", INDENT "刷新速率") @@ -1114,7 +1114,7 @@ #define TR_CURRENTSENSOR "傳感器" #define TR_AUTOOFFSET "自動偏移值" #define TR_ONLYPOSITIVE "正向" -#define TR_FILTER "濾波" +#define TR_FILTER "濾波器" #define TR_TELEMETRYFULL TR("項目已滿!", "回傳項目已滿!") #define TR_INVERTED_SERIAL INDENT "反向" #define TR_IGNORE_INSTANCE TR(INDENT "忽略ID", INDENT "忽略ID鑑別") @@ -1158,7 +1158,7 @@ #define TR_MENU_OTHER "其它" #define TR_MENU_INVERT "反向" #define TR_AUDIO_MUTE TR("自動靜音","音頻停播時自動靜音") -#define TR_JITTER_FILTER "類比輸入濾波" +#define TR_JITTER_FILTER "ADC濾波器" #define TR_DEAD_ZONE "死區" #define TR_RTC_CHECK TR("檢查時間電池", "檢查時間驅動電池電壓") #define TR_AUTH_FAILURE "驗證失敗"