Impelements and integrates DisplayFactory. Further does some refactoring

This commit is contained in:
Johannes Wendel
2020-01-06 12:42:04 +01:00
parent 10b200e4e4
commit fda8197a26
21 changed files with 192 additions and 127 deletions

View File

@@ -4,8 +4,9 @@
* Created on: December 28, 2019
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#include <output/SoundBoardPinController.h>
#include "SoundFactory.h"
namespace flippR_driver
{
namespace output
@@ -19,6 +20,9 @@ SoundFactory::SoundFactory(nlohmann::json &object, std::shared_ptr<SoundBoardPin
{
this->deactivation_time = object.at(config_path::deactivation_time).get<uint8_t>();
}
this->set_fire_pin();
this->set_address_pins();
}
std::map<std::string, std::shared_ptr<items::Item>> SoundFactory::getItemMap()
@@ -45,5 +49,31 @@ std::map<std::string, std::shared_ptr<items::Item>> SoundFactory::getItemMap()
return sound_map;
}
void SoundFactory::set_fire_pin()
{
auto fire_pin = object.at(config_path::fire_pin);
auto fire_pin_address = fire_pin.at(config_path::item_address).get<uint8_t>();
if (fire_pin.find(config_path::item_extender) != fire_pin.end())
{
auto extender_name = fire_pin.at(config_path::item_extender).get<std::string>();
fire_pin_address += this->get_extender_pin_base(extender_name);
}
std::dynamic_pointer_cast<detail::SoundBoardPinController>(this->pin_controller)->set_fire_address(fire_pin_address);
}
void SoundFactory::set_address_pins()
{
auto address_pins = object.at(config_path::sound_address_pins);
std::vector<uint8_t> pins;
for (auto & pin : address_pins)
{
pins.push_back(pin.get<uint8_t>());
}
std::dynamic_pointer_cast<detail::SoundBoardPinController>(this->pin_controller)->set_address_pins(pins);
}
}
}