46 lines
725 B
C++
46 lines
725 B
C++
#include "mbed.h"
|
|
|
|
#pragma once
|
|
|
|
|
|
namespace serialization {
|
|
|
|
//! Receive commands from the Touch OSC layout through a NodeMCU
|
|
class RCProtocol
|
|
{
|
|
|
|
public:
|
|
|
|
struct Packet {
|
|
int16_t Throttle;
|
|
int16_t Steering;
|
|
|
|
int16_t Kp;
|
|
int16_t Ki;
|
|
int16_t Kd;
|
|
|
|
bool Enabled;
|
|
} __attribute__ ((__packed__));
|
|
|
|
RCProtocol();
|
|
|
|
void start();
|
|
|
|
//! Read the latest package
|
|
RCProtocol::Packet read();
|
|
|
|
//! Append a byte until we have a package to read.
|
|
//! Returns true when a hole package is available
|
|
bool appendByte(uint8_t newByte);
|
|
|
|
// static int size();
|
|
|
|
const static uint32_t MAGIC_WORD = 0xDEC0DED;
|
|
|
|
private:
|
|
|
|
RCProtocol::Packet m_packet;
|
|
|
|
};
|
|
|
|
} |