File: waterfall.h

package info (click to toggle)
lysdr 1.0~git20141206+dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 832 kB
  • ctags: 1,685
  • sloc: python: 11,659; ansic: 1,335; makefile: 24
file content (117 lines) | stat: -rw-r--r-- 3,563 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*  lysdr Software Defined Radio
    (C) 2010-2011 Gordon JC Pearce MM0YEQ and others
    
    waterfall.h
    
	This file is part of lysdr.

	lysdr is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 2 of the License, or
	any later version.

	lysdr is distributed in the hope that it will be useful, but
	WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with lysdr.  If not, see <http://www.gnu.org/licenses/>.
*/



#ifndef __WATERFALL_H
#define __WATERFALL_H

#include <gtk/gtk.h>

G_BEGIN_DECLS

typedef struct _SDRWaterfall            SDRWaterfall;
typedef struct _SDRWaterfallClass       SDRWaterfallClass;
typedef struct _SDRWaterfallPrivate     SDRWaterfallPrivate;

enum {
    P_NONE,
    P_TUNING,
    P_HIGHPASS,
    P_LOWPASS,
    P_BANDSPREAD
};

enum {
    WF_O_VERTICAL,
    WF_O_HORIZONTAL
};

struct _SDRWaterfall {
    GtkDrawingArea parent;
    
    GtkAdjustment *tuning;
    GtkAdjustment *lp_tune;
    GtkAdjustment *hp_tune;

    GdkPixmap *pixmap;
    GdkPixmap *scale;
    cairo_surface_t *pix;

    gint mode;
    gint orientation;

    gint width;
    gint wf_height;
    
    gint sample_rate;
    gint centre_freq;
    gint fft_size;
};

struct _SDRWaterfallClass {
    GtkDrawingAreaClass parent_class;
};

struct _SDRWaterfallPrivate {
    gint cursor_pos;    // pixel position for tuning cursor
    gint lp_pos;        // pixel position for lowpass cursor
    gint hp_pos;        // pixel position for highpass cursor
    gint scroll_pos;    // which line the scroller is on
    gint prelight;
    gint drag;
    gint click_pos;
    gdouble bandspread;
    GMutex mutex;
};

#define SDR_TYPE_WATERFALL             (sdr_waterfall_get_type ())
#define SDR_WATERFALL(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), SDR_TYPE_WATERFALL, SDRWaterfall))
#define SDR_WATERFALL_CLASS(obj)       (G_TYPE_CHECK_CLASS_CAST ((obj), SDR_WATERFALL,  SDRWaterfallClass))
#define SDR_IS_WATERFALL(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SDR_TYPE_WATERFALL))
#define SDR_IS_WATERFALL_CLASS(obj)    (G_TYPE_CHECK_CLASS_TYPE ((obj), SDR_TYPE_WATERFALL))
#define SDR_WATERFALL_GET_CLASS        (G_TYPE_INSTANCE_GET_CLASS ((obj), SDR_TYPE_WATERFALL, SDRWaterfallClass))
#define SDR_WATERFALL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), SDR_TYPE_WATERFALL, SDRWaterfallPrivate))

G_END_DECLS

#define LOOSE 2
#define WITHIN(x, p) (x-1 > p-LOOSE) && (x-1 < p + LOOSE)

#define SCALE_HEIGHT 24
#define SCALE_WIDTH 50
#define SCALE_TICK 5000

SDRWaterfall *sdr_waterfall_new(GtkAdjustment *tuning, GtkAdjustment *lp_tune, GtkAdjustment *hp_tune, gint sample_rate, gint fft_size);
float sdr_waterfall_get_tuning(SDRWaterfall *wf);
float sdr_waterfall_get_lowpass(SDRWaterfall *wf);
float sdr_waterfall_get_highpass(SDRWaterfall *wf);

void sdr_waterfall_set_tuning(SDRWaterfall *wf, gdouble value);
void sdr_waterfall_update(GtkWidget *widget, guchar *row);
void sdr_waterfall_set_scale(GtkWidget *widget, gint centre_freq);
void sdr_waterfall_filter_cursors(SDRWaterfall *wf);
void sdr_waterfall_set_lowpass(SDRWaterfall *wf, gdouble value);
void sdr_waterfall_set_highpass(SDRWaterfall *wf, gdouble value);
GType sdr_waterfall_get_type(void);
#endif /* __WATERFALL_H */

/* vim: set noexpandtab ai ts=4 sw=4 tw=4: */