New answers tagged

0

In your MyClass example, the drawPaged() call is given only a single argument, while according to the library, it needs two: void drawPaged(void (*drawCallback)(const void*), const void* pv) The first argument is the function pointer (or the one wrapped by std::bind!). The second argument seems to be some data that will be passed on to that function. (...


1

std::function is not supported by the Arduino environment. (Edit: as mentioned by KIIV in a comment, it's supported on ARM targets, but not on AVR.) You can, however, pass a non-capturing lambda to a function that expects a plain function pointer. For example, given T reduce(const T initial, T (*acc)(T, T)) { T value = initial; for (size_t i = 0; i &...


3

The if statements (plural) you posted on GitHub are a lot different to the one you posted above. They contain a lot of of print commands to the LCD, so I think this is what is slowing your code down. It's a fair effort at nicely formatting the output on the display, but is rather convoluted. Here is a simplified version which writes to the LCD as little as ...


0

You can select, what you want. If you want to build an Arduino Project, you should choose "Arduino Project". If you don't want to use the Arduino Framework, you can choose "AVR Project".


0

Blynk.connected() returns true when hardware is connected to Blynk Server, so you can guard Blynk code with if( Blynk.connected() ){ // do Blynk things here } // Update the LCD anywhere outside of the above "if" statement.


2

Functions must have a body. So instead of: void setup() You need: void setup() { // do nothing } You have other issues, for example this is not C++: int (n,i,j,result); That should be: int n,i,j,result; Also you are returning 0, when void functions don't return a value. Also, here: printf("enter N Value"); scanf ("%d", &...


1

If you define instance as a global value, how about to set callback with using lambda expression as variable of constructor. #include <ros.h> #include <std_msgs/Empty.h> class ROSController { protected: ros::Subscriber<std_msgs::Empty> sub; ros::NodeHandle nh; public: ROSController(void (*staticPRYCallback)(const std_msgs::...


0

Singletons aren't a thing in Arduino. Sure, you could do it, but in general you'd make a class then instantiate a global object for that class. Most often that global object is instantiated in the library itself, not the sketch. Unless you're using an advanced chip with an RTOS (such as ESP32) and making use of the threads of that RTOS heavily there is no ...


Top 50 recent answers are included