* The code is a mess for now. I'm not sure if there is any reason to send a whole event to UI, it's better to send InterfaceWithData. * Sending to queue from Menu isn't great as well.
This commit is contained in:
parent
cd84528e61
commit
f0bbfb22ab
@ -8,8 +8,8 @@
|
||||
#include "Manager.h"
|
||||
#include "ThreadCommon.h"
|
||||
|
||||
Manager::Manager(ThreadCommon::QueueManager* qm, Menu * menu)
|
||||
: _qm(qm), _menu(menu)
|
||||
Manager::Manager(ThreadCommon::QueueManager* qm)
|
||||
: _qm(qm), _menu{qm}
|
||||
{
|
||||
}
|
||||
|
||||
@ -43,13 +43,12 @@ void Manager::taskFunction()
|
||||
{
|
||||
_qm->receive<Event>(ThreadCommon::QueueManager::manager_event_master, &data, portMAX_DELAY);
|
||||
event_pair= this->parseEvent(&data);
|
||||
_menu->HandleEventPair(&event_pair);
|
||||
_menu.HandleEventPair(&event_pair);
|
||||
}
|
||||
}
|
||||
|
||||
void thread_manager(void* pvParams)
|
||||
{
|
||||
Menu menu;
|
||||
Manager m(static_cast<ThreadCommon::QueueManager*>(pvParams), &menu);
|
||||
Manager m(static_cast<ThreadCommon::QueueManager*>(pvParams));
|
||||
m.taskFunction();
|
||||
}
|
||||
|
||||
@ -16,13 +16,13 @@
|
||||
|
||||
class Manager {
|
||||
public:
|
||||
Manager(ThreadCommon::QueueManager* qm, Menu * menu);
|
||||
Manager(ThreadCommon::QueueManager* qm);
|
||||
virtual ~Manager();
|
||||
void taskFunction();
|
||||
private:
|
||||
Event::EventPair parseEvent(Event* e);
|
||||
ThreadCommon::QueueManager* _qm;
|
||||
Menu* _menu;
|
||||
Menu _menu;
|
||||
|
||||
EventRawData rotary_action;
|
||||
};
|
||||
|
||||
@ -7,8 +7,10 @@
|
||||
|
||||
#include "Menu.h"
|
||||
#include <assert.h>
|
||||
#include "UserInterface.h"
|
||||
|
||||
Menu::Menu(): current(&Menu::sInitView), set_point(0, 100, 1),
|
||||
Menu::Menu(ThreadCommon::QueueManager* qm): _qm(qm),
|
||||
current(&Menu::sInitView), set_point(0, 100, 1),
|
||||
main_text ("CURRENT %2d DESIRED %2d "),
|
||||
set_point_text("CURRENT %2d DESIRED[%2d] ")
|
||||
{
|
||||
@ -164,4 +166,7 @@ void Menu::HandleObj (const MenuObjEvent &event)
|
||||
void Menu::NotifyAndRefreshUI (const char *str)
|
||||
{
|
||||
//Send string on a queue to UI task.
|
||||
UserInterface::InterfaceWithData ud = {UserInterface::LCD1, *str};
|
||||
Event * p_e = new Event(Event::EventType::NotifyUI, *(reinterpret_cast<EventRawData*>(&ud)));
|
||||
this->_qm->send<Event>(ThreadCommon::QueueManager::ui_event_manager, p_e, portMAX_DELAY);
|
||||
}
|
||||
@ -19,12 +19,13 @@ typedef void (Menu::*p_state) (const MenuObjEvent &);
|
||||
class Menu
|
||||
{
|
||||
public:
|
||||
Menu ();
|
||||
Menu (ThreadCommon::QueueManager* qm);
|
||||
virtual ~Menu ();
|
||||
void HandleEventPair (Event::EventPair *ep);
|
||||
|
||||
private:
|
||||
/* Variables and objects */
|
||||
ThreadCommon::QueueManager* _qm;
|
||||
p_state current;
|
||||
int ext_temp;
|
||||
Counter<EventRawData> set_point;
|
||||
|
||||
@ -32,7 +32,7 @@ void UserInterface::taskFunction()
|
||||
|
||||
for (;;)
|
||||
{
|
||||
this->_qm->receive(ThreadCommon::QueueManager::ui_event_manager, &data, portMAX_DELAY);
|
||||
this->_qm->receive<Event>(ThreadCommon::QueueManager::ui_event_manager, &data, portMAX_DELAY);
|
||||
//Don't mind the type, we care only about the raw_data.
|
||||
EventRawData ed = data.getDataOf(Event::NotifyUI);
|
||||
if(ed != ERROR_RETURN)
|
||||
|
||||
@ -23,7 +23,7 @@ public:
|
||||
|
||||
union InterfaceData
|
||||
{
|
||||
char str[64];
|
||||
const char str[64];
|
||||
};
|
||||
|
||||
struct InterfaceWithData
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user