Plot IQ data as red points on display, if overdriven (vector length >= 1.0)

This commit is contained in:
Andreas Eversberg
2017-01-13 13:55:49 +01:00
parent c0e30d35d6
commit 21c5c3195d

View File

@@ -29,6 +29,7 @@
#define SIZE 23 #define SIZE 23
static char screen[SIZE][MAX_DISPLAY_WIDTH]; static char screen[SIZE][MAX_DISPLAY_WIDTH];
static char overdrive[SIZE][MAX_DISPLAY_WIDTH];
static int iq_on = 0; static int iq_on = 0;
static double db = 80; static double db = 80;
@@ -107,7 +108,7 @@ void display_iq(float *samples, int length)
int i, j, k; int i, j, k;
int color = 9; /* default color */ int color = 9; /* default color */
int x_center, y_center; int x_center, y_center;
double I, Q, l, s; double I, Q, L, l, s;
int x, y; int x, y;
int width, h; int width, h;
@@ -134,12 +135,14 @@ void display_iq(float *samples, int length)
buffer[pos++] = *samples++; buffer[pos++] = *samples++;
if (pos == MAX_DISPLAY_IQ) { if (pos == MAX_DISPLAY_IQ) {
memset(&screen, ' ', sizeof(screen)); memset(&screen, ' ', sizeof(screen));
memset(&overdrive, 0, sizeof(overdrive));
for (j = 0; j < MAX_DISPLAY_IQ; j++) { for (j = 0; j < MAX_DISPLAY_IQ; j++) {
I = buffer[j * 2]; I = buffer[j * 2];
Q = buffer[j * 2 + 1]; Q = buffer[j * 2 + 1];
L = I*I + Q*Q;
if (iq_on > 1) { if (iq_on > 1) {
/* logarithmic scale */ /* logarithmic scale */
l = sqrt(I*I + Q*Q); l = sqrt(L);
s = log10(l) * 20 + db; s = log10(l) * 20 + db;
if (s < 0) if (s < 0)
s = 0; s = 0;
@@ -175,6 +178,8 @@ void display_iq(float *samples, int length)
screen[y/2][x] = '\''; screen[y/2][x] = '\'';
else else
screen[y/2][x] = '.'; screen[y/2][x] = '.';
if (L > 1.0)
overdrive[y/2][x] = 1;
} }
if (iq_on == 1) if (iq_on == 1)
sprintf(screen[0], "(IQ linear"); sprintf(screen[0], "(IQ linear");
@@ -202,10 +207,17 @@ void display_iq(float *samples, int length)
} else } else
putchar('|'); putchar('|');
} else if (screen[j][k] == ':' || screen[j][k] == '.' || screen[j][k] == '\'') { } else if (screen[j][k] == ':' || screen[j][k] == '.' || screen[j][k] == '\'') {
/* green plot */ /* red / green plot */
if (color != 2) { if (overdrive[j][k]) {
color = 2; if (color != 1) {
printf("\033[1;32m"); color = 1;
printf("\033[1;31m");
}
} else {
if (color != 2) {
color = 2;
printf("\033[1;32m");
}
} }
putchar(screen[j][k]); putchar(screen[j][k]);
} else if (screen[j][k] != ' ') { } else if (screen[j][k] != ' ') {