fuuuuuuuu
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
// Created by rhetenor on 14.12.18.
|
||||
//
|
||||
|
||||
#include <thread>
|
||||
#include "output/detail/DisplayBoardPinController.h"
|
||||
|
||||
#include "DisplayBoardPinController.h"
|
||||
#include <thread>
|
||||
|
||||
#include "utility/config.h"
|
||||
|
||||
@@ -37,7 +37,7 @@ void DisplayBoardPinController::write_display(const items::OutputDisplay &displa
|
||||
{
|
||||
std::string content = display.get_content();
|
||||
|
||||
for(uint8_t i = 0; i < content.size(); i++)
|
||||
for (uint8_t i = 0; i < content.size(); i++)
|
||||
{
|
||||
write_display_digit(display.get_address(), content.at(i), i);
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ public:
|
||||
explicit DisplayBoardPinController(std::map<std::string, uint8_t> pins_display);
|
||||
~DisplayBoardPinController() override = default;
|
||||
|
||||
void activate_displays() const override;
|
||||
void deactivate_displays() const override;
|
||||
void activate_displays() const;
|
||||
void deactivate_displays() const;
|
||||
|
||||
void write_display(const items::OutputDisplay &display) const override;
|
||||
void write_display(const items::OutputDisplay &display) const;
|
||||
|
||||
private:
|
||||
void write_display_digit(uint8_t display_address, uint8_t content, uint8_t position) const;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#include "DisplayController.h"
|
||||
#include "output/detail/DisplayController.h"
|
||||
|
||||
#include "utility/config.h"
|
||||
|
||||
@@ -16,8 +16,10 @@ namespace output
|
||||
namespace detail
|
||||
{
|
||||
|
||||
DisplayController::DisplayController(std::vector<std::shared_ptr<items::OutputDisplay>> displays, std::unique_ptr<DisplayBoardPinController> pin_controller)
|
||||
: displays(std::move(displays)), pin_controller(std::move(pin_controller)), is_running(true)
|
||||
DisplayController::DisplayController(std::vector<std::shared_ptr<items::OutputDisplay>> displays,
|
||||
std::unique_ptr<DisplayBoardPinController> pin_controller
|
||||
)
|
||||
: displays(std::move(displays)), pin_controller(std::move(pin_controller)), is_running(true)
|
||||
{
|
||||
this->display_cycle_thread = std::thread(&DisplayController::cycle_displays, this);
|
||||
|
||||
@@ -35,9 +37,9 @@ DisplayController::~DisplayController()
|
||||
|
||||
void DisplayController::cycle_displays() const
|
||||
{
|
||||
while(is_running)
|
||||
while (is_running)
|
||||
{
|
||||
for(auto &display : this->displays)
|
||||
for (auto &display : this->displays)
|
||||
{
|
||||
pin_controller->write_display(*display);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by rhetenor on 14.12.18.
|
||||
//
|
||||
|
||||
#include "DriverBoardPinController.h"
|
||||
#include "output/detail/DriverBoardPinController.h"
|
||||
|
||||
#include "output/items/DriverBoardItem.h"
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
DriverBoardPinController::DriverBoardPinController(std::shared_ptr<std::mutex> output_item_mutex) :
|
||||
output_item_mutex(std::move(output_item_mutex))
|
||||
@@ -39,5 +41,6 @@ void DriverBoardPinController::write_pin(uint8_t pin, bool value) const
|
||||
PinController::write_pin(pin, value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
42
FlippR-Driver/src/output/detail/DriverBoardPinController.h
Normal file
42
FlippR-Driver/src/output/detail/DriverBoardPinController.h
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Created by rhetenor on 14.12.18.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_OUTPUT_IMPL_DRIVERBOARDPINCONTROLLER_H
|
||||
#define FLIPPR_DRIVER_OUTPUT_IMPL_DRIVERBOARDPINCONTROLLER_H
|
||||
|
||||
#include "output/DriverBoardPinController.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class DriverBoardPinController : public output::DriverBoardPinController
|
||||
{
|
||||
public:
|
||||
virtual ~DriverBoardPinController() = default;
|
||||
|
||||
DriverBoardPinController(std::shared_ptr<std::mutex> output_item_mutex);
|
||||
|
||||
void activate(items::DriverBoardItem & driver_board_item);
|
||||
void deactivate(items::DriverBoardItem & driver_board_item);
|
||||
|
||||
private:
|
||||
void write_pin(uint8_t pin, bool value) const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<std::mutex> output_item_mutex;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //FLIPPR_DRIVER_DRIVERBOARDPINCONTROLLER_H
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <boost/range/algorithm/copy.hpp>
|
||||
#include <thread>
|
||||
|
||||
#include "OutputDriver.h"
|
||||
#include "output/OutputDriver.h"
|
||||
|
||||
#include "utility/config.h"
|
||||
|
||||
@@ -17,13 +17,18 @@ namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
using namespace items;
|
||||
|
||||
OutputDriver::OutputDriver(std::unique_ptr<output::DisplayController> display_controller, std::map<std::string, std::shared_ptr<Solenoid>> solenoids, std::map<std::string, std::shared_ptr<Lamp>> lamps, std::map<std::string, std::shared_ptr<Sound>> sounds, std::map<uint8_t, std::shared_ptr<items::Display>> displays)
|
||||
: display_controller(std::move(display_controller)), solenoids(std::move(solenoids)), lamps(std::move(lamps)), sounds(std::move(sounds)), displays(std::move(displays))
|
||||
OutputDriver::OutputDriver(std::unique_ptr<output::DisplayController> display_controller, std::map<std::string, std::shared_ptr<Solenoid>> solenoids,
|
||||
std::map<std::string, std::shared_ptr<Lamp>> lamps, std::map<std::string, std::shared_ptr<Sound>> sounds,
|
||||
std::map<std::string, std::shared_ptr<items::Flipper>> flippers, std::map<uint8_t, std::shared_ptr<items::Display>> displays):
|
||||
display_controller(std::move(display_controller)),
|
||||
solenoids(std::move(solenoids)),
|
||||
lamps(std::move(lamps)),
|
||||
sounds(std::move(sounds)),
|
||||
flippers(std::move(flippers)),
|
||||
displays(std::move(displays))
|
||||
{
|
||||
CLOG(INFO, OUTPUT_LOGGER) << "Created OutputDriver";
|
||||
}
|
||||
@@ -61,6 +66,16 @@ void OutputDriver::rotate_all_lamps() const
|
||||
}
|
||||
}
|
||||
|
||||
void OutputDriver::activate_all_flipper_relays() const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OutputDriver::deactivate_all_flipper_relays() const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Sound>> OutputDriver::get_sounds() const
|
||||
{
|
||||
std::vector<std::shared_ptr<Sound>> sounds;
|
||||
@@ -89,6 +104,15 @@ std::vector<std::shared_ptr<Lamp>> OutputDriver::get_lamps() const
|
||||
return lamps;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<items::Flipper>> OutputDriver::get_flippers() const
|
||||
{
|
||||
std::vector<std::shared_ptr<Flipper>> flippers;
|
||||
|
||||
boost::copy(this->flippers | boost::adaptors::map_values, std::back_inserter(flippers));
|
||||
|
||||
return flippers;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Solenoid>> OutputDriver::get_solenoids() const
|
||||
{
|
||||
std::vector<std::shared_ptr<Solenoid>> solenoids;
|
||||
@@ -113,6 +137,11 @@ boost::optional<std::shared_ptr<items::Sound>> OutputDriver::get_sound(const std
|
||||
return this->sounds.find(name)->second;
|
||||
}
|
||||
|
||||
boost::optional<std::shared_ptr<items::Flipper>> OutputDriver::get_flipper(const std::string &name) const
|
||||
{
|
||||
return this->flippers.find(name)->second;
|
||||
}
|
||||
|
||||
boost::optional<std::shared_ptr<items::Display>> OutputDriver::get_display(uint8_t number) const
|
||||
{
|
||||
return this->displays.find(number)->second;
|
||||
@@ -121,4 +150,3 @@ boost::optional<std::shared_ptr<items::Display>> OutputDriver::get_display(uint8
|
||||
|
||||
}
|
||||
} /* namespace output */
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* OutputDriver.h
|
||||
*
|
||||
* Created on: Aug 2, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
||||
*/
|
||||
|
||||
#ifndef _SRC_OUTPUT_OUTPUTDRIVER_H_
|
||||
#define _SRC_OUTPUT_OUTPUTDRIVER_H_
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "output/OutputDriver.h"
|
||||
#include "output/DisplayController.h"
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
namespace output
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class OutputDriver : public output::OutputDriver
|
||||
{
|
||||
public:
|
||||
OutputDriver(std::unique_ptr<output::DisplayController> display_controller, std::map<std::string, std::shared_ptr<items::Solenoid>> solenoids,
|
||||
std::map<std::string, std::shared_ptr<items::Lamp>> lamps, std::map<std::string, std::shared_ptr<items::Sound>> sounds,
|
||||
std::map<uint8_t, std::shared_ptr<output::items::Display>> displays);
|
||||
|
||||
~OutputDriver() override = default;
|
||||
|
||||
void activate_displays() const override;
|
||||
void deactivate_displays() const override;
|
||||
|
||||
void activate_all_lamps() const override;
|
||||
void deactivate_all_lamps() const override;
|
||||
void rotate_all_lamps() const override;
|
||||
|
||||
void activate_flipper_relay();
|
||||
void activate_top_flipper_relay();
|
||||
void deactivate_flipper_relay();
|
||||
void deactivate_top_flipper_relay();
|
||||
|
||||
// todo driver board run for activate/deactivate?
|
||||
// todo what is flipper_relay ?
|
||||
std::vector<std::shared_ptr<items::Lamp>> get_lamps() const override;
|
||||
std::vector<std::shared_ptr<items::Solenoid>> get_solenoids() const override;
|
||||
std::vector<std::shared_ptr<items::Sound>> get_sounds() const override;
|
||||
std::vector<std::shared_ptr<items::Display>> get_displays() const override;
|
||||
|
||||
boost::optional<std::shared_ptr<items::Lamp>> get_lamp(const std::string &name) const override;
|
||||
boost::optional<std::shared_ptr<items::Solenoid>> get_solenoid(const std::string &name) const override;
|
||||
boost::optional<std::shared_ptr<items::Sound>> get_sound(const std::string &name) const override;
|
||||
boost::optional<std::shared_ptr<items::Display>> get_display(uint8_t number) const override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<output::DisplayController> display_controller;
|
||||
|
||||
const std::map<std::string, std::shared_ptr<items::Lamp>> lamps;
|
||||
const std::map<std::string, std::shared_ptr<items::Solenoid>> solenoids;
|
||||
const std::map<std::string, std::shared_ptr<items::Sound>> sounds;
|
||||
|
||||
const std::map<uint8_t, std::shared_ptr<items::Display>> displays;
|
||||
};
|
||||
|
||||
}
|
||||
} /* namespace output */
|
||||
}
|
||||
#endif
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by rhetenor on 14.12.18.
|
||||
//
|
||||
|
||||
#include "SoundBoardPinController.h"
|
||||
#include "output/detail/SoundBoardPinController.h"
|
||||
|
||||
#include "utility/config.h"
|
||||
|
||||
@@ -13,17 +13,13 @@ 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))
|
||||
SoundBoardPinController::SoundBoardPinController(std::shared_ptr<std::mutex> output_item_mutex,
|
||||
const uint8_t &fire_address
|
||||
) :
|
||||
output_item_mutex(std::move(output_item_mutex)),
|
||||
fire_address(fire_address)
|
||||
{
|
||||
uint8_t i2c_address = pins_sound.at("i2c_address");
|
||||
uint8_t pin_base = pins_sound.at("pin_base");
|
||||
|
||||
initialize_i2c_address(i2c_address, pin_base);
|
||||
initialize_pins_output(pin_base, pins_sound.begin(), pins_sound.end());
|
||||
|
||||
CLOG(INFO, OUTPUT_LOGGER) << "Created SoundBoardPinController with i2c_address 0x" << std::hex << i2c_address << " and pin_base " << std::dec << pin_base;
|
||||
|
||||
CLOG(INFO, OUTPUT_LOGGER) << "Created SoundBoardPinController";
|
||||
}
|
||||
|
||||
void SoundBoardPinController::activate(const items::detail::Sound &sound)
|
||||
@@ -45,27 +41,27 @@ void SoundBoardPinController::deactivate(const items::detail::Sound &sound)
|
||||
}
|
||||
|
||||
|
||||
void SoundBoardPinController::write_sound_address(uint8_t address) const
|
||||
void SoundBoardPinController::write_sound_address(const 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);
|
||||
// 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() const
|
||||
{
|
||||
PinController::write_pin(pins_sound.at("fire"), true);
|
||||
|
||||
PinController::write_pin(pins_sound.at("fire"), false);
|
||||
// PinController::write_pin(pins_sound.at("fire"), true);
|
||||
//
|
||||
// PinController::write_pin(pins_sound.at("fire"), false);
|
||||
}
|
||||
|
||||
void SoundBoardPinController::write_pin(uint8_t pin, bool value) const
|
||||
void SoundBoardPinController::write_pin(const uint8_t &pin, const bool &value) const
|
||||
{
|
||||
PinController::write_pin(pins_sound.at("pin_base") + pin, value);
|
||||
// PinController::write_pin(pins_sound.at("pin_base") + pin, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,23 +19,22 @@ namespace detail
|
||||
class SoundBoardPinController : public output::SoundBoardPinController
|
||||
{
|
||||
public:
|
||||
SoundBoardPinController(std::map<std::string, uint8_t> pins_sound, std::shared_ptr<std::mutex> output_item_mutex);
|
||||
SoundBoardPinController(std::shared_ptr<std::mutex> output_item_mutex, const uint8_t & fire_address);
|
||||
~SoundBoardPinController() override = default;
|
||||
|
||||
void activate(const items::detail::Sound &sound) override;
|
||||
void deactivate(const items::detail::Sound &sound) override;
|
||||
void activate(const items::detail::Sound &sound);
|
||||
void deactivate(const items::detail::Sound &sound);
|
||||
|
||||
private:
|
||||
void write_sound_address(uint8_t address) const;
|
||||
void write_sound_address(const uint8_t & address) const;
|
||||
void fire_sound() const;
|
||||
|
||||
void write_pin(uint8_t pin, bool value) const;
|
||||
void write_pin(const uint8_t & pin, const bool & value) const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<std::mutex> output_item_mutex;
|
||||
|
||||
const std::map<std::string, uint8_t> pins_sound;
|
||||
|
||||
uint8_t fire_address;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user