Skip to content
This repository was archived by the owner on Jan 1, 2026. It is now read-only.
This repository was archived by the owner on Jan 1, 2026. It is now read-only.

Example using delay or yield in class instantiated in task #17

@thijse

Description

@thijse

It would be great if you can add an example on how to use a non blocking delay in a other class than the Task itself.

I am now doing it like the example below (based on the Simple.ino example), but it requires changing the scheduler to make delay & yield public

class PrintManager  {
  protected:
    Task* _task;
  public:
    PrintManager(Task* task) {
      _task = task;
    }
    
    void print() {
        Serial.println("Print Loop Start");
        _task->delay(4000);
        Serial.println("Print Loop End");
        _task->delay(4000);
    }
};


class PrintTask : public Task {
public:
    PrintTask() : Task(), printManager((Task *) this){}; 

protected:
    PrintManager printManager;
    void loop()  {      
        printManager.print();
    }
} print_task;

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions