Giter Club home page Giter Club logo

Comments (5)

joysfera avatar joysfera commented on June 22, 2024

could you please show me the relevant bits (i.e. the definition of nrfReceive) of your source code?

from arduino-tasker.

kratochviljan avatar kratochviljan commented on June 22, 2024

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.

joysfera avatar joysfera commented on June 22, 2024

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.

kratochviljan avatar kratochviljan commented on June 22, 2024

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.

joysfera avatar joysfera commented on June 22, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.