Lamp factory adaption

This commit is contained in:
Johannes Wendel
2020-01-15 16:17:06 +01:00
parent e32659a3e6
commit a4ccf2103d
7 changed files with 60 additions and 6 deletions

View File

@@ -6,6 +6,7 @@
*/
#include <output/items/Lamp.h>
#include <output/detail/DriverBoardPinController.h>
#include "LampFactory.h"
#include "output/items/detail/Lamp.h"
@@ -35,5 +36,28 @@ std::map<std::string, std::shared_ptr<items::Lamp>> LampFactory::getItemMap()
return lamp_map;
}
void LampFactory::set_address_pins()
{
auto address_pins = this->object.at(config_path::address_pins);
std::array<uint8_t, 3> pins;
pins.at(0) = address_pins.at("A0");
pins.at(1) = address_pins.at("A1");
pins.at(2) = address_pins.at("A2");
std::dynamic_pointer_cast<detail::DriverBoardPinController>(this->pin_controller)->set_address_pins(pins);
}
uint8_t LampFactory::get_address_pin(nlohmann::json & pin_object)
{
auto address = pin_object.at(config_path::item_address).get<uint8_t>();
auto extender = pin_object.at(config_path::item_extender).get<std::string>();
auto pin_base = this->get_extender_pin_base(extender);
return address + pin_base;
}
}
}