forked from analogdevicesinc/iio-oscilloscope
-
Notifications
You must be signed in to change notification settings - Fork 0
/
datatypes.h
157 lines (137 loc) · 3.34 KB
/
datatypes.h
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/**
* Copyright (C) 2012-2013 Analog Devices, Inc.
*
* Licensed under the GPL-2.
*
**/
#ifndef __DATA_TYPES__
#define __DATA_TYPES__
#include <glib.h>
#include <gtk/gtk.h>
#include <errno.h>
#include <stdbool.h>
#include <fftw3.h>
#include <iio.h>
#define FORCE_UPDATE TRUE
#define NORMAL_UPDATE FALSE
struct detachable_plugin {
const struct osc_plugin *plugin;
gboolean detached_state;
GtkWidget *detach_attach_button;
};
/* Types of transforms */
enum {
NO_TRANSFORM_TYPE,
TIME_TRANSFORM,
FFT_TRANSFORM,
CONSTELLATION_TRANSFORM,
COMPLEX_FFT_TRANSFORM,
CROSS_CORRELATION_TRANSFORM,
TRANSFORMS_TYPES_COUNT
};
typedef struct _transform Transform;
typedef struct _tr_list TrList;
struct extra_info {
struct iio_device *dev;
gfloat *data_ref;
off_t offset;
int shadow_of_enabled;
bool may_be_enabled;
};
struct extra_dev_info {
struct iio_buffer *buffer;
unsigned int sample_count;
double adc_freq, lo_freq;
char adc_scale;
GSList *plots_sample_counts;
};
struct buffer {
void *data;
void *data_copy;
unsigned int available;
unsigned int size;
};
struct plot_params{
unsigned int plot_id;
unsigned int sample_count;
};
struct _fft_alg_data{
gfloat fft_corr;
double *in;
double *win;
unsigned int m;
fftw_complex *in_c;
fftw_complex *out;
fftw_plan plan_forward;
int cached_fft_size;
int cached_num_active_channels;
int num_active_channels;
};
struct _transform {
int type_id;
struct iio_channel *channel_parent,
*channel_parent2,
*channel_parent3,
*channel_parent4;
gfloat **in_data;
gfloat *x_axis;
gfloat *y_axis;
unsigned x_axis_size;
unsigned y_axis_size;
bool destroy_x_axis;
bool destroy_y_axis;
bool local_output_buf;
GdkColor *graph_color;
bool has_the_marker;
void *settings;
void (*transform_function)(Transform *tr, gboolean init_transform);
};
struct _tr_list {
Transform **transforms;
int size;
};
struct _time_settings {
unsigned int num_samples;
gboolean apply_inverse_funct;
gboolean apply_multiply_funct;
gboolean apply_add_funct;
gfloat multiply_value;
gfloat add_value;
};
struct _fft_settings {
unsigned int fft_size;
unsigned int fft_avg;
gfloat fft_pwr_off;
struct _fft_alg_data fft_alg_data;
struct marker_type *markers;
struct marker_type *markers_copy;
GMutex *marker_lock;
enum marker_types *marker_type;
};
struct _constellation_settings {
unsigned int num_samples;
};
struct _cross_correlation_settings {
unsigned int num_samples;
fftw_complex *signal_a;
fftw_complex *signal_b;
fftw_complex *xcorr_data;
struct marker_type *markers;
enum marker_types *marker_type;
};
Transform* Transform_new(int tr_type);
void Transform_destroy(Transform *tr);
void Transform_resize_x_axis(Transform *tr, int new_size);
void Transform_resize_y_axis(Transform *tr, int new_size);
void Transform_set_in_data_ref(Transform *tr, gfloat **data_ref);
gfloat* Transform_get_x_axis_ref(Transform *tr);
gfloat* Transform_get_y_axis_ref(Transform *tr);
void Transform_attach_settings(Transform *tr, void *settings);
void Transform_attach_function(Transform *tr, void (*f)(Transform *tr , gboolean init_transform));
void Transform_setup(Transform *tr);
void Transform_update_output(Transform *tr);
TrList* TrList_new(void);
void TrList_destroy(TrList *list);
void TrList_add_transform(TrList *list, Transform *tr);
void TrList_remove_transform(TrList *list, Transform *tr);
#endif /* __DATA_TYPES__ */