refactored matrix_config to input_config
This commit is contained in:
@@ -42,32 +42,32 @@ void InputGPIOInterface::write_col(char data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InputGPIOInterface::InputGPIOInterface(std::istream& matrix_config_stream)
|
InputGPIOInterface::InputGPIOInterface(std::istream& input_config_stream)
|
||||||
{
|
{
|
||||||
init_members(matrix_config_stream);
|
init_members(input_config_stream);
|
||||||
|
|
||||||
init_pins();
|
init_pins();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputGPIOInterface::init_members(std::istream &matrix_config_stream)
|
void InputGPIOInterface::init_members(std::istream &input_config_stream)
|
||||||
{
|
{
|
||||||
json matrix_config;
|
json input_config;
|
||||||
matrix_config_stream >> matrix_config;
|
input_config_stream >> input_config;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
json matrix_config_input = matrix_config.at("input");
|
json matrix_config_input = input_config.at("input");
|
||||||
|
|
||||||
json row_json = matrix_config.at("row");
|
json row_json = input_config.at("row");
|
||||||
row_address_A = row_json.at("A").get<json::number_integer_t>();
|
row_address_A = row_json.at("A").get<json::number_integer_t>();
|
||||||
row_address_B = row_json.at("B").get<json::number_integer_t>();
|
row_address_B = row_json.at("B").get<json::number_integer_t>();
|
||||||
row_address_C = row_json.at("C").get<json::number_integer_t>();
|
row_address_C = row_json.at("C").get<json::number_integer_t>();
|
||||||
|
|
||||||
json col_json = matrix_config.at("col");
|
json col_json = input_config.at("col");
|
||||||
col_address_A = col_json.at("A").get<json::number_integer_t>();
|
col_address_A = col_json.at("A").get<json::number_integer_t>();
|
||||||
col_address_B = col_json.at("B").get<json::number_integer_t>();
|
col_address_B = col_json.at("B").get<json::number_integer_t>();
|
||||||
col_address_C = col_json.at("C").get<json::number_integer_t>();
|
col_address_C = col_json.at("C").get<json::number_integer_t>();
|
||||||
|
|
||||||
data_address = matrix_config.at("data").get<nlohmann::json::number_integer_t>();
|
data_address = input_config.at("data").get<nlohmann::json::number_integer_t>();
|
||||||
} catch (json::type_error& e) {
|
} catch (json::type_error& e) {
|
||||||
CLOG(ERROR, INPUT_LOGGER) << "ERROR";
|
CLOG(ERROR, INPUT_LOGGER) << "ERROR";
|
||||||
} catch (json::out_of_range& e) {
|
} catch (json::out_of_range& e) {
|
||||||
|
|||||||
@@ -15,11 +15,11 @@
|
|||||||
class InputGPIOInterface : public IInputGPIOInterface, GPIOInterface
|
class InputGPIOInterface : public IInputGPIOInterface, GPIOInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InputGPIOInterface(std::istream& matrix_config_stream);
|
InputGPIOInterface(std::istream& input_config_stream);
|
||||||
bool read_data(char pin);
|
bool read_data(char pin);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init_members(std::istream& matrix_config_stream);
|
void init_members(std::istream& input_config_stream);
|
||||||
void init_pins();
|
void init_pins();
|
||||||
void write_row(char data);
|
void write_row(char data);
|
||||||
void write_col(char data);
|
void write_col(char data);
|
||||||
|
|||||||
Reference in New Issue
Block a user