GNU Radio's TEST Package
fosphor.h
Go to the documentation of this file.
1 /*
2  * fosphor.h
3  *
4  * Main fosphor entry point
5  *
6  * Copyright (C) 2013-2021 Sylvain Munaut
7  * SPDX-License-Identifier: GPL-3.0-or-later
8  */
9 
10 #pragma once
11 
12 /*! \defgroup fosphor
13  * @{
14  */
15 
16 /*! \file fosphor.h
17  * \brief Main fosphor entry point
18  */
19 
20 struct fosphor;
21 struct fosphor_render;
22 
23 
24 /* Main API */
25 
26 struct fosphor *fosphor_init(void);
27 void fosphor_release(struct fosphor *self);
28 
29 int fosphor_process(struct fosphor *self, void *samples, int len);
30 void fosphor_draw(struct fosphor *self, struct fosphor_render *render);
31 
33 void fosphor_set_fft_window(struct fosphor *self, float *win);
34 
35 void fosphor_set_power_range(struct fosphor *self, int db_ref, int db_per_div);
37  double center, double span);
38 
39 
40 /* Render */
41 
42 #define FOSPHOR_MAX_CHANNELS 8
43 
45 {
46  int enabled; /*!< \brief Showed (1) or hidden (0) */
47  float center; /*!< \brief Normalized center frequency */
48  float width; /*!< \brief Normalized bandwidth */
49 };
50 
51 #define FRO_LIVE (1<<0) /*!< \brief Display live spectrum */
52 #define FRO_MAX_HOLD (1<<1) /*!< \brief Display max-hold spectrum */
53 #define FRO_HISTO (1<<2) /*!< \brief Display histogram */
54 #define FRO_WATERFALL (1<<3) /*!< \brief Display waterfall */
55 #define FRO_LABEL_FREQ (1<<4) /*!< \brief Display frequency labels */
56 #define FRO_LABEL_PWR (1<<5) /*!< \brief Display power labels */
57 #define FRO_LABEL_TIME (1<<6) /*!< \brief Display time labels */
58 #define FRO_CHANNELS (1<<7) /*!< \brief Display channels */
59 #define FRO_COLOR_SCALE (1<<8) /*!< \brief Display intensity color scale */
60 
61 /*! \brief fosphor render options */
63 {
64  /* User fields */
65  int pos_x; /*!< \brief X origin (lower left corner) */
66  int pos_y; /*!< \brief Y origin (lower left corner) */
67  int width; /*!< \brief Width */
68  int height; /*!< \brief Height */
69  int options; /*!< \brief Options (See FRO_??? constants) */
70  float histo_wf_ratio; /*!< \brief Ratio histogram/waterfall ]0,1[ */
71  int freq_n_div; /*!< \brief Number of frequency divisions */
72  float freq_center; /*!< \brief Frequency zoom center ]0,1[ */
73  float freq_span; /*!< \brief Frequency zoom span ]0,1] */
74  float wf_span; /*!< \brief Waterfall time zoom ]0,1] */
75 
76  /*! \brief Displayed channels */
78 
79  /* Private fields */
80  int _wf_pos; /*!< \brief (private) Waterfall position */
81 
82  float _x_div; /*!< \brief (private) X divisions width */
83  float _x[2]; /*!< \brief (private) X endpoints */
84  float _x_label; /*!< \brief (private) X location for labels */
85 
86  float _y_histo_div; /*!< \brief (private) Y histogram divisions height */
87  float _y_histo[2]; /*!< \brief (private) Y histogram endpoints */
88  float _y_wf[2]; /*!< \brief (private) Y waterfall endpoints */
89  float _y_label; /*!< \brief (private) Y location for label */
90 };
91 
94 
95 
96 /* Position Mapping */
97 
98 double fosphor_pos2freq(struct fosphor *self, struct fosphor_render *render, int x);
99 float fosphor_pos2pwr (struct fosphor *self, struct fosphor_render *render, int y);
100 int fosphor_pos2samp(struct fosphor *self, struct fosphor_render *render, int y);
101 int fosphor_freq2pos(struct fosphor *self, struct fosphor_render *render, double freq);
102 int fosphor_pwr2pos (struct fosphor *self, struct fosphor_render *render, float pwr);
103 int fosphor_samp2pos(struct fosphor *self, struct fosphor_render *render, int time);
104 
105 int fosphor_render_pos_inside(struct fosphor_render *render, int x, int y);
106 
107 
108 /*! @} */
void fosphor_set_power_range(struct fosphor *self, int db_ref, int db_per_div)
int fosphor_pwr2pos(struct fosphor *self, struct fosphor_render *render, float pwr)
void fosphor_set_fft_window(struct fosphor *self, float *win)
void fosphor_draw(struct fosphor *self, struct fosphor_render *render)
void fosphor_render_defaults(struct fosphor_render *render)
int fosphor_pos2samp(struct fosphor *self, struct fosphor_render *render, int y)
int fosphor_samp2pos(struct fosphor *self, struct fosphor_render *render, int time)
void fosphor_set_fft_window_default(struct fosphor *self)
struct fosphor * fosphor_init(void)
void fosphor_set_frequency_range(struct fosphor *self, double center, double span)
void fosphor_release(struct fosphor *self)
float fosphor_pos2pwr(struct fosphor *self, struct fosphor_render *render, int y)
double fosphor_pos2freq(struct fosphor *self, struct fosphor_render *render, int x)
int fosphor_process(struct fosphor *self, void *samples, int len)
#define FOSPHOR_MAX_CHANNELS
Definition: fosphor.h:42
int fosphor_render_pos_inside(struct fosphor_render *render, int x, int y)
void fosphor_render_refresh(struct fosphor_render *render)
int fosphor_freq2pos(struct fosphor *self, struct fosphor_render *render, double freq)
Definition: fosphor.h:45
int enabled
Showed (1) or hidden (0)
Definition: fosphor.h:46
float width
Normalized bandwidth.
Definition: fosphor.h:48
float center
Normalized center frequency.
Definition: fosphor.h:47
fosphor render options
Definition: fosphor.h:63
float histo_wf_ratio
Ratio histogram/waterfall ]0,1[.
Definition: fosphor.h:70
float freq_center
Frequency zoom center ]0,1[.
Definition: fosphor.h:72
int _wf_pos
(private) Waterfall position
Definition: fosphor.h:80
float _x_label
(private) X location for labels
Definition: fosphor.h:84
float _y_histo_div
(private) Y histogram divisions height
Definition: fosphor.h:86
int width
Width
Definition: fosphor.h:67
float _y_histo[2]
(private) Y histogram endpoints
Definition: fosphor.h:87
float _y_wf[2]
(private) Y waterfall endpoints
Definition: fosphor.h:88
struct fosphor_channel channels[FOSPHOR_MAX_CHANNELS]
Displayed channels.
Definition: fosphor.h:77
float _x[2]
(private) X endpoints
Definition: fosphor.h:83
int pos_x
X origin (lower left corner)
Definition: fosphor.h:65
float freq_span
Frequency zoom span ]0,1].
Definition: fosphor.h:73
int pos_y
Y origin (lower left corner)
Definition: fosphor.h:66
float _y_label
(private) Y location for label
Definition: fosphor.h:89
int freq_n_div
Number of frequency divisions.
Definition: fosphor.h:71
int height
Height.
Definition: fosphor.h:68
float _x_div
(private) X divisions width
Definition: fosphor.h:82
int options
Options (See FRO_??? constants)
Definition: fosphor.h:69
float wf_span
Waterfall time zoom ]0,1].
Definition: fosphor.h:74
Definition: private.h:31
int db_per_div
Definition: private.h:46
double center
Definition: private.h:52
double span
Definition: private.h:53
int db_ref
Definition: private.h:45