ESP8266 Scheduler. Tasks in separate files

Hi, I want to create simple weather station with esp8266 but with scheduler to updating data and GUI more simultaneously. I've downloaded scheduler from here but there is information:

Tasks must be declared globally on the stack (not a pointer). Failure to do so will crash your device

Does that mean that I have to write all task classes in *.ino file? Can I save them in separate files and call to sketch file? How to do that? I've tried few times but the code won't compile.
Simpliest example of sketch:

#include <Scheduler.h>
#include <Arduino.h>

class SimpleTask : public Task {
protected:
    void setup() {
      Serial.println("Setup func");

    }

    void loop() {
      Serial.println("Loop func");
      delay(600);
    }
    
} simple_task;

void setup() {
      Serial.begin(115200);

Scheduler.start(&simple_task);
Scheduler.begin();
}

void loop() { }

tomacaster:
Hi, I want to create simple weather station with esp8266 but with scheduler to updating data and GUI more simultaneously. I've downloaded scheduler from here but there is information:

Tasks must be declared globally on the stack (not a pointer). Failure to do so will crash your device

No it means that you should avoid dynamically allocating memory for the task, new keyword, malloc, etc.

What is the error that you get?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.