wrote display stuff and refactored thousend things

This commit is contained in:
Johannes Wendel
2018-11-08 00:42:31 +01:00
parent b94fb345c1
commit 8e4b7391b0
35 changed files with 203 additions and 119 deletions

View File

@@ -2,11 +2,53 @@
// Created by rhetenor on 10.10.18.
//
#include "Display.h"
#include "utility/config.h"
#include <string>
#include <algorithm>
namespace FlippR_Driver
{
namespace output
{
template<int DigitCount>
Display<DigitCount>::Display(int address, int id) :
address(address),
id(id)
{
}
template<int DigitCount>
int Display<DigitCount>::getID()
{
return this->id;
}
template<int DigitCount>
void Display<DigitCount>::write_score(int score)
{
auto score_string = std::to_string(score);
auto score_length = score_string.length();
if (score_length > DigitCount)
{
CLOG(DEBUG, OUTPUT_LOGGER) << "Score too long for display";
this->content = score_string.substr(score_length-DigitCount,score_length);
return;
}
std::string spaces;
std::generate_n(spaces.begin(), DigitCount-score_length, []{return " ";});
this->content = spaces + score_string;
}
template<int DigitCount>
void Display<DigitCount>::write_content( std::array<char, DigitCount> content)
{
this->content = content;
}
}
}
}