Move amplitude (level) debugging to debug.c
This commit is contained in:
parent
adc3270dc0
commit
7aa2445b47
|
@ -188,21 +188,6 @@ static void fsk_receive_bit(bnetz_t *bnetz, int bit, double level, double qualit
|
|||
bnetz_receive_telegramm(bnetz, bnetz->fsk_filter_telegramm, level, quality);
|
||||
}
|
||||
|
||||
char *show_level(int value)
|
||||
{
|
||||
static char text[22];
|
||||
|
||||
value /= 5;
|
||||
if (value < 0)
|
||||
value = 0;
|
||||
if (value > 20)
|
||||
value = 20;
|
||||
strcpy(text, " ");
|
||||
text[value] = '*';
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
//#define DEBUG_FILTER
|
||||
//#define DEBUG_QUALITY
|
||||
|
||||
|
@ -236,8 +221,8 @@ static inline void fsk_decode_step(bnetz_t *bnetz, int pos)
|
|||
if (softbit < 0)
|
||||
softbit = 0;
|
||||
#ifdef DEBUG_FILTER
|
||||
printf("|%s", show_level(result[0]/level*100));
|
||||
printf("|%s| low=%.3f high=%.3f level=%d\n", show_level(result[1]/level*100), result[0]/level, result[1]/level, (int)level);
|
||||
printf("|%s", debug_amplitude(result[0]/level));
|
||||
printf("|%s| low=%.3f high=%.3f level=%d\n", debug_amplitude(result[1]/level), result[0]/level, result[1]/level, (int)level);
|
||||
#endif
|
||||
if (softbit > 0.5)
|
||||
bit = 1;
|
||||
|
@ -264,8 +249,8 @@ static inline void fsk_decode_step(bnetz_t *bnetz, int pos)
|
|||
} else if (--bnetz->fsk_filter_sample == 0) {
|
||||
/* if sample counter bit reaches 0, we reset sample counter to one bit duration */
|
||||
#ifdef DEBUG_QUALITY
|
||||
printf("|%s| quality=%.2f ", show_level(softbit * 100), quality);
|
||||
printf("|%s|\n", show_level(quality * 100));
|
||||
printf("|%s| quality=%.2f ", debug_amplitude(softbit), quality);
|
||||
printf("|%s|\n", debug_amplitude(quality);
|
||||
#endif
|
||||
/* adjust level, so we get peak of sine curve */
|
||||
fsk_receive_bit(bnetz, bit, level / 0.63662 * 32768.0 / TX_PEAK_TONE, quality);
|
||||
|
|
|
@ -552,18 +552,6 @@ static int fsk_distributed_encode(cnetz_t *cnetz, const char *bits)
|
|||
return count;
|
||||
}
|
||||
|
||||
void show_level(double level)
|
||||
{
|
||||
char text[42] = " ";
|
||||
|
||||
if (level > 1.0)
|
||||
level = 1.0;
|
||||
if (level < -1.0)
|
||||
level = -1.0;
|
||||
text[20 - (int)(level * 20)] = '*';
|
||||
printf("%s\n", text);
|
||||
}
|
||||
|
||||
/* decode samples and hut for bit changes
|
||||
* use deviation to find greatest slope of the signal (bit change)
|
||||
*/
|
||||
|
|
|
@ -317,17 +317,6 @@ got_sync:
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DECODER
|
||||
static void fsk_show_level(double level)
|
||||
{
|
||||
if (level > 1.0)
|
||||
level = 1.0;
|
||||
if (level < -1.0)
|
||||
level = -1.0;
|
||||
printf(" *\n" + 10 - (int)(level * 10));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* DOC TBD: find change for bit change */
|
||||
static inline void find_change(fsk_fm_demod_t *fsk)
|
||||
{
|
||||
|
@ -438,7 +427,7 @@ void fsk_fm_demod(fsk_fm_demod_t *fsk, int16_t *samples, int length)
|
|||
if (fsk->cnetz->dsp_mode != DSP_MODE_SPK_V) {
|
||||
#ifdef DEBUG_DECODER
|
||||
DEBUG_DECODER
|
||||
fsk_show_level((double)samples[i] / 32768.0);
|
||||
puts(debug_amplitude((double)samples[i] / 32768.0));
|
||||
#endif
|
||||
find_change(fsk);
|
||||
} else {
|
||||
|
@ -462,7 +451,7 @@ void fsk_fm_demod(fsk_fm_demod_t *fsk, int16_t *samples, int length)
|
|||
if (t >= 0.5 && t < 5.5) {
|
||||
#ifdef DEBUG_DECODER
|
||||
DEBUG_DECODER
|
||||
fsk_show_level((double)samples[i] / 32768.0);
|
||||
puts(debug_amplitude((double)samples[i] / 32768.0));
|
||||
#endif
|
||||
find_change(fsk);
|
||||
} else
|
||||
|
|
|
@ -70,3 +70,17 @@ void _printdebug(const char *file, const char *function, int line, int cat, int
|
|||
fflush(stdout);
|
||||
}
|
||||
|
||||
const char *debug_amplitude(double level)
|
||||
{
|
||||
static char text[42];
|
||||
|
||||
strcpy(text, " : ");
|
||||
if (level > 1.0)
|
||||
level = 1.0;
|
||||
if (level < -1.0)
|
||||
level = -1.0;
|
||||
text[20 + (int)(level * 20)] = '*';
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,5 +19,7 @@
|
|||
#define PDEBUG(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, fmt, ## arg)
|
||||
void _printdebug(const char *file, const char *function, int line, int cat, int level, const char *fmt, ...);
|
||||
|
||||
const char *debug_amplitude(double level);
|
||||
|
||||
extern int debuglevel;
|
||||
|
||||
|
|
|
@ -267,21 +267,6 @@ static void fsk_receive_bit(nmt_t *nmt, int bit, double quality, double level)
|
|||
nmt_receive_frame(nmt, nmt->fsk_filter_frame, quality, level * 32768.0 / TX_PEAK_FSK, frames_elapsed);
|
||||
}
|
||||
|
||||
char *show_level(int value)
|
||||
{
|
||||
static char text[22];
|
||||
|
||||
value /= 5;
|
||||
if (value < 0)
|
||||
value = 0;
|
||||
if (value > 20)
|
||||
value = 20;
|
||||
strcpy(text, " ");
|
||||
text[value] = '*';
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
//#define DEBUG_MODULATOR
|
||||
//#define DEBUG_FILTER
|
||||
//#define DEBUG_QUALITY
|
||||
|
@ -317,9 +302,9 @@ static inline void fsk_decode_step(nmt_t *nmt, int pos)
|
|||
#define MIN_QUALITY 0.33
|
||||
softbit = (softbit - MIN_QUALITY) / (1.0 - MIN_QUALITY - MIN_QUALITY);
|
||||
#ifdef DEBUG_FILTER
|
||||
// printf("|%s", show_level(result[0]/level*100));
|
||||
// printf("|%s| low=%.3f high=%.3f level=%d\n", show_level(result[1]/level*100), result[0]/level, result[1]/level, (int)level);
|
||||
printf("|%s| softbit=%.3f\n", show_level(softbit * 100), softbit);
|
||||
// printf("|%s", debug_amplitude(result[0]/level));
|
||||
// printf("|%s| low=%.3f high=%.3f level=%d\n", debug_amplitude(result[1]/level), result[0]/level, result[1]/level, (int)level);
|
||||
printf("|%s| softbit=%.3f\n", debug_amplitude(softbit), softbit);
|
||||
#endif
|
||||
if (softbit > 1)
|
||||
softbit = 1;
|
||||
|
@ -348,8 +333,8 @@ static inline void fsk_decode_step(nmt_t *nmt, int pos)
|
|||
else
|
||||
quality = 1.0 - softbit * 2.0;
|
||||
#ifdef DEBUG_QUALITY
|
||||
printf("|%s| quality=%.2f ", show_level(softbit * 100), quality);
|
||||
printf("|%s|\n", show_level(quality * 100));
|
||||
printf("|%s| quality=%.2f ", debug_amplitude(softbit), quality);
|
||||
printf("|%s|\n", debug_amplitude(quality));
|
||||
#endif
|
||||
/* adjust level, so a peak level becomes 100% */
|
||||
fsk_receive_bit(nmt, bit, quality, level / 0.63662);
|
||||
|
@ -442,7 +427,7 @@ void sender_receive(sender_t *sender, int16_t *samples, int length)
|
|||
spl = nmt->fsk_filter_spl;
|
||||
for (i = 0; i < length; i++) {
|
||||
#ifdef DEBUG_MODULATOR
|
||||
printf("|%s|\n", show_level((int)((samples[i] / TX_PEAK_FSK) * 50)+50));
|
||||
printf("|%s|\n", debug_amplitude((double)samples[i] / TX_PEAK_FSK / 2.0));
|
||||
#endif
|
||||
spl[pos++] = samples[i];
|
||||
if (nmt->fsk_filter_mute) {
|
||||
|
|
Loading…
Reference in New Issue