Fixes some issues with sounds and the appropriate factory. Further moved the calculation of pin addresses with pin base into the factories
This commit is contained in:
@@ -33,8 +33,6 @@ std::map<std::string, std::shared_ptr<items::Sound>> SoundFactory::getItemMap()
|
||||
{
|
||||
auto name = sound.at(config_path::item_name).get<std::string>();
|
||||
auto address = sound.at(config_path::item_address).get<uint8_t >();
|
||||
auto extender = sound.at(config_path::item_extender).get<std::string>();
|
||||
auto pin_base = this->get_extender_pin_base(extender);
|
||||
auto id = sound.at(config_path::item_identifier).get<uint>();
|
||||
|
||||
std::chrono::milliseconds deactivation_time_chrono{this->deactivation_time};
|
||||
@@ -42,7 +40,7 @@ std::map<std::string, std::shared_ptr<items::Sound>> SoundFactory::getItemMap()
|
||||
{
|
||||
deactivation_time_chrono = std::chrono::milliseconds{sound.at(config_path::deactivation_time).get<uint8_t>()};
|
||||
}
|
||||
auto sound_item = std::make_shared<items::detail::Sound>(std::static_pointer_cast<SoundBoardPinController>(this->pin_controller), address, pin_base, name, deactivation_time_chrono, id);
|
||||
auto sound_item = std::make_shared<items::detail::Sound>(std::static_pointer_cast<SoundBoardPinController>(this->pin_controller), address, name, deactivation_time_chrono, id);
|
||||
|
||||
sound_map.emplace(name, sound_item);
|
||||
}
|
||||
@@ -67,9 +65,21 @@ void SoundFactory::set_address_pins()
|
||||
|
||||
std::vector<uint8_t> pins;
|
||||
|
||||
for (auto & pin : address_pins)
|
||||
for (auto & pin_json : address_pins)
|
||||
{
|
||||
pins.push_back(pin.get<uint8_t>());
|
||||
pins.push_back(0);
|
||||
}
|
||||
for (auto & pin_json : address_pins)
|
||||
{
|
||||
uint8_t pin = pin_json.at(config_path::item_address).get<uint8_t>();
|
||||
if (pin_json.find(config_path::item_extender) != pin_json.end())
|
||||
{
|
||||
auto extender_name = pin_json.at(config_path::item_extender).get<std::string>();
|
||||
pin += this->get_extender_pin_base(extender_name);
|
||||
}
|
||||
uint8_t id = pin_json.at(config_path::item_identifier).get<uint8_t>();
|
||||
|
||||
pins[id] = pin;
|
||||
}
|
||||
|
||||
std::dynamic_pointer_cast<detail::SoundBoardPinController>(this->pin_controller)->set_address_pins(pins);
|
||||
|
||||
Reference in New Issue
Block a user