Merge branch 'master' of github.com:swinginbird/flippr-code

This commit is contained in:
Johannes Wendel
2020-01-09 21:27:30 +01:00
4 changed files with 10 additions and 16 deletions

View File

@@ -1,5 +1,4 @@
{ {
"deactivation_time_milliseconds" : 10,
"port_extenders" : "port_extenders" :
[ [
{ {
@@ -53,11 +52,15 @@
], ],
"sounds" : "sounds" :
[ [
{
"id" : 255,
"address" : 0,
"name" : "Deactivation Sound"
}
{ {
"id" : 0, "id" : 0,
"address" : 22, "address" : 22,
"name" : "Sound 1", "name" : "Sound 1",
"deactivation_time_milliseconds" : 10
}, },
{ {
"id" : 1, "id" : 1,
@@ -148,7 +151,7 @@
"id" : 18, "id" : 18,
"address" : 40, "address" : 40,
"name" : "Sound 19" "name" : "Sound 19"
}, },84.4932%
{ {
"id" : 19, "id" : 19,
"address" : 41, "address" : 41,

View File

@@ -63,15 +63,12 @@ void SoundBoardPinController::write_sound_address(const uint8_t &address) const
void SoundBoardPinController::fire_sound() const void SoundBoardPinController::fire_sound() const
{ {
PinController::write_pin(this->fire_address, true); PinController::write_pin(this->fire_address, true);
PinController::write_pin(this->fire_address, false); PinController::write_pin(this->fire_address, false);
} }
void SoundBoardPinController::write_pin(const uint8_t &pin, const bool &value) const void SoundBoardPinController::write_pin(const uint8_t &pin, const bool &value) const
{ {
PinController::write_pin(pin, value); PinController::write_pin(pin, value);
PinController::write_pin(this->fire_address, true);
PinController::write_pin(this->fire_address, false);
} }
void SoundBoardPinController::set_address_pins(std::vector<uint8_t> address_pins) void SoundBoardPinController::set_address_pins(std::vector<uint8_t> address_pins)

View File

@@ -20,10 +20,10 @@ namespace items
namespace detail namespace detail
{ {
Sound::Sound(std::shared_ptr<SoundBoardPinController> pin_controller, const uint8_t & address, const std::string & name, const std::chrono::milliseconds & deactivation_time, const u_int id) Sound::Sound(std::shared_ptr<SoundBoardPinController> pin_controller, const uint8_t & address, const std::string & name, const u_int id)
: detail::Item(std::move(name)), DriverBoardItem(pin_controller, address), pin_controller(std::move(pin_controller)), deactivation_time(deactivation_time), id(id) : detail::Item(std::move(name)), DriverBoardItem(pin_controller, address), pin_controller(std::move(pin_controller)), id(id)
{ {
CLOG(DEBUG, OUTPUT_LOGGER) << "Created sound " << id << " \"" << name << "\" with address " << int(address) << ". Deactivation time is: " << deactivation_time.count(); CLOG(DEBUG, OUTPUT_LOGGER) << "Created sound " << id << " \"" << name << "\" with address " << int(address);
} }
void Sound::play() void Sound::play()
@@ -35,10 +35,6 @@ void Sound::play()
void Sound::playTask() void Sound::playTask()
{ {
pin_controller->activate(*this); pin_controller->activate(*this);
std::this_thread::sleep_for(deactivation_time);
pin_controller->deactivate(*this);
} }
} }

View File

@@ -35,14 +35,12 @@ public:
u_int id; u_int id;
public: public:
Sound(std::shared_ptr<SoundBoardPinController> pin_controller, const uint8_t & address, const std::string & name, const std::chrono::milliseconds & deactivation_time, const u_int id); Sound(std::shared_ptr<SoundBoardPinController> pin_controller, const uint8_t & address, const std::string & name, const u_int id);
~Sound() override = default; ~Sound() override = default;
void play() override; void play() override;
private: private:
const std::chrono::milliseconds deactivation_time;
const std::shared_ptr<SoundBoardPinController> pin_controller; const std::shared_ptr<SoundBoardPinController> pin_controller;
std::future<void> play_task; std::future<void> play_task;