Browse Source

Touch Buttons variable repeat delay (#15236)

pull/1/head
Robby Candra 5 years ago
committed by Scott Lahteine
parent
commit
3f129b6574
  1. 7
      Marlin/src/lcd/menu/menu.cpp
  2. 6
      Marlin/src/lcd/ultralcd.cpp
  3. 4
      Marlin/src/lcd/ultralcd.h

7
Marlin/src/lcd/menu/menu.cpp

@ -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;

6
Marlin/src/lcd/ultralcd.cpp

@ -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

4
Marlin/src/lcd/ultralcd.h

@ -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;

Loading…
Cancel
Save