Hello!
I am wondering how to use a function as a parameter in Processing (Java). In Arduino (C/C++), it is done like this:
- void timer(unsigned long interval, void (*g)()){
static unsigned long prev = 0;
if (millis() - prev >= interval){
g();
prev = millis();
}
}
But, if I do this in Processing...
- void timer(long interval, void (*g)()){
static long prev = 0;
if (millis() - prev >= interval){
g();
prev = millis();
}
}
I get the error "expecting TRIPLE_DOT, found '('". The static variable also seems to cause an error. I declared it static, because I no not want it to be recreated everytime the function is rerun (i.e. prev becoming 0 again when I want it to be millis()). It works in Arduino. Can someone tell me the Processing equivalent of this code?
Thanks
1