diff --git a/radio/src/thirdparty/libopenui/src/basenumberedit.h b/radio/src/thirdparty/libopenui/src/basenumberedit.h index 375b1ecb6..dd5cf2bcc 100644 --- a/radio/src/thirdparty/libopenui/src/basenumberedit.h +++ b/radio/src/thirdparty/libopenui/src/basenumberedit.h @@ -78,6 +78,26 @@ class BaseNumberEdit: public FormField return step; } + void setFastStep(int value) + { + fastStep = value; + } + + int32_t getFastStep() const + { + return fastStep; + } + + void setAccelFactor(int value) + { + accelFactor = value; + } + + int32_t getAccelFactor() const + { + return accelFactor; + } + void setValue(int value) { auto newValue = limit(vmin, value, vmax); @@ -190,6 +210,8 @@ class BaseNumberEdit: public FormField int vmin; int vmax; int step = 1; + int fastStep = 10; + int accelFactor = 4; int currentValue; bool instantChange = true; std::string prefix; diff --git a/radio/src/thirdparty/libopenui/src/libopenui_depends.h b/radio/src/thirdparty/libopenui/src/libopenui_depends.h index 414fccf85..279a4e070 100644 --- a/radio/src/thirdparty/libopenui/src/libopenui_depends.h +++ b/radio/src/thirdparty/libopenui/src/libopenui_depends.h @@ -30,6 +30,9 @@ void DMACopyAlphaMask(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t void onKeyError(); void killEvents(event_t event); +// multiplication factor between 0 and 25 +int8_t rotaryEncoderGetAccel(); + // // These colors MUST be defined // diff --git a/radio/src/thirdparty/libopenui/src/numberedit.cpp b/radio/src/thirdparty/libopenui/src/numberedit.cpp index e202e29ec..bdd6f232c 100644 --- a/radio/src/thirdparty/libopenui/src/numberedit.cpp +++ b/radio/src/thirdparty/libopenui/src/numberedit.cpp @@ -66,8 +66,10 @@ void NumberEdit::onEvent(event_t event) #if defined(HARDWARE_KEYS) case EVT_ROTARY_RIGHT: { int value = getValue(); + auto step = getStep(); + step += (rotaryEncoderGetAccel() * getAccelFactor()) / 8; do { - value += ROTARY_ENCODER_SPEED() * step; + value += step; } while (isValueAvailable && !isValueAvailable(value) && value <= vmax); if (value <= vmax) { setValue(value); @@ -81,8 +83,10 @@ void NumberEdit::onEvent(event_t event) case EVT_ROTARY_LEFT: { int value = getValue(); + auto step = getStep(); + step += (rotaryEncoderGetAccel() * getAccelFactor()) / 8; do { - value -= ROTARY_ENCODER_SPEED() * step; + value -= step; } while (isValueAvailable && !isValueAvailable(value) && value >= vmin); if (value >= vmin) { setValue(value); @@ -104,11 +108,11 @@ void NumberEdit::onEvent(event_t event) break; case EVT_VIRTUAL_KEY_FORWARD: - setValue(getValue() + 10 * getStep()); + setValue(getValue() + getFastStep() * getStep()); break; case EVT_VIRTUAL_KEY_BACKWARD: - setValue(getValue() - 10 * getStep()); + setValue(getValue() - getFastStep() * getStep()); break; case EVT_VIRTUAL_KEY_DEFAULT: