From 8e6a0d35c058ed22fb5058ad0b16a00e8e2bb328 Mon Sep 17 00:00:00 2001 From: dd060606 Date: Fri, 7 Feb 2025 14:23:36 +0100 Subject: [PATCH] setup: task library --- lib/Tasks/library.json | 18 +++++++++++++ lib/Tasks/library.properties | 9 +++++++ lib/Tasks/src/Task.cpp | 49 ++++++++++++++++++++++++++++++++++++ lib/Tasks/src/Task.h | 25 ++++++++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 lib/Tasks/library.json create mode 100644 lib/Tasks/library.properties create mode 100644 lib/Tasks/src/Task.cpp create mode 100644 lib/Tasks/src/Task.h diff --git a/lib/Tasks/library.json b/lib/Tasks/library.json new file mode 100644 index 0000000..27b2a78 --- /dev/null +++ b/lib/Tasks/library.json @@ -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": "*" +} diff --git a/lib/Tasks/library.properties b/lib/Tasks/library.properties new file mode 100644 index 0000000..26b3ff0 --- /dev/null +++ b/lib/Tasks/library.properties @@ -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=* diff --git a/lib/Tasks/src/Task.cpp b/lib/Tasks/src/Task.cpp new file mode 100644 index 0000000..e195bb6 --- /dev/null +++ b/lib/Tasks/src/Task.cpp @@ -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; +} \ No newline at end of file diff --git a/lib/Tasks/src/Task.h b/lib/Tasks/src/Task.h new file mode 100644 index 0000000..3631634 --- /dev/null +++ b/lib/Tasks/src/Task.h @@ -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