feat(color): Display current stick position on CurveEdit screen (#2580)

* Display current stick position on the CurveEdit screen

* auto source selection

* Display current stick position on the CurveEdit screen

* auto source selection

* unlock source when entering directly
 from model menu.

* Whitespace

* Git EoF newline

Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
eshifri
2022-12-06 20:04:47 +10:00
committed by GitHub
co-authored by Peter Feerick
parent 241c5e6925
commit 1fe9de6d79
5 changed files with 52 additions and 13 deletions
+37 -8
View File
@@ -115,21 +115,38 @@ void CurveDataEdit::update()
}
void CurveDataEdit::paint(BitmapBuffer * dc)
void CurveDataEdit::paint(BitmapBuffer* dc)
{
dc->clear(COLOR_THEME_SECONDARY3);
// dc->drawSolidHorizontalLine(0, rect.h / 3, getInnerWidth(), 0);
// dc->drawSolidHorizontalLine(0, 2 * rect.h / 3, getInnerWidth(), 0);
}
CurveEdit::CurveEdit(Window * parent, const rect_t & rect, uint8_t index) :
FormField(parent, rect, NO_FOCUS),
preview(this, {0, 0, width(), height()}, [=](int x) -> int {
return applyCustomCurve(x, index);
}),
index(index),
current(0)
void CurveEdit::SetCurrentSource(uint32_t source)
{
CurveEdit::currentSource = source;
if (source)
lockSource = true;
else
lockSource = false;
}
mixsrc_t CurveEdit::currentSource = 0;
bool CurveEdit::lockSource = false;
CurveEdit::CurveEdit(Window* parent, const rect_t& rect, uint8_t index) :
FormField(parent, rect, NO_FOCUS),
preview(
this, {0, 0, width(), height()},
[=](int x) -> int { return applyCustomCurve(x, index); },
[=]()->int {
return getValue(CurveEdit::currentSource);
}),
index(index),
current(0)
{
TRACE("CurveEdit::currentSource=%d\tCurveEdit::lockSource=%d",
CurveEdit::currentSource, CurveEdit::lockSource);
updatePreview();
}
@@ -279,3 +296,15 @@ void CurveEdit::onEvent(event_t event)
break;
}
}
void CurveEdit::checkEvents()
{
if (!lockSource) {
int16_t val = getMovedSource(MIXSRC_FIRST_INPUT);
if (val) {
CurveEdit::currentSource = val + 1 - MIXSRC_FIRST_INPUT;
TRACE("source=%d", CurveEdit::currentSource);
}
}
FormField::checkEvents();
}
+9 -5
View File
@@ -48,6 +48,7 @@ class CurveEdit: public FormField
public:
CurveEdit(Window * parent, const rect_t & rect, uint8_t index);
static void SetCurrentSource(uint32_t source);
void deleteLater(bool detach = true, bool trash = true) override
{
@@ -62,16 +63,19 @@ class CurveEdit: public FormField
void updatePreview();
void onEvent(event_t event) override;
void checkEvents(void) override;
// #if defined(HARDWARE_TOUCH)
// bool onTouchEnd(coord_t x, coord_t y) override;
// void onFocusLost() override;
// #endif
// #if defined(HARDWARE_TOUCH)
// bool onTouchEnd(coord_t x, coord_t y) override;
// void onFocusLost() override;
// #endif
protected:
protected:
Curve preview;
uint8_t index;
uint8_t current;
static mixsrc_t currentSource;
static bool lockSource;
void next();
void previous();
void up();
+3
View File
@@ -25,6 +25,7 @@
#include "curve_param.h"
#include "gvar_numberedit.h"
#include "input_source.h"
#include "curveedit.h"
#include "opentx.h"
@@ -80,6 +81,8 @@ InputEditWindow::InputEditWindow(int8_t input, uint8_t index) :
preview->setWidth(INPUT_EDIT_CURVE_WIDTH);
preview->setHeight(INPUT_EDIT_CURVE_HEIGHT);
CurveEdit::SetCurrentSource(expoAddress(index)->srcRaw);
}
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(2),
+1
View File
@@ -113,6 +113,7 @@ void MixEditWindow::buildBody(FormWindow* form)
new StaticText(line, rect_t{}, STR_SOURCE, 0, COLOR_THEME_PRIMARY1);
new SourceChoice(line, rect_t{}, 0, MIXSRC_LAST,
GET_SET_DEFAULT(mix->srcRaw));
CurveEdit::SetCurrentSource(mix->srcRaw);
// Weight
line = form->newLine(&grid);
+2
View File
@@ -325,6 +325,8 @@ void ModelCurvesPage::build(FormWindow * window, int8_t focusIndex)
grid.setLabelWidth(66);
window->padAll(0);
CurveEdit::SetCurrentSource(0);
for (uint8_t index = 0; index < MAX_CURVES; index++) {
CurveHeader &curve = g_model.curves[index];