Added libheptaled
This commit is contained in:
parent
b2da04a840
commit
5229158dd9
|
@ -0,0 +1 @@
|
|||
--std=c++11
|
|
@ -0,0 +1,27 @@
|
|||
OBJDIR = bin
|
||||
|
||||
CXX = clang++
|
||||
CXXFLAGS = --std=c++11
|
||||
LDFLAGS =
|
||||
|
||||
|
||||
$(OBJDIR)/display.o : common.h digit.h display.h display.cpp
|
||||
|
||||
all : start $(OBJDIR)/display.o
|
||||
@echo ":: Done !"
|
||||
|
||||
start :
|
||||
@echo " LibHeptaled"
|
||||
@echo "============="
|
||||
@echo ":: Building using $(CXX)"
|
||||
|
||||
$(OBJDIR)/%.o : %.cpp Makefile
|
||||
mkdir -p $$(dirname $@)
|
||||
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/$(TARGET) : $(OBJDIR)/$(TARGET).o
|
||||
$(CXX) $+ $(LDFLAGS) -o $@
|
||||
|
||||
clean :
|
||||
@rm -rf $(OBJDIR)
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef COMMON_H
|
||||
#define COMMON_H COMMON_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace HeptaLed {
|
||||
|
||||
typedef std::vector<uint8_t> ByteBuffer;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef DIGIT_H
|
||||
#define DIGIT_H DIGIT_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
namespace HeptaLed {
|
||||
|
||||
|
||||
class Digit {
|
||||
public:
|
||||
virtual void render(std::string::const_iterator stringIt, ByteBuffer::iterator const& bufferIt) = 0;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,26 @@
|
|||
#include "display.h"
|
||||
|
||||
namespace HeptaLed {
|
||||
|
||||
Display& Display::add(std::shared_ptr<Digit> digit) {
|
||||
digits.push_back(digit);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
ByteBuffer Display::render(std::string const& s) {
|
||||
ByteBuffer buffer(digits.size());
|
||||
|
||||
std::string::const_iterator stringIt = s.begin();
|
||||
ByteBuffer::iterator byteIt = buffer.begin();
|
||||
|
||||
for(DigitVector::iterator it = digits.begin(); it != digits.end(); ++it) {
|
||||
(*it)->render(stringIt,byteIt);
|
||||
++byteIt;
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef DISPLAY_H
|
||||
#define DISPLAY_H DISPLAY_H
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "digit.h"
|
||||
|
||||
namespace HeptaLed {
|
||||
|
||||
typedef std::vector<std::shared_ptr<Digit>> DigitVector;
|
||||
|
||||
class Display {
|
||||
|
||||
public:
|
||||
Display& add(std::shared_ptr<Digit> digit);
|
||||
ByteBuffer render(std::string const& s);
|
||||
|
||||
private:
|
||||
DigitVector digits;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue