mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Skeleton work to factor out the encoder logic.
This commit is contained in:
22
lib/encoders/encoders.cc
Normal file
22
lib/encoders/encoders.cc
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user