Output enhancements
* no more flicker on wave form display while scrolling * dialing console gets cleared/overwritten correctly * fixes on stderr output
This commit is contained in:
parent
938fb74bae
commit
d52d0242bf
|
@ -261,18 +261,18 @@ int main(int argc, char *argv[])
|
|||
if (num_kanal == 1 && num_sounddev == 0)
|
||||
num_sounddev = 1; /* use defualt */
|
||||
if (num_kanal != num_sounddev) {
|
||||
fprintf(stdout, "You need to specify as many sound devices as you have channels.\n");
|
||||
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
if (num_kanal == 1 && num_chan_type == 0)
|
||||
num_chan_type = 1; /* use defualt */
|
||||
if (num_kanal != num_chan_type) {
|
||||
fprintf(stdout, "You need to specify as many channel types as you have channels.\n");
|
||||
fprintf(stderr, "You need to specify as many channel types as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (bis && latency > 5) {
|
||||
fprintf(stdout, "If you use BUSY/IDLE bit, you need to lower the round-trip delay to 5 ms (--latenc 5).\n");
|
||||
fprintf(stderr, "If you use BUSY/IDLE bit, you need to lower the round-trip delay to 5 ms (--latenc 5).\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ int main(int argc, char *argv[])
|
|||
if (num_kanal == 1 && num_sounddev == 0)
|
||||
num_sounddev = 1; /* use defualt */
|
||||
if (num_kanal != num_sounddev) {
|
||||
fprintf(stdout, "You need to specify as many sound devices as you have channels.\n");
|
||||
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -155,13 +155,13 @@ int main(int argc, char *argv[])
|
|||
if (num_kanal == 1 && num_sounddev == 0)
|
||||
num_sounddev = 1; /* use defualt */
|
||||
if (num_kanal != num_sounddev) {
|
||||
fprintf(stdout, "You need to specify as many sound devices as you have channels.\n");
|
||||
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
if (num_kanal == 1 && num_pilot == 0)
|
||||
num_pilot = 1; /* use defualt */
|
||||
if (num_kanal != num_pilot) {
|
||||
fprintf(stdout, "You need to specify as many pilot tone settings as you have channels.\n");
|
||||
fprintf(stderr, "You need to specify as many pilot tone settings as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -219,13 +219,13 @@ int main(int argc, char *argv[])
|
|||
if (num_kanal == 1 && num_sounddev == 0)
|
||||
num_sounddev = 1; /* use defualt */
|
||||
if (num_kanal != num_sounddev) {
|
||||
fprintf(stdout, "You need to specify as many sound devices as you have channels.\n");
|
||||
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
if (num_kanal == 1 && num_chan_type == 0)
|
||||
num_chan_type = 1; /* use defualt */
|
||||
if (num_kanal != num_chan_type) {
|
||||
fprintf(stdout, "You need to specify as many channel types as you have channels.\n");
|
||||
fprintf(stderr, "You need to specify as many channel types as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -582,10 +582,13 @@ dial_after_hangup:
|
|||
sprintf(console_text, "call disconnected: %s (enter h=hangup)\r", cause_name(call.disc_cause));
|
||||
break;
|
||||
}
|
||||
clear_console_text();
|
||||
console_len = strlen(console_text);
|
||||
memset(console_clear, ' ', console_len - 1);
|
||||
console_clear[console_len - 1] = '\r';
|
||||
printf("\033[1;37m");
|
||||
fwrite(console_text, console_len, 1, stdout);
|
||||
printf("\033[0;39m");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
@ -596,6 +599,7 @@ void clear_console_text(void)
|
|||
|
||||
fwrite(console_clear, console_len, 1, stdout);
|
||||
// note: fflused by user of this function
|
||||
console_len = 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include "debug.h"
|
||||
#include "display_wave.h"
|
||||
#include "call.h"
|
||||
|
||||
const char *debug_level[] = {
|
||||
|
@ -89,7 +90,9 @@ void _printdebug(const char *file, const char __attribute__((unused)) *function,
|
|||
|
||||
clear_console_text();
|
||||
// printf("%s%s:%d %s() %s: %s\033[0;39m", debug_cat[cat].color, file, line, function, debug_level[level], buffer);
|
||||
display_limit_scroll(1);
|
||||
printf("%s%s:%d %s: %s\033[0;39m", debug_cat[cat].color, file, line, debug_level[level], buffer);
|
||||
display_limit_scroll(0);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,17 +20,35 @@
|
|||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "sender.h"
|
||||
|
||||
#define DISPLAY_INTERVAL 0.04
|
||||
|
||||
#define WIDTH 80
|
||||
#define HEIGHT 11
|
||||
|
||||
static int num_sender = 0;
|
||||
static char screen[HEIGHT][WIDTH+1];
|
||||
static char screen[HEIGHT][MAX_DISPLAY_WIDTH];
|
||||
static int wave_on = 0;
|
||||
|
||||
static void get_win_size(int *w, int *h)
|
||||
{
|
||||
struct winsize win;
|
||||
int rc;
|
||||
|
||||
rc = ioctl(0, TIOCGWINSZ, &win);
|
||||
if (rc) {
|
||||
*w = 80;
|
||||
*h = 25;
|
||||
return;
|
||||
}
|
||||
|
||||
*h = win.ws_row;
|
||||
*w = win.ws_col;
|
||||
if (*w > MAX_DISPLAY_WIDTH - 1)
|
||||
*w = MAX_DISPLAY_WIDTH - 1;
|
||||
}
|
||||
|
||||
void display_wave_init(sender_t *sender, int samplerate)
|
||||
{
|
||||
dispwav_t *disp = &sender->dispwav;
|
||||
|
@ -43,6 +61,9 @@ void display_wave_init(sender_t *sender, int samplerate)
|
|||
void display_wave_on(int on)
|
||||
{
|
||||
int i, j;
|
||||
int w, h;
|
||||
|
||||
get_win_size(&w, &h);
|
||||
|
||||
if (on < 0)
|
||||
wave_on = 1 - wave_on;
|
||||
|
@ -53,13 +74,27 @@ void display_wave_on(int on)
|
|||
printf("\0337\033[H");
|
||||
for (i = 0; i < num_sender; i++) {
|
||||
for (j = 0; j < HEIGHT; j++) {
|
||||
screen[j][WIDTH] = '\0';
|
||||
screen[j][w] = '\0';
|
||||
puts(screen[j]);
|
||||
}
|
||||
}
|
||||
printf("\0338"); fflush(stdout);
|
||||
}
|
||||
|
||||
void display_limit_scroll(int on)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
if (!wave_on)
|
||||
return;
|
||||
|
||||
get_win_size(&w, &h);
|
||||
|
||||
printf("\0337");
|
||||
printf("\033[%d;%dr", (on) ? num_sender * HEIGHT + 1 : 1, h);
|
||||
printf("\0338");
|
||||
}
|
||||
|
||||
/*
|
||||
* draw wave form:
|
||||
*
|
||||
|
@ -84,10 +119,13 @@ void display_wave(sender_t *sender, int16_t *samples, int length)
|
|||
int color = 9; /* default color */
|
||||
int center_line;
|
||||
char center_char;
|
||||
int width, h;
|
||||
|
||||
if (!wave_on)
|
||||
return;
|
||||
|
||||
get_win_size(&width, &h);
|
||||
|
||||
/* at what line we draw our zero-line and what character we use */
|
||||
center_line = (HEIGHT - 1) >> 1;
|
||||
center_char = (HEIGHT & 1) ? '-' : '_';
|
||||
|
@ -97,15 +135,15 @@ void display_wave(sender_t *sender, int16_t *samples, int length)
|
|||
buffer = disp->buffer;
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
if (pos >= WIDTH) {
|
||||
if (pos >= width) {
|
||||
if (++pos == max)
|
||||
pos = 0;
|
||||
continue;
|
||||
}
|
||||
buffer[pos++] = samples[i];
|
||||
if (pos == WIDTH) {
|
||||
if (pos == width) {
|
||||
memset(&screen, ' ', sizeof(screen));
|
||||
for (j = 0; j < WIDTH; j++) {
|
||||
for (j = 0; j < width; j++) {
|
||||
/* 32767 - buffer[j] never reaches 65536, so
|
||||
* the result is below HEIGHT * 2 - 1
|
||||
*/
|
||||
|
@ -118,7 +156,7 @@ void display_wave(sender_t *sender, int16_t *samples, int length)
|
|||
for (j = 0; j < disp->offset; j++)
|
||||
puts("");
|
||||
for (j = 0; j < HEIGHT; j++) {
|
||||
for (k = 0; k < WIDTH; k++) {
|
||||
for (k = 0; k < width; k++) {
|
||||
if (j == center_line && screen[j][k] == ' ') {
|
||||
/* blue 0-line */
|
||||
if (color != 4) {
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
#define MAX_DISPLAY_WIDTH 1024
|
||||
|
||||
typedef struct sender sender_t;
|
||||
|
||||
typedef struct display_wave {
|
||||
int interval_pos;
|
||||
int interval_max;
|
||||
int offset;
|
||||
int16_t buffer[256];
|
||||
int16_t buffer[MAX_DISPLAY_WIDTH];
|
||||
} dispwav_t;
|
||||
|
||||
void display_wave_init(sender_t *sender, int samplerate);
|
||||
void display_wave_on(int on);
|
||||
void display_limit_scroll(int on);
|
||||
void display_wave(sender_t *sender, int16_t *samples, int length);
|
||||
|
||||
|
|
|
@ -289,7 +289,8 @@ void sighandler(int sigset)
|
|||
if (sigset == SIGPIPE)
|
||||
return;
|
||||
|
||||
fprintf(stderr, "\nSignal received: %d\n", sigset);
|
||||
clear_console_text();
|
||||
printf("Signal received: %d\n", sigset);
|
||||
|
||||
quit = 1;
|
||||
}
|
||||
|
@ -374,7 +375,8 @@ next_char:
|
|||
switch (c) {
|
||||
case 3:
|
||||
/* quit */
|
||||
fprintf(stderr, "\nCTRL+c received, quitting!\n");
|
||||
clear_console_text();
|
||||
printf("CTRL+c received, quitting!\n");
|
||||
*quit = 1;
|
||||
goto next_char;
|
||||
case 'w':
|
||||
|
@ -397,6 +399,7 @@ next_char:
|
|||
usleep(interval * 1000);
|
||||
}
|
||||
|
||||
/* get rid of last entry */
|
||||
clear_console_text();
|
||||
|
||||
/* reset terminal */
|
||||
|
|
|
@ -283,13 +283,13 @@ int main(int argc, char *argv[])
|
|||
if (num_kanal == 1 && num_sounddev == 0)
|
||||
num_sounddev = 1; /* use defualt */
|
||||
if (num_kanal != num_sounddev) {
|
||||
fprintf(stdout, "You need to specify as many sound devices as you have channels.\n");
|
||||
fprintf(stderr, "You need to specify as many sound devices as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
if (num_kanal == 1 && num_chan_type == 0)
|
||||
num_chan_type = 1; /* use defualt */
|
||||
if (num_kanal != num_chan_type) {
|
||||
fprintf(stdout, "You need to specify as many channel types as you have channels.\n");
|
||||
fprintf(stderr, "You need to specify as many channel types as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue