Helpers.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 inverse_tanh(double x);
  20. float lerp(float a, float b, float t);
  21. class LogTimer{
  22. double start;
  23. const char* name;
  24. public:
  25. explicit LogTimer(const char* name);
  26. ~LogTimer();
  27. };
  28. class TypeRegistry {
  29. public:
  30. template <typename T>
  31. static int getTypeID() {
  32. static int typeID = getNextTypeID();
  33. return typeID;
  34. }
  35. private:
  36. static int getNextTypeID() {
  37. static int currentTypeID = 0;
  38. return ++currentTypeID;
  39. }
  40. };