Merge branch 'master' of https://github.com/swinginbird/flippr-code
This commit is contained in:
@@ -14,6 +14,7 @@ namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
class IDisplay
|
||||
{
|
||||
|
||||
@@ -21,9 +22,6 @@ public:
|
||||
IDisplay();
|
||||
virtual ~IDisplay();
|
||||
|
||||
virtual void write_score(int score) = 0;
|
||||
virtual void write_content(std::array<char, DigitCount> content) = 0;
|
||||
|
||||
virtual int getID() = 0;
|
||||
|
||||
private:
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace flippR_driver
|
||||
namespace output
|
||||
{
|
||||
|
||||
Lamp::Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name, bool activated) :
|
||||
OutputItem(output_gpio_interface, address, name),
|
||||
Lamp::Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int i2c_address, int data_pin, std::string name, bool activated) :
|
||||
OutputItem(output_gpio_interface, i2c_address, data_pin, name),
|
||||
activated(activated)
|
||||
{
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
@@ -9,16 +9,17 @@
|
||||
#define _SRC_OUTPUT_LAMP_H_
|
||||
|
||||
#include "OutputItem.h"
|
||||
#include "ILamp.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
|
||||
class Lamp : public OutputItem
|
||||
class Lamp : public OutputItem, ILamp
|
||||
{
|
||||
public:
|
||||
Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name, bool activated = false);
|
||||
Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int i2c_address, int data_pin, std::string name, bool activated = false);
|
||||
virtual ~Lamp();
|
||||
|
||||
void activate();
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace output
|
||||
class OutputItem : public IOutputItem
|
||||
{
|
||||
public:
|
||||
OutputItem(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
OutputItem(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int i2c_address, int data_pin_address, std::string name);
|
||||
virtual ~OutputItem();
|
||||
|
||||
protected:
|
||||
int address, i2c_address, data_pin_address;
|
||||
int i2c_address, data_pin_address;
|
||||
std::string name;
|
||||
|
||||
std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface;
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace flippR_driver
|
||||
{
|
||||
namespace output {
|
||||
|
||||
Solenoid::Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name, std::chrono::milliseconds deactivation_time) :
|
||||
OutputItem(output_gpio_interface, address, name),
|
||||
Solenoid::Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int i2c_address, int data_pin, std::string name, std::chrono::milliseconds deactivation_time) :
|
||||
OutputItem(output_gpio_interface, i2c_address, data_pin, name),
|
||||
deactivation_time(deactivation_time)
|
||||
{
|
||||
// TODO Auto-generated constructor stub
|
||||
@@ -26,9 +26,8 @@ Solenoid::~Solenoid()
|
||||
|
||||
void Solenoid::trigger()
|
||||
{
|
||||
// activate
|
||||
// wait
|
||||
// deactivate
|
||||
this->activate();
|
||||
this->wait_thread = std::async(this->deactivate_after_wait);
|
||||
}
|
||||
|
||||
void Solenoid::activate()
|
||||
@@ -36,6 +35,13 @@ void Solenoid::activate()
|
||||
|
||||
}
|
||||
|
||||
void Solenoid::deactivate_after_wait()
|
||||
{
|
||||
this->std::this_thread::sleep_for(deactivation_time);
|
||||
this->deactivate();
|
||||
|
||||
}
|
||||
|
||||
void Solenoid::deactivate()
|
||||
{
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#define _SRC_OUTPUT_SOLENOID_H_
|
||||
|
||||
#include "OutputItem.h"
|
||||
#include "ISolenoid.h"
|
||||
|
||||
#include <future>
|
||||
#include <thread>
|
||||
@@ -19,10 +20,10 @@ namespace flippR_driver
|
||||
namespace output
|
||||
{
|
||||
|
||||
class Solenoid : public OutputItem
|
||||
class Solenoid : public ISolenoid, OutputItem
|
||||
{
|
||||
public:
|
||||
Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name, std::chrono::milliseconds deactivation_time);
|
||||
Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int i2c_address, int data_pin, std::string name, std::chrono::milliseconds deactivation_time);
|
||||
virtual ~Solenoid();
|
||||
|
||||
//muss task sein
|
||||
@@ -34,6 +35,8 @@ private:
|
||||
|
||||
void activate();
|
||||
void deactivate();
|
||||
|
||||
void deactivate_after_wait();
|
||||
};
|
||||
|
||||
} /* namespace output */
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace flippR_driver
|
||||
namespace output
|
||||
{
|
||||
|
||||
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)
|
||||
Sound::Sound(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int i2c_address, int data_pin, std::string name) :
|
||||
OutputItem(output_gpio_interface, i2c_address, data_pin, name)
|
||||
{}
|
||||
|
||||
void Sound::play()
|
||||
|
||||
@@ -20,19 +20,15 @@ namespace flippR_driver
|
||||
namespace output
|
||||
{
|
||||
|
||||
class Sound : ISound
|
||||
class Sound : public ISound, OutputItem
|
||||
{
|
||||
public:
|
||||
Sound(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int address, std::string name);
|
||||
Sound(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, int i2c_address, int data_pin, std::string name);
|
||||
virtual ~Sound() = default;
|
||||
|
||||
virtual void play();
|
||||
|
||||
private:
|
||||
std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface;
|
||||
|
||||
int address;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
} /* namespace output */
|
||||
|
||||
Reference in New Issue
Block a user