display dependencies
This commit is contained in:
@@ -54,7 +54,7 @@ std::shared_ptr<OutputDriver> get_OutputDriver(std::istream &output_pin_config,
|
||||
auto displays = create_displays(display_config);
|
||||
|
||||
// todo
|
||||
std::vector<std::shared_ptr<items::Display>> displays_vec;
|
||||
std::vector<std::shared_ptr<items::OutputDisplay>> displays_vec;
|
||||
boost::copy(displays | boost::adaptors::map_values, std::back_inserter(displays_vec));
|
||||
std::unique_ptr<DisplayController> display_controller(new impl::DisplayController(displays_vec, std::move(display_board_pin_controller)));
|
||||
|
||||
@@ -256,14 +256,14 @@ std::shared_ptr<items::impl::Sound> create_sound(nlohmann::json &sound_json, std
|
||||
}
|
||||
}
|
||||
|
||||
std::map<uint8_t, std::shared_ptr<items::Display>> create_displays(std::istream &display_config)
|
||||
std::map<uint8_t, std::shared_ptr<items::OutputDisplay>> create_displays(std::istream &display_config)
|
||||
{
|
||||
std::map<uint8_t, std::shared_ptr<items::Display>> displays;
|
||||
std::map<uint8_t, std::shared_ptr<items::OutputDisplay>> displays;
|
||||
|
||||
json display_config_json;
|
||||
display_config >> display_config_json;
|
||||
|
||||
json displays_json = display_config_json.at('displays');
|
||||
json displays_json = display_config_json.at("displays");
|
||||
for(json &display_json : displays_json)
|
||||
{
|
||||
auto display = create_display(display_json);
|
||||
@@ -272,7 +272,7 @@ std::map<uint8_t, std::shared_ptr<items::Display>> create_displays(std::istream
|
||||
return displays;
|
||||
}
|
||||
|
||||
std::shared_ptr<items::Display> create_display(nlohmann::json &display_json)
|
||||
std::shared_ptr<items::OutputDisplay> create_display(nlohmann::json &display_json)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -286,19 +286,18 @@ std::shared_ptr<items::Display> create_display(nlohmann::json &display_json)
|
||||
}
|
||||
else if(digits == 7)
|
||||
{
|
||||
return std::make_shared<items::impl::SevenDigitDisplay(address, id);
|
||||
return std::make_shared<items::impl::SevenDigitDisplay>(address, id);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new std::logic_error("Display digits can either be 7 or 8");
|
||||
}
|
||||
|
||||
}
|
||||
catch(json::exception &e)
|
||||
{
|
||||
// todo log
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
return std::shared_ptr<items::Display>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user