libdisplay: Removing dependency from libmobile
This commit is contained in:
@@ -3,9 +3,8 @@
|
||||
|
||||
#define MAX_DISPLAY_WIDTH 1024
|
||||
|
||||
typedef struct sender sender_t;
|
||||
|
||||
typedef struct display_wave {
|
||||
int kanal;
|
||||
int interval_pos;
|
||||
int interval_max;
|
||||
int offset;
|
||||
@@ -43,7 +42,9 @@ typedef struct display_measurements_param {
|
||||
} dispmeasparam_t;
|
||||
|
||||
typedef struct display_measurements {
|
||||
dispmeasparam_t *head;
|
||||
struct display_measurements *next;
|
||||
int kanal;
|
||||
dispmeasparam_t *param;
|
||||
} dispmeas_t;
|
||||
|
||||
#define MAX_DISPLAY_IQ 1024
|
||||
@@ -56,20 +57,27 @@ typedef struct display_iq {
|
||||
|
||||
#define MAX_DISPLAY_SPECTRUM 1024
|
||||
|
||||
typedef struct display_spectrum_mark {
|
||||
struct display_spectrum_mark *next;
|
||||
int kanal;
|
||||
double frequency;
|
||||
} dispspectrum_mark_t;
|
||||
|
||||
typedef struct display_spectrum {
|
||||
int interval_pos;
|
||||
int interval_max;
|
||||
double buffer_I[MAX_DISPLAY_SPECTRUM];
|
||||
double buffer_Q[MAX_DISPLAY_SPECTRUM];
|
||||
dispspectrum_mark_t *mark;
|
||||
} dispspectrum_t;
|
||||
|
||||
#define MAX_HEIGHT_STATUS 32
|
||||
|
||||
void get_win_size(int *w, int *h);
|
||||
|
||||
void display_wave_init(sender_t *sender, int samplerate);
|
||||
void display_wave_init(dispwav_t *disp, int samplerate, int kanal);
|
||||
void display_wave_on(int on);
|
||||
void display_wave(sender_t *sender, sample_t *samples, int length, double range);
|
||||
void display_wave(dispwav_t *disp, sample_t *samples, int length, double range);
|
||||
|
||||
void display_status_on(int on);
|
||||
void display_status_start(void);
|
||||
@@ -77,10 +85,10 @@ void display_status_channel(int channel, const char *type, const char *state);
|
||||
void display_status_subscriber(const char *number, const char *state);
|
||||
void display_status_end(void);
|
||||
|
||||
void display_measurements_init(sender_t *sender, int samplerate);
|
||||
void display_measurements_exit(sender_t *sender);
|
||||
void display_measurements_init(dispmeas_t *disp, int samplerate, int kanal);
|
||||
void display_measurements_exit(dispmeas_t *disp);
|
||||
void display_measurements_on(int on);
|
||||
dispmeasparam_t *display_measurements_add(sender_t *sender, char *name, char *format, enum display_measurements_type type, enum display_measurements_bar bar, double min, double max, double mark);
|
||||
dispmeasparam_t *display_measurements_add(dispmeas_t *disp, char *name, char *format, enum display_measurements_type type, enum display_measurements_bar bar, double min, double max, double mark);
|
||||
void display_measurements_update(dispmeasparam_t *param, double value, double value2);
|
||||
void display_measurements(double elapsed);
|
||||
|
||||
@@ -89,6 +97,8 @@ void display_iq_on(int on);
|
||||
void display_iq(float *samples, int length);
|
||||
|
||||
void display_spectrum_init(int samplerate, double center_frequency);
|
||||
void display_spectrum_add_mark(int kanal, double frequency);
|
||||
void display_spectrum_exit(void);
|
||||
void display_spectrum_on(int on);
|
||||
void display_spectrum(float *samples, int length);
|
||||
|
||||
|
@@ -24,8 +24,8 @@
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
#include "../libsample/sample.h"
|
||||
#include "../libmobile/sender.h"
|
||||
#include "../libdebug/debug.h"
|
||||
#include "../libdisplay/display.h"
|
||||
|
||||
/* must be odd value! */
|
||||
#define SIZE 23
|
||||
|
@@ -25,8 +25,8 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <math.h>
|
||||
#include "../libsample/sample.h"
|
||||
#include "../libmobile/sender.h"
|
||||
#include "../libdebug/debug.h"
|
||||
#include "../libdisplay/display.h"
|
||||
|
||||
#define MAX_NAME_LEN 16
|
||||
#define MAX_UNIT_LEN 16
|
||||
@@ -38,27 +38,34 @@ static int lines_total = 0;
|
||||
static char line[MAX_DISPLAY_WIDTH];
|
||||
static char line_color[MAX_DISPLAY_WIDTH];
|
||||
|
||||
void display_measurements_init(sender_t *sender, int __attribute__((unused)) samplerate)
|
||||
dispmeas_t *meas_head = NULL;
|
||||
|
||||
void display_measurements_init(dispmeas_t *disp, int __attribute__((unused)) samplerate, int kanal)
|
||||
{
|
||||
dispmeas_t *disp = &sender->dispmeas;
|
||||
dispmeas_t **disp_p;
|
||||
|
||||
memset(disp, 0, sizeof(*disp));
|
||||
disp->kanal = kanal;
|
||||
has_init = 1;
|
||||
lines_total = 0;
|
||||
time_elapsed = 0.0;
|
||||
|
||||
disp_p = &meas_head;
|
||||
while (*disp_p)
|
||||
disp_p = &((*disp_p)->next);
|
||||
*disp_p = disp;
|
||||
}
|
||||
|
||||
void display_measurements_exit(sender_t *sender)
|
||||
void display_measurements_exit(dispmeas_t *disp)
|
||||
{
|
||||
dispmeas_t *disp = &sender->dispmeas;
|
||||
dispmeasparam_t *param = disp->head, *temp;
|
||||
dispmeasparam_t *param = disp->param, *temp;
|
||||
|
||||
while (param) {
|
||||
temp = param;
|
||||
param = param->next;
|
||||
free(temp);
|
||||
}
|
||||
disp->head = NULL;
|
||||
disp->param = NULL;
|
||||
has_init = 0;
|
||||
}
|
||||
|
||||
@@ -86,7 +93,7 @@ static void display_line(int on, int w)
|
||||
|
||||
static void print_measurements(int on)
|
||||
{
|
||||
sender_t *sender;
|
||||
dispmeas_t *disp;
|
||||
dispmeasparam_t *param;
|
||||
int i, j;
|
||||
int width, h;
|
||||
@@ -104,13 +111,13 @@ static void print_measurements(int on)
|
||||
lines_total = 0;
|
||||
color = -1;
|
||||
printf("\0337\033[H");
|
||||
for (sender = sender_head; sender; sender = sender->next) {
|
||||
for (disp = meas_head; disp; disp = disp->next) {
|
||||
memset(line, ' ', width);
|
||||
memset(line_color, 7, width);
|
||||
sprintf(line, "(chan %d", sender->kanal);
|
||||
sprintf(line, "(chan %d", disp->kanal);
|
||||
*strchr(line, '\0') = ')';
|
||||
display_line(on, width);
|
||||
for (param = sender->dispmeas.head; param; param = param->next) {
|
||||
for (param = disp->param; param; param = param->next) {
|
||||
memset(line, ' ', width);
|
||||
memset(line_color, 7, width);
|
||||
memset(line_color, 3, MAX_NAME_LEN); /* yellow */
|
||||
@@ -259,10 +266,9 @@ void display_measurements_on(int on)
|
||||
}
|
||||
|
||||
/* add new parameter on startup to the list of measurements */
|
||||
dispmeasparam_t *display_measurements_add(sender_t *sender, char *name, char *format, enum display_measurements_type type, enum display_measurements_bar bar, double min, double max, double mark)
|
||||
dispmeasparam_t *display_measurements_add(dispmeas_t *disp, char *name, char *format, enum display_measurements_type type, enum display_measurements_bar bar, double min, double max, double mark)
|
||||
{
|
||||
dispmeas_t *disp = &sender->dispmeas;
|
||||
dispmeasparam_t *param, **param_p = &disp->head;
|
||||
dispmeasparam_t *param, **param_p = &disp->param;
|
||||
int i;
|
||||
|
||||
if (!has_init) {
|
||||
|
@@ -23,12 +23,13 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "../libsample/sample.h"
|
||||
#include "../libmobile/sender.h"
|
||||
#include "../libfft/fft.h"
|
||||
#include "../libdebug/debug.h"
|
||||
#include "../libdisplay/display.h"
|
||||
|
||||
#define HEIGHT 20
|
||||
|
||||
static int has_init = 0;
|
||||
static double buffer_delay[MAX_DISPLAY_SPECTRUM];
|
||||
static double buffer_hold[MAX_DISPLAY_SPECTRUM];
|
||||
static char screen[HEIGHT][MAX_DISPLAY_WIDTH];
|
||||
@@ -50,6 +51,42 @@ void display_spectrum_init(int samplerate, double _center_frequency)
|
||||
|
||||
center_frequency = _center_frequency;
|
||||
frequency_range = (double)samplerate;
|
||||
|
||||
has_init = 1;
|
||||
}
|
||||
|
||||
void display_spectrum_add_mark(int kanal, double frequency)
|
||||
{
|
||||
dispspectrum_mark_t *mark, **mark_p;
|
||||
|
||||
if (!has_init)
|
||||
return;
|
||||
|
||||
mark = calloc(1, sizeof(*mark));
|
||||
if (!mark) {
|
||||
fprintf(stderr, "no mem!");
|
||||
abort();
|
||||
}
|
||||
mark->kanal = kanal;
|
||||
mark->frequency = frequency;
|
||||
|
||||
mark_p = &disp.mark;
|
||||
while (*mark_p)
|
||||
mark_p = &((*mark_p)->next);
|
||||
*mark_p = mark;
|
||||
}
|
||||
|
||||
void display_spectrum_exit(void)
|
||||
{
|
||||
dispspectrum_mark_t *mark = disp.mark, *temp;
|
||||
|
||||
while (mark) {
|
||||
temp = mark;
|
||||
mark = mark->next;
|
||||
free(temp);
|
||||
}
|
||||
disp.mark = NULL;
|
||||
has_init = 0;
|
||||
}
|
||||
|
||||
void display_spectrum_on(int on)
|
||||
@@ -88,7 +125,7 @@ void display_spectrum_on(int on)
|
||||
*/
|
||||
void display_spectrum(float *samples, int length)
|
||||
{
|
||||
sender_t *sender;
|
||||
dispspectrum_mark_t *mark;
|
||||
char print_channel[32], print_frequency[32];
|
||||
int width, h;
|
||||
int pos, max;
|
||||
@@ -300,8 +337,8 @@ void display_spectrum(float *samples, int length)
|
||||
}
|
||||
}
|
||||
/* add channel positions in spectrum */
|
||||
for (sender = sender_head; sender; sender = sender->next) {
|
||||
j = (int)((sender->empfangsfrequenz - center_frequency) / frequency_range * (double) fft_size + width / 2 + 0.5);
|
||||
for (mark = disp.mark; mark; mark = mark->next) {
|
||||
j = (int)((mark->frequency - center_frequency) / frequency_range * (double) fft_size + width / 2 + 0.5);
|
||||
if (j < 0 || j >= width) /* check out-of-range, should not happen */
|
||||
continue;
|
||||
for (k = 0; k < HEIGHT; k++) {
|
||||
@@ -311,7 +348,7 @@ void display_spectrum(float *samples, int length)
|
||||
screen[k][j] = ':';
|
||||
screen_color[k][j] = 12;
|
||||
}
|
||||
sprintf(print_channel, "Ch%d", sender->kanal);
|
||||
sprintf(print_channel, "Ch%d", mark->kanal);
|
||||
for (o = 0; o < (int)strlen(print_channel); o++) {
|
||||
s = j - strlen(print_channel) + o;
|
||||
if (s >= 0 && s < width) {
|
||||
@@ -319,10 +356,10 @@ void display_spectrum(float *samples, int length)
|
||||
screen_color[HEIGHT - 1][s] = 7;
|
||||
}
|
||||
}
|
||||
if (fmod(sender->empfangsfrequenz, 1000.0))
|
||||
sprintf(print_frequency, "%.4f", sender->empfangsfrequenz / 1e6);
|
||||
if (fmod(mark->frequency, 1000.0))
|
||||
sprintf(print_frequency, "%.4f", mark->frequency / 1e6);
|
||||
else
|
||||
sprintf(print_frequency, "%.3f", sender->empfangsfrequenz / 1e6);
|
||||
sprintf(print_frequency, "%.3f", mark->frequency / 1e6);
|
||||
for (o = 0; o < (int)strlen(print_frequency); o++) {
|
||||
s = j + o + 1;
|
||||
if (s >= 0 && s < width) {
|
||||
|
@@ -23,8 +23,8 @@
|
||||
#include <pthread.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "../libsample/sample.h"
|
||||
#include "../libmobile/sender.h"
|
||||
#include "../libdebug/debug.h"
|
||||
#include "../libdisplay/display.h"
|
||||
|
||||
static int status_on = 0;
|
||||
static int line_count = 0;
|
||||
|
@@ -24,8 +24,8 @@
|
||||
#include <math.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "../libsample/sample.h"
|
||||
#include "../libmobile/sender.h"
|
||||
#include "../libdebug/debug.h"
|
||||
#include "../libdisplay/display.h"
|
||||
|
||||
#define HEIGHT 11
|
||||
|
||||
@@ -51,13 +51,12 @@ void get_win_size(int *w, int *h)
|
||||
*w = MAX_DISPLAY_WIDTH - 1;
|
||||
}
|
||||
|
||||
void display_wave_init(sender_t *sender, int samplerate)
|
||||
void display_wave_init(dispwav_t *disp, int samplerate, int kanal)
|
||||
{
|
||||
dispwav_t *disp = &sender->dispwav;
|
||||
|
||||
memset(disp, 0, sizeof(*disp));
|
||||
disp->offset = (num_sender++) * HEIGHT;
|
||||
disp->interval_max = (double)samplerate * DISPLAY_INTERVAL + 0.5;
|
||||
disp->kanal = kanal;
|
||||
}
|
||||
|
||||
void display_wave_on(int on)
|
||||
@@ -105,9 +104,8 @@ void display_wave_on(int on)
|
||||
* y is in range of 0..4, so these are 5 steps, where 2 is the
|
||||
* center line. this is calculated by (HEIGHT * 2 - 1)
|
||||
*/
|
||||
void display_wave(sender_t *sender, sample_t *samples, int length, double range)
|
||||
void display_wave(dispwav_t *disp, sample_t *samples, int length, double range)
|
||||
{
|
||||
dispwav_t *disp = &sender->dispwav;
|
||||
int pos, max;
|
||||
sample_t *buffer;
|
||||
int i, j, k, s, e;
|
||||
@@ -218,7 +216,7 @@ void display_wave(sender_t *sender, sample_t *samples, int length, double range)
|
||||
screen[k][j] = '|';
|
||||
}
|
||||
}
|
||||
sprintf(screen[0], "(chan %d", sender->kanal);
|
||||
sprintf(screen[0], "(chan %d", disp->kanal);
|
||||
*strchr(screen[0], '\0') = ')';
|
||||
printf("\0337\033[H");
|
||||
for (j = 0; j < disp->offset; j++)
|
||||
|
Reference in New Issue
Block a user