| 12345678910111213141516171819202122232425262728293031323334353637 |
- #include "Helpers.h"
- char *get_basename(const char *path) {
- const char *base = path;
- while (*path) {
- if (*path++ == '/') {
- base = path;
- }
- }
- return (char *) base;
- }
- void check_ptr(void *p, const char *file, int line, const char *func) {
- UNUSED(file);
- UNUSED(line);
- UNUSED(func);
- if (p == NULL) {
- FURI_LOG_W("App", "[NULLPTR] %s:%s():%i", get_basename((char *) file), func, line);
- }
- }
- float lerp(float a, float b, float t) {
- if (t > 1) return b;
- return (1 - t) * a + t * b;
- }
- LogTimer::LogTimer(const char *n) : name(n) {
- start = furi_get_tick();
- }
- LogTimer::~LogTimer() {
- FURI_LOG_D("App", "%s took %fms", name, furi_get_tick() - start);
- }
- float inverse_tanh(double x) {
- return 0.5f * (float)log((1 + x) / (1 - x));
- }
|