Skip to content

Commit

Permalink
UI bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dbdexter-dev committed Feb 3, 2019
1 parent aa9abda commit 43a4d36
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 45 deletions.
6 changes: 0 additions & 6 deletions src/agc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
#include "agc.h"
#include "utils.h"

/* AGC default parameters */
#define AGC_WINSIZE 1024*64
#define AGC_TARGET 180
#define AGC_MAX_GAIN 20
#define AGC_BIAS_WINSIZE 1024*1024

/* Initialize an AGC object */
Agc*
agc_init()
Expand Down
6 changes: 6 additions & 0 deletions src/include/agc.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
#ifndef METEOR_AGC_H
#define METEOR_AGC_H

/* AGC default parameters */
#define AGC_WINSIZE 1024*64
#define AGC_TARGET 180
#define AGC_MAX_GAIN 20
#define AGC_BIAS_WINSIZE 256*1024

#include <complex.h>

typedef struct {
Expand Down
4 changes: 4 additions & 0 deletions src/include/pll.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@

#include <complex.h>


/* Costas loop default parameters */
#define COSTAS_BW 100
#define COSTAS_DAMP 1/M_SQRT2
#define COSTAS_INIT_FREQ 0.001
#define FREQ_MAX 0.8
#define AVG_WINSIZE 2500

typedef struct {
float nco_phase, nco_freq;
Expand Down
2 changes: 1 addition & 1 deletion src/include/tui.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

void tui_init(unsigned upd_interval);
void tui_deinit(void);
void tui_handle_resize(void);
void tui_handle_resize(int sig);

int tui_process_input(void);

Expand Down
4 changes: 2 additions & 2 deletions src/include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#ifndef METEOR_UTILS_H
#define METEOR_UTILS_H

#define MAX(X, Y) (X > Y) ? X : Y
#define MIN(X, Y) (X < Y) ? X : Y
#define MAX(X, Y) ((X) > (Y)) ? X : Y
#define MIN(X, Y) ((X) < (Y)) ? X : Y

#include <complex.h>
#include <stdlib.h>
Expand Down
5 changes: 2 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include <complex.h>
#include <math.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "demod.h"
Expand All @@ -20,9 +22,6 @@
#define SLEEP_INTERVAL 5000
#define UPD_INTERVAL 50

/* Costas loop default parameters */
#define COSTAS_BW 100

/* RRC default parameters, alpha taken from the .grc meteor decode script */
#define RRC_ALPHA 0.6
#define RRC_FIR_ORDER 64
Expand Down
3 changes: 0 additions & 3 deletions src/pll.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
#include "tui.h"
#include "utils.h"

#define FREQ_MAX 0.8
#define AVG_WINSIZE 40000

static float costas_compute_delta(float i_branch, float q_branch);
static float* _lut_tanh;
inline float lut_tanh(float val);
Expand Down
48 changes: 24 additions & 24 deletions src/tui.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ tui_init(unsigned upd_interval)

/* Handle terminal resizing by moving the windows around */
void
tui_handle_resize()
tui_handle_resize(int sig)
{
int nr, nc;
int iq_size, cur_row;
int iq_size;

/* Re-initialize ncurses with the correct dimensions */
werase(stdscr);
Expand All @@ -70,23 +70,20 @@ tui_handle_resize()
refresh();
getmaxyx(stdscr, nr, nc);

iq_size = MIN(CONSTELL_MAX, nr);
cur_row = 0;
iq_size = (MIN(CONSTELL_MAX, MIN(nr, nc/2))) | 0x3;

wresize(tui.banner_top, 1, nc);
mvwin(tui.banner_top, 0, 0);
wresize(tui.iq, iq_size/2, iq_size);
mvwin(tui.iq, 2, 0);
wresize(tui.pll, iq_size/6, nc - iq_size);
mvwin(tui.pll, 2+cur_row, iq_size+2);
cur_row += iq_size/6;
wresize(tui.filein, iq_size/6, nc - iq_size);
mvwin(tui.filein, 2+cur_row, iq_size+2);
cur_row += iq_size/6;
wresize(tui.dataout, iq_size/6, nc - iq_size);
mvwin(tui.dataout, 2+cur_row, iq_size+2);
wresize(tui.infowin, MIN(nr - iq_size, 10), nc);
mvwin(tui.infowin, 2+iq_size/2+2, 0);
wresize(tui.pll, 3, nc - iq_size - 2);
mvwin(tui.pll, 2, iq_size+2);
wresize(tui.filein, 2, nc - iq_size - 2);
mvwin(tui.filein, 6, iq_size+2);
wresize(tui.dataout, 2, nc - iq_size - 2);
mvwin(tui.dataout, 9, iq_size+2);
wresize(tui.infowin, MIN(5, nr-iq_size/2-4), nc);
mvwin(tui.infowin, MAX(12, 2+iq_size/2+1), 0);

print_banner(tui.banner_top);
iq_draw_quadrants(tui.iq);
Expand All @@ -104,7 +101,7 @@ tui_process_input()

switch(ch) {
case KEY_RESIZE:
tui_handle_resize();
tui_handle_resize(0);
break;
case 'q':
return 1;
Expand Down Expand Up @@ -265,6 +262,12 @@ tui_wait_for_user_input()
void
tui_deinit()
{
delwin(tui.iq);
delwin(tui.pll);
delwin(tui.filein);
delwin(tui.dataout);
delwin(tui.infowin);
delwin(tui.banner_top);
endwin();
}

Expand All @@ -282,19 +285,16 @@ void
windows_init(int rows, int cols)
{
int iq_size;
int cur_row;

iq_size = MIN(CONSTELL_MAX, cols);
cur_row = 0;
iq_size = (MIN(CONSTELL_MAX, MIN(rows, cols/2))) | 0x3;

tui.banner_top = newwin(1, cols, 0, 0);
tui.iq = newwin(iq_size/2, iq_size, 2, 0);
tui.pll = newwin(iq_size/6, cols-iq_size-2, 2+cur_row, iq_size+2);
cur_row += iq_size/6;
tui.filein = newwin(iq_size/6, cols-iq_size-2, 2+cur_row, iq_size+2);
cur_row += iq_size/6;
tui.dataout = newwin(iq_size/6, cols-iq_size-2, 2+cur_row, iq_size+2);
tui.infowin = newwin(MIN(rows - iq_size/2, 10), cols, 2+iq_size/2+2, 0);
tui.pll = newwin(3, cols-iq_size-2, 2, iq_size+2);
tui.filein = newwin(2, cols-iq_size-2, 6, iq_size+2);
tui.dataout = newwin(2, cols-iq_size-2, 9, iq_size+2);
tui.infowin = newwin(MIN(5, rows-iq_size/2-4), cols,
MAX(12, 2+iq_size/2+1), 0);

scrollok(tui.infowin, TRUE);
wtimeout(tui.infowin, _upd_interval);
Expand Down
7 changes: 1 addition & 6 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,8 @@ dehumanize(const char *buf)
case 'M':
ret = tmp * 1000000;
break;
case '\n':
case ' ':
case '\0':
ret = tmp;
break;
default:
ret = -1;
ret = tmp;
break;
}

Expand Down

0 comments on commit 43a4d36

Please sign in to comment.