From a268a9a1d763d09945303ee4eef63c4728b0ead3 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Wed, 14 Jul 2021 19:22:56 +0200 Subject: [PATCH] [color] Fixed throttle trim switch setting --- radio/src/datastructs.h | 16 ++++++++++++++++ radio/src/gui/colorlcd/model_setup.cpp | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/radio/src/datastructs.h b/radio/src/datastructs.h index a41f03b68..ad59b8b4a 100644 --- a/radio/src/datastructs.h +++ b/radio/src/datastructs.h @@ -672,6 +672,22 @@ PACK(struct ModelData { return thrTrimSw + MIXSRC_FIRST_TRIM; } } + + void setThrottleStickTrimSource(int16_t src) + { + // The order here is TERA, so that 0 (default) means Throttle + switch (src) { + case MIXSRC_TrimThr: + thrTrimSw = 0; + break; + case MIXSRC_TrimRud: + thrTrimSw = 2; + break; + default: + thrTrimSw = src - MIXSRC_FIRST_TRIM; + break; + } + } }); /* diff --git a/radio/src/gui/colorlcd/model_setup.cpp b/radio/src/gui/colorlcd/model_setup.cpp index 989890f46..75149e8b2 100644 --- a/radio/src/gui/colorlcd/model_setup.cpp +++ b/radio/src/gui/colorlcd/model_setup.cpp @@ -1160,7 +1160,10 @@ void ModelSetupPage::build(FormWindow * window) // Throttle trim source new StaticText(window, grid.getLabelSlot(true), STR_TTRIM_SW); - new SourceChoice(window, grid.getFieldSlot(), 0, NUM_TRIMS - 1, GET_SET_DEFAULT( g_model.thrTrimSw)); + new SourceChoice( + window, grid.getFieldSlot(), MIXSRC_FIRST_TRIM, MIXSRC_LAST_TRIM, + [=]() { return g_model.getThrottleStickTrimSource(); }, + [=](int16_t src) { g_model.setThrottleStickTrimSource(src); }); grid.nextLine(); }