setup: task library

This commit is contained in:
dd060606
2025-02-07 14:23:36 +01:00
parent cb0a5a8c7f
commit 8e6a0d35c0
4 changed files with 101 additions and 0 deletions

18
lib/Tasks/library.json Normal file
View File

@@ -0,0 +1,18 @@
{
"name": "TaskLibrary",
"version": "1.0.0",
"description": "A simple task library for Arduino",
"keywords": ["marcel", "arduino", "platformio"],
"repository": {
"type": "git",
"url": "https://github.com/modelec/MarcelMoteur.git"
},
"authors": [
{
"name": "",
"email": ""
}
],
"frameworks": "arduino",
"platforms": "*"
}

View File

@@ -0,0 +1,9 @@
name=TaskLibrary
version=1.0.0
author=
maintainer=
sentence=A simple task library for Arduino.
paragraph=A simple task library for Arduino.
category=Uncategorized
url=https://github.com/modelec/MarcelMoteur.git
architectures=*

49
lib/Tasks/src/Task.cpp Normal file
View File

@@ -0,0 +1,49 @@
#include "Task.h"
// Constructeur
Task::Task() : is_paused(false), is_running(false) {}
// Démarre la tâche
void Task::start()
{
is_running = true;
is_paused = false;
}
// Met en pause la tâche
void Task::pause()
{
if (is_running && !is_paused)
{
is_paused = true;
}
}
// Reprend la tâche
void Task::resume()
{
if (is_paused)
{
is_paused = false;
}
}
// Arrête la tâche
void Task::stop()
{
if (is_running)
{
is_running = false;
is_paused = false;
}
}
// Getters
bool Task::isPaused()
{
return is_paused;
}
bool Task::isRunning()
{
return is_running;
}

25
lib/Tasks/src/Task.h Normal file
View File

@@ -0,0 +1,25 @@
#ifndef TASK_H
#define TASK_H
class Task
{
private:
bool is_paused;
bool is_running;
public:
Task(); // Constructeur
// Mise en pause de la tâche
void pause();
// Reprise de la tâche
void resume();
// Démarrage de la tâche
void start();
// Arrêt de la tâche
void stop();
// Getters
bool isPaused();
bool isRunning();
};
#endif // TASK_H