fixed multiple events at a time
This commit is contained in:
@@ -37,8 +37,8 @@ void Detector::detect()
|
|||||||
{
|
{
|
||||||
while(this->is_running)
|
while(this->is_running)
|
||||||
{
|
{
|
||||||
char address;
|
std::vector<char> detected_addresses = check_inputs();
|
||||||
if(this->check_inputs(address))
|
for(auto& address : detected_addresses)
|
||||||
{
|
{
|
||||||
try
|
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++)
|
for(char pin = 0; pin < (INPUT_MATRIX_SIZE * INPUT_MATRIX_SIZE); pin++)
|
||||||
{
|
{
|
||||||
if(input_gpio_interface->read_data(pin))
|
if(input_gpio_interface->read_data(pin))
|
||||||
{
|
{
|
||||||
CLOG(TRACE, INPUT_LOGGER) << "Pin " << std::to_string(pin) << " is triggered.";
|
CLOG(TRACE, INPUT_LOGGER) << "Pin " << std::to_string(pin) << " is triggered.";
|
||||||
address = pin;
|
detected_addresses.push_back(pin);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return detected_addresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "utilities/IInputGPIOInterface.h"
|
#include "utilities/IInputGPIOInterface.h"
|
||||||
@@ -38,7 +39,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void detect();
|
void detect();
|
||||||
bool check_inputs(char& address);
|
std::vector<char> check_inputs();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<IInputGPIOInterface> input_gpio_interface;
|
std::unique_ptr<IInputGPIOInterface> input_gpio_interface;
|
||||||
|
|||||||
Reference in New Issue
Block a user