diff --git a/.gitmodules b/.gitmodules index 60f5e9c..59dc600 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,3 +2,6 @@ path = LinearAlgebra url = ../linear-algebra.git brnach = main +[submodule "float16"] + path = float16 + url = http://gitlab.passervr.com/passer/cpp/float16.git diff --git a/NetworkSync.cpp b/NetworkSync.cpp index ecdf3c3..68c5ee0 100644 --- a/NetworkSync.cpp +++ b/NetworkSync.cpp @@ -8,6 +8,7 @@ #include "LinearAlgebra/Angle8.h" #include "LinearAlgebra/Spherical.h" +#include "float16/float16.h" NetworkSync::NetworkSync(Roboid *roboid) { this->roboid = roboid; } @@ -158,6 +159,14 @@ void NetworkSync::SendSingle100(unsigned char *data, unsigned int startIndex, // data[startIndex + ix] = ((unsigned char *)&intValue)[ix]; // } } +void NetworkSync::SendFloat16(unsigned char *data, unsigned char *startIndex, + float value) { + float16 value16 = float16(value); + short binary = value16.getBinary(); + + data[(*startIndex)++] = (binary >> 8) & 0x0F; + data[(*startIndex)++] = binary & 0x0F; +} void NetworkSync::SendInt32(unsigned char *data, unsigned int startIndex, Int32 value) { diff --git a/NetworkSync.h b/NetworkSync.h index 4d3f350..a23df6a 100644 --- a/NetworkSync.h +++ b/NetworkSync.h @@ -76,6 +76,8 @@ protected: InterestingThing *object); void SendSingle100(unsigned char *data, unsigned int startIndex, float value); + void SendFloat16(unsigned char *data, unsigned char *startIndex, float value); + void SendInt32(unsigned char *data, unsigned int startIndex, Int32 value); void SendAngle8(unsigned char *data, unsigned int startIndex, const float value); diff --git a/float16 b/float16 new file mode 160000 index 0000000..51cffc3 --- /dev/null +++ b/float16 @@ -0,0 +1 @@ +Subproject commit 51cffc3ae3da69212ef290a7ad6ed1c747ffa6ab