fixed multiple events at a time
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user