-
Notifications
You must be signed in to change notification settings - Fork 89
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
How can I create a class with its own timer #76
Comments
Hi Sevtek,
Due to the lack of the C++ version used in Arduino Due, you can only attach
callbacks and pass as parameter functions that do not require the scope of
object instances, example: You can pass along a pointer to a static class
function, but cannot pass a method (a function bound to the instance).
That being said, your way out of this problem is to either convert your
"class" to static methods (and just be a better organization), or in case
you need multiple instances, create a global mapping table (an array of
mappings) that convert the instance ID (some value that starts with 0 in
the first instance of your class and gets stored inside it, and goes up
every time you instantiate it). Store itself in the mapping table in that
index position, and once the callback is fired, you try to redirect the
call to the proper class. This is not that easy to do, but is feasible if
needed.
Hope it helps!
Em sáb., 17 de out. de 2020 às 19:12, sevketk <[email protected]>
escreveu:
… I need a one class , have a timer. in class method can start, stop timer.
#include <DueTimer.h>
void RGBmatrixPanel::begin(void) {
Timer3.attachInterrupt(updateDisplay);
Timer3.start(250);
}
void RGBmatrixPanel::updateDisplay() {
if(something doing){
Timer3.stop();
}
}
But i get error on arduinodue
E:\kutuphane\belgelerim\Arduino\libraries\RGB-matrix-Panel-master\RGBmatrixPanel.cpp: In member function 'void RGBmatrixPanel::begin()':
E:\kutuphane\belgelerim\Arduino\libraries\RGB-matrix-Panel-master\RGBmatrixPanel.cpp:86:41: error: no matching function for call to 'DueTimer::attachInterrupt(<unresolved overloaded function type>)'
Timer3.attachInterrupt(updateDisplay);
^
E:\kutuphane\belgelerim\Arduino\libraries\RGB-matrix-Panel-master\RGBmatrixPanel.cpp:86:41: note: candidate is:
In file included from E:\kutuphane\belgelerim\Arduino\libraries\RGB-matrix-Panel-master\RGBmatrixPanel.h:26:0,
from E:\kutuphane\belgelerim\Arduino\libraries\RGB-matrix-Panel-master\RGBmatrixPanel.cpp:3:
E:\kutuphane\belgelerim\Arduino\libraries\DueTimer-master/DueTimer.h:84:12: note: DueTimer& DueTimer::attachInterrupt(void (*)())
DueTimer& attachInterrupt(void (*isr)());
how to use in a class duetimer library?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#76>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXVLLYZAREPHTLHHJUT52TSLIJF5ANCNFSM4SUUOFUQ>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I need a one class , have a timer. in class method can start, stop timer.
But i get error on arduinodue
how to use in a class duetimer library?
The text was updated successfully, but these errors were encountered: