commenting and fixing bugs

This commit is contained in:
Jonas Zeunert
2018-05-07 18:50:17 +02:00
parent 23f04f472f
commit 744f25c19c
2 changed files with 19 additions and 4 deletions

View File

@@ -27,8 +27,8 @@ Detector::~Detector()
{
is_running = false;
detect_thread.join();
notify_thread.join();
detect_thread.join();
}
void Detector::register_input_event_handler(InputEventHandler* handler)
@@ -61,12 +61,13 @@ void Detector::notify_handlers()
LOCK_EVENT_HANDLER();
for(auto* handler : event_handler)
{
// todo timeout!
handler->handle(event);
}
}
}
// Cycles over all inputs and enqueues an input event if detected.
void Detector::detect()
{
while(is_running)
@@ -74,12 +75,20 @@ void Detector::detect()
char address;
if(check_inputs(address))
{
InputEvent& event = input_events.at(address);
event_queue.emplace(event);
try
{
InputEvent& event = input_events.at(address);
event_queue.emplace(event);
}
catch(std::out_of_range& e)
{
// todo log exception!
}
}
}
}
// todo work with gpiointerface
bool Detector::check_inputs(char& address)
{
for(int row = 0; row < 8; row++)

View File

@@ -1,6 +1,12 @@
/*
* Detector.h
*
* Responsible for detecting InputEvents.
*
* Creates two Threads;
* One cycles over the inputs gpios and pushes detected input events to a queue.
* The other cycles over the queue and notifies input event handlers.
*
* Created on: Apr 5, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/