mirror of
https://github.com/modelec/MarcelMoteur.git
synced 2026-01-18 16:27:22 +01:00
setup: task library
This commit is contained in:
18
lib/Tasks/library.json
Normal file
18
lib/Tasks/library.json
Normal 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": "*"
|
||||
}
|
||||
9
lib/Tasks/library.properties
Normal file
9
lib/Tasks/library.properties
Normal 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
49
lib/Tasks/src/Task.cpp
Normal 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
25
lib/Tasks/src/Task.h
Normal 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
|
||||
Reference in New Issue
Block a user