rotary: init task [#9]

This commit is contained in:
Vasily Davydov
2023-04-26 16:54:50 +03:00
parent e4885adbc9
commit 809358b341
6 changed files with 92 additions and 36 deletions

View File

@@ -18,6 +18,13 @@
namespace ThreadCommon
{
enum RotaryAction
{
Right,
Left,
Press,
Idle
};
class ThreadManager
{
public:

View File

@@ -18,7 +18,7 @@ void Master::taskFunction() {
bool LedState = true;
for (;;) {
_qm->receive<Event>(ThreadCommon::QueueManager::master_event_all, &data, portMAX_DELAY);
if(data.getDataOf(Event::Rotary) == 1){
if(data.getDataOf(Event::Rotary) == ThreadCommon::RotaryAction::Idle){
Board_LED_Set(led, LedState);
}
}

View File

@@ -0,0 +1,26 @@
/*
* Rotary.cpp
*
* Created on: 26 Apr 2023
* Author: tylen
*/
#include "Rotary.h"
Rotary::Rotary(ThreadCommon::QueueManager* qm) : _qm(qm) {}
Rotary::~Rotary() {}
void Rotary::taskFunction()
{
Event data(Event::Null, 0);
Event* e = new Event(Event::Rotary, ThreadCommon::RotaryAction::Idle);
_qm->send<Event>(ThreadCommon::QueueManager::master_event_all, e, 10);
for (;;) {}
}
void rotary_thread(void* pvParams)
{
Rotary r(static_cast<ThreadCommon::QueueManager*>(pvParams));
r.taskFunction();
}

View File

@@ -0,0 +1,26 @@
/*
* Rotary.h
*
* Created on: 26 Apr 2023
* Author: tylen
*/
#ifndef THREADS_ROTARY_ROTARY_H_
#define THREADS_ROTARY_ROTARY_H_
#include "Event.h"
#include "ThreadCommon.h"
class Rotary {
public:
Rotary(ThreadCommon::QueueManager* qm);
virtual ~Rotary();
void taskFunction();
private:
Event* message;
ThreadCommon::QueueManager* _qm;
};
void rotary_thread(void* pvParams);
#endif /* THREADS_ROTARY_ROTARY_H_ */