![](/media/cache/group/Racelogic_Blue_Logo.jpg.50x50_q85.jpg)
I messed up the merge, so pushing it over to another repo so I don't lose it. Will tidy up and remove later
Dependencies: BufferedSerial FatFileSystemCpp mbed
Diff: VIPSSerialProtocol.h
- Revision:
- 35:7ecf25d9c414
- Parent:
- 18:ad407a2ed4c9
- Child:
- 65:8ee40ed9295b
- Child:
- 66:066b16c6c34f
--- a/VIPSSerialProtocol.h Wed Aug 04 16:43:45 2021 +0000 +++ b/VIPSSerialProtocol.h Thu Aug 05 13:44:45 2021 +0000 @@ -4,33 +4,62 @@ #include "mbed.h" #include "position.h" #include "BufferedSerial.h" +#include "LTCApp.h" +#include "LowPassFilter.h" extern const char* VIPSStatusMessages[]; +struct UserSettings_s; -class VIPSSerial { +class VIPSSerial +{ -public: +public: VIPSSerial(const PinName Tx, const PinName Rx); void run(void); + bool setFilters(struct UserSettings_s *settings); // send all position outputs rather than just when requested. void sendAllUpdated(bool enable); // send a position output for the requested time. Times are based on the global TimeSinceLastFrame timer. position* sendPositionForTime(uint32_t timeValue); - position* getWaitingPostion() {position *ptr = outputPtr; outputPtr=NULL; return ptr;} + position* getWaitingPostion() + { + position *ptr = outputPtr; + outputPtr=NULL; + return ptr; + } static void getCRC(void *data, int len, void *checksum); // void setOutMask(uint32_t outputMask) {_outputMask = outputMask;}; - bool EnableSmoothing(bool enabled) { hyperSmoothEnabled = enabled; return hyperSmoothEnabled;}; - bool SmoothingEnabled(void) { return hyperSmoothEnabled;}; + bool EnableSmoothing(bool enabled) + { + hyperSmoothEnabled = enabled; + return hyperSmoothEnabled; + }; + bool SmoothingEnabled(void) + { + return hyperSmoothEnabled; + }; - int GetSmoothLevel(void) { return SmoothBy; }; - bool SetSmoothLevel (const int newSmooth) { if (newSmooth == SmoothBy) return false; SmoothBy = newSmooth; SmoothRunning = false; return true; }; - void EnableBypass(bool enable) { BypassMode = enable;}; + int GetSmoothLevel(void) + { + return SmoothBy; + }; + bool SetSmoothLevel (const int newSmooth) + { + if (newSmooth == SmoothBy) return false; + SmoothBy = newSmooth; + SmoothRunning = false; + return true; + }; + void EnableBypass(bool enable) + { + BypassMode = enable; + }; void bypassTx(char byte); void sendQueued(void); @@ -55,8 +84,8 @@ bool checkNewPacketRC(unsigned char* data); RawSerial _port; unsigned char messageInBuffer[128]; - unsigned char messageOutBuffer[16]; - #define posHistoryLen 3 + unsigned char messageOutBuffer[16]; +#define posHistoryLen 3 struct posAndTime_s lastPositions[posHistoryLen]; int nextPosition; struct posAndTime_s lastPos; // the most recent position received @@ -76,14 +105,18 @@ int queueLen; int SmoothBy; - // total as a float we would start to see rounding errors at valuses of ~20m + // total as a float we would start to see rounding errors at valuses of ~20m double XSmoothTotal; double YSmoothTotal; double ZSmoothTotal; bool SmoothRunning; bool BypassMode; - - + LowPassFilter yFilter; + LowPassFilter xFilter; + LowPassFilter zFilter; + LowPassFilter rollFilter; + LowPassFilter pitchFilter; + LowPassFilter yawFilter; }; #endif