Add float16 sending support

This commit is contained in:
Pascal Serrarens 2024-05-27 12:14:56 +02:00
parent 89453f621c
commit 3606cb642a
4 changed files with 15 additions and 0 deletions

3
.gitmodules vendored
View File

@ -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

View File

@ -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) {

View File

@ -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);

1
float16 Submodule

@ -0,0 +1 @@
Subproject commit 51cffc3ae3da69212ef290a7ad6ed1c747ffa6ab