philsson 6f5fbc1ce5 RC Parser on UART implemented
The receiving end on the stm32.
TODO: Send back data to the NodeMCU
2018-09-17 21:09:21 +02:00

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;
};
}