Changed displays from id to name
This commit is contained in:
@@ -21,7 +21,7 @@ class SevenDigitDisplay : public virtual Display
|
|||||||
public:
|
public:
|
||||||
virtual ~SevenDigitDisplay() = default;
|
virtual ~SevenDigitDisplay() = default;
|
||||||
|
|
||||||
virtual void write_content(std::string content) = 0;
|
virtual void write_content(std::string & content) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#include "output/items/detail/SevenDigitDisplay.h"
|
#include "output/items/detail/SevenDigitDisplay.h"
|
||||||
#include "DisplayFactory.h"
|
#include "DisplayFactory.h"
|
||||||
|
|
||||||
|
|
||||||
namespace flippR_driver
|
namespace flippR_driver
|
||||||
{
|
{
|
||||||
namespace output
|
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);
|
auto displays = this->object.at(config_path::display_list);
|
||||||
for (auto & display : displays)
|
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 address = display.at(config_path::item_address).get<uint8_t>();
|
||||||
auto digits = display.at(config_path::display_digits).get<uint8_t>();
|
auto digits = display.at(config_path::display_digits).get<uint8_t>();
|
||||||
if (digits == 8)
|
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)
|
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
|
else
|
||||||
throw new std::logic_error{"Display digits can either be 7 or 8"};
|
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);
|
nlohmann::json board_config = this->object.at(config_path::display_board);
|
||||||
this->pin_map["run"] = board_config.at(config_path::run_pin);
|
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);
|
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_A"] = segment_select.at("A");
|
||||||
this->pin_map["segment_select_B"] = segment_select.at("B");
|
this->pin_map["segment_select_B"] = segment_select.at("B");
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace output
|
|||||||
class DisplayFactory : ItemFactory
|
class DisplayFactory : ItemFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit DisplayFactory(nlohmann::json & object, std::shared_ptr<DisplayBoardPinController> pin_controller);
|
DisplayFactory(nlohmann::json & object, std::shared_ptr<DisplayBoardPinController> pin_controller);
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<items::Display>> getItemMap();
|
std::map<std::string, std::shared_ptr<items::Display>> getItemMap();
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace output
|
|||||||
class FlipperFactory : ItemFactory
|
class FlipperFactory : ItemFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit FlipperFactory(nlohmann::json & object, std::shared_ptr<DriverBoardPinController> pin_controller);
|
FlipperFactory(nlohmann::json & object, std::shared_ptr<DriverBoardPinController> pin_controller);
|
||||||
std::map <std::string, std::shared_ptr<items::Flipper>> getItemMap();
|
std::map <std::string, std::shared_ptr<items::Flipper>> getItemMap();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace output
|
|||||||
class LampFactory : ItemFactory
|
class LampFactory : ItemFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit LampFactory(nlohmann::json & object, std::shared_ptr<DriverBoardPinController> pin_controller);
|
LampFactory(nlohmann::json & object, std::shared_ptr<DriverBoardPinController> pin_controller);
|
||||||
std::map<std::string, std::shared_ptr<items::Lamp>> getItemMap();
|
std::map<std::string, std::shared_ptr<items::Lamp>> getItemMap();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace output
|
|||||||
class SolenoidFactory : public ItemFactory
|
class SolenoidFactory : public ItemFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit SolenoidFactory(nlohmann::json &object, std::shared_ptr<DriverBoardPinController> pin_controller);
|
SolenoidFactory(nlohmann::json &object, std::shared_ptr<DriverBoardPinController> pin_controller);
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<items::Solenoid>> getItemMap();
|
std::map<std::string, std::shared_ptr<items::Solenoid>> getItemMap();
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace output
|
|||||||
class SoundFactory : ItemFactory
|
class SoundFactory : ItemFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit SoundFactory(nlohmann::json & object, std::shared_ptr<SoundBoardPinController> pin_controller);
|
SoundFactory(nlohmann::json & object, std::shared_ptr<SoundBoardPinController> pin_controller);
|
||||||
std::map<std::string, std::shared_ptr<items::Sound>> getItemMap();
|
std::map<std::string, std::shared_ptr<items::Sound>> getItemMap();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public:
|
|||||||
virtual ~OutputDisplay() = default;
|
virtual ~OutputDisplay() = default;
|
||||||
|
|
||||||
virtual uint8_t get_address() const = 0;
|
virtual uint8_t get_address() const = 0;
|
||||||
virtual uint8_t get_id() const = 0;
|
virtual std::string get_name() const = 0;
|
||||||
virtual std::string get_content() const = 0;
|
virtual std::string get_content() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -17,16 +17,16 @@ namespace items
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
Display::Display(const uint8_t & address, const uint8_t & id) :
|
Display::Display(const uint8_t & address, const std::string & name) :
|
||||||
address(address),
|
address{address},
|
||||||
id(id)
|
name{name}
|
||||||
{
|
{
|
||||||
CLOG(DEBUG, OUTPUT_LOGGER) << "Created display with id " << int{id} << " and address " << int{address} << ".";
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created display " << name << " with address " << int{address} << ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Display::get_id() const
|
std::string Display::get_name() const
|
||||||
{
|
{
|
||||||
return this->id;
|
return this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display::write_score(const unsigned int & score, const unsigned int & length)
|
void Display::write_score(const unsigned int & score, const unsigned int & length)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace detail
|
|||||||
class Display : public virtual items::OutputDisplay
|
class Display : public virtual items::OutputDisplay
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Display(const uint8_t & address, const uint8_t & id);
|
Display(const uint8_t & address, const std::string & name);
|
||||||
virtual ~Display() = default;
|
virtual ~Display() = default;
|
||||||
|
|
||||||
void write_score(const unsigned int & score, const unsigned int & length);
|
void write_score(const unsigned int & score, const unsigned int & length);
|
||||||
@@ -32,7 +32,7 @@ public:
|
|||||||
|
|
||||||
std::string get_content() const override;
|
std::string get_content() const override;
|
||||||
uint8_t get_address() const override;
|
uint8_t get_address() const override;
|
||||||
uint8_t get_id() const override;
|
std::string get_name() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string fit_score_string(std::string & score_string, const unsigned int & length);
|
std::string fit_score_string(std::string & score_string, const unsigned int & length);
|
||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
std::string content;
|
std::string content;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const uint8_t id;
|
const std::string name;
|
||||||
const uint8_t address;
|
const uint8_t address;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ namespace detail
|
|||||||
class EightDigitDisplay : public virtual items::detail::Display, public virtual items::EightDigitDisplay
|
class EightDigitDisplay : public virtual items::detail::Display, public virtual items::EightDigitDisplay
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EightDigitDisplay(uint8_t address, uint8_t id) :
|
EightDigitDisplay(const uint8_t & address, const std::string & name) :
|
||||||
detail::Display(address, id)
|
detail::Display(address, name)
|
||||||
{
|
{
|
||||||
CLOG(DEBUG, OUTPUT_LOGGER) << "Created EightDigitDisplay with address " << int{this->address} << " and id: " << int{id};
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created EightDigitDisplay " << name << " with address " << int{this->address};
|
||||||
}
|
}
|
||||||
|
|
||||||
~EightDigitDisplay() override = default;
|
~EightDigitDisplay() override = default;
|
||||||
@@ -43,7 +43,7 @@ public:
|
|||||||
|
|
||||||
std::string get_name() const override
|
std::string get_name() const override
|
||||||
{
|
{
|
||||||
return "EightDigitDisplay " + this->id;
|
return "EightDigitDisplay " + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,17 +21,17 @@ namespace detail
|
|||||||
class SevenDigitDisplay : public virtual items::detail::Display, public virtual items::SevenDigitDisplay
|
class SevenDigitDisplay : public virtual items::detail::Display, public virtual items::SevenDigitDisplay
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SevenDigitDisplay(uint8_t address, uint8_t id) :
|
SevenDigitDisplay(const uint8_t & address, const std::string & name) :
|
||||||
detail::Display(address, id)
|
detail::Display(address, name)
|
||||||
{
|
{
|
||||||
CLOG(DEBUG, OUTPUT_LOGGER) << "Created SevenDigitDisplay with address " << int{this->address} << " and id: " << int{id};
|
CLOG(DEBUG, OUTPUT_LOGGER) << "Created SevenDigitDisplay " << name << " with address " << int{this->address};
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_score(unsigned int score) override
|
void write_score(unsigned int score) override
|
||||||
{
|
{
|
||||||
detail::Display::write_score(score, 7);
|
detail::Display::write_score(score, 7);
|
||||||
}
|
}
|
||||||
void write_content(std::string content) override
|
void write_content(std::string & content) override
|
||||||
{
|
{
|
||||||
detail::Display::write_content(content, 7);
|
detail::Display::write_content(content, 7);
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ public:
|
|||||||
|
|
||||||
std::string get_name() const override
|
std::string get_name() const override
|
||||||
{
|
{
|
||||||
return "EightDigitDisplay " + this->id;
|
return "EightDigitDisplay " + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user