10 #ifdef KNOCK_SPECTROGRAM
17 static Logging scLogging(
"knock_spectrogram", PROTOCOL_KNOCK_SPECTROGRAMM_BUFFER,
sizeof(PROTOCOL_KNOCK_SPECTROGRAMM_BUFFER));
19 static char compressToByte(
const float& v,
const float& min,
const float& max) {
20 float vn = (v-min) / (max-min);
21 int iv =int((
float)256 * vn);
23 char compressed = (char)(iv-128);
27 void base64(
Logging& l,
const float* data,
size_t size,
const float& min,
const float& max) {
28 static constexpr
char encTable[] = {
29 'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
30 'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
31 'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
32 'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
33 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'+',
'/'};
36 size_t out_len = 4 * ((in_len + 2) / 3);
41 for (i = 0; in_len > 2 && i < in_len - 2; i += 3) {
52 if (i == (in_len - 1)) {
70 float min = 99999999999;
71 float max = -99999999999;
72 for(
size_t i = 0; i <
size; ++i) {
void void appendFloat(float value, int precision)
size_t remainingSize() const
void appendPrintf(const char *fmt,...) __attribute__((format(printf
void knockSpectorgramAddLine(float main_freq, float *data, size_t size)
static char compressToByte(const float &v, const float &min, const float &max)
void base64(Logging &l, const float *data, size_t size, const float &min, const float &max)
static Logging scLogging("knock_spectrogram", PROTOCOL_KNOCK_SPECTROGRAMM_BUFFER, sizeof(PROTOCOL_KNOCK_SPECTROGRAMM_BUFFER))
static char PROTOCOL_KNOCK_SPECTROGRAMM_BUFFER[128] CCM_OPTIONAL
void scheduleLogging(Logging *logging)