fixed multiple events at a time

This commit is contained in:
Jonas Zeunert
2018-09-21 01:15:57 +02:00
parent 96e76f7180
commit 3f771d275e
2 changed files with 8 additions and 7 deletions

View File

@@ -37,8 +37,8 @@ void Detector::detect()
{
while(this->is_running)
{
char address;
if(this->check_inputs(address))
std::vector<char> detected_addresses = check_inputs();
for(auto& address : detected_addresses)
{
try
{
@@ -55,18 +55,18 @@ void Detector::detect()
}
}
bool Detector::check_inputs(char& address)
std::vector<char> Detector::check_inputs()
{
std::vector<char> detected_addresses;
for(char pin = 0; pin < (INPUT_MATRIX_SIZE * INPUT_MATRIX_SIZE); pin++)
{
if(input_gpio_interface->read_data(pin))
{
CLOG(TRACE, INPUT_LOGGER) << "Pin " << std::to_string(pin) << " is triggered.";
address = pin;
return true;
detected_addresses.push_back(pin);
}
}
return false;
return detected_addresses;
}
}

View File

@@ -16,6 +16,7 @@
#include <thread>
#include <vector>
#include <map>
#include "utilities/IInputGPIOInterface.h"
@@ -38,7 +39,7 @@ public:
private:
void detect();
bool check_inputs(char& address);
std::vector<char> check_inputs();
private:
std::unique_ptr<IInputGPIOInterface> input_gpio_interface;