Helpers.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #define M_PIX2 6.28318530717958647692 /* 2 pi */
  3. #include "furi.h"
  4. #define l_abs(x) ((x) < 0 ? -(x) : (x))
  5. #define DEG_2_RAD 0.01745329251994329576f
  6. #define RAD_2_DEG 565.48667764616278292327f
  7. #define DEBUG_BUILD
  8. #ifdef DEBUG_BUILD
  9. #define check_pointer(X) check_ptr( X, __FILE__, __LINE__, __FUNCTION__)
  10. #else
  11. #define check_pointer(X) while(0)
  12. #endif
  13. #define CHECK_HEAP() FURI_LOG_I("Solitaire", "Free/total heap: %zu / %zu", memmgr_get_free_heap(), memmgr_get_total_heap())
  14. char *get_basename(const char *path);
  15. #ifndef basename
  16. #define basename(path) get_basename(path)
  17. #endif
  18. void check_ptr(void *p, const char *file, int line, const char *func);
  19. float lerp(float a, float b, float t);
  20. class LogTimer{
  21. double start;
  22. const char* name;
  23. public:
  24. explicit LogTimer(const char* name);
  25. ~LogTimer();
  26. };
  27. class TypeRegistry {
  28. public:
  29. template <typename T>
  30. static int getTypeID() {
  31. static int typeID = getNextTypeID();
  32. return typeID;
  33. }
  34. private:
  35. static int getNextTypeID() {
  36. static int currentTypeID = 0;
  37. return ++currentTypeID;
  38. }
  39. };