Use Blynk inside custom library

Hi everyone! First of all, thanks for reading!
I’m doing a big project in arduino pro mini, which has a physical button that I want to replace with a really simple Blynk app.
In this project, the Setup looks like

void Setup(){

Where the class is in a custom library.
In some of those functions I have a period of time in which I wait for the user to push the button.

the code is something like

while(t0-millis()<10000)// Check for 10 secs if the button was pushed
  if(digitalRead(2)==HIGH) buttonPushed=true; //actually I use a debounce library, but you get the idea
if(buttonPushed=true) doSomething();

So I guess that if I have a button widget attached to pin 2, I shoud use “” inside the while loop. And, in order to do that, I have to include BlynkSimpleSerialBLE.h and SoftwareSerial.h to my library, create the SoftwareSerial as a class atribute, and use it for the “Blynk.Begin()”.

I tried many ways, but I couldn’t make it work so far. I can get the first part right if Ideclare the SoftwareSerial as a pointer and initialize it in the constructor, but then I get an error on the Blynk.Begi(), because it doesn’t receives pointers.

Do you have any ideas?

Thank you very much!

If all you need to do is replicate a physical button on a digital pin, then you could “merge in Blynk” (often easier said then done) and do so with a simple Button Widget connected to the same digital pin…

However, based on what you have said so far, I highly suggest you start using just the basic Blynk examples and playing around with them (independent of your existing code) until you have a much better idea on how the Blynk library works and the “new” required layout of your existing code when using Blynk. Such as needing a clean void loop() and using timers or alternative coding wherever possible instead of any blocking code like delay() and while() commands (e.g. interrupts for the button, not regularly polled loops).

A post was split to a new topic: Using 4 custom classes, one of which needs to integrate blynk functions