wrote display stuff and refactored thousend things
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "ICabinetItem.h"
|
||||
|
||||
#include "utilities/IOutputGPIOInterface.h"
|
||||
#include "utility/IOutputGPIOInterface.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -23,7 +23,7 @@ namespace output
|
||||
class CabinetItem : public ICabinetItem
|
||||
{
|
||||
public:
|
||||
CabinetItem(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
CabinetItem(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
virtual ~CabinetItem();
|
||||
|
||||
virtual bool isActivated();
|
||||
@@ -39,4 +39,4 @@ protected:
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -2,11 +2,53 @@
|
||||
// Created by rhetenor on 10.10.18.
|
||||
//
|
||||
|
||||
#include "Display.h"
|
||||
#include "utility/config.h"
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace FlippR_Driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
template<int DigitCount>
|
||||
Display<DigitCount>::Display(int address, int id) :
|
||||
address(address),
|
||||
id(id)
|
||||
{
|
||||
}
|
||||
|
||||
template<int DigitCount>
|
||||
int Display<DigitCount>::getID()
|
||||
{
|
||||
return this->id;
|
||||
}
|
||||
|
||||
template<int DigitCount>
|
||||
void Display<DigitCount>::write_score(int score)
|
||||
{
|
||||
auto score_string = std::to_string(score);
|
||||
auto score_length = score_string.length();
|
||||
if (score_length > DigitCount)
|
||||
{
|
||||
CLOG(DEBUG, OUTPUT_LOGGER) << "Score too long for display";
|
||||
this->content = score_string.substr(score_length-DigitCount,score_length);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string spaces;
|
||||
std::generate_n(spaces.begin(), DigitCount-score_length, []{return " ";});
|
||||
this->content = spaces + score_string;
|
||||
}
|
||||
|
||||
template<int DigitCount>
|
||||
void Display<DigitCount>::write_content( std::array<char, DigitCount> content)
|
||||
{
|
||||
this->content = content;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ template <int DigitCount>
|
||||
class Display : public IDisplay
|
||||
{
|
||||
public:
|
||||
Display();
|
||||
Display(int address, int id);
|
||||
virtual ~Display() = default;
|
||||
|
||||
virtual int getID();
|
||||
@@ -38,4 +38,5 @@ private:
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace FlippR_Driver
|
||||
namespace output
|
||||
{
|
||||
|
||||
DisplayController::DisplayController(std::vector<std::shared_ptr<IDisplay>> displays, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface)
|
||||
DisplayController::DisplayController(std::vector<std::shared_ptr<IDisplay>> displays, std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface)
|
||||
: displays(displays), output_gpio_interface(output_gpio_interface), is_running(true)
|
||||
{
|
||||
this->display_cycle_thread = std::thread(&DisplayController::cycle_displays, this);
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace output
|
||||
class DisplayController : public IDisplayController
|
||||
{
|
||||
public:
|
||||
explicit DisplayController(std::vector<std::shared_ptr<IDisplay>> displays, std::shared_ptr<IOutputGPIOInterface> output_gpio_interface);
|
||||
explicit DisplayController(std::vector<std::shared_ptr<IDisplay>> displays, std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface);
|
||||
~DisplayController();
|
||||
|
||||
private:
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
|
||||
std::thread display_cycle_thread;
|
||||
|
||||
std::shared_ptr<IOutputGPIOInterface> output_gpio_interface;
|
||||
std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface;
|
||||
|
||||
bool is_running;
|
||||
};
|
||||
|
||||
@@ -20,10 +20,8 @@ public:
|
||||
virtual ~IDisplay();
|
||||
|
||||
virtual int getID() = 0;
|
||||
|
||||
virtual void write() = 0;
|
||||
};
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace FlippR_Driver
|
||||
namespace output
|
||||
{
|
||||
|
||||
Lamp::Lamp()
|
||||
Lamp::Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name) :
|
||||
CabinetItem(output_gpio_interface, address, name)
|
||||
{
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
@@ -24,4 +25,4 @@ Lamp::~Lamp()
|
||||
}
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace output
|
||||
class Lamp : public CabinetItem
|
||||
{
|
||||
public:
|
||||
Lamp();
|
||||
virtual ~Lamp();
|
||||
Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
virtual ~Lamp();
|
||||
};
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -11,12 +11,15 @@ namespace FlippR_Driver
|
||||
{
|
||||
namespace output {
|
||||
|
||||
Solenoid::Solenoid() {
|
||||
Solenoid::Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name) :
|
||||
CabinetItem(output_gpio_interface, address, name)
|
||||
{
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
}
|
||||
|
||||
Solenoid::~Solenoid() {
|
||||
Solenoid::~Solenoid()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace output
|
||||
class Solenoid : public CabinetItem
|
||||
{
|
||||
public:
|
||||
Solenoid();
|
||||
virtual ~Solenoid();
|
||||
Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
virtual ~Solenoid();
|
||||
};
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -12,14 +12,14 @@ namespace FlippR_Driver
|
||||
namespace output
|
||||
{
|
||||
|
||||
Sound::Sound(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, int address, std::string name)
|
||||
: output_gpio_interface(output_gpio_interface), address(address), name(name)
|
||||
Sound::Sound(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name) :
|
||||
output_gpio_interface(output_gpio_interface), address(address), name(name)
|
||||
{}
|
||||
|
||||
void Sound::play()
|
||||
{
|
||||
this->output_gpio_interface->activate(this);
|
||||
// this->output_gpio_interface->activate(this);
|
||||
}
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "utilities/IOutputGPIOInterface.h"
|
||||
#include "utility/IOutputGPIOInterface.h"
|
||||
|
||||
namespace FlippR_Driver
|
||||
{
|
||||
@@ -23,13 +23,13 @@ namespace output
|
||||
class Sound : ISound
|
||||
{
|
||||
public:
|
||||
Sound(std::shared_ptr<IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
Sound(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
virtual ~Sound() = default;
|
||||
|
||||
virtual void play();
|
||||
|
||||
private:
|
||||
std::shared_ptr<IOutputGPIOInterface> output_gpio_interface;
|
||||
std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface;
|
||||
|
||||
int address;
|
||||
std::string name;
|
||||
@@ -37,4 +37,4 @@ private:
|
||||
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user