fix(color): New inputs disappear until restart (#4317)
This commit is contained in:
@@ -20,21 +20,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "model_inputs.h"
|
#include "model_inputs.h"
|
||||||
#include "opentx.h"
|
|
||||||
#include "gvar_numberedit.h"
|
|
||||||
#include "libopenui.h"
|
|
||||||
#include "choice.h"
|
|
||||||
#include "model_curves.h"
|
|
||||||
#include "input_edit.h"
|
|
||||||
#include "input_mix_group.h"
|
|
||||||
#include "input_mix_button.h"
|
|
||||||
#include "input_mapping.h"
|
|
||||||
|
|
||||||
#include "tasks/mixer_task.h"
|
|
||||||
#include "hal/adc_driver.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "choice.h"
|
||||||
|
#include "gvar_numberedit.h"
|
||||||
|
#include "hal/adc_driver.h"
|
||||||
|
#include "input_edit.h"
|
||||||
|
#include "input_mapping.h"
|
||||||
|
#include "input_mix_button.h"
|
||||||
|
#include "input_mix_group.h"
|
||||||
|
#include "libopenui.h"
|
||||||
|
#include "model_curves.h"
|
||||||
|
#include "opentx.h"
|
||||||
|
#include "tasks/mixer_task.h"
|
||||||
|
|
||||||
#define SET_DIRTY() storageDirty(EE_MODEL)
|
#define SET_DIRTY() storageDirty(EE_MODEL)
|
||||||
|
|
||||||
uint8_t getExposCount()
|
uint8_t getExposCount()
|
||||||
@@ -124,23 +124,36 @@ class InputLineButton : public InputMixButton
|
|||||||
*s = '\0';
|
*s = '\0';
|
||||||
|
|
||||||
if (line.name[0]) {
|
if (line.name[0]) {
|
||||||
int cnt = lv_snprintf(s, maxlen, "%.*s ", (int)sizeof(line.name), line.name);
|
int cnt =
|
||||||
if ((size_t)cnt >= maxlen) maxlen = 0;
|
lv_snprintf(s, maxlen, "%.*s ", (int)sizeof(line.name), line.name);
|
||||||
else { maxlen -= cnt; s += cnt; }
|
if ((size_t)cnt >= maxlen)
|
||||||
|
maxlen = 0;
|
||||||
|
else {
|
||||||
|
maxlen -= cnt;
|
||||||
|
s += cnt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.swtch || line.curve.value) {
|
if (line.swtch || line.curve.value) {
|
||||||
if (line.swtch) {
|
if (line.swtch) {
|
||||||
char* sw_pos = getSwitchPositionName(line.swtch);
|
char* sw_pos = getSwitchPositionName(line.swtch);
|
||||||
int cnt = lv_snprintf(s, maxlen, "%s ", sw_pos);
|
int cnt = lv_snprintf(s, maxlen, "%s ", sw_pos);
|
||||||
if ((size_t)cnt >= maxlen) maxlen = 0;
|
if ((size_t)cnt >= maxlen)
|
||||||
else { maxlen -= cnt; s += cnt; }
|
maxlen = 0;
|
||||||
|
else {
|
||||||
|
maxlen -= cnt;
|
||||||
|
s += cnt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (line.curve.value != 0) {
|
if (line.curve.value != 0) {
|
||||||
getCurveRefString(s, maxlen, line.curve);
|
getCurveRefString(s, maxlen, line.curve);
|
||||||
int cnt = strnlen(s, maxlen);
|
int cnt = strnlen(s, maxlen);
|
||||||
if ((size_t)cnt >= maxlen) maxlen = 0;
|
if ((size_t)cnt >= maxlen)
|
||||||
else { maxlen -= cnt; s += cnt; }
|
maxlen = 0;
|
||||||
|
else {
|
||||||
|
maxlen -= cnt;
|
||||||
|
s += cnt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lv_label_set_text_fmt(opts, "%.*s", (int)sizeof(tmp_str), tmp_str);
|
lv_label_set_text_fmt(opts, "%.*s", (int)sizeof(tmp_str), tmp_str);
|
||||||
@@ -152,8 +165,7 @@ protected:
|
|||||||
bool isActive() const override { return isExpoActive(index); }
|
bool isActive() const override { return isExpoActive(index); }
|
||||||
};
|
};
|
||||||
|
|
||||||
ModelInputsPage::ModelInputsPage():
|
ModelInputsPage::ModelInputsPage() : PageTab(STR_MENUINPUTS, ICON_MODEL_INPUTS)
|
||||||
PageTab(STR_MENUINPUTS, ICON_MODEL_INPUTS)
|
|
||||||
{
|
{
|
||||||
setOnSetVisibleHandler([=]() {
|
setOnSetVisibleHandler([=]() {
|
||||||
// reset clipboard
|
// reset clipboard
|
||||||
@@ -172,10 +184,9 @@ bool ModelInputsPage::reachExposLimit()
|
|||||||
|
|
||||||
InputMixGroup* ModelInputsPage::getGroupBySrc(mixsrc_t src)
|
InputMixGroup* ModelInputsPage::getGroupBySrc(mixsrc_t src)
|
||||||
{
|
{
|
||||||
auto g =
|
auto g = std::find_if(
|
||||||
std::find_if(groups.begin(), groups.end(), [=](InputMixGroup* g) -> bool {
|
groups.begin(), groups.end(),
|
||||||
return g->getMixSrc() == src;
|
[=](InputMixGroup* g) -> bool { return g->getMixSrc() == src; });
|
||||||
});
|
|
||||||
|
|
||||||
if (g != groups.end()) return *g;
|
if (g != groups.end()) return *g;
|
||||||
|
|
||||||
@@ -299,12 +310,14 @@ void ModelInputsPage::addLineButton(mixsrc_t src, uint8_t index)
|
|||||||
groups.emplace_back(group_w);
|
groups.emplace_back(group_w);
|
||||||
auto g = groups.rbegin();
|
auto g = groups.rbegin();
|
||||||
if (g != groups.rend()) {
|
if (g != groups.rend()) {
|
||||||
auto g_prev = g; ++g_prev;
|
auto g_prev = g;
|
||||||
|
++g_prev;
|
||||||
while (g_prev != groups.rend()) {
|
while (g_prev != groups.rend()) {
|
||||||
if ((*g_prev)->getMixSrc() < (*g)->getMixSrc()) break;
|
if ((*g_prev)->getMixSrc() < (*g)->getMixSrc()) break;
|
||||||
lv_obj_swap((*g)->getLvObj(), (*g_prev)->getLvObj());
|
lv_obj_swap((*g)->getLvObj(), (*g_prev)->getLvObj());
|
||||||
std::swap(*g, *g_prev);
|
std::swap(*g, *g_prev);
|
||||||
++g; ++g_prev;
|
++g;
|
||||||
|
++g_prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -316,7 +329,8 @@ void ModelInputsPage::addLineButton(mixsrc_t src, uint8_t index)
|
|||||||
// insertion sort for the focus group
|
// insertion sort for the focus group
|
||||||
auto l = lines.rbegin();
|
auto l = lines.rbegin();
|
||||||
if (l != lines.rend()) {
|
if (l != lines.rend()) {
|
||||||
auto l_prev = l; ++l_prev;
|
auto l_prev = l;
|
||||||
|
++l_prev;
|
||||||
while (l_prev != lines.rend()) {
|
while (l_prev != lines.rend()) {
|
||||||
if ((*l_prev)->getIndex() < (*l)->getIndex()) break;
|
if ((*l_prev)->getIndex() < (*l)->getIndex()) break;
|
||||||
// Swap elements (focus + line list)
|
// Swap elements (focus + line list)
|
||||||
@@ -332,7 +346,8 @@ void ModelInputsPage::addLineButton(mixsrc_t src, uint8_t index)
|
|||||||
std::swap(*l, *l_prev);
|
std::swap(*l, *l_prev);
|
||||||
// Inc index of elements after
|
// Inc index of elements after
|
||||||
(*l)->setIndex((*l)->getIndex() + 1);
|
(*l)->setIndex((*l)->getIndex() + 1);
|
||||||
++l; ++l_prev;
|
++l;
|
||||||
|
++l_prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -343,26 +358,27 @@ void ModelInputsPage::newInput()
|
|||||||
menu->setTitle(STR_MENU_INPUTS);
|
menu->setTitle(STR_MENU_INPUTS);
|
||||||
|
|
||||||
uint8_t chn = 0;
|
uint8_t chn = 0;
|
||||||
|
uint8_t index = 0;
|
||||||
ExpoData* line = g_model.expoData;
|
ExpoData* line = g_model.expoData;
|
||||||
|
|
||||||
// search for unused channels
|
// search for unused channels
|
||||||
for (uint8_t i = 0; i < MAX_EXPOS; i++) {
|
for (uint8_t i = 0; i < MAX_EXPOS && chn < MAX_INPUTS; i++) {
|
||||||
if (!EXPO_VALID(line) || (line->chn > chn)) {
|
if (!EXPO_VALID(line) || (line->chn > chn)) {
|
||||||
if (chn >= MAX_INPUTS) break;
|
|
||||||
std::string name(getSourceString(chn + 1));
|
std::string name(getSourceString(chn + 1));
|
||||||
menu->addLineBuffered(name.c_str(), [=]() { insertInput(chn, i); });
|
menu->addLineBuffered(name.c_str(), [=]() { insertInput(chn, index); });
|
||||||
}
|
}
|
||||||
if (EXPO_VALID(line))
|
if (EXPO_VALID(line)) {
|
||||||
chn = line->chn + 1;
|
chn = line->chn + 1;
|
||||||
else
|
index += 1;
|
||||||
|
} else {
|
||||||
chn += 1;
|
chn += 1;
|
||||||
|
}
|
||||||
++line;
|
++line;
|
||||||
}
|
}
|
||||||
|
|
||||||
menu->updateLines();
|
menu->updateLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ModelInputsPage::editInput(uint8_t input, uint8_t index)
|
void ModelInputsPage::editInput(uint8_t input, uint8_t index)
|
||||||
{
|
{
|
||||||
_copyMode = 0;
|
_copyMode = 0;
|
||||||
@@ -469,7 +485,6 @@ void ModelInputsPage::build(FormWindow *window)
|
|||||||
uint8_t index = 0;
|
uint8_t index = 0;
|
||||||
ExpoData* line = g_model.expoData;
|
ExpoData* line = g_model.expoData;
|
||||||
for (uint8_t input = 0; input < MAX_INPUTS; input++) {
|
for (uint8_t input = 0; input < MAX_INPUTS; input++) {
|
||||||
|
|
||||||
if (index >= MAX_EXPOS) break;
|
if (index >= MAX_EXPOS) break;
|
||||||
|
|
||||||
if (line->chn == input && EXPO_VALID(line)) {
|
if (line->chn == input && EXPO_VALID(line)) {
|
||||||
@@ -486,12 +501,9 @@ void ModelInputsPage::build(FormWindow *window)
|
|||||||
++index;
|
++index;
|
||||||
++line;
|
++line;
|
||||||
}
|
}
|
||||||
} else if (line->chn > input && EXPO_VALID(line)) {
|
|
||||||
TRACE("missing input for channel #%d", input);
|
|
||||||
} else if (!EXPO_VALID(line)) {
|
} else if (!EXPO_VALID(line)) {
|
||||||
TRACE("invalid line #%d", index);
|
// End of list
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user