written output item logic
This commit is contained in:
@@ -64,6 +64,7 @@ void Display<DigitCount>::write_content( std::array<char, DigitCount> content)
|
||||
<int DigitCount>
|
||||
std::vector<char> Display<DigitCount>::get_content()
|
||||
{
|
||||
// todo: expensive?
|
||||
return std::vector<char>(content, content + DigitCount);
|
||||
}
|
||||
|
||||
|
||||
25
FlippR-Driver/src/output/items/IDriverBoardItem.h
Normal file
25
FlippR-Driver/src/output/items/IDriverBoardItem.h
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by rhetenor on 23.11.18.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_IDRIVERBOARDITEM_H
|
||||
#define FLIPPR_DRIVER_IDRIVERBOARDITEM_H
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace items
|
||||
{
|
||||
|
||||
class IDriverBoardItem : public IItem
|
||||
{
|
||||
virtual ~IDriverBoardItem()
|
||||
{};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //FLIPPR_DRIVER_IDRIVERBOARDITEM_H
|
||||
@@ -11,20 +11,18 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
|
||||
OutputItem::OutputItem(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin_address, std::string name) :
|
||||
Item::Item(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, u_int8_t address, std::string name) :
|
||||
address(address),
|
||||
i2c_address(i2c_address),
|
||||
data_pin_address(data_pin_address),
|
||||
name(name),
|
||||
output_gpio_interface(output_gpio_interface)
|
||||
{}
|
||||
|
||||
void OutputItem::activate()
|
||||
void Item::activate()
|
||||
{
|
||||
output_gpio_interface->activate_output_item(this);
|
||||
}
|
||||
|
||||
void OutputItem::deactivate()
|
||||
void Item::deactivate()
|
||||
{
|
||||
output_gpio_interface->deactivate_output_item(this);
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
|
||||
class OutputItem : public IOutputItem
|
||||
class Item : public IItem
|
||||
{
|
||||
public:
|
||||
OutputItem(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, u_int8_t address, std::string name);
|
||||
virtual ~OutputItem();
|
||||
Item(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, u_int8_t address, std::string name);
|
||||
virtual ~Item();
|
||||
|
||||
public:
|
||||
const u_int8_t address;
|
||||
|
||||
@@ -16,18 +16,18 @@ namespace items
|
||||
|
||||
Lamp::Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, unsigned int i2c_address, unsigned int address, unsigned int data_pin, std::string name)
|
||||
:
|
||||
OutputItem(output_gpio_interface, address, i2c_address, data_pin, name),
|
||||
Item(output_gpio_interface, address, i2c_address, data_pin, name),
|
||||
activated(false)
|
||||
{}
|
||||
|
||||
void Lamp::activate()
|
||||
{
|
||||
OutputItem::activate();
|
||||
Item::activate();
|
||||
}
|
||||
|
||||
void Lamp::deactivate()
|
||||
{
|
||||
OutputItem::deactivate();
|
||||
Item::deactivate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
|
||||
class Lamp : public OutputItem, ILamp
|
||||
class Lamp : public Item, ILamp
|
||||
{
|
||||
public:
|
||||
Lamp(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, u_int8_t address, std::string name);
|
||||
|
||||
@@ -17,17 +17,17 @@ namespace items
|
||||
{
|
||||
|
||||
Solenoid::Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin, std::string name, std::chrono::milliseconds deactivation_time):
|
||||
OutputItem(output_gpio_interface, address, i2c_address, data_pin, name),
|
||||
Item(output_gpio_interface, address, i2c_address, data_pin, name),
|
||||
deactivation_time(deactivation_time)
|
||||
{}
|
||||
|
||||
void Solenoid::triggerTask()
|
||||
{
|
||||
OutputItem::activate();
|
||||
Item::activate();
|
||||
|
||||
std::this_thread::sleep_for(deactivation_time);
|
||||
|
||||
OutputItem::deactivate();
|
||||
Item::deactivate();
|
||||
}
|
||||
|
||||
void Solenoid::trigger()
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
|
||||
class Solenoid : public OutputItem, ISolenoid
|
||||
class Solenoid : public Item, ISolenoid
|
||||
{
|
||||
public:
|
||||
Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin, std::string name, std::chrono::milliseconds deactivation_time);
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace items
|
||||
{
|
||||
|
||||
Sound::Sound(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin, std::string name, std::chrono::milliseconds deactivation_time) :
|
||||
OutputItem(output_gpio_interface, address, i2c_address, data_pin, name),
|
||||
Item(output_gpio_interface, address, i2c_address, data_pin, name),
|
||||
deactivation_time(deactivation_time)
|
||||
{}
|
||||
|
||||
@@ -28,11 +28,11 @@ void Sound::play()
|
||||
|
||||
void Sound::playTask()
|
||||
{
|
||||
OutputItem::activate();
|
||||
Item::activate();
|
||||
|
||||
std::this_thread::sleep_for(deactivation_time);
|
||||
|
||||
OutputItem::deactivate();
|
||||
Item::deactivate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace output
|
||||
namespace items
|
||||
{
|
||||
|
||||
class Sound : public ISound, OutputItem
|
||||
class Sound : public ISound, Item
|
||||
{
|
||||
public:
|
||||
Sound(std::shared_ptr<utility::IOutputGPIOInterface> output_gpio_interface, unsigned int address, unsigned int i2c_address, unsigned int data_pin, std::string name, std::chrono::milliseconds deactivation_time);
|
||||
|
||||
Reference in New Issue
Block a user