Prep formatting for upcoming PR
This commit is contained in:
parent
27ac3e985d
commit
422582da71
@ -164,17 +164,17 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l
|
|||||||
} \
|
} \
|
||||||
_menuItemNr++; \
|
_menuItemNr++; \
|
||||||
} while(0)
|
} while(0)
|
||||||
#endif
|
#endif //ENCODER_RATE_MULTIPLIER
|
||||||
#define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0)
|
#define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0)
|
||||||
#define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
|
#define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
|
||||||
#define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
|
#define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
|
||||||
#ifdef ENCODER_RATE_MULTIPLIER
|
#ifdef ENCODER_RATE_MULTIPLIER
|
||||||
#define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
|
#define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
|
||||||
#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
|
#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
|
||||||
#else
|
#else //!ENCODER_RATE_MULTIPLIER
|
||||||
#define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
|
#define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
|
||||||
#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
|
#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
|
||||||
#endif
|
#endif //!ENCODER_RATE_MULTIPLIER
|
||||||
#define END_MENU() \
|
#define END_MENU() \
|
||||||
if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; \
|
if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; \
|
||||||
if ((uint8_t)(encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) - LCD_HEIGHT + 1; lcdDrawUpdate = 1; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \
|
if ((uint8_t)(encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) - LCD_HEIGHT + 1; lcdDrawUpdate = 1; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \
|
||||||
@ -1423,25 +1423,18 @@ void lcd_update()
|
|||||||
int32_t encoderMultiplier = 1;
|
int32_t encoderMultiplier = 1;
|
||||||
|
|
||||||
#ifdef ENCODER_RATE_MULTIPLIER
|
#ifdef ENCODER_RATE_MULTIPLIER
|
||||||
if (encoderRateMultiplierEnabled)
|
|
||||||
{
|
if (encoderRateMultiplierEnabled) {
|
||||||
int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP;
|
int32_t encoderMovementSteps = abs(encoderDiff) / ENCODER_PULSES_PER_STEP;
|
||||||
|
|
||||||
if (lastEncoderMovementMillis != 0)
|
if (lastEncoderMovementMillis != 0) {
|
||||||
{
|
|
||||||
// Note that the rate is always calculated between to passes through the
|
// Note that the rate is always calculated between to passes through the
|
||||||
// loop and that the abs of the encoderDiff value is tracked.
|
// loop and that the abs of the encoderDiff value is tracked.
|
||||||
float encoderStepRate =
|
float encoderStepRate =
|
||||||
(float)(encoderMovementSteps) / ((float)(millis() - lastEncoderMovementMillis)) * 1000.0;
|
(float)(encoderMovementSteps) / ((float)(millis() - lastEncoderMovementMillis)) * 1000.0;
|
||||||
|
|
||||||
if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC)
|
if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = 100;
|
||||||
{
|
else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10;
|
||||||
encoderMultiplier = 100;
|
|
||||||
}
|
|
||||||
else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC)
|
|
||||||
{
|
|
||||||
encoderMultiplier = 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ENCODER_RATE_MULTIPLIER_DEBUG
|
#ifdef ENCODER_RATE_MULTIPLIER_DEBUG
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
@ -1453,12 +1446,13 @@ void lcd_update()
|
|||||||
SERIAL_ECHO(ENCODER_10X_STEPS_PER_SEC);
|
SERIAL_ECHO(ENCODER_10X_STEPS_PER_SEC);
|
||||||
SERIAL_ECHO(" ENCODER_100X_STEPS_PER_SEC: ");
|
SERIAL_ECHO(" ENCODER_100X_STEPS_PER_SEC: ");
|
||||||
SERIAL_ECHOLN(ENCODER_100X_STEPS_PER_SEC);
|
SERIAL_ECHOLN(ENCODER_100X_STEPS_PER_SEC);
|
||||||
#endif
|
#endif //ENCODER_RATE_MULTIPLIER_DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
lastEncoderMovementMillis = millis();
|
lastEncoderMovementMillis = millis();
|
||||||
}
|
}
|
||||||
#endif
|
#endif //ENCODER_RATE_MULTIPLIER
|
||||||
|
|
||||||
lcdDrawUpdate = 1;
|
lcdDrawUpdate = 1;
|
||||||
encoderPosition += (encoderDiff * encoderMultiplier) / ENCODER_PULSES_PER_STEP;
|
encoderPosition += (encoderDiff * encoderMultiplier) / ENCODER_PULSES_PER_STEP;
|
||||||
encoderDiff = 0;
|
encoderDiff = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user