mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Move the flx stuff into external.
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
#include "lib/core/globals.h"
|
||||
#include "lib/data/fluxmap.h"
|
||||
#include "lib/external/kryoflux.h"
|
||||
#include "protocol.h"
|
||||
#include "lib/fluxsource/flx.h"
|
||||
|
||||
std::unique_ptr<Fluxmap> readFlxBytes(const Bytes& bytes)
|
||||
{
|
||||
ByteReader br(bytes);
|
||||
|
||||
/* Skip header. */
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (br.eof())
|
||||
error("malformed FLX stream");
|
||||
uint8_t b = br.read_8();
|
||||
if (b == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
auto fluxmap = std::make_unique<Fluxmap>();
|
||||
while (!br.eof())
|
||||
{
|
||||
uint8_t b = br.read_8();
|
||||
switch (b)
|
||||
{
|
||||
case FLX_INDEX:
|
||||
fluxmap->appendIndex();
|
||||
continue;
|
||||
|
||||
case FLX_STOP:
|
||||
goto stop;
|
||||
|
||||
default:
|
||||
{
|
||||
if (b < 32)
|
||||
error("unknown FLX opcode 0x{:2x}", b);
|
||||
nanoseconds_t interval = b * FLX_TICK_NS;
|
||||
fluxmap->appendInterval(interval / NS_PER_TICK);
|
||||
fluxmap->appendPulse();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
stop:
|
||||
|
||||
return fluxmap;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#ifndef FLX_H
|
||||
#define FLX_H
|
||||
|
||||
#define FLX_TICK_NS 40 /* ns per tick */
|
||||
|
||||
/* Special FLX opcodes */
|
||||
|
||||
enum
|
||||
{
|
||||
FLX_INDEX = 0x08,
|
||||
FLX_STOP = 0x0d
|
||||
};
|
||||
|
||||
extern std::unique_ptr<Fluxmap> readFlxBytes(const Bytes& bytes);
|
||||
|
||||
#endif
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "lib/data/fluxmap.h"
|
||||
#include "lib/fluxsource/fluxsource.pb.h"
|
||||
#include "lib/fluxsource/fluxsource.h"
|
||||
#include "lib/fluxsource/flx.h"
|
||||
#include "lib/external/flx.h"
|
||||
|
||||
class FlxFluxSource : public TrivialFluxSource
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user