Files
flippr-code/FlippR-Driver/src/output/items/detail/Sound.cpp
2019-12-20 16:23:37 +01:00

48 lines
1.1 KiB
C++

/*
* Sound.cpp
*
* Created on: Aug 2, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#include "Sound.h"
#include <output/SoundBoardPinController.h>
#include "utility/config.h"
namespace flippR_driver
{
namespace output
{
namespace items
{
namespace detail
{
Sound::Sound(std::shared_ptr<SoundBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name, const std::chrono::milliseconds & deactivation_time, const u_int id)
: detail::Item(std::move(name)), DriverBoardItem(pin_controller, address, pin_base), pin_controller(std::move(pin_controller)), deactivation_time(deactivation_time), id(id)
{
//CLOG(INFO , OUTPUT_LOGGER) << "Created sound \"" << name << "\" with pin-base " << int(pin_base) << " and address " << int(address);
}
void Sound::play()
{
CLOG(INFO, OUTPUT_LOGGER) << "Play Sound " << id << " " << name;
this->play_task = std::async(std::launch::async, &Sound::playTask, this);
}
void Sound::playTask()
{
pin_controller->activate(*this);
std::this_thread::sleep_for(deactivation_time);
pin_controller->deactivate(*this);
}
}
}
} /* namespace output */
}