70 lines
1.6 KiB
C++
70 lines
1.6 KiB
C++
/*
|
|
* OutputGPIOInterface.h
|
|
*
|
|
* Created on: May 31, 2018
|
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
|
*/
|
|
|
|
#ifndef SRC_UTILITIES_OUTPUTGPIOINTERFACE_H_
|
|
#define SRC_UTILITIES_OUTPUTGPIOINTERFACE_H_
|
|
|
|
#include "IOutputGPIOInterface.h"
|
|
#include "GPIOInterface.h"
|
|
|
|
#include "output/items/IItem.h"
|
|
|
|
#include "json/json.hpp"
|
|
|
|
#include <mcp23017.h>
|
|
#include <mutex>
|
|
#include <map>
|
|
|
|
namespace flippR_driver
|
|
{
|
|
namespace output
|
|
{
|
|
|
|
class OutputGPIOInterface : public GPIOInterface, public IOutputGPIOInterface
|
|
{
|
|
|
|
public:
|
|
OutputGPIOInterface(std::map<std::string, uint8_t> pins_driver_board, std::map<std::string, uint8_t> pins_sound, std::map<std::string, uint8_t> pins_display);
|
|
|
|
~OutputGPIOInterface() override = default;
|
|
|
|
void activate(items::IItem *driver_board_item) override;
|
|
void activate(items::ISoundItem *sound) override;
|
|
|
|
void deactivate(items::IItem *driver_board_item) override;
|
|
void deactivate(items::ISoundItem *sound) override;
|
|
|
|
void write_display(std::shared_ptr<output::items::IDisplay> display) override;
|
|
|
|
private:
|
|
void initialize_i2c_addresses();
|
|
|
|
void initialize_pins();
|
|
void initialize_all_pins(uint8_t pin_base);
|
|
|
|
void write_driver_board_address(uint8_t address);
|
|
void select_mux(uint8_t latch);
|
|
void select_latch(uint8_t latch);
|
|
void select_pin(uint8_t pin);
|
|
void write_data(bool data);
|
|
|
|
void write_sound_address(uint8_t address);
|
|
void fire_sound(bool fire);
|
|
|
|
private:
|
|
std::mutex output_item_mutex;
|
|
|
|
const std::map<std::string, uint8_t> pins_driver_board;
|
|
const std::map<std::string, uint8_t> pins_sound;
|
|
const std::map<std::string, uint8_t> pins_display;
|
|
};
|
|
|
|
}
|
|
}
|
|
|
|
#endif
|