BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Multiple input timer

Hello, I´m not a programmer and with the help of some topics here I managed to time an output according to the settings of the time input widget with start, end time and day of the week. My question now is: Can I use this same logic to insert two time inputs for the same output? On the same day the output would be on 10-12h and 14-15h for example?

#include <WiFi.h>
#include <WiFiClient.h>
const char* ssid = "xxx";
const char* password =  "xxx";
char auth[] = "xxx";

#define BLYNK_PRINT Serial                      // Mensagens Blynk serão printadas na serial
#include <Blynk.h>                                      // Blynk-ESP32
#include <BlynkSimpleEsp32.h>                // Blynk-ESP32
#include <TimeLib.h>
#include <WidgetRTC.h>

WidgetRTC rtc;
BlynkTimer timer;                              // Timer

//Time Input Variables
char currentTime[9];
char currentDate[11];
char startTime[9];
char stopTime[9];
int SThour;
int STmin;
int STsec;
int SPhour;
int SPmin;
int SPsec;
int dayNumber;
bool activeToday = false;

void ClockDisplay()                                        // RTC Blynk
{
  sprintf(currentTime, "%02d:%02d:%02d", hour(), minute(), second());
  sprintf(currentDate, "%02d/%02d/%04d", day(), month(), year());

  Blynk.virtualWrite(V11, currentTime);                   // Time sent widget lcd Blynk
  Blynk.virtualWrite(V12, currentDate);                   // Date sent widget lcd Blynk
}

BLYNK_WRITE(V10)                                            // Timer CO2
{
TimeInputParam t(param);
  SThour = t.getStartHour();
  STmin = t.getStartMinute();
  STsec = t.getStartSecond();
  SPhour = t.getStopHour();
  SPmin = t.getStopMinute();
  SPsec = t.getStopSecond();
  dayNumber = weekday();
  activeToday = false;
 
  int dayadjustment = -1;                     // Adjust weekday 1-7 being Sunday
     if (weekday() == 1) {                      // Adjust weekday 1-7 being Sunday
 dayadjustment = 6;                           // Adjust weekday 1-7 being Sunday
    }
     if (t.isWeekdaySelected((weekday() + dayadjustment)))
    {
      activeToday =true;
      }
      Serial.println(weekday());
  }
  
void TimeCheck()
{
  sprintf(currentTime, "%02d:%02d:%02d", hour(), minute(), second());         //Get RTC time
  Serial.print("Hora atual: ");
  Serial.println(currentTime);
  sprintf(startTime, "%02d:%02d:%02d", SThour, STmin, STsec);   //Get start time from widget
  Serial.print("Start time: ");
  Serial.println(startTime);  
  sprintf(stopTime, "%02d:%02d:%02d", SPhour, SPmin, SPsec);   //Get stop time from widget
  Serial.print("Stopping time: ");
  Serial.println(stopTime);
  
  if (activeToday == true)
  {
    if (hour() == SThour)
    {
      if (minute() == STmin)
      {
        Serial.println("CO2 turn ON");
        digitalWrite(19, LOW); // Turn ON
        }
        else if (minute() < STmin)
        {
          Serial.println("Will do something");
        }
        else if (minute() > STmin)
        {
          Serial.println("Did something");
        }
        else
        {
          Serial.println("I don´t know");
        }
    }
    if (hour() == SPhour)
    {
      if (minute() == SPmin)
      {
        Serial.println("CO2 turn OFF");
        digitalWrite(19, HIGH);                         // Turn OFF
      }
      else if (minute() < SPmin)
      {
        Serial.println("Will stop something");
        }
        else if (minute() > SPmin)
        {
          Serial.println("Stopped something");
          }
          else
          {
            Serial.println("I don´t Know 2");
          }
    }
    Serial.println("----------");
  }
}

BLYNK_CONNECTED()                               
{
Blynk.syncAll();
TimeCheck();
}

void setup() 
{
Serial.begin(115200);
digitalWrite (19, HIGH);                  // GPIO 19 CO2 OFF sempre ao inicializar
Blynk.begin(auth, ssid, password);       // Inicia o Blynk
rtc.begin();                             // Inicia RTC Blynk
setSyncInterval(360);                    // Set de sinc RTC Blink
timer.setInterval(1000L, ClockDisplay);  // Set interval ClockDisplay event
timer.setInterval(30000L, TimeCheck);    // Set interval TimeCheck event
}

void loop() 
{
Blynk.run();
timer.run();
}

Maybe BLYNK_WRITE_DEFAULT()? Blynk.syncVirtual(Vx)? But I don´t know the order of this in the source font.