Skip to content

Implementation of digitalFASTread() possibility#45

Merged
mathertel merged 2 commits intomathertel:masterfrom
JoJos1220:digitalFASTread()---Integration
Oct 25, 2025
Merged

Implementation of digitalFASTread() possibility#45
mathertel merged 2 commits intomathertel:masterfrom
JoJos1220:digitalFASTread()---Integration

Conversation

@JoJos1220
Copy link
Contributor

I wanted to avoid digitalRead()/digitalWrite() operation within my Project. Therefore I made a split-up of the tick() function - to enable the possibility to read the Encoder-State within my loop function and the usage of a digitalFASTread() Operation and overload it to the tick function directly.

@JoJos1220 JoJos1220 marked this pull request as ready for review June 7, 2024 19:10
@JoJos1220
Copy link
Contributor Author

I made successfull Comissioning on ESP32-WROOM by implementing:
encoder.tick(digitalFASTRead(encoderPinB), digitalFASTRead(encoderPinA));
Instead of:
encoder.tick();
And it worked to me perfectly.
My used digitalFASTREAD() function I used is:
/*-----------------------------------------------------------------------------

  • digitalFASTRead(): Function to read a GPIO Pin State as fast alternative to digitalRead()

*/
int digitalFASTRead(uint8_t pin) {
if (pin < 0 || pin >= 40) {
// Pinnumber outside of valid area!
return false;
}

uint32_t bit = digitalPinToBitMask(pin);
uint32_t port = digitalPinToPort(pin);

if (port == NOT_A_PIN) {
// Invalid Pinnumber
return false;
}

// Pointer on GPIO-Register
volatile uint32_t *reg = portInputRegister(port);

// Read Pin State
bool state = ((*reg) & bit) != 0;

return state;
}

… performance; update documentation accordingly.
Copy link
Owner

@mathertel mathertel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional Pin Initialization:
The RotaryEncoder constructor now checks if the pins are valid before initializing them with INPUT_PULLUP.

@mathertel mathertel merged commit 1fb1452 into mathertel:master Oct 25, 2025
@mathertel
Copy link
Owner

mathertel commented Oct 25, 2025

@JoJos1220 : Thank you for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants