SubGhz: add protocol BinRAW (binarization of data quantized by the minimum correlated duration) (#2322)

* 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>
This commit is contained in:
Skorpionm
2023-02-09 08:48:06 +04:00
committed by GitHub
parent 71871949ec
commit 163be139eb
28 changed files with 1451 additions and 65 deletions

View File

@@ -28,27 +28,27 @@ void furi_log_print_format(FuriLogLevel level, const char* tag, const char* form
FuriString* string;
string = furi_string_alloc();
const char* color = FURI_LOG_CLR_RESET;
const char* color = _FURI_LOG_CLR_RESET;
const char* log_letter = " ";
switch(level) {
case FuriLogLevelError:
color = FURI_LOG_CLR_E;
color = _FURI_LOG_CLR_E;
log_letter = "E";
break;
case FuriLogLevelWarn:
color = FURI_LOG_CLR_W;
color = _FURI_LOG_CLR_W;
log_letter = "W";
break;
case FuriLogLevelInfo:
color = FURI_LOG_CLR_I;
color = _FURI_LOG_CLR_I;
log_letter = "I";
break;
case FuriLogLevelDebug:
color = FURI_LOG_CLR_D;
color = _FURI_LOG_CLR_D;
log_letter = "D";
break;
case FuriLogLevelTrace:
color = FURI_LOG_CLR_T;
color = _FURI_LOG_CLR_T;
log_letter = "T";
break;
default:
@@ -58,7 +58,7 @@ void furi_log_print_format(FuriLogLevel level, const char* tag, const char* form
// Timestamp
furi_string_printf(
string,
"%lu %s[%s][%s] " FURI_LOG_CLR_RESET,
"%lu %s[%s][%s] " _FURI_LOG_CLR_RESET,
furi_log.timestamp(),
color,
log_letter,
@@ -80,6 +80,23 @@ void furi_log_print_format(FuriLogLevel level, const char* tag, const char* form
}
}
void furi_log_print_raw_format(FuriLogLevel level, const char* format, ...) {
if(level <= furi_log.log_level &&
furi_mutex_acquire(furi_log.mutex, FuriWaitForever) == FuriStatusOk) {
FuriString* string;
string = furi_string_alloc();
va_list args;
va_start(args, format);
furi_string_vprintf(string, format, args);
va_end(args);
furi_log.puts(furi_string_get_cstr(string));
furi_string_free(string);
furi_mutex_release(furi_log.mutex);
}
}
void furi_log_set_level(FuriLogLevel level) {
if(level == FuriLogLevelDefault) {
level = FURI_LOG_LEVEL_DEFAULT;

View File

@@ -22,21 +22,21 @@ typedef enum {
FuriLogLevelTrace = 6,
} FuriLogLevel;
#define FURI_LOG_CLR(clr) "\033[0;" clr "m"
#define FURI_LOG_CLR_RESET "\033[0m"
#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_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)
#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);
@@ -54,6 +54,15 @@ void furi_log_init();
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
@@ -95,6 +104,22 @@ void furi_log_set_timestamp(FuriLogTimestamp timestamp);
#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