Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Nov 3, 2020
1 parent 5fe49f0 commit b8ba652
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/eez/modules/psu/gui/psu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1769,34 +1769,43 @@ void onEncoder(int counter, bool clicked) {

float min = getMin(g_focusCursor, g_focusDataId).getFloat();
float max = getMax(g_focusCursor, g_focusDataId).getFloat();

StepValues stepValues;
edit_mode_step::getStepValues(stepValues);
mcu::encoder::enableAcceleration(true, max - min, stepValues.values[0]);

float limit;
Value limitValue = getLimit(g_focusCursor, g_focusDataId);
if (limitValue.getType() == VALUE_TYPE_FLOAT) {
limit = limitValue.getFloat();
} else {
limit = max;
}

float newValue;

Value stepValue = getEncoderStep(g_focusCursor, g_focusDataId);
if (stepValue.getType() != VALUE_TYPE_NONE) {
mcu::encoder::enableAcceleration(false);

float step;
if (mcu::encoder::getEncoderMode() == mcu::encoder::ENCODER_MODE_AUTO) {
step = stepValue.getFloat();
} else {
step = edit_mode_step::getCurrentEncoderStepValue().getFloat();
}

newValue = roundPrec(value.getFloat() + counter * step, step);
if (getAllowZero(g_focusCursor, g_focusDataId) && newValue < value.getFloat() && newValue < min) {
newValue = 0;
} else {
newValue = clamp(newValue, min, max);
}
} else {
StepValues stepValues;
edit_mode_step::getStepValues(stepValues);
mcu::encoder::enableAcceleration(true, limit - min, stepValues.values[0]);

newValue = encoderIncrement(value, counter, min, max);
}

Value limitValue = getLimit(g_focusCursor, g_focusDataId);
if (limitValue.getType() != VALUE_TYPE_NONE) {
float limit = limitValue.getFloat();
if (limitValue.getType() == VALUE_TYPE_FLOAT) {
if (newValue > limit && value.getFloat() < limit) {
newValue = limit;
}
Expand Down

0 comments on commit b8ba652

Please sign in to comment.