From 704640bf98af30a3fc080ee40b9b9abde7f9e068 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 30 Oct 2017 17:04:37 -0500 Subject: [PATCH 1/2] Faster menu navigation for Anet A8 Addressing #8166 --- Marlin/ultralcd.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 95b4d1996d..d365acadec 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -4337,27 +4337,30 @@ void kill_screen(const char* lcd_msg) { #if ENABLED(ADC_KEYPAD) inline bool handle_adc_keypad() { + #define ADC_MIN_KEY_DELAY 100 static uint8_t adc_steps = 0; if (buttons_reprapworld_keypad) { if (adc_steps < 20) ++adc_steps; - lcd_quick_feedback(); lcdDrawUpdate = LCDVIEW_REDRAW_NOW; if (encoderDirection == -1) { // side effect which signals we are inside a menu if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN) encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM; else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP) encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; - else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_LEFT) menu_action_back(); - else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT) lcd_return_to_status(); + else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_LEFT) { menu_action_back(); lcd_quick_feedback(); } + else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT) { lcd_return_to_status(); lcd_quick_feedback(); } } else { - const int8_t step = adc_steps > 19 ? 100 : adc_steps > 10 ? 10 : 1; - if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN) encoderPosition += ENCODER_PULSES_PER_STEP * step; - else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP) encoderPosition -= ENCODER_PULSES_PER_STEP * step; - else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT) encoderPosition = 0; + if (buttons_reprapworld_keypad & (EN_REPRAPWORLD_KEYPAD_DOWN|EN_REPRAPWORLD_KEYPAD_UP|EN_REPRAPWORLD_KEYPAD_RIGHT)) { + const int8_t step = adc_steps > 19 ? 100 : adc_steps > 10 ? 10 : 1; + if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN) encoderPosition += ENCODER_PULSES_PER_STEP * step; + else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP) encoderPosition -= ENCODER_PULSES_PER_STEP * step; + else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT) encoderPosition = 0; + } } #if ENABLED(ADC_KEYPAD_DEBUG) SERIAL_PROTOCOLLNPAIR("buttons_reprapworld_keypad = ", (uint32_t)buttons_reprapworld_keypad); SERIAL_PROTOCOLLNPAIR("encoderPosition = ", (uint32_t)encoderPosition); #endif + next_button_update_ms = millis() + ADC_MIN_KEY_DELAY; return true; } else if (!thermalManager.current_ADCKey_raw) @@ -4672,7 +4675,7 @@ void lcd_update() { #endif - bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP); + const bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP); if (encoderPastThreshold || lcd_clicked) { if (encoderPastThreshold) { int32_t encoderMultiplier = 1; From 34aeaec553e785b8055cded21f2c0777956f5d2e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 3 Nov 2017 03:42:52 -0500 Subject: [PATCH 2/2] Remove ADKey steps acceleration --- Marlin/ultralcd.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index d365acadec..9a11535bee 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -4338,9 +4338,7 @@ void kill_screen(const char* lcd_msg) { inline bool handle_adc_keypad() { #define ADC_MIN_KEY_DELAY 100 - static uint8_t adc_steps = 0; if (buttons_reprapworld_keypad) { - if (adc_steps < 20) ++adc_steps; lcdDrawUpdate = LCDVIEW_REDRAW_NOW; if (encoderDirection == -1) { // side effect which signals we are inside a menu if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN) encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM; @@ -4350,9 +4348,8 @@ void kill_screen(const char* lcd_msg) { } else { if (buttons_reprapworld_keypad & (EN_REPRAPWORLD_KEYPAD_DOWN|EN_REPRAPWORLD_KEYPAD_UP|EN_REPRAPWORLD_KEYPAD_RIGHT)) { - const int8_t step = adc_steps > 19 ? 100 : adc_steps > 10 ? 10 : 1; - if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN) encoderPosition += ENCODER_PULSES_PER_STEP * step; - else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP) encoderPosition -= ENCODER_PULSES_PER_STEP * step; + if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN) encoderPosition += ENCODER_PULSES_PER_STEP; + else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP) encoderPosition -= ENCODER_PULSES_PER_STEP; else if (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT) encoderPosition = 0; } } @@ -4363,8 +4360,6 @@ void kill_screen(const char* lcd_msg) { next_button_update_ms = millis() + ADC_MIN_KEY_DELAY; return true; } - else if (!thermalManager.current_ADCKey_raw) - adc_steps = 0; // reset stepping acceleration return false; }