tools.c 577 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. * tools.c
  3. *
  4. * Created: 20.08.2019 9:58:08
  5. * Author: Radioman
  6. */
  7. #include "tools.h"
  8. void UInt8ToFloat(uint8_t *int_part, uint8_t *frac_part, float *result)
  9. {
  10. *result = (float)(*int_part) + (float)(*frac_part) / 100.0;
  11. }
  12. void FloatToUInt8(float *input, uint8_t *int_out, uint8_t *frac_out)
  13. {
  14. *int_out = (uint8_t)(*input);
  15. *frac_out = (uint8_t)((*input - ((uint8_t)(*input))) * 100);
  16. }
  17. /*
  18. void arrncpy(void *dest, void *source, uint16_t n)
  19. {
  20. uint16_t i;
  21. for(i = 0; i < n; i++)
  22. {
  23. ((uint8_t*)dest)[i] = ((uint8_t*)source)[i];
  24. }
  25. }
  26. */