Visitar URL original
GitHub - mathieucarbou/MycilaTaskManager: Arduino / ESP32 Task Manager Library · GitHub
Skip to content

About

Arduino / ESP32 Task Manager Library

Resources

Code of conduct

Contributing

Stars

7 stars

Watchers

1 watching

Forks

Repository files navigation

MycilaTaskManager

License: MIT Continuous Integration PlatformIO Registry

Arduino / ESP32 Task Manager Library — runs cooperative, non-blocking tasks at a chosen frequency, on the loop() or in a dedicated FreeRTOS task.

📖 Full documentation and API reference → mathieu.carbou.me/MycilaTaskManager

Setup

PlatformIO

[env:myproject]
platform = espressif32
framework = arduino
board = esp32dev

lib_deps =
  mathieucarbou/MycilaTaskManager@^5.0.0

Arduino IDE

  1. Go to Sketch → Include Library → Manage Libraries
  2. Search for MycilaTaskManager
  3. Install the library by Mathieu Carbou

Minimal Sketch

#include <MycilaTaskManager.h>

Mycila::TaskManager tasks("loop()");

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

  tasks.newTask("hello", [](void* params) {
    Serial.println("Hello");
  }).setInterval(1000);
}

void loop() {
  tasks.loop();
}

Requirements

  • ESP32 (any variant) with the Arduino framework
  • ArduinoJson 7.x — only when MYCILA_JSON_SUPPORT is defined

Configuration Macros

All configuration is compile-time. Set the flags in build_flags:

build_flags =
  -D MYCILA_JSON_SUPPORT

Feature Flags

Macro Effect
MYCILA_JSON_SUPPORT Enables toJson() on Task, TaskManager and BinStatistics. Requires ArduinoJson 7.x.
MYCILA_TASK_MANAGER_NO_PARAMS Task functions become std::function<void()>. Removes setData() / data() and the void* params argument.
MYCILA_TASK_MANAGER_NO_CALLBACKS Removes onDone() and the done callback.
MYCILA_TASK_MANAGER_NO_STATS Removes all profiling: enableProfiling(), statistics(), BinStatistics. profiled() returns false.

⚠️ MYCILA_TASK_MANAGER_NO_PARAMS changes the task lambda signature

// default
Mycila::Task t("t", [](void* params) { /* ... */ });

// with MYCILA_TASK_MANAGER_NO_PARAMS
Mycila::Task t("t", []() { /* ... */ });

Version Macros

Always defined, for runtime or compile-time checks:

MYCILA_TASK_MANAGER_VERSION           // "5.0.0"
MYCILA_TASK_MANAGER_VERSION_MAJOR     // 4
MYCILA_TASK_MANAGER_VERSION_MINOR     // 2
MYCILA_TASK_MANAGER_VERSION_REVISION  // 5

Logging

Logs use the TASKS tag through ESP_LOGx. Control the verbosity with the Arduino core macro:

build_flags =
  -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG

License

This project is licensed under the MIT License — see the LICENSE file for details.


Author: Mathieu Carbou

About

Arduino / ESP32 Task Manager Library

Resources

Code of conduct

Contributing

Stars

7 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages