Skip to content

Commit

Permalink
auto source selection
Browse files Browse the repository at this point in the history
  • Loading branch information
eshifri committed Oct 17, 2022
1 parent 57cc182 commit 33b6a59
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
16 changes: 16 additions & 0 deletions radio/src/gui/colorlcd/curveedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,12 @@ void CurveDataEdit::paint(BitmapBuffer* dc)
void CurveEdit::SetCurrentSource(uint32_t source)
{
CurveEdit::currentSource = source;
if (source)
lockSource = true;
}

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),
Expand All @@ -140,6 +143,7 @@ CurveEdit::CurveEdit(Window* parent, const rect_t& rect, uint8_t index) :
index(index),
current(0)
{
TRACE("CurveEdit::currentSource=%d", CurveEdit::currentSource);
updatePreview();
}

Expand Down Expand Up @@ -289,3 +293,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();
}
13 changes: 7 additions & 6 deletions radio/src/gui/colorlcd/curveedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,26 @@ class CurveEdit: public FormField
return;

preview.deleteLater(true, false);
// CurveEdit::currentSource = 0;

FormField::deleteLater(detach, trash);
}

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();
Expand Down

0 comments on commit 33b6a59

Please sign in to comment.