Helpers.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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("FlipperGameEngine", "Free/total heap: %zu / %zu", memmgr_get_free_heap(), memmgr_get_total_heap())
  14. char *basename(const char *path);
  15. void check_ptr(void *p, const char *file, int line, const char *func);
  16. float lerp(float a, float b, float t);
  17. class LogTimer{
  18. double start;
  19. const char* name;
  20. public:
  21. explicit LogTimer(const char* name);
  22. ~LogTimer();
  23. };
  24. class TypeRegistry {
  25. public:
  26. template <typename T>
  27. static int getTypeID() {
  28. static int typeID = getNextTypeID();
  29. return typeID;
  30. }
  31. private:
  32. static int getNextTypeID() {
  33. static int currentTypeID = 0;
  34. return ++currentTypeID;
  35. }
  36. };