Questions tagged [callbacks]

This refer to the call back procedure in computer programming.

In computer programming, a callback is a piece of executable code that is passed as an argument to other code, which is expected to call back (execute) the argument at some convenient time. The invocation may be immediate as in a synchronous callback, or it might happen at a later time as in an asynchronous callback.

19 questions
5
votes
2 answers

User callback functions

I want to write a class that allows the user to attach his own function to a member function that listens for messages coming from a wireless module, so that the user's function can be called depending on the message. I am thinking about using…
Vasil Kalchev
  • 285
  • 1
  • 2
  • 12
5
votes
1 answer

Non-blocking MQTT library

Are there any MQTT libraries that do not block while connecting? I'm currently using PubSubClient, and the connection part contains this code: https://github.com/knolleary/pubsubclient/blob/master/src/PubSubClient.cpp while…
4
votes
1 answer

How to get variable from callback function?

There is a library davetcc / IoAbstraction. The only library working as expected with my rotary encoder. The problem that on rotation I can only see serial output with position data, but I cannot get these data as some variable value. There is the…
4
votes
2 answers

How to pass variables to custom callback functions

I want to use the Ticker library of the ESP8266 Arduino core to (asynchronously) delay the switch of a pin to a desired state like below. I am not sure about the "here is" function definitions and I am having a hard time to find some documentation.…
milkpirate
  • 143
  • 1
  • 4
3
votes
1 answer

What are the parameters of the browseUrl() callback in the Ethercard library?

I'm reading a code that uses Arduino as a webclient and when he tries to catch the info from the site, he uses a callback with the following parameters: static void response_callback (byte status, word off, word len) Can anyone explain me how does…
2
votes
1 answer

Passing non-static member function using bind

I'm using the GxEPD2 library to communicate with an E-Paper display. I now wanted to use the drawPaged method of this library with an object display. I also have written my own class from which I want to print stuff on the display. Here's the…
Lithimlin
  • 145
  • 8
1
vote
2 answers

Array of Functions

I'm new to C++. How to make a menu without if() {} else {} & switch() case? I made a menu on an array, but for some reason it doesn't compile. How to correct it? typedef void (*cbd)(uint8_t, uint8_t); typedef void (*cbt)(uint8_t, uint8_t); typedef…
Andre
  • 27
  • 5
1
vote
2 answers

Call functions of one class from another class - Callback

I am new to C++ & I need to call functions of one class from another class. And so that the classes do not know anything about each other. How to do it in Arduino environment? class Encoder { using CallBack2 = void( * )(const int, const int); …
Andre
  • 27
  • 5
1
vote
2 answers

Callback functions when using a class

This question is somewhat similar to How to pass non-static class member to callback?, but there are a few differences, especially since a lot of my uses have "interesting" additional complexities. I'd like to understand better my options in using…
RDragonrydr
  • 338
  • 4
  • 15
1
vote
2 answers

ESP8266 ASyncTCP class example

I am new to ESP programming on Arduino, as before I was developing on eLua. There were some memory problems in Lua, so I decided to move to Arduino. After looking at some examples, I found a library called AsyncTCP and I was very glad because it…
mansoor
  • 11
  • 3
1
vote
1 answer

Pass class's public function as an argument to external command

I am trying to write a library for encoders. main.ino: #include <./Encoders.h> Encoders encoders(); void setup(){ Serial.begin(9600); } void loop(){ Serial.print(""); } Encoders.h: #ifndef Encoders_h #define…
Marcel
  • 171
  • 4
  • 11
0
votes
3 answers

Trigger event onRelease of button

I am using the EasyButton library to detect button presses on an arduino. I want do execute a function when the user Presses a button Presses and holds a button Releases a button Detecting when a user presses or holds a button is straight…
spuder
  • 111
  • 6
0
votes
1 answer

Passing a method pointer

I created a small library, which takes a callback function: MyClass::add_callback(bool (*callback_function)(), byte behaviour) { // ... bool result = callback_function(); // ... } So far, I'm using it for periodic polling (for which I don't…
MacFreek
  • 103
  • 4
0
votes
1 answer

Use callbacks in Arduino with pointers to functions (will functions persist in memory?)

As I been learning Arduino (micro controllers, c++, etc) I have learned that memory is very limited. I already understand how memory works when it comes to variables. But I do not understand how memory works when it comes to functions. Since I am a…
Tono Nam
  • 938
  • 7
  • 19
0
votes
2 answers

Parent class callback from child class

I want the Parent class to pass a pointer to a callback function to the child class when the child class is created. I got this working when the parent was the sketch thanks to this post: In this example, the parent was the .ino file, i.e. not a…
Bob Jones
  • 131
  • 6
1
2