DataConversion.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include <stdint.h>
  3. class DataConversion
  4. {
  5. public:
  6. /***************************************
  7. Function: floatTofixed()
  8. Purpose: Converts a 5.23 float value to 5-byte HEX and stores it to a buffer
  9. Inputs: float value; Value to convert
  10. uint8_t *buffer; Buffer to store the converted data to
  11. Returns: None
  12. ***************************************/
  13. static void floatToFixed(float value, uint8_t* buffer);
  14. /***************************************
  15. Function: intToFixed()
  16. Purpose: Converts a 28.0 integer value to 5-byte HEX and stores it to a buffer
  17. Inputs: int32_t value; Value to convert
  18. uint8_t *buffer; Buffer to store the converted data to
  19. Returns: None
  20. ***************************************/
  21. static void intToFixed(int32_t value, uint8_t* buffer);
  22. /***************************************
  23. Function: floatToInt()
  24. Purpose: Converts a 5.23 float value to int 28.0
  25. Inputs: float value; Value to convert
  26. Returns: int32_t; Converted value
  27. ***************************************/
  28. static int32_t floatToInt(float value);
  29. };