rtl_power: linear output

squashed
Kyle Keen 2014-08-23 08:33:43 -04:00
rodzic 1214d98271
commit 396dbe7487
1 zmienionych plików z 17 dodań i 4 usunięć

Wyświetl plik

@ -105,6 +105,7 @@ struct tuning_state
int downsample_passes; /* for the recursive filter */
int comp_fir_size;
int peak_hold;
int linear;
int bin_spec;
double crop;
int crop_i1, crop_i2;
@ -135,6 +136,7 @@ struct misc_settings
int boxcar;
int comp_fir_size;
int peak_hold;
int linear;
int target_rate;
double crop;
int gain;
@ -181,7 +183,8 @@ void usage(void)
"\t try -F 0 with '-c 50%%' to hide the roll off\n"
"\t[-r max_sample_rate (default: 2.4M)]\n"
"\t possible values are 2M to 3.2M\n"
"\t[-P enables peak hold (default: off)]\n"
"\t[-P enables peak hold (default: off/averaging)]\n"
"\t[-L enable linear output (default: off/dB)]\n"
"\t[-D direct_sampling_mode, 0 (default/off), 1 (I), 2 (Q), 3 (no-mod)]\n"
"\t[-O enable offset tuning (default: off)]\n"
"\n"
@ -638,6 +641,7 @@ void frequency_range(char *arg, struct misc_settings *ms)
ts->downsample_passes = c.downsample_passes;
ts->comp_fir_size = ms->comp_fir_size;
ts->peak_hold = ms->peak_hold;
ts->linear = ms->linear;
ts->avg = (long*)malloc((1<<c.bin_e) * sizeof(long));
if (!ts->avg) {
fprintf(stderr, "Error: malloc.\n");
@ -936,8 +940,12 @@ void csv_dbm(struct tuning_state *ts)
dbm = (double)ts->avg[i];
dbm /= (double)ts->rate;
dbm /= (double)ts->samples;
dbm = 10 * log10(dbm);
fprintf(file, "%.2f%s", dbm, sep);
if (ts->linear) {
fprintf(file, "%.5g%s", dbm, sep);
} else {
dbm = 10 * log10(dbm);
fprintf(file, "%.2f%s", dbm, sep);
}
}
for (i=0; i<len; i++) {
ts->avg[i] = 0L;
@ -954,6 +962,8 @@ void init_misc(struct misc_settings *ms)
ms->gain = AUTO_GAIN;
ms->window_fn = rectangle;
ms->smoothing = 0;
ms->peak_hold = 0;
ms->linear = 0;
}
int main(int argc, char **argv)
@ -983,7 +993,7 @@ int main(int argc, char **argv)
freq_optarg = "";
init_misc(&ms);
while ((opt = getopt(argc, argv, "f:i:s:r:t:d:g:p:e:w:c:F:1PD:Oh")) != -1) {
while ((opt = getopt(argc, argv, "f:i:s:r:t:d:g:p:e:w:c:F:1PLD:Oh")) != -1) {
switch (opt) {
case 'f': // lower:upper:bin_size
if (f_set) {
@ -1047,6 +1057,9 @@ int main(int argc, char **argv)
case 'P':
ms.peak_hold = 1;
break;
case 'L':
ms.linear = 1;
break;
case 'D':
direct_sampling = atoi(optarg);
break;