working on big refactor
This commit is contained in:
56
FlippR-Driver/src/output/impl/SoundBoardPinController.cpp
Normal file
56
FlippR-Driver/src/output/impl/SoundBoardPinController.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// Created by rhetenor on 14.12.18.
|
||||
//
|
||||
|
||||
#include "SoundBoardPinController.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
|
||||
void SoundBoardPinController::activate(items::Sound &sound)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(output_item_mutex);
|
||||
|
||||
write_sound_address(sound->get_address());
|
||||
|
||||
fire_sound(true);
|
||||
}
|
||||
|
||||
void SoundBoardPinController::deactivate(items::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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
PinController::write_pin(pins_sound.at("fire"), fire);
|
||||
}
|
||||
|
||||
void SoundBoardPinController::write_pin(uint8_t pin, bool value)
|
||||
{
|
||||
PinController::write_pin(pins_sound.at("pin_base") + pin, value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user