Skeleton work to factor out the encoder logic.

This commit is contained in:
David Given
2019-08-03 22:30:30 +02:00
parent 8e1774c69f
commit 973f4c2c2d
8 changed files with 18 additions and 1 deletions

22
lib/encoders/encoders.cc Normal file
View File

@@ -0,0 +1,22 @@
#include "globals.h"
#include "fluxmap.h"
#include "protocol.h"
Fluxmap& Fluxmap::appendBits(const std::vector<bool>& bits, nanoseconds_t clock)
{
nanoseconds_t now = duration();
for (unsigned i=0; i<bits.size(); i++)
{
now += clock;
if (bits[i])
{
unsigned delta = (now - duration()) / NS_PER_TICK;
appendInterval(delta);
appendPulse();
}
}
return *this;
}