Touch Buttons variable repeat delay (#15236)

This commit is contained in:
Robby Candra 2019-09-13 10:14:24 +07:00 committed by Scott Lahteine
parent 5bf635cec2
commit 3f129b6574
3 changed files with 16 additions and 1 deletions

View File

@ -143,6 +143,9 @@ void MenuItem_gcode::action(PGM_P const pgcode) { queue.inject_P(pgcode); }
* MenuItem_int3::action_edit(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999) * MenuItem_int3::action_edit(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
*/ */
void MenuItemBase::edit(strfunc_t strfunc, loadfunc_t loadfunc) { void MenuItemBase::edit(strfunc_t strfunc, loadfunc_t loadfunc) {
#if ENABLED(TOUCH_BUTTONS)
ui.repeat_delay = 50;
#endif
if (int16_t(ui.encoderPosition) < 0) ui.encoderPosition = 0; if (int16_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
if (int16_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue; if (int16_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue;
if (ui.should_draw()) if (ui.should_draw())
@ -212,6 +215,10 @@ bool printer_busy() {
void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, const uint8_t top/*=0*/, const uint8_t items/*=0*/) { void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, const uint8_t top/*=0*/, const uint8_t items/*=0*/) {
if (currentScreen != screen) { if (currentScreen != screen) {
#if ENABLED(TOUCH_BUTTONS)
repeat_delay = 250;
#endif
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
// Shadow for editing the fade height // Shadow for editing the fade height
lcd_z_fade_height = planner.z_fade_height; lcd_z_fade_height = planner.z_fade_height;

View File

@ -195,6 +195,10 @@ millis_t MarlinUI::next_button_update_ms; // = 0
int8_t MarlinUI::encoderDirection = ENCODERBASE; int8_t MarlinUI::encoderDirection = ENCODERBASE;
#endif #endif
#if ENABLED(TOUCH_BUTTONS)
uint8_t MarlinUI::repeat_delay;
#endif
bool MarlinUI::lcd_clicked; bool MarlinUI::lcd_clicked;
float move_menu_scale; float move_menu_scale;
@ -792,7 +796,7 @@ void MarlinUI::update() {
if (touch_buttons & (EN_A | EN_B)) { // A and/or B button? if (touch_buttons & (EN_A | EN_B)) { // A and/or B button?
encoderDiff = (ENCODER_STEPS_PER_MENU_ITEM) * (ENCODER_PULSES_PER_STEP) * encoderDirection; encoderDiff = (ENCODER_STEPS_PER_MENU_ITEM) * (ENCODER_PULSES_PER_STEP) * encoderDirection;
if (touch_buttons & EN_A) encoderDiff *= -1; if (touch_buttons & EN_A) encoderDiff *= -1;
next_button_update_ms = ms + 50; // Assume the repeat delay next_button_update_ms = ms + repeat_delay; // Assume the repeat delay
if (!wait_for_unclick && !arrow_pressed) { // On click prepare for repeat if (!wait_for_unclick && !arrow_pressed) { // On click prepare for repeat
next_button_update_ms += 250; // Longer delay on first press next_button_update_ms += 250; // Longer delay on first press
arrow_pressed = true; // Mark arrow as pressed arrow_pressed = true; // Mark arrow as pressed

View File

@ -406,6 +406,10 @@ public:
#if HAS_LCD_MENU #if HAS_LCD_MENU
#if ENABLED(TOUCH_BUTTONS)
static uint8_t repeat_delay;
#endif
#if ENABLED(ENCODER_RATE_MULTIPLIER) #if ENABLED(ENCODER_RATE_MULTIPLIER)
static bool encoderRateMultiplierEnabled; static bool encoderRateMultiplierEnabled;
static millis_t lastEncoderMovementMillis; static millis_t lastEncoderMovementMillis;