Skip to content

[1.1.x] Fix LCD button / newbutton issue#13157

Merged
thinkyhead merged 1 commit intoMarlinFirmware:bugfix-1.1.xfrom
7eggert:bugfix-1.1.x
Feb 14, 2019
Merged

[1.1.x] Fix LCD button / newbutton issue#13157
thinkyhead merged 1 commit intoMarlinFirmware:bugfix-1.1.xfrom
7eggert:bugfix-1.1.x

Conversation

@7eggert
Copy link
Contributor

@7eggert 7eggert commented Feb 13, 2019

Logic errors in ultralcd.cpp

  1. Minor:
    buttons is a volatile variable. button |= slow_buttons should not be done
    if newbuttons |= ... can be done

  2. Major:
    #if ENABLED(ADC_KEYPAD) ... buttons = 0 is done after buttons = newbuttons
    The values from a rotary encoder (which I installed) are erased by this
    line, and newbuttons would have been 0 anyway if there was no button.

    TL;DR: Don't undo reading the rotary encoder before reading the ADC keys

Benefits // Related Issues

I created a display having a rotary encoder and back/home buttons by using an ADC_KEY. Being in a deep menu, these extra keys are helpful, while also giving the benefit of having a rotary encoder instead of emulating one using the up/down keys. The encoder would not work even though the pins were read correctly.

1) Minor:
   buttons is a volatile variable. button |= slow_buttons should not be done
   if newbuttons |= ... can be done

2) Major:
   #if ENABLED(ADC_KEYPAD) ... buttons = 0 is done after buttons = newbuttons
   The values from a rotary encoder (which I installed) are erased by this
   line, and newbuttons would have been 0 anyway if there was no button.

   TL;DR: Don't undo reading the rotary encoder before reading the ADC keys
wmandra added a commit to wmandra/Marlin that referenced this pull request Feb 13, 2019
Logic errors in ultralcd.cpp

1) Minor:
   buttons is a volatile variable. button |= slow_buttons should not be done
   if newbuttons |= ... can be done

2) Major:
   #if ENABLED(ADC_KEYPAD) ... buttons = 0 is done after buttons = newbuttons
   The values from a rotary encoder (which I installed) are erased by this
   line, and newbuttons would have been 0 anyway if there was no button.

   TL;DR: Don't undo reading the rotary encoder before reading the ADC keys
@thinkyhead
Copy link
Member

Marlin 1.1.x is end-of-life and won't get any new releases, so you should focus on Marlin bugfix-2.0.x going forward.

@thinkyhead thinkyhead merged commit 01674c5 into MarlinFirmware:bugfix-1.1.x Feb 14, 2019
@thinkyhead thinkyhead changed the title Logic errors in ultralcd.cpp Fix LCD button / newbutton issue Feb 14, 2019
@thinkyhead thinkyhead changed the title Fix LCD button / newbutton issue [1.1.x] Fix LCD button / newbutton issue Feb 14, 2019
thinkyhead pushed a commit that referenced this pull request Sep 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants