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