//
// Created by rhetenor on 14.12.18.
//

#ifndef FLIPPR_DRIVER_OUTPUT_IMPL_DISPLAYPINCONTROLLER_H
#define FLIPPR_DRIVER_OUTPUT_IMPL_DISPLAYPINCONTROLLER_H

#include "output/DisplayBoardPinController.h"

#include <map>

namespace flippR_driver
{
namespace output
{
namespace detail
{

class DisplayBoardPinController : public output::DisplayBoardPinController
{
public:
  explicit DisplayBoardPinController(std::map<std::string, uint8_t> pins_display);
  ~DisplayBoardPinController() override = default;

  void activate_displays() const;
  void deactivate_displays() const;

  void write_display(const items::OutputDisplay &display) const;

private:
  void write_display_digit(uint8_t display_address, uint8_t content, uint8_t position) const;
  void select_display_segment(uint8_t digit) const;
  void select_display_digit(uint8_t content) const;
  void run_display(uint8_t address) const;

private:
  const std::map<std::string, uint8_t> pins_display_board;
};

}
}
}
#endif //FLIPPR_DRIVER_DISPLAYPINCONTROLLER_H
