common code: Display multiple wave forms for each channel used

Use 'w' key to enable/disable RX wave form display.
pull/1/head
Andreas Eversberg 6 years ago
parent ea32ab3fa3
commit 6c1b6119ad
  1. 16
      src/common/display_wave.c
  2. 1
      src/common/display_wave.h
  3. 11
      src/common/sender.c

@ -27,6 +27,7 @@
#define WIDTH 80
#define HEIGHT 10
static int num_sender = 0;
static char screen[HEIGHT][WIDTH+1];
static int wave_on = 0;
@ -35,12 +36,13 @@ void display_wave_init(sender_t *sender, int samplerate)
dispwav_t *disp = &sender->dispwav;
memset(disp, 0, sizeof(*disp));
disp->offset = (num_sender++) * HEIGHT;
disp->interval_max = (double)samplerate * DISPLAY_INTERVAL + 0.5;
}
void display_wave_on(int on)
{
int j;
int i, j;
if (on < 0)
wave_on = 1 - wave_on;
@ -49,9 +51,11 @@ void display_wave_on(int on)
memset(&screen, ' ', sizeof(screen));
printf("\0337\033[H");
for (j = 0; j < HEIGHT; j++) {
screen[j][WIDTH] = '\0';
puts(screen[j]);
for (i = 0; i < num_sender; i++) {
for (j = 0; j < HEIGHT; j++) {
screen[j][WIDTH] = '\0';
puts(screen[j]);
}
}
printf("\0338"); fflush(stdout);
}
@ -84,7 +88,11 @@ void display_wave(sender_t *sender, int16_t *samples, int length)
y = (32767 - (int)buffer[j]) * HEIGHT * 2 / 65536;
screen[y >> 1][j] = (y & 1) ? '_' : '-';
}
sprintf(screen[0], "(chan %d", sender->kanal);
*strchr(screen[0], '\0') = ')';
printf("\0337\033[H");
for (j = 0; j < disp->offset; j++)
puts("");
for (j = 0; j < HEIGHT; j++) {
screen[j][WIDTH] = '\0';
puts(screen[j]);

@ -3,6 +3,7 @@ typedef struct sender sender_t;
typedef struct display_wave {
int interval_pos;
int interval_max;
int offset;
int16_t buffer[256];
} dispwav_t;

@ -137,8 +137,7 @@ int sender_create(sender_t *sender, int kanal, const char *sounddev, int sampler
*sender_tailp = sender;
sender_tailp = &sender->next;
if (sender == sender_head)
display_wave_init(sender, samplerate);
display_wave_init(sender, samplerate);
return 0;
error:
@ -249,8 +248,7 @@ cant_recover:
#ifndef WAVE_WRITE_TX
if (sender->wave_rec.fp)
wave_write(&sender->wave_rec, samples, count);
if (sender == sender_head)
display_wave(sender, samples, count);
display_wave(sender, samples, count);
sender_receive(sender, samples, count);
#endif
}
@ -273,6 +271,7 @@ cant_recover:
if (slave->wave_rec.fp)
wave_write(&slave->wave_rec, slave_samples, count);
#endif
display_wave(slave, slave_samples, count);
sender_receive(slave, slave_samples, count);
}
/* do pre emphasis towards radio, not wave_write */
@ -379,8 +378,7 @@ cant_recover:
if (sender->wave_rec.fp)
wave_write(&sender->wave_rec, samples, count);
#endif
if (sender == sender_head)
display_wave(sender, samples, count);
display_wave(sender, samples, count);
sender_receive(sender, samples, count);
}
if (sender->loopback == 3)
@ -398,6 +396,7 @@ cant_recover:
if (slave->wave_rec.fp)
wave_write(&slave->wave_rec, slave_samples, count);
#endif
display_wave(slave, slave_samples, count);
sender_receive(slave, slave_samples, count);
}
if (slave->loopback == 3)

Loading…
Cancel
Save