Finished LampFactory
This commit is contained in:
@@ -15,7 +15,35 @@ namespace output
|
||||
Factory::Factory(nlohmann::json &object) :
|
||||
object{object}
|
||||
{
|
||||
this->initialize_port_extenders();
|
||||
this->port_extenders = this->object.at("port_extenders");
|
||||
}
|
||||
|
||||
void Factory::initialize_port_extender(nlohmann::json &extender)
|
||||
{
|
||||
auto i2c_address = extender.at("i2c_address").get<uint8_t>();
|
||||
auto pin_base = extender.at("pin_base").get<uint8_t>();
|
||||
this->pin_controller->initialize_port_expander(i2c_address, pin_base);
|
||||
}
|
||||
|
||||
void Factory::initialize_port_extenders()
|
||||
{
|
||||
for (auto extender : port_extenders)
|
||||
{
|
||||
this->initialize_port_extender(extender);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t Factory::get_extender_pin_base(std::string &name)
|
||||
{
|
||||
for (auto extender : port_extenders)
|
||||
{
|
||||
if (extender.at("name").get<std::string>() == name)
|
||||
{
|
||||
return extender.at("pin_base").get<uint8_t>();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user