Skip to content

attachInterrupt() callback methods with C++ class for ESP32? #965

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

Closed
huming2207 opened this issue Jan 5, 2018 · 6 comments
Closed

attachInterrupt() callback methods with C++ class for ESP32? #965

huming2207 opened this issue Jan 5, 2018 · 6 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@huming2207
Copy link

Hi all,

I was very confused about this issue for a few hours. I've searched this issue but for AVR micro controllers, the callback method must be static, or some other tricky workarounds are needed. So I would like to ask that is there any better solutions for implementing non-static method as callback?

Regards,
Jackson

@ferchinas
Copy link

ferchinas commented Jan 14, 2018

Hi, I am looking for the same information. @huming2207 Did you find something?
For the ESP8266 I have successfully used this form esp8266/Arduino#1925
But I can not find a way for ESP32.

@atanisoft
Copy link
Collaborator

I couldn't find a way to do this without static. I opted for a struct with methods instead and templates on the methods for instance specific params. It works pretty well for my usage.

@ferchinas
Copy link

@atanisoft I do not know how to do what you mention, can you pass me some link that is explained with that?
Thank you very much

@atanisoft
Copy link
Collaborator

@ferchinas Here is how I am doing it today...

This function:
https://github.com/atanisoft/DCCppESP32/blob/master/src/SignalGenerator.cpp#L169

gets used for two ISRs by using the template parameter to pass in an index which points back to a struct which holds parameters for the ISR routine. The call to attach the ISR is here: https://github.com/atanisoft/DCCppESP32/blob/master/src/SignalGenerator.cpp#L225

The timers are used to generate a square wave with specific durations based on the data being fed into the dcc signal generator.

@stale
Copy link

stale bot commented Aug 1, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Aug 1, 2019
@sauvant
Copy link

sauvant commented Nov 8, 2019

I would like to reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

4 participants