8000 Offers possibility to deactivate default INPUT_PULLUP pin mode by ldebs · Pull Request #83 · PaulStoffregen/Encoder · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Offers possibility to deactivate default INPUT_PULLUP pin mode #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
#define ENCODER_ARGLIST_SIZE 0
#endif

#if defined(ENCODER_USE_PULLUP) || !defined(ENCODER_DO_NOT_USE_PULLUP)
#define ENCODER_USE_PULLUP
#endif

// Use ICACHE_RAM_ATTR for ISRs to prevent ESP8266 resets
#if defined(ESP8266) || defined(ESP32)
#define ENCODER_ISR_ATTR ICACHE_RAM_ATTR
Expand All @@ -77,15 +81,17 @@ class Encoder
{
public:
Encoder(uint8_t pin1, uint8_t pin2) {
#ifdef INPUT_PULLUP
#if defined(INPUT_PULLUP) && defined(ENCODER_USE_PULLUP)
pinMode(pin1, INPUT_PULLUP);
pinMode(pin2, INPUT_PULLUP);
#else
pinMode(pin1, INPUT);
digitalWrite(pin1, HIGH);
pinMode(pin2, INPUT);
#if defined(ENCODER_USE_PULLUP)
digitalWrite(pin1, HIGH);
digitalWrite(pin2, HIGH);
#endif
#endif
encoder.pin1_register = PIN_TO_BASEREG(pin1);
encoder.pin1_bitmask = PIN_TO_BITMASK(pin1);
encoder.pin2_register = PIN_TO_BASEREG(pin2);
Expand Down
0