configurable decimation rate

pull/18/head
Xael South 2021-01-28 13:32:59 +00:00
rodzic 683c99e1d8
commit 4098aa84bb
1 zmienionych plików z 9 dodań i 4 usunięć

Wyświetl plik

@ -446,19 +446,21 @@ static void time2_algorithm(unsigned bit, unsigned rssi, struct time2_algorithm
static int opts_run_length_algorithm_enabled = 1;
static int opts_time2_algorithm_enabled = 1;
static unsigned decimation_rate = 2u;
static void print_usage(const char *program_name)
{
fprintf(stdout, "Usage %s:\n", program_name);
fprintf(stdout, "\t-r 0 to disable run length algorithm\n");
fprintf(stdout, "\t-t 0 to disable time2 algorithm\n");
fprintf(stdout, "\t-d 2 set decimation rate to 2 (defaults to 2 if omitted)\n");
}
static void process_options(int argc, char *argv[])
{
int option;
while ((option = getopt(argc, argv, "r:t:")) != -1)
while ((option = getopt(argc, argv, "d:r:t:")) != -1)
{
switch (option)
{
@ -484,6 +486,9 @@ static void process_options(int argc, char *argv[])
exit(EXIT_FAILURE);
}
break;
case 'd':
decimation_rate = strtoul(optarg, NULL, 10);
break;
default:
print_usage(argv[0]);
exit(EXIT_FAILURE);
@ -500,7 +505,7 @@ int main(int argc, char *argv[])
// configurable via command line.
const unsigned CLOCK_LOCK_THRESHOLD = 2;
const unsigned DECIMATION_RATE = 2;
// --- parameter section end ---
__attribute__((__aligned__(16))) uint8_t samples[4096];
@ -577,7 +582,7 @@ int main(int argc, char *argv[])
#endif
++decimation_rate_index;
if (decimation_rate_index < DECIMATION_RATE) continue;
if (decimation_rate_index < decimation_rate) continue;
decimation_rate_index = 0;
// Demodulate.
@ -602,7 +607,7 @@ int main(int argc, char *argv[])
rssi = rssi_filter(rssi); // comment out, if rssi filtering is unwanted
#if defined(USE_MOVING_AVERAGE)
// If using moving average, we would have doubles of each of i- and q- signal components.
rssi /= DECIMATION_RATE;
rssi /= decimation_rate;
#endif
// --- rssi filtering section end ---