.

Dependencies:   L432KC_SPI_Pey_Lal

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers toolbox.cpp Source File

toolbox.cpp

00001 #include "toolbox.hpp"
00002 
00003 double limitToInterval(double value, double min, double max)
00004 {
00005     if (value > max)
00006         return max;
00007     else if (value < min)
00008         return min;
00009     else
00010         return value;
00011 }
00012 
00013 float convertBytesToFloat(char *array, char startIndex)
00014 {
00015     float *fPtr = (float*)(array + startIndex);
00016     float f = *fPtr;
00017     return f;
00018 }
00019 
00020 void convertFloatToBytes(float *f, char *array, char startIndex)
00021 {
00022     char *fPtr = (char *)f;
00023     for (int i = 0; i < 4; i++)
00024         array[startIndex + i] = fPtr[i];
00025 }