rotary: init task [#9]
This commit is contained in:
@@ -18,6 +18,13 @@
|
||||
|
||||
namespace ThreadCommon
|
||||
{
|
||||
enum RotaryAction
|
||||
{
|
||||
Right,
|
||||
Left,
|
||||
Press,
|
||||
Idle
|
||||
};
|
||||
class ThreadManager
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
26
source/shoh/src/threads/rotary/Rotary.cpp
Normal file
26
source/shoh/src/threads/rotary/Rotary.cpp
Normal 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();
|
||||
}
|
||||
26
source/shoh/src/threads/rotary/Rotary.h
Normal file
26
source/shoh/src/threads/rotary/Rotary.h
Normal 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_ */
|
||||
Reference in New Issue
Block a user