renamed impl to detail
This commit is contained in:
62
FlippR-Driver/src/output/detail/SoundBoardPinController.cpp
Normal file
62
FlippR-Driver/src/output/detail/SoundBoardPinController.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// Created by rhetenor on 14.12.18.
|
||||
//
|
||||
|
||||
#include "SoundBoardPinController.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
SoundBoardPinController::SoundBoardPinController(std::map<std::string, uint8_t> pins_sound, std::shared_ptr<std::mutex> output_item_mutex) :
|
||||
pins_sound(std::move(pins_sound)), output_item_mutex(std::move(output_item_mutex))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SoundBoardPinController::activate(const items::detail::Sound &sound)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(*output_item_mutex);
|
||||
|
||||
write_sound_address(sound.get_address());
|
||||
|
||||
fire_sound(true);
|
||||
}
|
||||
|
||||
void SoundBoardPinController::deactivate(const items::detail::Sound &sound)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(*output_item_mutex);
|
||||
|
||||
write_sound_address(sound.get_address());
|
||||
|
||||
fire_sound(false);
|
||||
}
|
||||
|
||||
|
||||
void SoundBoardPinController::write_sound_address(uint8_t address) const
|
||||
{
|
||||
write_pin(pins_sound.at("A"), address & 0b0000001u);
|
||||
write_pin(pins_sound.at("B"), address & 0b0000010u);
|
||||
write_pin(pins_sound.at("C"), address & 0b0000100u);
|
||||
write_pin(pins_sound.at("D"), address & 0b0001000u);
|
||||
write_pin(pins_sound.at("E"), address & 0b0010000u);
|
||||
write_pin(pins_sound.at("F"), address & 0b0100000u);
|
||||
write_pin(pins_sound.at("G"), address & 0b1000000u);
|
||||
}
|
||||
|
||||
void SoundBoardPinController::fire_sound(bool fire) const
|
||||
{
|
||||
PinController::write_pin(pins_sound.at("fire"), fire);
|
||||
}
|
||||
|
||||
void SoundBoardPinController::write_pin(uint8_t pin, bool value) const
|
||||
{
|
||||
PinController::write_pin(pins_sound.at("pin_base") + pin, value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user