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:
@@ -115,21 +115,38 @@ void CurveDataEdit::update()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveDataEdit::paint(BitmapBuffer * dc)
|
void CurveDataEdit::paint(BitmapBuffer* dc)
|
||||||
{
|
{
|
||||||
dc->clear(COLOR_THEME_SECONDARY3);
|
dc->clear(COLOR_THEME_SECONDARY3);
|
||||||
// dc->drawSolidHorizontalLine(0, rect.h / 3, getInnerWidth(), 0);
|
// dc->drawSolidHorizontalLine(0, rect.h / 3, getInnerWidth(), 0);
|
||||||
// dc->drawSolidHorizontalLine(0, 2 * 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) :
|
void CurveEdit::SetCurrentSource(uint32_t source)
|
||||||
FormField(parent, rect, NO_FOCUS),
|
|
||||||
preview(this, {0, 0, width(), height()}, [=](int x) -> int {
|
|
||||||
return applyCustomCurve(x, index);
|
|
||||||
}),
|
|
||||||
index(index),
|
|
||||||
current(0)
|
|
||||||
{
|
{
|
||||||
|
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();
|
updatePreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,3 +296,15 @@ void CurveEdit::onEvent(event_t event)
|
|||||||
break;
|
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();
|
||||||
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ class CurveEdit: public FormField
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
CurveEdit(Window * parent, const rect_t & rect, uint8_t index);
|
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
|
void deleteLater(bool detach = true, bool trash = true) override
|
||||||
{
|
{
|
||||||
@@ -62,16 +63,19 @@ class CurveEdit: public FormField
|
|||||||
void updatePreview();
|
void updatePreview();
|
||||||
|
|
||||||
void onEvent(event_t event) override;
|
void onEvent(event_t event) override;
|
||||||
|
void checkEvents(void) override;
|
||||||
|
|
||||||
// #if defined(HARDWARE_TOUCH)
|
// #if defined(HARDWARE_TOUCH)
|
||||||
// bool onTouchEnd(coord_t x, coord_t y) override;
|
// bool onTouchEnd(coord_t x, coord_t y) override;
|
||||||
// void onFocusLost() override;
|
// void onFocusLost() override;
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Curve preview;
|
Curve preview;
|
||||||
uint8_t index;
|
uint8_t index;
|
||||||
uint8_t current;
|
uint8_t current;
|
||||||
|
static mixsrc_t currentSource;
|
||||||
|
static bool lockSource;
|
||||||
void next();
|
void next();
|
||||||
void previous();
|
void previous();
|
||||||
void up();
|
void up();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "curve_param.h"
|
#include "curve_param.h"
|
||||||
#include "gvar_numberedit.h"
|
#include "gvar_numberedit.h"
|
||||||
#include "input_source.h"
|
#include "input_source.h"
|
||||||
|
#include "curveedit.h"
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
@@ -80,6 +81,8 @@ InputEditWindow::InputEditWindow(int8_t input, uint8_t index) :
|
|||||||
|
|
||||||
preview->setWidth(INPUT_EDIT_CURVE_WIDTH);
|
preview->setWidth(INPUT_EDIT_CURVE_WIDTH);
|
||||||
preview->setHeight(INPUT_EDIT_CURVE_HEIGHT);
|
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),
|
static const lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(2),
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ void MixEditWindow::buildBody(FormWindow* form)
|
|||||||
new StaticText(line, rect_t{}, STR_SOURCE, 0, COLOR_THEME_PRIMARY1);
|
new StaticText(line, rect_t{}, STR_SOURCE, 0, COLOR_THEME_PRIMARY1);
|
||||||
new SourceChoice(line, rect_t{}, 0, MIXSRC_LAST,
|
new SourceChoice(line, rect_t{}, 0, MIXSRC_LAST,
|
||||||
GET_SET_DEFAULT(mix->srcRaw));
|
GET_SET_DEFAULT(mix->srcRaw));
|
||||||
|
CurveEdit::SetCurrentSource(mix->srcRaw);
|
||||||
|
|
||||||
// Weight
|
// Weight
|
||||||
line = form->newLine(&grid);
|
line = form->newLine(&grid);
|
||||||
|
|||||||
@@ -325,6 +325,8 @@ void ModelCurvesPage::build(FormWindow * window, int8_t focusIndex)
|
|||||||
grid.setLabelWidth(66);
|
grid.setLabelWidth(66);
|
||||||
window->padAll(0);
|
window->padAll(0);
|
||||||
|
|
||||||
|
CurveEdit::SetCurrentSource(0);
|
||||||
|
|
||||||
for (uint8_t index = 0; index < MAX_CURVES; index++) {
|
for (uint8_t index = 0; index < MAX_CURVES; index++) {
|
||||||
|
|
||||||
CurveHeader &curve = g_model.curves[index];
|
CurveHeader &curve = g_model.curves[index];
|
||||||
|
|||||||
Reference in New Issue
Block a user