Changed displays from id to name

This commit is contained in:
Johannes Wendel
2020-01-09 22:33:23 +01:00
parent ebf5a158b5
commit 1333445bf5
12 changed files with 28 additions and 35 deletions

View File

@@ -10,7 +10,6 @@
#include "output/items/detail/SevenDigitDisplay.h"
#include "DisplayFactory.h"
namespace flippR_driver
{
namespace output
@@ -29,13 +28,13 @@ std::map<std::string, std::shared_ptr<items::Display>> DisplayFactory::getItemMa
auto displays = this->object.at(config_path::display_list);
for (auto & display : displays)
{
auto id = display.at(config_path::item_identifier).get<uint8_t>();
auto name = display.at(config_path::item_name).get<std::string>();
auto address = display.at(config_path::item_address).get<uint8_t>();
auto digits = display.at(config_path::display_digits).get<uint8_t>();
if (digits == 8)
display_map.emplace(std::string{static_cast<char>(id)}, std::dynamic_pointer_cast<items::Display>(std::make_shared<items::detail::EightDigitDisplay>(address, id)));
display_map.emplace(name, std::dynamic_pointer_cast<items::Display>(std::make_shared<items::detail::EightDigitDisplay>(address, name)));
else if (digits == 7)
display_map.emplace(std::string{static_cast<char>(id)}, std::dynamic_pointer_cast<items::Display>(std::make_shared<items::detail::SevenDigitDisplay>(address, id)));
display_map.emplace(name, std::dynamic_pointer_cast<items::Display>(std::make_shared<items::detail::SevenDigitDisplay>(address, name)));
else
throw new std::logic_error{"Display digits can either be 7 or 8"};
}
@@ -47,12 +46,6 @@ void DisplayFactory::create_pin_map()
nlohmann::json board_config = this->object.at(config_path::display_board);
this->pin_map["run"] = board_config.at(config_path::run_pin);
nlohmann::json display_select = board_config.at(config_path::display_select);
for(int i = 1; i < 6; i++)
{
this->pin_map["display_select" + std::to_string(i)] = display_select.at(std::to_string(i));
}
nlohmann::json segment_select = board_config.at(config_path::display_segement_select);
this->pin_map["segment_select_A"] = segment_select.at("A");
this->pin_map["segment_select_B"] = segment_select.at("B");