Make libdebug not depend on libdisplay
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include "../libsample/sample.h"
|
#include "../libsample/sample.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "../libdisplay/display.h"
|
#include "../libdisplay/display.h"
|
||||||
@@ -72,6 +73,24 @@ void (*print_console_text)(void) = NULL;
|
|||||||
|
|
||||||
int debug_limit_scroll = 0;
|
int debug_limit_scroll = 0;
|
||||||
|
|
||||||
|
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 _printdebug(const char *file, const char __attribute__((unused)) *function, int line, int cat, int level, int chan, const char *fmt, ...)
|
void _printdebug(const char *file, const char __attribute__((unused)) *function, int line, int cat, int level, int chan, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char buffer[4096], *b = buffer;
|
char buffer[4096], *b = buffer;
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
#define DUHD 18
|
#define DUHD 18
|
||||||
#define DSOAPY 19
|
#define DSOAPY 19
|
||||||
|
|
||||||
|
void get_win_size(int *w, int *h);
|
||||||
|
|
||||||
#define PDEBUG(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, -1, fmt, ## arg)
|
#define PDEBUG(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, -1, fmt, ## arg)
|
||||||
#define PDEBUG_CHAN(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, CHAN, fmt, ## arg)
|
#define PDEBUG_CHAN(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, CHAN, fmt, ## arg)
|
||||||
void _printdebug(const char *file, const char *function, int line, int cat, int level, int chan, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 7, 8)));
|
void _printdebug(const char *file, const char *function, int line, int cat, int level, int chan, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 7, 8)));
|
||||||
|
@@ -73,8 +73,6 @@ typedef struct display_spectrum {
|
|||||||
|
|
||||||
#define MAX_HEIGHT_STATUS 32
|
#define MAX_HEIGHT_STATUS 32
|
||||||
|
|
||||||
void get_win_size(int *w, int *h);
|
|
||||||
|
|
||||||
void display_wave_init(dispwav_t *disp, int samplerate, int kanal);
|
void display_wave_init(dispwav_t *disp, int samplerate, int kanal);
|
||||||
void display_wave_on(int on);
|
void display_wave_on(int on);
|
||||||
void display_wave(dispwav_t *disp, sample_t *samples, int length, double range);
|
void display_wave(dispwav_t *disp, sample_t *samples, int length, double range);
|
||||||
|
@@ -33,24 +33,6 @@ static int num_sender = 0;
|
|||||||
static char screen[HEIGHT][MAX_DISPLAY_WIDTH];
|
static char screen[HEIGHT][MAX_DISPLAY_WIDTH];
|
||||||
static int wave_on = 0;
|
static int wave_on = 0;
|
||||||
|
|
||||||
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(dispwav_t *disp, int samplerate, int kanal)
|
void display_wave_init(dispwav_t *disp, int samplerate, int kanal)
|
||||||
{
|
{
|
||||||
memset(disp, 0, sizeof(*disp));
|
memset(disp, 0, sizeof(*disp));
|
||||||
|
@@ -36,8 +36,6 @@ static void gen_samples(sample_t *samples, double freq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int num_kanal;
|
int num_kanal;
|
||||||
int get_win_size;
|
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
@@ -35,7 +35,6 @@ static void gen_samples(sample_t *samples, double freq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int num_kanal;
|
int num_kanal;
|
||||||
int get_win_size;
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user