Comments (5)
could you please show me the relevant bits (i.e. the definition of nrfReceive) of your source code?
from arduino-tasker.
Yes, surely I can. But it does not matter on mentioned code. Look at two example below, first one not working - error while compiling, second one working fine. The only difference is in the declaration of the called function (void) x (int).
void nrfReceive(void) {
if (radio.available()) {
while (radio.available()) {
radio.read(&meteo, sizeof(meteo));
}
}
#ifdef DEBUG
Serial.println("");
Serial.print("Velikost packetu: ");
Serial.print(sizeof(meteo));
Serial.println("");
Serial.print("NRF-RX>>> ");
Serial.print(meteo.crc);
#endif
}
// NOT WORKING
#include <Tasker.h>
Tasker tasker;
void setup() {
Serial.begin(115200);
tasker.setInterval(printsomething, 1000);
}
void loop() {
tasker.loop();
}
void printsomething(void) {
Serial.println("Hello Word!");
}
// WORKING FINE
#include <Tasker.h>
Tasker tasker;
void setup() {
Serial.begin(115200);
tasker.setInterval(printsomething, 1000);
}
void loop() {
tasker.loop();
}
void printsomething(int) {
Serial.println("Hello Word!");
}
from arduino-tasker.
Tasker expects the callback to be defined as void fn(int). The documentation does not explain it explicitly but all examples show that so please define your callbacks with the (int parameter) even if you didn't want to use it. Just like in the MultiBlink example:
void blink1(int /* unused */)
{
...
from arduino-tasker.
Yes, I already alter my code that way.
You're definitely a better coder in C/C++ than me, so please correct me if I'm wrong.
Valid declaraction of function i C which has no input arguments and return nothing should be: void function(void) {...}
, which is exactly my mentioned case. If I change the declaration to void function (int) {...}
copmpiler expect, that function has (int) argument or not ?
(maybe we can continue by mail directly and in Czech I guess...)
from arduino-tasker.
That function will receive an int argument - Tasker is sending that just in case you needed a flag, a counter or something. It does come handy, as the examples show. You are not obliged to use that parameter's value in your function, of course. You can even declare it without a name so it will get ignored. The examples show this as well.
Feel free to mail me directly, I'm going to close this issue.
from arduino-tasker.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino-tasker.