mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-30 16:29:12 +00:00
163be139eb
* SubGhz: add protocol DataRAW (binarization of data quantized by the minimum correlated duration) * SubGhz: fix name history * SubGhz: add encoder Data_RAW protocol * SubGhz: decreasing the size of the LevelDuration structure * SubGhz: history, added check that there is free RAM * SubGhz: checking for free memory, support to pass without gap * SubGhz: add running average to average the result, auto cut noise at the end of a burst * SubGhz: support for repeating sequences * SubGhz: fix secplus_v2 decoder * SubGhz: bin_RAW fix add history * SubGhz: add debug * SubGhz: debug refactoring * FURI_LOG: add FURI_LOG_RAW_x formatted string output like printf * SubGhz: fix new FURI_LOG metod * FURI_LOG: fix unit test * SubGhz: add enable/disable BinRAW protocol decoding * SubGhz: fix PVS * SubGhz: forcibly turn off the speaker when exiting SubGhz * SubGhz: adaptive adjustment to the noise level Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
125 lines
3.3 KiB
C
125 lines
3.3 KiB
C
/**
|
|
* @file log.h
|
|
* Furi Logging system
|
|
*/
|
|
#pragma once
|
|
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <stdarg.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef enum {
|
|
FuriLogLevelDefault = 0,
|
|
FuriLogLevelNone = 1,
|
|
FuriLogLevelError = 2,
|
|
FuriLogLevelWarn = 3,
|
|
FuriLogLevelInfo = 4,
|
|
FuriLogLevelDebug = 5,
|
|
FuriLogLevelTrace = 6,
|
|
} FuriLogLevel;
|
|
|
|
#define _FURI_LOG_CLR(clr) "\033[0;" clr "m"
|
|
#define _FURI_LOG_CLR_RESET "\033[0m"
|
|
|
|
#define _FURI_LOG_CLR_BLACK "30"
|
|
#define _FURI_LOG_CLR_RED "31"
|
|
#define _FURI_LOG_CLR_GREEN "32"
|
|
#define _FURI_LOG_CLR_BROWN "33"
|
|
#define _FURI_LOG_CLR_BLUE "34"
|
|
#define _FURI_LOG_CLR_PURPLE "35"
|
|
|
|
#define _FURI_LOG_CLR_E _FURI_LOG_CLR(_FURI_LOG_CLR_RED)
|
|
#define _FURI_LOG_CLR_W _FURI_LOG_CLR(_FURI_LOG_CLR_BROWN)
|
|
#define _FURI_LOG_CLR_I _FURI_LOG_CLR(_FURI_LOG_CLR_GREEN)
|
|
#define _FURI_LOG_CLR_D _FURI_LOG_CLR(_FURI_LOG_CLR_BLUE)
|
|
#define _FURI_LOG_CLR_T _FURI_LOG_CLR(_FURI_LOG_CLR_PURPLE)
|
|
|
|
typedef void (*FuriLogPuts)(const char* data);
|
|
typedef uint32_t (*FuriLogTimestamp)(void);
|
|
|
|
/** Initialize logging */
|
|
void furi_log_init();
|
|
|
|
/** Print log record
|
|
*
|
|
* @param level
|
|
* @param tag
|
|
* @param format
|
|
* @param ...
|
|
*/
|
|
void furi_log_print_format(FuriLogLevel level, const char* tag, const char* format, ...)
|
|
_ATTRIBUTE((__format__(__printf__, 3, 4)));
|
|
|
|
/** Print log record
|
|
*
|
|
* @param level
|
|
* @param format
|
|
* @param ...
|
|
*/
|
|
void furi_log_print_raw_format(FuriLogLevel level, const char* format, ...)
|
|
_ATTRIBUTE((__format__(__printf__, 2, 3)));
|
|
|
|
/** Set log level
|
|
*
|
|
* @param[in] level The level
|
|
*/
|
|
void furi_log_set_level(FuriLogLevel level);
|
|
|
|
/** Get log level
|
|
*
|
|
* @return The furi log level.
|
|
*/
|
|
FuriLogLevel furi_log_get_level();
|
|
|
|
/** Set log output callback
|
|
*
|
|
* @param[in] puts The puts callback
|
|
*/
|
|
void furi_log_set_puts(FuriLogPuts puts);
|
|
|
|
/** Set timestamp callback
|
|
*
|
|
* @param[in] timestamp The timestamp callback
|
|
*/
|
|
void furi_log_set_timestamp(FuriLogTimestamp timestamp);
|
|
|
|
/** Log methods
|
|
*
|
|
* @param tag The application tag
|
|
* @param format The format
|
|
* @param ... VA Args
|
|
*/
|
|
#define FURI_LOG_E(tag, format, ...) \
|
|
furi_log_print_format(FuriLogLevelError, tag, format, ##__VA_ARGS__)
|
|
#define FURI_LOG_W(tag, format, ...) \
|
|
furi_log_print_format(FuriLogLevelWarn, tag, format, ##__VA_ARGS__)
|
|
#define FURI_LOG_I(tag, format, ...) \
|
|
furi_log_print_format(FuriLogLevelInfo, tag, format, ##__VA_ARGS__)
|
|
#define FURI_LOG_D(tag, format, ...) \
|
|
furi_log_print_format(FuriLogLevelDebug, tag, format, ##__VA_ARGS__)
|
|
#define FURI_LOG_T(tag, format, ...) \
|
|
furi_log_print_format(FuriLogLevelTrace, tag, format, ##__VA_ARGS__)
|
|
|
|
/** Log methods
|
|
*
|
|
* @param format The raw format
|
|
* @param ... VA Args
|
|
*/
|
|
#define FURI_LOG_RAW_E(format, ...) \
|
|
furi_log_print_raw_format(FuriLogLevelError, format, ##__VA_ARGS__)
|
|
#define FURI_LOG_RAW_W(format, ...) \
|
|
furi_log_print_raw_format(FuriLogLevelWarn, format, ##__VA_ARGS__)
|
|
#define FURI_LOG_RAW_I(format, ...) \
|
|
furi_log_print_raw_format(FuriLogLevelInfo, format, ##__VA_ARGS__)
|
|
#define FURI_LOG_RAW_D(format, ...) \
|
|
furi_log_print_raw_format(FuriLogLevelDebug, format, ##__VA_ARGS__)
|
|
#define FURI_LOG_RAW_T(format, ...) \
|
|
furi_log_print_raw_format(FuriLogLevelTrace, format, ##__VA_ARGS__)
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|